As this post was published on the 7th of February 2022 (07/02/22), we would like to use a Python algorithm to solve the following arithmetic puzzle:
Let’s consider a string consisting of 10 characters “2”: string = “2222222222”
This computing challenge consists of writing an algorithm to work out the largest number we can create by inserting 2 multiplication operators (*) anywhere within this string.
- 2 * 2 * 22222222 = 88,888,888
- 2 * 22 * 2222222 = 97,777,768
- 2222 * 2222 * 22 = 108,620,248
- 222 * 222 * 2222 = 109,509,048
10th February 2022
You can use the trinket below to write and test your algorithm… We have started the code for you to test all possible positions of the first multiplication operator. Your task is to complete this code to:
- Add a second multiplication sign and test every possible position for this second sign,
- Calculate the result of each expression and output the largest value reached.
Solution...The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area