7 kyu
GCD sum
1,294 of 3,279KenKamau
Description:
Given the sum and gcd of two numbers, return those two numbers in ascending order. If the numbers do not exist, return -1
, (or NULL
in C, tuple (-1,-1)
in C#, pair (-1,-1)
in C++,None
in Rust, array {-1,-1}
in Java and Golang).
For example:
Given sum = 12 and gcd = 4...
solve(12,4) = [4,8]. The two numbers 4 and 8 sum to 12 and have a gcd of 4.
solve(12,5) = -1. No two numbers exist that sum to 12 and have gcd of 5.
solve(10,2) = [2,8]. Note that [4,6] is also a possibility but we pick the one with the lower first element: 2 < 4, so we take [2,8].
More examples in test cases.
Good luck!
Fundamentals
Similar Kata:
Stats:
Created | Nov 18, 2019 |
Published | Nov 18, 2019 |
Warriors Trained | 5644 |
Total Skips | 239 |
Total Code Submissions | 8054 |
Total Times Completed | 3279 |
JavaScript Completions | 1294 |
Python Completions | 1038 |
Ruby Completions | 111 |
Haskell Completions | 67 |
C Completions | 106 |
Clojure Completions | 27 |
C# Completions | 157 |
C++ Completions | 213 |
Java Completions | 280 |
Go Completions | 137 |
Rust Completions | 82 |
Total Stars | 69 |
% of votes with a positive feedback rating | 89% of 694 |
Total "Very Satisfied" Votes | 575 |
Total "Somewhat Satisfied" Votes | 85 |
Total "Not Satisfied" Votes | 34 |
Total Rank Assessments | 14 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |