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

It is only funny because it is true.

Change your loop to only loop while $v < 42, and then when the md5 matches, set $v to be the number of copies of "gonna" in the text. ( * ) Print the final string at the end.

If you had a good random generator then with very high probability this program would be correct, although it is unable to run in any reasonable time.

* There are exactly 42 copies of "gonna" in that text. Did God speaking through Douglas Adams subtly rickroll all of us?




Could this not also theoretically colide with a string with the same hash and more than 42 occurrences of "gonna"? Better set the flag to `$v==42` just to be safe.


The probability is overwhelmingly against there being another string of the same length and even 10 copies of "gonna".

The odds of another one with under 2k bytes and exactly 42 copies of "gonna" is a lot higher than having one with 43 copies of "gonna".

In a code golf competition, one character matters. Therefore the odds are that you should use "<" not "==" here.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: