/* mcdo.tc - lrb - 1/18/2012 mcdo [ pl "" ps "mcdo.tc - lrb - 1/18/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 "" int n,m,l,ba(6*10+9*10+20*10),foo,ans,ul ul=10 /* figure out which order quantities are OK for (n=0;n<=ul;++n) [ for (m=0;m<=ul;++m) [ for (l=0;l<=ul;++l) [ ba(n*6 + m*9 + l*20) = 1 /* order quantity is OK ]]] /* as soon as we find 100 OKs after a not OK, we got it for (l=0;l<6*ul+9*ul+20*ul;++l) [ if (ba(l)==0) [foo=0;ans=l] else ++foo if (foo==100) [pl "";ps "The answer is";pn ans;ps ".";pl "";break] ] ]