Find two numbers, given their sum and product
Description:
After you complete this Kata, please point out any issues present. Thank you!
Disclaimer
This is a step-up from the Sum and Multiply (author: Almusawi) and Find two doubles for the given sum and product (author: ProgramFOX) Kata, so I recommend solving those before this one.
Description
Complete the function find_numbers
that, given two 64-bit integers (let us call them sum
and product
), returns a pair (C: struct) of complex double
s (e.g. sol1
and sol2
, such that sol1 + sol2 ≅ sum
and sol1 * sol2 ≅ product
.
Requirements
Both elements must be calculated without any rounding or truncation: you pass the test if the absolute difference between your answers and the expected answers is not more than 10 ** -15
.
The sample test-cases have more information.
There are 150
tests in total: 5
fixed for purely real and purely complex numbers each, and 140
random cases.
Hint
If you know how to solve a quadratic equation, you know how to solve this.
Similar Kata:
Stats:
Created | Sep 10, 2022 |
Warriors Trained | 8 |
Total Skips | 0 |
Total Code Submissions | 15 |
Total Times Completed | 4 |
C Completions | 4 |
Total Stars | 0 |
% of votes with a positive feedback rating | 0% of 1 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 1 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |