(Ovid) RE: YAJAPH
by Ovid (Cardinal) on Nov 11, 2000 at 00:47 UTC
|
Are you referring to the rotated Mayan numerals? I know what you mean about it being easier to understand. It was my understanding that if a judge could look at an entry and get a feel for what it was doing, it was disqualified.
I read through the winner and saw what was going on. I played around with it and really got a handle on it. While I will admit that I thought it was a beautiful obfuscation, it hardly fell in the "difficult" category. I suspect that it won because of the interesting approach.
Frankly, I'm not a good enough Perl programmer to "get" most obfuscated code (that's the point, huh?), so if I see something I "get", I don't really think it's obfuscated.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats. | [reply] [Watch: Dir/Any] |
|
Ovid wrote:
>Are you referring to the rotated Mayan numerals?
Right, that one. I thought it was a cute idea, but it was basically a gimmick,
and the code itself was not obfuscated; it was straightforward.
If I had thought of doing that I would have decided it was not interesting
enough to submit.
I don't mind getting second place, but I do wish that the program that had won had been
harder to understand.
| [reply] [Watch: Dir/Any] |
YAJAPH Solution
by Dominus (Parson) on Dec 02, 2000 at 06:46 UTC
|
| [reply] [Watch: Dir/Any] |
YAJAPH Hint #01
by Dominus (Parson) on Nov 12, 2000 at 21:56 UTC
|
If you think you understand what is going on in this program, ask
yourself the following question:
What is @P for? Why does it have the value it has?
If you don't know the answer, you don't understand the program.
@P is the most important data structure. Tampering with @P will break
the program totally.
| [reply] [Watch: Dir/Any] [d/l] [select] |
YAJAPH Hint #02
by Dominus (Parson) on Nov 14, 2000 at 22:13 UTC
|
How is the output being printed? What is in $_
when the print
statement is executed? | [reply] [Watch: Dir/Any] |
YAJAPH Hint #03
by Dominus (Parson) on Nov 17, 2000 at 00:48 UTC
|
Since the print prints
$_, and $_ contains only one character, but
the program produces 32 bytes of output, clearly there are at least 32
processes involved.
Each process does
sleep rand(2)
to emphasize this.
But the output comes out in the right order even though 32 concurrent
processes are each printing a single character.
How is that accomplished?
| [reply] [Watch: Dir/Any] [d/l] |
YAJAPH Hint #04
by Dominus (Parson) on Nov 20, 2000 at 05:57 UTC
|
Why are there exactly five calls to the p() function?
| [reply] [Watch: Dir/Any] |
YAJAPH Hint #05
by Dominus (Parson) on Nov 23, 2000 at 23:25 UTC
|
$q is used to index the data array
@d to select which character is printed.
How is $q computed?
| [reply] [Watch: Dir/Any] |
YAJAPH Hint #06
by Dominus (Parson) on Nov 26, 2000 at 23:46 UTC
|
"r$p" and "u$p" are used in the
pipe() call as filehandle names and
also as keys into the %p hash. Therefore,
%p is tracking something
about the filehandles.
| [reply] [Watch: Dir/Any] |
YAJAPH Hint #07
by Dominus (Parson) on Nov 29, 2000 at 04:16 UTC
|
%p is updated by the two statements:
$P = $P[$f|ord($p{$_})&6];
$p{$_}=/ ^$P/ix?$P:close$_
I promised back in HINT01 that @P
was the most important data
structure in the program. What is the significance of
the index
$f|ord($p{$_})&6 here?
| [reply] [Watch: Dir/Any] [d/l] |
YAJAPH Hint #08
by Dominus (Parson) on Nov 30, 2000 at 00:12 UTC
|
| [reply] [Watch: Dir/Any] |
YAJAPH Hint #09
by Dominus (Parson) on Nov 30, 2000 at 19:24 UTC
|
Under what circumstances is the close() call exercised?
What is closed?
| [reply] [Watch: Dir/Any] |
YAJAPH Hint #10
by Dominus (Parson) on Dec 01, 2000 at 05:14 UTC
|
Try making a diagram of where the pipes go.
| [reply] [Watch: Dir/Any] |
RE: YAJAPH
by arturo (Vicar) on Nov 11, 2000 at 00:23 UTC
|
use the "d/l code" link that shows up at the bottom of nodes containing <code> tags. It will give you "just the code" as a text/plain doc in your browser window (unless your browser's set to d/l the text) Philosophy can be made out of anything. Or less -- Jerry A. Fodor
| [reply] [Watch: Dir/Any] |
|
Yeah, but it's silly to have to do that.
They should break the lines at 80 characters, not 70.
| [reply] [Watch: Dir/Any] |
|
OK, I now present the exclusive Perl Monks-only verion of the program:
@P=split//,".URRUU\c8R";sub p{@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";
++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|6&ord$p{$_}];$p{$_}=/ ^$P/ix?$P:
close $_} keys %p} @d= split //, "\nrekcah xinU / lreP rehtona tsuJ"
;p;p;p;p;p;
map{ $p{$_} =~ /^[P.]/ && close$_} %p; wait until$?;
map{/^r/&&<$_>} %p;$_ = $d[$q]; sleep rand(2)if/\S/;
print
| [reply] [Watch: Dir/Any] [d/l] |
|
This is a setting you can change in your user preferences.
| [reply] [Watch: Dir/Any] |
|