Select Change


Collapse Content

In this challenge, there can be up to 30 different coins! Can you select a specific sum from a list of coins, without picking up 3 coins in a row?

Details
You will be given a list of numbers where the first number is the desired sum and the remaining numbers are the coins. Determine if the coins can be added together to reach the exact sum. However, you cannot select 3 coins in a row. (You also cannot use the same exact coin twice.)

For example, when given {12, 1, 2, 3, 4, 5}, print true since 1+2+4+5 = 12. When given 50 1 3 5 37 18 5 print false, since you cannot select a sum of 50 without picking 3 coins in a row.

Challenge

Print true if you can select the exact sum from the given numbers (without 3 in a row), and false otherwise.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Contact Us
Sign in or email us at [email protected]