19
2
Also known as the [analog root]
(Opposite of the digital root!) ;)
The digital root of a number is the continuous summation of its digits until it is a single digit, for example, the digital root of 89456 is calculated like this:
8 + 9 + 4 + 5 + 6 = 32
3 + 2 = 5
The digital root of 89456 is 5.
Given a digit as input via STDIN, print/return all of the possible two digit numbers that have that digital root. If you need it to, it can include itself, e.g. 05
These are all of the possible inputs and outputs:
(You get to choose whether or not to include the leading zero for the digit itself)
I/O
0 => 0 or 00 or nothing
1 => 01 and/or 1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91 - Make sure that 1 does not return 100
2 => 02 and/or 2, 11, 20, 29, 38, 47, 56, 65, 74, 83, 92
3 => 03 and/or 3, 12, 21, 30, 39, 48, 57, 66, 75, 84, 93
4 => 04 and/or 4, 13, 22, 31, 40, 49, 58, 67, 76, 85, 94
5 => 05 and/or 5, 14, 23, 32, 41, 50 ,59, 68, 77, 86, 95
6 => 06 and/or 6, 15, 24, 33, 42, 51, 60, 69, 78, 87, 96
7 => 07 and/or 7, 16, 25, 34, 43, 52, 61, 70, 79, 88, 97
8 => 08 and/or 8, 17, 26, 35, 44, 53, 62, 71, 80, 89, 98
9 => 09 and/or 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99
No standard loopholes, and it's code-golf, so the shortest answer in bytes wins.
Congrats to Heeby Jeeby Man on his amazing 46 byte brain-flak answer!
1does the number itself count as a two digit number? (05)? – Destructible Lemon – 2017-05-29T00:44:58.610
2Inverse challenge – FryAmTheEggman – 2017-05-29T00:48:32.733
5What should the output be for 0? And again, in a case like this where there are only 10 possible inputs, it would be of great benefit to supply the outputs in your challenge. – FryAmTheEggman – 2017-05-29T00:50:03.303
1Your decision on how to handle zero invalidates many of the answers that were posted. It would be considerate to let the participants know you have made a decision. – FryAmTheEggman – 2017-05-29T02:48:44.037
@FryAmTheEggman I just updated the post – FantaC – 2017-05-29T03:01:36.097
2is the opposite of a digital root an analog root? – tuskiomi – 2017-05-29T03:32:35.857
Why should
0
return0
, that is not a 2 digits number (the same for all other 9 digits) – edc65 – 2017-05-29T06:52:00.650@edc65 You're right, I'm not sure exactly what I was thinking. I will modify the req. – FantaC – 2017-05-29T13:01:15.190
Must
1
and01
both be included (for input1
)? – user202729 – 2018-01-13T06:31:00.283@user202729 no, you get to choose – FantaC – 2018-01-13T14:33:41.637