Computer Science Canada

Obfuscated Coding Contest

Author:  Martin [ Fri Feb 04, 2005 10:45 am ]
Post subject:  Obfuscated Coding Contest

200 bits for this one.

What your program has to do is output "Hello World" to the screen. There's a catch though: your goal is to make your code as confusing and difficult to read as possible.

Only rule is that your code must be indented properly.

Your program must finish executing within 5 seconds of loading up.

Go!

Author:  Tony [ Fri Feb 04, 2005 10:59 am ]
Post subject: 

brainfuck:

++++++++[>+++++++++<-]>.<++++[>+++++++<-]>+.<++[>+++<-]>+..+++.++++[>++++++++<-]>.<+++++[>++++++++++<-]>+++++.<<.+++.------.<+++[>---<-]>+.

Author:  rizzix [ Fri Feb 04, 2005 11:13 am ]
Post subject: 

that is not obfuscated tony.. its just bf.

Author:  Martin [ Fri Feb 04, 2005 11:43 am ]
Post subject: 

One of the languages that is supported by this site, or that wtd has written a tutorial for only.

Author:  Tony [ Fri Feb 04, 2005 12:07 pm ]
Post subject: 

*Opens up adminPanel and adds brainfuck to the list of forums*
Twisted Evil

Author:  Martin [ Fri Feb 04, 2005 1:23 pm ]
Post subject: 

Fine. -1000 bits for plagerizing.

Author:  Brightguy [ Fri Feb 04, 2005 5:08 pm ]
Post subject:  Re: Obfuscated Coding Contest

VisualBASIC:
Sub Form_Load()
    Dim a(0 To 10)
    a(0) = 29492
    a(1) = -42248461/504
    a(2) = 4881462049/50400
    a(3) = -2761745939/45360
    a(4) = 8480639179/362880
    a(5) = -99877913/17280
    a(6) = 20304973/21600
    a(7) = -6042593/60480
    a(8) = 807637/120960
    a(9) = -92357/362880
    a(10) = 3827/907200
    For b = 1 To 11
        c = 0
        For d = 0 To 10
            c = c + a(d) * (b ^ d)
        Next
        Print Chr(c);
    Next
End Sub

If you can't see the output make sure the form's AutoRedraw is True.

Author:  rizzix [ Fri Feb 04, 2005 5:23 pm ]
Post subject: 

k, beat this:

Perl:
#!/usr/bin/perl

for (($______ = "M") =~ tr/J-M/A-E/,$_____ = '\\'.$______.'+',
       ($____ = qw(s/$1/ord("h")/goix||s{$1$5}(($1|$1).?\D+[$7,0,9,$8]?as)xo&)
              . qw(&s/$1[:]*/$2.*[$3]?/xgo||m($1?\P{$1$2}.*[$1,$1,$4]+)||s/$1)
              . qw([0-5]?.*($1$1[0,1]$1$6)/0?.$3$2+\s+$1$1$5/goi&&s/[1,0,4]?$1[)
              . qw(0-5]?/$[1,0,2]\D+$1$1$6/&&m[$1$2$5]ix))
              =~ s*($_____)**go, $__ = 0, $k = "", $___ = 3;
    $__ < 6*8; $__ += $___) {
        ($k .= chr(int(substr($____, $__, $___)))) and
        (length($k) == 16-1 ? eval("*_ = ".$k."}") ? eval('$_ = "oLSSV wVYSK\n"'):false:false)
} tr/H-Za-r/a-zA-Z/; _ ($_);

Author:  zylum [ Fri Feb 04, 2005 5:38 pm ]
Post subject: 

rizzix wrote:
k, beat this:

Perl:
#!/usr/bin/perl

for (($______ = "M") =~ tr/J-M/A-E/,$_____ = '\\'.$______.'+',
       ($____ = qw(s/$1/ord("h")/goix||s{$1$5}(($1|$1).?\D+[$7,0,9,$8]?as)xo&)
              . qw(&s/$1[:]*/$2.*[$3]?/xgo||m($1?\P{$1$2}.*[$1,$1,$4]+)||s/$1)
              . qw([0-5]?.*($1$1[0,1]$1$6)/0?.$3$2+\s+$1$1$5/goi&&s/[1,0,4]?$1[)
              . qw(0-5]?/$[1,0,2]\D+$1$1$6/&&m[$1$2$5]ix))
              =~ s*($_____)**go, $__ = 0, $k = "", $___ = 3;
    $__ < 6*8; $__ += $___) {
        ($k .= chr(int(substr($____, $__, $___)))) and
        (length($k) == 16-1 ? eval("*_ = ".$k."}") ? eval('$_ = "oLSSV wVYSK\n"'):false:false)
} tr/H-Za-r/a-zA-Z/; _ ($_);


lmfao Laughing

Author:  bugzpodder [ Fri Feb 04, 2005 5:58 pm ]
Post subject: 

at least mine is original
c:

see version two below

Author:  rizzix [ Fri Feb 04, 2005 6:04 pm ]
Post subject: 

yea so is mine Smile

nice one btw. Wink

Author:  Martin [ Fri Feb 04, 2005 11:56 pm ]
Post subject: 

Can anyone beat these...?

The race is on. Contest closes Sunday.

Author:  bugzpodder [ Sat Feb 05, 2005 12:13 am ]
Post subject: 

version two:

c:

#include<stdio.h>
#define B int
#define I main
#define T ()
#define S {
#define T1 (
#define ME T1
#define T2 )
#define Z }
#define s ;
#define b 0
#define BO return
#define lunch putchar

B I T S for ME B i s i["]<i;++i){--i;}"] s i++ T2 lunch T1 i ["\x48\105\x4C\114\117 W\x4FR\x4C\104!\n"] T2 s BO b s Z

Author:  bugzpodder [ Sat Feb 05, 2005 12:37 am ]
Post subject: 

is there a judging criteria? messy/code length/etc

Author:  rizzix [ Sat Feb 05, 2005 12:44 am ]
Post subject: 

yea good question.. although keep in mind martin, obfuscation is really vague.. it covers horrifyingly messy code to beautifully decorated code.. but one thing is for sure: the code should break standard coding conventions and they do tend to make decyphering difficult.

edit: i suggest looking at international obfucated coding contests.. they give a better picture.

Author:  md [ Sat Feb 05, 2005 9:54 am ]
Post subject: 

C:
code:

int main(void){printf("Hello world!");}


haha! I win! Wink

Author:  rizzix [ Sat Feb 05, 2005 11:34 am ]
Post subject: 

here's a rather simple, yet amusing one:

Perl:
#!/usr/bin/perl

sub says {print shift} sub hi  {v72.101.108.108.111.32.shift}
sub to   {shift().v10} sub all {v87.111.114.108.100.33}
sub UNIVERSAL::AUTOLOAD {}

Perl, says hi to all and yes this entire sentence is part of the executable code

Author:  Martin [ Sat Feb 05, 2005 11:34 am ]
Post subject: 

I'm going to put this up to a vote. It will be a combination of the artisticness and the unreadability of the code.

Author:  Martin [ Sun Feb 06, 2005 8:06 pm ]
Post subject: 

Contest closed. 200 bits to bugz, 100 bits to BrightGuy.

Good job everyone Smile

Author:  rizzix [ Sun Feb 06, 2005 8:30 pm ]
Post subject: 

sadly only three eligible persons participated in the contest Rolling Eyes

Author:  Catalyst [ Sun Feb 06, 2005 8:56 pm ]
Post subject: 

too late but oh well
c++:

#include <iostream>
#define __for(a,b) int _it=b;_it<(int)(a*100);_it++
#define _ghy(a) a++
#define _ghz(a) a--
#define ghj 255
#define sif else if
#define sql(a) c[a]
#define loop_h(b) if (sql(_it)==c[b])
int main(int argc, char *argv[])
{       
        int m[1000];int _p;for(__for(10,0)){m[_it]=_p=0;}
        char c[350]="ebzdafghifklmnopqrtsuvwxycaahav$aayauanaaafcanaaaca$ahavaayauanaaa$canaaanaaadddbgcccaaedaeanaa\
                                      anaaaee$anaaedanaaa$edanaafcbmbnbb$dbgcecaahavaay$auaaeb$mbnbbbmbnbbeaa\
                                         aebmbnbb$bbebmbnbbbmbnbbeddana$afcanaaad$bgcaaedaahava$ayauanaaae"
;
        for (__for(3,26)){
                loop_h(4) {_ghy(m[_p]);} loop_h(1) {_ghz(m[_p]);}
                loop_h(25) {_ghy(_p);}   loop_h(3) {_ghz(_p);}     
                loop_h(0) {std::cout<<(char)(m[_p]);}        
                loop_h(9) {if (m[_p]==0) {for(;c[_it+1]!=c[6];){_it++;}}}              
                loop_h(6) {if (m[_p]!=0) {for(;c[_it+1]!=c[9];){_it--;}}}       
        }
}

Author:  rizzix [ Sun Feb 06, 2005 9:04 pm ]
Post subject: 

yea i think martin should extend the contest by another two weeks.
Wink (i'm expecting more to contribute)

Author:  rizzix [ Sun Feb 06, 2005 9:07 pm ]
Post subject: 

catalyst, ur code does not compile (using g++ 3.4)

Author:  Catalyst [ Sun Feb 06, 2005 9:13 pm ]
Post subject: 

hmm, ive been editing it, try now
edit: new code works using gcc 3.3.1

Author:  rizzix [ Sun Feb 06, 2005 9:15 pm ]
Post subject: 

awesome, works Wink

Author:  Martin [ Sun Feb 06, 2005 9:53 pm ]
Post subject: 

Alright, contest is extended for two more weeks, ending on the Sunday.

Author:  Catalyst [ Thu Feb 10, 2005 1:41 am ]
Post subject: 

c++:

#include <iostream>
#define __for(a,b) int _it=b;_it<(int)(a*100);_it++
#define _h(a,b) (c[_it]==c[a]||c[_it]==c[b])&&c[_it]==c[a]
#define _h2(a,b) (c[_it]==c[b])

int main(int argc, char *argv[])
{       
         int m[1000];int _p,inc=0,_b=-1;for(__for(10,0)){m[_it]=_p=0;}
         char c[350]="ebzdafghifklmnopqrtsuvwxycaahav$aayauanaaafcanaaaca$ahavaayauanaaa$canaaanaaadddbgcccaaedaeanaa\
                      anaaaee$anaaedanaaa$edanaafcbmbnbb$dbgcecaahavaay$auaaeb$mbnbbbmbnbbeaa\
                      aebmbnbb$bbebmbnbbbmbnbbeddana$afcanaaad$bgcaaedaahava$ayauanaaae"
;
         for (__for(3,26)){
                                _h(4,1)?m[_p]++:_h2(4,1)?m[_p]--:_b=_b;
                                _h(25,3)?_p++:_h2(25,3)?_p--:_p=_p;                             
                                if (_h2(25,0))std::cout<<(char)(m[_p]);
                                _h(9,6)?(m[_p]==0?_b=1:_b=0):_h2(9,6)?(m[_p]!=0?_b=1:_b=0):_p=_p;                                         
                                m[_p]==0&&_b==1?inc=1:_b=_b; m[_p]!=0&&_b==1?inc=-1:_it=_it;                    
                                for(;c[_it+1]!=c[(inc>0?6:9)]&&_b==1;){_it+=inc;}       
        }
}


better now Very Happy

Author:  rizzix [ Mon Sep 19, 2005 7:54 pm ]
Post subject: 

ehm you guys.. need to repost... cuz of the rollback we lost everything in that week..

Author:  [Gandalf] [ Mon Sep 19, 2005 8:12 pm ]
Post subject: 

Sigh... And I spent a whole hour doing my crappy trial. Luckily, I saved it Smile.

Turing:
var l:array 1..26of char:=init('p','o','i','u','y','t','r','e','w','q','l','k','j','h','g','f','d','s','a','m','n','b','v','c','x','z')
var w:=l(8*2-2)+l(14div 2+1)+l(16-6+1)+l(18+5-12)+l(22-21+1)+chr(43-11)+chr(upper(l)+93)+l(5div 3+1)+l(round(9*0.81))+l(round(21/2))+l(12-2+7)
for i:1..length(w)
put chr(ord(w(i))*round(sqrt(4))div(4/2))..
end for

Author:  beard0 [ Mon Sep 19, 2005 8:27 pm ]
Post subject: 

Ah yes, here goes:
(Again, idea from Tony, whose program incidentally does not work)

code:
var hw := "++++++++[>++++[>++>+++>+++>+<<<<-]>+>->+>>+[<]<-]"
hw += ">>.>>---.+++++++..+++.>.<<-.>.+++.------.--------.>+.>++.#"
proc runprog (prog : string)
    var w := Window.Open ("text,title:BF Run Window,position:0;0")
    var cell : array 1 .. 300000 of int
    for i : 1 .. upper (cell)
        cell (i) := 0
    end for
    var c : string (1)
    var i := 1
    var p := 1
    loop
        c := prog (p)
        exit when c = "#"
        if c = ">" then
            i += 1
            p += 1
        elsif c = "<" then
            i -= 1
            p += 1
        elsif c = "+" then
            cell (i) += 1
            if cell (i) = 256 then
                cell (i) := 0
            end if
            p += 1
        elsif c = "-" then
            cell (i) -= 1
            if cell (i) = -1 then
                cell (i) := 255
            end if
            p += 1
        elsif c = "[" and cell (i) = 0 then
            var a := 0
            loop
                p += 1
                exit when p > upper (prog)
                c := prog (p)
                if c = "[" then
                    a += 1
                elsif c = "]" and a > 0 then
                    a -= 1
                elsif c = "]" and a = 0 then
                    exit
                end if
            end loop
        elsif c = "[" and cell (i) not= 0 then
            p += 1
        elsif c = "]" and cell (i) not= 0 then
            var a := 0
            loop
                p -= 1
                c := prog (p)
                if c = "]" then
                    a += 1
                elsif c = "[" and a > 0 then
                    a -= 1
                elsif c = "[" and a = 0 then
                    exit
                end if
            end loop
        elsif c = "]" and cell (i) = 0 then
            p += 1
        elsif c = "." then
            put chr (cell (i)) ..
            p += 1
        elsif c = "," then
            var inp : string (1)
            getch (inp)
            cell (i) := ord (inp)
            p += 1
        elsif c = "#" then
            exit
        else
            p += 1
        end if
        exit when p > length (prog)
    end loop
end runprog
runprog (hw)


Edit: Changed const to var in the first line of code

Author:  Mr. T [ Sun Oct 02, 2005 3:09 pm ]
Post subject:  Alex's Opinion

Your code doesn't work beard0. Confused

Author:  beard0 [ Sun Oct 02, 2005 3:17 pm ]
Post subject:  Re: Alex's Opinion

Pwned wrote:
Your code doesn't work beard0. Confused


Thanks, does now. I had made a last minute change in spliting the hw string into two pieces to make it more readable, and forgot that I had used a constant, and didn't test.

Author:  codemage [ Mon Oct 03, 2005 1:30 pm ]
Post subject: 

There wasn't a Turing solution yet when I started in... Wink It's leaning more towards crypto than obfus... but here goes:

(Turing)
code:
var x : array 1 .. 11 of int := init (5976, 8383, 8964, 8964, 9213, 2656, 7221, 9213, 9462, 8964, 8300)
Rand.Reset
for y : 1 .. 11
    Rand.Set (0)
    put chr( (x (y)) div Rand.Int (1, 1000)) ..
end for

Author:  Andy [ Mon Oct 03, 2005 1:55 pm ]
Post subject: 

err wtf u talking about, there is a turing solution on the last page

Author:  beard0 [ Mon Oct 03, 2005 2:46 pm ]
Post subject: 

codemage wrote:
There wasn't a Turing solution yet when I started in... ;) It's leaning more towards crypto than obfus... but here goes:

(Turing)
code:
var x : array 1 .. 11 of int := init (5976, 8383, 8964, 8964, 9213, 2656, 7221, 9213, 9462, 8964, 8300)
Rand.Reset
for y : 1 .. 11
    Rand.Set (0)
    put chr( (x (y)) div Rand.Int (1, 1000)) ..
end for


It's missing the !

code:
var x : array 1 .. 12 of int := init (5976, 8383, 8964, 8964, 9213, 2656, 7221, 9213, 9462, 8964, 8300, 2750)
Rand.Reset
for y : 1 .. 12
    Rand.Set (0)
    put chr ((x (y)) div Rand.Int (1, 1000)) ..
end for

Author:  codemage [ Tue Oct 04, 2005 7:10 am ]
Post subject: 

Well done2750


: