Thread: reversed c

    #1
  1. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,888
    Rep Power
    509

    reversed c


    This program written in reversed c solves the adventofcode/day/11 puzzles for 2015.
    Code:
    }
    ;0 nruter  
    }  
    ;)'n\'(rahctup    
    ;)a,"s8.% "(ftnirp ,)a ,v(a2v ,)v(txen ,)v(cni      
    )i++ ;7 < i ;0 = i( rof    
    ;))v(dilav ,va* ," d% s%"(ftnirp    
    ;)v ,va*(v2a    
    { )ca-- , va++( elihw  
    ;v V  
    ;]8[a rahc  
    ;i tni  
    { )][va*rahc,ca tni(niam tni
    /*
    sdnjxjqc tuo.a $ :esu  
    .tnemugra margorp eht ta gnitrats sdrowssap lareves yalpsid  
    */
    
    }
    ;)v(cni    
    ))v(dilav !( elihw  
    { )v V(txen diov
    
    }
    ;'a' + ]i[v = ]i[cp    
    )i++ ;8 < i ;0 = i( rof  
    ;i tni  
    { )]8[cp rahc ,v V(a2v diov
    
    }
    ;0 = ]i[v    
    )i++ ;8 < i ;( rof  
    ;'a' - ++cp* = ]i[v    
    )i++ ;)8 < i( && cp* ;0 = i( rof  
    ;i tni  
    { )v V ,cp*rahc(v2a diov
    
    }
    ;0 = ]i[v    
    )]i[v < 52( fi  
    ;]1-i[v++ ,0 = ]i[v      
    )]i[v < 52( fi    
    )i-- ;i < 0 ;dleif = i( rof  
    ;0 = ]i[v    
    )i++ ;8 < i ;1 + dleif = i( rof  
    ;]dleif[v++  
    ;7 = dleif    
    )0 < dleif( fi  
    ;)v(ezinoil = dleif ,i tni  
    { )v V(cni diov
    
    }
    ;)v(sriap && )v(thgiarts && )v(noil nruter  
    { )v V(dilav tni
    /*
    ko gnirts ffi eurt nruter  
    */
    
    }
    ;0 nruter  
    ;1 nruter      
    )]1+i[v == ]i[v( fi    
    )i++ ;7 < i ;2 =+ i( rof  
    ;0 nruter    
    )j!( fi  
    }    
    ;kaerb      
    ;1 = j      
    { )]1+i[v == ]i[v( fi    
    )i++ ;5 < i ;0 = i( rof  
    ;0 = j ,i tni  
    { )v V(sriap tni
    /*
    ceps siht steem gnirts eht ffi 1 nruter  
    .zz ro ,bb ,aa ekil ,srettel fo sriap owt tsael ta niatnoc tsum sdrowssaP  
    */
    
    }
    ;1- == )v(ezinoil nruter  
    { )v V(noil tni
    /*
    .lio niatnoc ton seod gnirts eht fi 1 nruter  
    ;gnisufnoc erofereht era dna sretcarahc rehto rof nekatsim eb nac srettel eseht sa  
    ,l ro ,o ,i srettel eht niatnoc ton yam sdrowssaP  
    */
    
    }
    ;0 nruter  
    ;1 nruter      
    ))1+]i[v == ]1+i[v( && )2+]i[v == ]2+i[v(( fi    
    )i++ ;7 < i ;1 = i( rof  
    ;i tni  
    { )v V(thgiarts tni
    /*
    .thgiarts a sah gnirts eht ffi eurt nruter  
    ;tnuoc t'\nseod dba  
    ;srettel piks tonnac yehT .zyx ot pu ,no os dna ,edc ,dcb ,cba ekil  
    ,srettel eerht tsael ta fo thgiarts gnisaercni eno edulcni tsum sdrowssaP  
    */
    
    }
    ;1- nruter  
    ;i nruter      
    ))]i[v == )'a'-'l'(( || )]i[v == )'a'-'i'(( || )]i[v == )'a'-'o'((( fi    
    )i++ ;8 < i ;0 = i( rof  
    ;i tni  
    { )v V(ezinoil tni
    /*
    tneserp ton fi 1- ro ,lio retcarahc tsrif eht fo xedni eht nruter  
    */
    
    ;]8[V rahc dengisnu fedepyt
    
    >h.bildts<edulcni#
    >h.oidts<edulcni#
    
    /*
    sdnjxjqc ccbaajhg nmlkjihg aaffdcba hgfedcba kjgecbba gffecbba nmmlkjih a$ && a$ ekam && c/.=a  
    dnammoc xunil yb nevig noitulos dna stset 11/yad/moc.edocfotnevda  
    . c.c elif eht eb siht teL  
    */
    [code]Code tags[/code] are essential for python code and Makefiles!
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,888
    Rep Power
    509
    adventofcode day 16 solution in J Home
    Code:
       TAPE=:<;._2 noun define
    children: 3
    cats: 7
    samoyeds: 2
    pomeranians: 3
    akitas: 0
    vizslas: 0
    goldfish: 5
    trees: 3
    cars: 2
    perfumes: 1
    )
       
       
       read=: 1!:1@boxopen
    
       SUE=: [;._2 LF,~read'name_of_data_file'
    
       NB. exact matches, no need for numerical complications
       match=: 1 e. (E.~ >)~
    
       NB. first 3 characters of object don't appear
       forgotten=: 1 -.@e. (E.~ (4 {. >))~
    
       NB. partial mask for part 2
       MASK=:(0 2 4 5 8 9{TAPE)(forgotten +. match)"0 1/SUE
       (6=+/MASK)#SUE
    
    
    
       TAPE
    +-----------+-------+-----------+--------------+---------+----------+-----------+--------+-------+-----------+
    |children: 3|cats: 7|samoyeds: 2|pomeranians: 3|akitas: 0|vizslas: 0|goldfish: 5|trees: 3|cars: 2|perfumes: 1|
    +-----------+-------+-----------+--------------+---------+----------+-----------+--------+-------+-----------+
    
       3{.SUE
    Sue 1: cars: 9, akitas: 3, goldfish: 0             
    Sue 2: akitas: 9, children: 3, samoyeds: 9         
    Sue 3: trees: 6, cars: 6, children: 4              
       
    
       match     NB. exact matches, no need for numerical complications
    1 e. (E.~ >)~
    
       forgotten NB. first 3 characters of object don't appear
    1 -.@e. (E.~ (4 {. >))~
    
       NB. partial mask for part 2
       MASK=:(0 2 4 5 8 9{TAPE)(forgotten +. match)"0 1/SUE
       (6=+/MASK)#SUE
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo