Reaching a number by *3 or +5 (retired)
Description:
In this kata, your goal is to find a way to reach a target number from 1
by multiplying by 3
(* 3
) or adding 5
(+ 5
) only. If there is a way, format your solution as a mathematical equation as a string. If there is not a way, return null
, Nothing
or a similar empty value.
For more information about formatting...
Each step of the equation should be in parentheses ()
except the last. They should go from the inside out, as per mathematical convention. Space everything by one space except for numbers and parentheses joined together. So, if your target was 11
, you should return "((1) + 5) + 5"
.
The multiply symbol used for this kata is an asterisk *
.
If you need more examples, please take a look at the test cases.
Note - the test cases go up to 1000
( from 1
). Because there can be multiple possible solutions, valid test cases will check if your string evaluates to the given number. Your return string must be formatted according to the rules set above (* 3
or + 5
, parentheses, spacing, and the starting 1
).
Also, optimize your output by reaching the number in the least steps possible, to prevent memory limit errors.
Similar Kata:
Stats:
Created | Apr 2, 2020 |
Warriors Trained | 38 |
Total Skips | 0 |
Total Code Submissions | 166 |
Total Times Completed | 16 |
JavaScript Completions | 14 |
Haskell Completions | 4 |
Total Stars | 0 |
% of votes with a positive feedback rating | 40% of 10 |
Total "Very Satisfied" Votes | 3 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |