/* mcdon.tc - lrb - 1/19,27/2012 mcdon [ pl "" ps "mcdon.tc - lrb - 1/19/2012" pl "" pl "At McDonald's you can order Chicken McNuggets in boxes of 6, 9, and 20." pl "What is the largest number such that you can not order any combination" pl "of the above to achieve exactly the number you want?" pl "" pl "Mathematically, this is equivalent to asking what is the largest integer" pl "k such that n*6 + m*9 + l*20 = k has no solution for any n, m, l?" pl "" pl "http://primepuzzle.com/charles/chicken-nuggets.jpg" pl "" sak;pl "" int n,m,l,ba(6*10+9*10+20*10),ul int wan(1000),wam(1000),wal(1000) ul=10 int pf /* plus sign (+) flag /* figure out which order quantities are OK for (l=ul;l>=0;--l) [ for (m=ul;m>=0;--m) [ for (n=ul;n>=0;--n) [ if (ba(n*6 + m*9 + l*20)!=1) [ ba(n*6 + m*9 + l*20)=1 if n wan(n*6 + m*9 + l*20)=n if m wam(n*6 + m*9 + l*20)=m if l wal(n*6 + m*9 + l*20)=l ]]]] pl "" int lctr for (l=100;l>0;--l) [ if lctr>16 [sak;pl "";pl "";lctr=0] pn l if ba(l) [ ++lctr;pf=0;ps " =" if wan(l) [pn wan(l);ps " *";pn 6;pf=1] if wam(l) [if pf ps " +";pn wam(l);ps " *";pn 9;pf=1] if wal(l) [if pf ps " +";pn wal(l);ps " *";pn 20] ] else [ bell;pl "";pl "";ps "no solution!";pl "";lctr=lctr+3 ] pl "" ] ] /* sound middle C for a second bell [ beep 523,10 ]