subject
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

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 00:00, addisonrausch
What season was better from fortnite?
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, mona92
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, paulusl19
The first screen you see when you open word2016 what is called?
Answers: 1
image
Computers and Technology, 23.06.2019 11:20, 1tzM3
Http is the protocol that governs communications between web servers and web clients (i. e. browsers). part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. some of the codes and their meanings are listed below: 200, ok (fulfilled)403, forbidden404, not found500, server errorgiven an int variable status, write a switch statement that prints out the appropriate label from the above list based on status.
Answers: 2
You know the right answer?
Programming challenge description: A number is a self-describing number when (assuming digit posit...

Questions in other subjects: