Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: (TIMTOWTDI / Golf / Obfu) Airplanes in class

by Roger (Parson)
on Oct 04, 2003 at 11:22 UTC ( [id://296492]=note: print w/replies, xml ) Need Help??


in reply to (TIMTOWTDI / Golf / Obfu) Airplanes in class

Hehehe... very interesting. Below are my attempts -

Method 1 - Unnecessarily complicated
print qq{@{[qw/I will not throw paper airplanes in class./]}\n} for 1. +.500;
Method 2 - The C look alike
for ($i=0;$i<500;$i++) { printf("I will not throw paper airplanes in class.\n"); }
Method 3 - Embedded text
my $line = <DATA>; map { print $line } 1..500; __DATA__ I will not throw paper airplanes in class.
Method 4 - Simple obfuscation
$line="\n.ssalc ni senalpria repap worht ton lliw I"; print join'',reverse split//,$line for 1..500;
Method 5 - Another obfuscation
%x=qw/airplanes 5 class. 7 I 0 in 6 not 2 paper 4 throw 3 will 1/; print qq{@{[map {$_ ->[0]} sort{$a->[1]<=>$b->[1 ]}map{[$_, $x{$_}]}keys %x]} } for 1..length 'x' x 2 x 5 x 5 x 5 x 2; $a;$b;$c;$d;$e;
Method 6 - Back to BASIC, my own embedded mini BASIC interpreter!
while(<DATA>){chomp,m/^(\d+)\s+(.*)/,$p[$1]=$2}{ redo if ($p[++$pc] eq undef); if($p[$pc]=~/^(?:\s)*FOR\s+(\w+)(?:\s)*=(?:\s)*(\d+)(?:\s)*TO(?:\s)* +(\d+)/x){ $var{$1} = [$pc, $2, $3]; }elsif ($p[$pc] =~ /^(?:\s)*PRINT\s+'(.*)'/x){ print "$1\n"; }elsif ($p[$pc] =~ /^(?:\s)*NEXT\s+(\w+)/x){ die "variable $1 not defined!" if !$var{$1}; $var{$1}->[1]++; $pc = $var{$1}->[0] if $var{$1}->[1] <= $var{$1}->[2]; }elsif ($p[$pc] =~ /^(?:\s)*END/x){ exit(0); } redo; } __DATA__ 1 REM ****** BASIC PROGRAM ******* 2 REM *** Print Text 500 times *** 3 10 FOR I = 1 TO 500 20 PRINT 'I will not throw paper airplanes in class.' 30 NEXT I 31 32 REM ****** I CAN DO NESTED LOOP TOO ****** 33 40 FOR I = 1 TO 2 50 FOR J = 1 TO 5 60 FOR K = 1 TO 5 70 FOR L = 1 TO 10 80 PRINT 'I will not throw paper airplanes in class.' 90 NEXT L 100 NEXT K 110 NEXT J 120 NEXT I 130 END

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://296492]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-24 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found