in reply to read string (which is in binary) and make decision
Output:use Modern::Perl; while (<DATA>) { chomp; say "$_ : ", ( /^0+$/ or /^1+$/ ) ? 'PASS' : ( /^0+1+$/ or /^1+0+$/ ) ? 'CLEAN' : 'FAIL'; } __DATA__ 000000 111111 000011111 1111111000 10001001110000011
000000 : PASS 111111 : PASS 000011111 : CLEAN 1111111000 : CLEAN 10001001110000011 : FAIL
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: read string (which is in binary) and make decision
by hey_frind (Initiate) on Nov 17, 2012 at 09:50 UTC | |
by AnomalousMonk (Archbishop) on Nov 17, 2012 at 21:05 UTC | |
by CountZero (Bishop) on Nov 17, 2012 at 10:10 UTC |
In Section
Seekers of Perl Wisdom