Computers and Technology
Computers and Technology, 27.08.2021 01:50, giovney

Programming challenge description: A number is a self-describing number when (assuming digit positions are labeled 0 to N-1), the digit in each position is equal to the number of times that that digit appears in the number.
Input:
Your program should read lines of text from standard input. Each line contains a single positive integer, N.
Output:
For each input N, print 1 to standard output if N is a self-describing number. Otherwise, print 0.
For the curious, here''s how 2020 is a self-describing number: Position 0 has value 2 and there are two 0s in the number. Position 1 has value 0 because there are no 1's in the number. Position 2 has value 2 and there are two 2's. And the position 3 has value 0 and there are zero 3's.
Test 1
Test Input
2020
Expected Output
1
Test 2
Test Input
22
Expected Output
1
Test 2
Test Input
22
Expected Output
0
Test 3
Test Input
1210
Expected Output
1

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 15:30, ninja12302
Some of the items below indicate the steps required to move a slide to a different location in a presentation. select those steps and indicate the order in which they should be performed to move the slide. (for example, if an item describes what you do first, select 1.) included in the list are items that are not part of the process. for these items, select n/a, an abbreviation for not applicable. 1 — first 2 — second 3 — third 4 — fourth 5 — fifth 6 — sixth n/a — not applicable drag the slide to the desired place. enter the slide position desired. hold the mouse button down. select move from the tools menu. select the slide. switch to the notes view.
Answers: 3
image
Computers and Technology, 21.06.2019 18:00, kimmosley80
Which if the following allows you to view and access important information about your documents all in one location
Answers: 3
image
Computers and Technology, 23.06.2019 00:00, puppylove899
Which is the correct sequence of steps to set up a document in landscape orientation? a. select page setup from the file menu. then click the margins tab and select landscape. b. select page setup from the edit menu. then click the margins tab and select landscape. c. select page setup from the insert menu. then click the margins tab and select landscape. d. select page setup from the format menu. then click the margins tab and select landscape
Answers: 1
image
Computers and Technology, 23.06.2019 13:00, alexacarillo
In excel - calculate the actual increase/decrease from first quarter to the second quarter then subtract subtract first quarter value from second quarter total then divide result by first quarter value
Answers: 1
Do you know the correct answer?
Programming challenge description: A number is a self-describing number when (assuming digit posit...

Questions in other subjects:

Konu
Mathematics, 27.09.2019 00:00
Konu
Mathematics, 27.09.2019 00:00