Retired

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.

Algorithms
Logic
Mathematics
Numbers
Recursion
Computability Theory
Theoretical Computer Science

More By Author:

Check out these other kata created by WestwardLand968

Stats:

CreatedApr 2, 2020
Warriors Trained38
Total Skips0
Total Code Submissions166
Total Times Completed16
JavaScript Completions14
Haskell Completions4
Total Stars0
% of votes with a positive feedback rating40% of 10
Total "Very Satisfied" Votes3
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes5
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • WestwardLand968 Avatar
  • JohanWiltink Avatar
  • user8436785 Avatar
Ad