7 kyu
Count the Digit
1,213 of 50,091g964
Description:
Take an integer n (n >= 0)
and a digit d (0 <= d <= 9)
as an integer.
Square all numbers k (0 <= k <= n)
between 0 and n.
Count the numbers of digits d
used in the writing of all the k**2
.
Implement the function taking n
and d
as parameters and returning this count.
Examples:
n = 10, d = 1
the k*k are 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100
We are using the digit 1 in: 1, 16, 81, 100. The total count is then 4.
The function, when given n = 25 and d = 1 as argument, should return 11 since
the k*k that contain the digit 1 are:
1, 16, 81, 100, 121, 144, 169, 196, 361, 441.
So there are 11 digits 1 for the squares of numbers between 0 and 25.
Note that 121
has twice the digit 1.
Fundamentals
Similar Kata:
Stats:
Created | Dec 15, 2015 |
Published | Dec 15, 2015 |
Warriors Trained | 116850 |
Total Skips | 24957 |
Total Code Submissions | 150585 |
Total Times Completed | 50091 |
Ruby Completions | 1213 |
Python Completions | 12908 |
JavaScript Completions | 16489 |
CoffeeScript Completions | 35 |
Haskell Completions | 512 |
Java Completions | 4466 |
C# Completions | 2108 |
Clojure Completions | 262 |
Elixir Completions | 346 |
C++ Completions | 2663 |
PHP Completions | 1458 |
Crystal Completions | 41 |
F# Completions | 134 |
TypeScript Completions | 964 |
C Completions | 1543 |
Shell Completions | 237 |
OCaml Completions | 67 |
Kotlin Completions | 1088 |
Fortran Completions | 29 |
Swift Completions | 1111 |
NASM Completions | 23 |
Julia Completions | 52 |
R Completions | 130 |
PowerShell Completions | 100 |
Go Completions | 1588 |
Nim Completions | 25 |
Rust Completions | 833 |
Reason Completions | 7 |
Racket Completions | 31 |
Scala Completions | 269 |
Groovy Completions | 52 |
Haxe Completions | 10 |
Pascal Completions | 42 |
Dart Completions | 589 |
Perl Completions | 64 |
Prolog Completions | 15 |
Lua Completions | 135 |
Elm Completions | 16 |
COBOL Completions | 16 |
D Completions | 15 |
Erlang Completions | 15 |
Total Stars | 948 |
% of votes with a positive feedback rating | 88% of 4731 |
Total "Very Satisfied" Votes | 3734 |
Total "Somewhat Satisfied" Votes | 839 |
Total "Not Satisfied" Votes | 158 |