PDA

View Full Version : Obfuscated code



Sockerdrickan
January 12th, 2009, 08:59 AM
post your code! :popcorn:

//gcc guess.c && ./a.out

i,r,t;main()
{srand (time(0))
;r=rand() %9;puts(
"guess" " 0-9");do
{scanf ("%d",&i)
;++t ;puts(i<
r?"higher"
:"lower"
);}while
(i-r);
printf
("yes "
"(%d "
"trie"

"s)\n"
,t);}

u-slayer
January 12th, 2009, 09:18 AM
post your code! :popcorn:

//gcc guess.c && ./a.out

i,r,t;main()
{srand (time(0))
;r=rand() %9;puts(
"guess" " 0-9");do
{scanf ("%d",&i)
;++t ;puts(i<
r?"higher"
:"lower"
);}while
(i-r);
printf
("yes "
"(%d "
"trie"

"s)\n"
,t);}


Haven't bothered to compile it, but from a quick read thru, this code generates a random number 0-8 and asks the user to guess it, it then prompts the user higher or lower as to how to guess again while keeping track of the number of tries.

What confuses me is how you got away with not declaring or initializing i, r, t.

slavik
January 12th, 2009, 09:33 AM
I believe they are int types by default.

Tuna-Fish
January 12th, 2009, 11:58 AM
Haven't bothered to compile it, but from a quick read thru, this code generates a random number 0-8 and asks the user to guess it, it then prompts the user higher or lower as to how to guess again while keeping track of the number of tries.

What confuses me is how you got away with not declaring or initializing i, r, t.


i,r,t;main()

Right there.

slavik
January 12th, 2009, 02:39 PM
Perl one liner (it is actually one statement).


print join ", ", map { join " ", @$_ } sort { $a->[1] <=> $b->[1] } map { [split /\s+/] } split /\s*,\s*/, <>;

Greyed
January 12th, 2009, 02:47 PM
The bane of writing in Python, obfuscation is hard. If there was ever a proof of a language being easier to write good code I think that would be it. Of course if I took the cheap way out with map(), reduce() and lamba() like Slavik did I guess that could be obfuscated. But with the full power of Perl at his fingertips I think Slavik has to make a real entry which doesn't use any of those. ;)

slavik
January 12th, 2009, 03:02 PM
The bane of writing in Python, obfuscation is hard. If there was ever a proof of a language being easier to write good code I think that would be it. Of course if I took the cheap way out with map(), reduce() and lamba() like Slavik did I guess that could be obfuscated. But with the full power of Perl at his fingertips I think Slavik has to make a real entry which doesn't use any of those. ;)
Here's a cop out answer for you: in Perl6, for loops also return lists like maps ;)
ie: @arr = map { 1 } 1..100 is similar to @arr = for 1..100 { 1 };

Greyed
January 12th, 2009, 03:11 PM
Here's a cop out answer for you: in Perl6, for loops also return lists like maps ;)
ie: @arr = map { 1 } 1..100 is similar to @arr = for 1..100 { 1 };

Bah, Perl6, the Duke Nuk'em Forever of languages.

And just so I am not remiss in an entry.



,+.+.+.+.+.

slavik
January 12th, 2009, 03:18 PM
Bah, Perl6, the Duke Nuk'em Forever of languages.

And just so I am not remiss in an entry.



,+.+.+.+.+.

I already write Perl6 code :)

loell
January 12th, 2009, 03:21 PM
I already write Perl6 code :)

I envy you, i already know 1/4 of perl 5.x and yet you do perl 6, swoosh just like that. :)

slavik
January 12th, 2009, 03:34 PM
http://rakudo.org/

Back on topic: Anyone else got neat obfuscated code?

nvteighen
January 12th, 2009, 07:31 PM
http://rakudo.org/

Back on topic: Anyone else got neat obfuscated code?


yq28whww; %(8, 8); ?
?? * + ]


It's that obfuscated that even I don't know what language it is and what it does :D

slavik
January 12th, 2009, 08:12 PM
yq28whww; %(8, 8); ?
?? * + ]


It's that obfuscated that even I don't know what language it is and what it does :D
HAHA, perfect ....