1
$\begingroup$

I am currently creating a maths game and need a little help.

Inside the Game you can add up coins.

maximum 1 each

(1p,2p,5p,10p,20p,50p,£1,£2)

You can also multiply the current sum

maximum 1 each

(x2,x3,x5)

The total sum of adding coins and multiplying has to equal to a random generated number which is between £10 and £20.(with decimals)

An example: Random Number = £12.22

Answer: [50p] [x2] [£1] [x5] [£2] [20p] [2p]

My Question is: If there is always a solution to a random Generated Number? If the answer is no then what should be the upper-bound

Thank you

$\endgroup$
  • $\begingroup$ Well you obviously cannot get higher than (1p+2p+5p+10p+20p+50p+$1+£2)x5=19.40 unless you are allowed to use coins more than once. There are also some lower numbers you cannot get. $\endgroup$ – almagest Jun 18 '16 at 21:41
  • $\begingroup$ sorry couldn't explain properly. You can also multiply with the number 2 and 3. It doesn't have to be in the end of sum. $\endgroup$ – TaZlyy Jun 18 '16 at 21:44
  • $\begingroup$ But can you multiply the £2 by both 3 and 5? $\endgroup$ – almagest Jun 18 '16 at 21:47
  • $\begingroup$ for example (1p+2p+5p+10p+20p+50p+£1+£2)x5x3x2 = £116.4 or (1p x2 +2p+5p x5 +10p+20p x3 +50p+£1+£2) = £5.75 $\endgroup$ – TaZlyy Jun 18 '16 at 21:48
  • $\begingroup$ But can you multiply the £2 by both 3 and 5? yes you can $\endgroup$ – TaZlyy Jun 18 '16 at 21:49
1
$\begingroup$

I wrote a program to scan the possible plays, and the maximum number of actions (add a coin or multiply) required to reach any value in your playing range is $9$, which occurs only twice at $£16.99$ and $£19.99$

All values up to $£40.00$ are also reachable with no more than $10$ actions. The first value to require all $11$ actions is $£41.99$. The lowest value that cannot be reached is $£59.97$, and $£59.99$ is also unreachable.

$\endgroup$
  • $\begingroup$ oh wow that is awesome... I wrote this code in Java and I was trying to solve the number £15.98 and am struggling. But its good to know that they all work. I would also like to know the first unreachable number as its very interesting. Thank you Joffan $\endgroup$ – TaZlyy Jun 18 '16 at 22:29
  • $\begingroup$ "Amazingly"? I'm not surprised. I'd be interested in which values are easy to reach and which are hard. I imagine x.99 are generally few ways to reach. $\endgroup$ – fleablood Jun 18 '16 at 22:33
  • $\begingroup$ @TaZlyy £15.98 can be made as 5p, +£1, $\times 5$, +1p, $\times 3$, +20p $\endgroup$ – Joffan Jun 18 '16 at 22:59
  • $\begingroup$ thanks joffan, you helped me alot! +rep $\endgroup$ – TaZlyy Jun 18 '16 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.