in reply to Re^2: Homework Golf (35)
in thread Homework Golf
Those spaces around or are annoying... Let's use something else to express conditionnal printing. With -p, x= does the job:#23456789_123456789_123456789_123456789_12 perl -nlE'65^unpack"%c*","?"x30&uc or say'
While we're looking at those switches... Why the -l? Removing it and adding ord("\n") (10) to the target (65) shaves another stroke:#23456789_123456789_123456789_123456789_1 perl -ple'$_ x=65==unpack"%c*","?"x30&uc'
There's a much shorter solution using a 6-bit checksum. The problem is that it comes up with a few false positives (words whose value is 1, 129, 193...):#23456789_123456789_123456789_123456789_ perl -pe'$_ x=75=~unpack"%c*","?"x30&uc'
Using a 5-bit checksum removes the need for uc, but brings even more false positives:#23456789_123456789_123456789_1234 perl -ple'$_ x=1==unpack"%6c*",uc' perl -pe'$_ x=11==unpack"%6c*",uc'
#23456789_123456789_123456789_1 perl -ple'$_ x=1==unpack"%5c*"' perl -pe'$_ x=11==unpack"%5c*"' perl -nlE'1^unpack"%5c*"or say' perl -nE'11^unpack"%5c*"or say'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Homework Golf (35)
by McD (Chaplain) on Dec 09, 2013 at 18:18 UTC | |
by eyepopslikeamosquito (Archbishop) on Dec 09, 2013 at 19:14 UTC |