5 kyu
The Sum and The Rest of Certain Pairs of Numbers have to be Perfect Squares (more Challenging)
93 of 190raulbc777
Description:
This the second part part of the kata:
In this part we will have to create a faster algorithm because the tests will be more challenging.
The function n_closestPairs_tonum()
, (Javascript: nClosestPairsToNum()
), will accept two arguments, upper_limit
and k
.
The function should return the k
largest pair of numbers [m, n] and the closest to upper_limit
. Expressing it in code:
n_closestPairs_tonum(upper_limit, k) #-> [[m1, n1], [m2, n2], ...., [mk, nk]]
Such that:
upper_limit >= m1 >= m2 >= ....>= mk > 0
Examples:
upper_limit = 1000; k = 4
n_closestPairs_tonum(upper_limit, k) == [[997, 372], [986, 950], [986, 310], [985, 864]]
upper_limit = 10000; k = 8
n_closestPairs_tonum(upper_limit, k) == [[9997, 8772], [9997, 2772], [9992, 6392], [9986, 5890], [9985, 7176], [9985, 4656], [9981, 9900], [9973, 9348]]
Features of the tests:
1000 ≤ upper_limit ≤ 200000
2 ≤ k ≤ 20
Enjoy it!
Algorithms
Mathematics
Data Structures
Similar Kata:
Stats:
Created | Aug 10, 2016 |
Published | Aug 10, 2016 |
Warriors Trained | 831 |
Total Skips | 97 |
Total Code Submissions | 829 |
Total Times Completed | 190 |
Python Completions | 93 |
Ruby Completions | 20 |
JavaScript Completions | 52 |
C++ Completions | 42 |
Total Stars | 17 |
% of votes with a positive feedback rating | 87% of 47 |
Total "Very Satisfied" Votes | 36 |
Total "Somewhat Satisfied" Votes | 10 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 4 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |