You're viewing a comment by Peter Stuifzand and its responses.

November 10, 2011, 11:56

I created a oneliner that checks for point 119 how many numbers it matches between 0 and 255. This number should be 256, but its not.

perl -E 'for (0..255) { $count+=m/^(([0-9])|([0-9][0-9])|([12][0-5][0-5]))$/}END{say$count}'

Comment Responses

November 10, 2011, 12:03

I was confident it was right. I never checked it, I only trusted my reasoning. Now it will be interesting to find where I went wrong.

Edit: Aha, 106 - 109, 116 - 119, ..., 156 - 199 don't get matched, and 206-209, 216-219, 226-229, 236-239, 246-249.

Here is the fix:

/^(([0-9])|([0-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))$/

Matches 0-9 or 10-99 or 100-199 or 200-249 or 250-255.

Here is the original, broken one that I had:

/^(([0-9])|([0-9][0-9])|([12][0-5][0-5]))$/

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "halflife3_277": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.