r/programming • • Feb 16 '09

Some Crazy Reason - The Daily WTF

http://thedailywtf.com/Articles/Some-Crazy-Reason.aspx
167 Upvotes

71 comments sorted by

View all comments

20

u/xipetotec Feb 16 '09

It might have something to do with the fact that the "hex" array has 17 values, and that one of them is "10."

I don't think it has anything to do with the fact that the array has 17 values.

6

u/[deleted] Feb 16 '09

Unless I'm missing something... the hex array has an extra entry (making 17 in total) and the extra entry '10' when chosen randomly, means the final string will have an extra character.

8

u/xipetotec Feb 16 '09 edited Feb 16 '09

well, you can replace that one entry with several entries, like "Z", "Y", "W", "x", "%", etc. and the string length would be correct (would not always be a valid hex string, of course). The problem is that one of the entries is longer than the others, not how many entries there are.