5 kyu
Calculate Fibonacci return count of digit occurrences
636 of 1,145user8476848
Description:
Fibonacci numbers are generated by setting F0 = 0, F1 = 1, and then using the formula:
Fn = Fn-1 + Fn-2
Your task is to efficiently calculate the nth element in the Fibonacci sequence and then count the occurrence of each digit in the number. Return a list of integer pairs sorted in descending order.
10 ≤ n ≤ 100000
Examples
f(10) = 55 # returns [(2, 5)], as there are two occurances of digit 5
f(10000) # returns:
[(254, 3),
(228, 2),
(217, 6),
(217, 0),
(202, 5),
(199, 1),
(198, 7),
(197, 8),
(194, 4),
(184, 9)]
If two integers have the same count, sort them in descending order.
Your algorithm must be efficient.
Algorithms
Similar Kata:
Stats:
Created | Jul 4, 2016 |
Published | Jul 4, 2016 |
Warriors Trained | 3391 |
Total Skips | 409 |
Total Code Submissions | 4202 |
Total Times Completed | 1145 |
Python Completions | 636 |
Ruby Completions | 58 |
Haskell Completions | 51 |
JavaScript Completions | 186 |
C# Completions | 123 |
Java Completions | 140 |
Total Stars | 62 |
% of votes with a positive feedback rating | 92% of 225 |
Total "Very Satisfied" Votes | 192 |
Total "Somewhat Satisfied" Votes | 28 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 10 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |