[Community Puzzle] The Total is Right - Weird edition

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

can be labeled as dynamic programming problem

also , my first solution passed all validators but not test 4 , where there is a sub-expression with the value more than n * a^2 . i mistakenly thought that any sub-expression couldn’t exceed n * a which apparently is true for all validators , but not test 4

1 Like

Rly awsome comment… FEELS good to see ppl with EXACT same issues !

1 Like

I am trying to wrap my head about how to do this puzzle, but one part of the statement is nagging me.

Note: Divisions are valid only if the result is an integer. Thus, 8/4 is valid and 10/3 is not.

I cannot visualize what kind of situation it is that should be prevented. Is it something like (3*3-3/3)/3 is not allowed because it results in a non-integer, so somehow I should avoid any intermediate division that leads to an intermediate non-integer?

(3*3-3/3)/3 + (3*3-3/3)/3 + (3*3-3/3)/3 results an integer, but not allowed because partial results are non-integers. I think it is to avoid using floats and the possible rounding errors.

2 Likes

I really liked this puzzle - it is a good challenge initially to analyse a way of solving it, followed by a nice bit of intricate coding to keep within the timeout. And it really demonstrates how fast computers are versus humans if you try to solve any of the tests on paper!

I’m not sure if this question is allowed or not, but i can’t figure out how to get to 665 with 11s in 7 repeats :sweat_smile:

(11 * 11 * 11 * 11 - 11) / (11 + 11) = 665

1 Like