Hacker News new | past | comments | ask | show | jobs | submit login

Very cool solution. Out of curiosity, how many iterations complete before finding the solution?



Normally, inner loops are executed more times than outer loops, but in this program the inner loops are skipped (because of the continue statements) when constraints fail in the the outer loops. The five loops are executed a total of 69, 1265, 520, 890 and 109 times respectively (I put counter in each loop, all counters were initialized before any of the loops begin).

Python is great for simple problems like this. I wrote this program while waiting for my daughter to come downstairs to be driven to school this morning.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: