We bought one of our magazines earlier this week and I like to do the quizzes within them.
Below is one that will interest all you people out there.
There is a list of numbers that have to be fitted into a crossword style grid, and the number that is left over, when correctly completed, is the answer to the posed question.
If you use only the standard UK coinage of 1p, 2p, 5p, 10p, 20p, 50p, £1 & £2, how many different ways are there to make exactly £2?
No cheating or using Google etc. Only guesses or actual working it out.
Answer will be posted tomorrow night around this time, so the whole world gets a chance.
Post your guesses and we will see who is closes. No prizes, just satisfaction of being closest.
Doesn't look like anyone else figured it out, what was your solution? I wasted about 5 minutes at work today throwing this together
#include<stdio.h>
main(){
int i,j,k,l,m,n,o,x=1;
for(i=0;i<201;i++){
for(j=0;j<101;j++){
for(k=0;k<41;k++){
for(l=0;l<21;l++){
for(m=0;m<11;m++){
for(n=0;n<5;n++){
for(o=0;o<3;o++){
if((i+(j*2)+(k*5)+(l*10)+(m*20)+(n*50)+(o*100))==200)x++;
}}}}}}}
printf("%dn",x);
}
I wrote almost the same program in basic. Then I couldn't figure out how to run it under windows 10.
Quote: "phfoticus"I wonder how long those loops would take in something interpreted like Python, Ruby, Tcl, Perl, Javascript, PHP, etc. (one without JIT compilation)?
A bit longer, but probably still nothing unbearable. This was a 24 hour thread, so plenty of time to be patient... It could be optimized by doing partial sums at each level, and breaking that loop whenever it's greater than 200, a lot less total computations when you run it, but a lot more code to write. And I already had my answer so no reason to bother with that nonsense
I didn't write it myself I just remembered that somebody who likes these kind of riddles and likes to code send me this python script a while ago. I just modified it to the conditions of this quest.
Just a summation with arrays and took 1.8 sec for a complete run it seems.
def Anzahl(S, m, n ):
if (n == 0):
return 1
if (n < 0):
return 0;
if (m <=0 and n >= 1):
return 0
return Anzahl( S, m - 1, n ) + Anzahl( S, m, n-S[m-1] );
Muenzen = [1, 2, 5, 10 , 20, 50, 100, 200]
m = len(Muenzen)
print(Anzahl(arr, m, 200))
Ok, it's answer time. A little early, but its hot in my office, so I thought anyone who wanted to have a go, would have done so by now.
Attached are two photographs.
Left-the whole quiz, with numbers to left, crossed out if used and the crossword grid filled in.
Right-The list of numbers, clearly showing the one that has not been used, which is the answer.
I guess 'plenty'is an answer that covers this problem well. I really do not like to get headach, doing maths, once
I am enjoying my favorit coin site in my small freetime:)...
I don't understand the posted scripts. Idolenz: what is arr? It seems undefined. Houseofham: initially ways is a list ("ways = [1] + [0]*target"), how can you add a number to it ("ways += ways[i-coin]")?
Quote: "numinis"I don't understand the posted scripts.
Idolenz: what is arr? It seems undefined.
Houseofham: initially ways is a list ("ways = [1] + [0]*target"), how can you add a number to it ("ways += ways[i-coin]")?
Argh!! Buggy forum ate some characters cause it thinks i in square brackets is bbcode for italic :(
ways[ i ] += ways[i-con]
How about for spice, we assume its 1984 and we also have the ½p coin, what would that take it up to?
I love coins. Especially silver, gold and anything really old.
Member of the Royal Numismatic Society of New Zealand and the Auckland Numismatic Society