14
1
Your task is to write a function or program that takes two non-negative integers i
and k
(i
≤ k
), and figure out how many zeroes you'd write if you wrote all whole numbers from i
to k
(inclusive) in your base of choice on a piece of paper. Output this integer, the number of zeroes, to stdout or similar.
-30%
if you also accept a third argument b
, the integer base to write down the numbers in. At least two bases must be handled to achieve this bonus.
- You may accept the input in any base you like, and you may change the base between test cases.
- You may accept the arguments
i
,k
and optionallyb
in any order you like. - Answers must handle at least one base that is not unary.
Test cases (in base 10):
i k -> output
10 10 -> 1
0 27 -> 3
100 200 -> 22
0 500 -> 92
This is code-golf; fewest bytes win.
2If you can go with whatever base you'd like from case to case, couldn't you do each in base k and print 0 or 1, depending on whether i = 0? – StephenTG – 2016-01-29T20:23:41.040
4You might want to exclude unary as a base, or else this problem is trivial: get inputs, print 0. – Mego – 2016-01-29T20:29:56.037
Can you add some test cases for other bases? – Morgan Thrapp – 2016-01-29T20:34:23.123
3I think this would be more interesting if the base argument were required. "Base of your choice" is weird to me. – Alex A. – 2016-01-29T20:34:39.060
1Yes, @AlexA. but too late to change that now, 10 answers in. – Filip Haglund – 2016-01-29T20:53:23.737
Can we get input in unary? – lirtosiast – 2016-01-30T02:43:16.517
@ThomasKwa yes, unary input is ok – Filip Haglund – 2016-01-30T11:50:45.530
@Mego According to Wikipedia, "in order to represent a number N, an arbitrarily chosen symbol representing 1 is repeated N times". It would actually make the most sense to use
0
, since there is no2
symbol in base 2, no3
in base 3, etc. So it makes sense that base 1 has no1
. – mbomb007 – 2017-03-23T13:32:01.087