13
\$\begingroup\$

This is the robbers' thread. For the cops' thread, go here.

Introduction

For this Cops/Robbers challenge, the cops will write output-producing programs and interweave them together. It is the robber's job to pick apart the cops' programs to produce the desired outputs.

Robber rules

Robbers will try to find the different programs that people post in submissions to the cops' thread (linked above). If a robber solves a cop's code, they must post the separated programs and match them with their outputs in an answer here and post that they have cracked the code on the cop's answer.

Scoring

There are two components that are added together when scoring a cracked submission.

  • 2 to the power of the number of different programs used in the cop's answer
  • Round the number of bytes in the interweaving down to the nearest power of 2.

For example, if a robber cracks TIliGoEnR as being TIGER and lion, then the robber receives 2^2+8=12 points.

The winner of the robbers' challenge will be the person with the most points after a sufficient period of time for people to participate.


(Who wants to help with a snippet?)

\$\endgroup\$

10 Answers 10

6
\$\begingroup\$

Vitsy, 12 points

'o'2\I/NO

Try it online!

a5F\aZ

Try it online!

The NaN in NaNo was a dead giveaway.

The obvious way to push NaN would be to divide 0 by itself, 2\I pushes the input length (0) twice, / performs division, and N prints a float.

We're left with printing o, and 'o' is a string literal that O prints.

Whatever characters were left had to belong to the other program. In fact, a pushes a linefeed, 5F the factorial of 5 (120), \a turns that into 120 linefeeds, and Z prints the entire stack.

\$\endgroup\$
  • \$\begingroup\$ So fancy, so beautiful. Well done. +1 \$\endgroup\$ – Addison Crump Nov 23 '15 at 23:01
4
\$\begingroup\$

BitShift, 2^2 + 64=68 points

cops thread

0101100110110101001001010110111011101110111011101101010

prints ! ?

1011101110111011101110110101000000000110010101101101010

prints ? !

Code

0101100110110101001001010110111011101110111011101101010 # '! ?'
01011001101101010 # '! '
0101              # XOR 0 with 128 
                  # Making current value 128 (1000 0000)
    10            # Bitshift 1 to left making 10000000 -> 01000000
      01          # Bitshift 1 to left making 01000000 -> 00100000  
        101       # XOR 00100000 with 1 making it 00100001
           101010 # print 00100000 which is binary for !
010010101         #
010               # XOR 00100001 with 1 making it 00100000
   010101         # print 00100000 which is binary for <space>
10111011101110111011101101010  # '?'
101               # XOR 00100000 with 1
   1              # Bitshift 1 to left making 00100001 -> 01000010
                      # This gets repeated till 01000010 becomes 0111111
101010                # print 0111111 which is binary for ?

I will add some description later(split the code in the parts that print individual parts)

\$\endgroup\$
  • \$\begingroup\$ Can someone explain how to calculate the score I don't quite understand the calculation \$\endgroup\$ – Dennis_J Nov 23 '15 at 15:42
  • 1
    \$\begingroup\$ Well done. The score is calculated by 2^programs + 256/bytes=points. In this case it's 2^2 + 256/128=6 points. I think this will be edited though, because as it is now, fewer byte count programs receive a higher bonus for robbers. Which feels off \$\endgroup\$ – Bassdrop Cumberwubwubwub Nov 23 '15 at 16:16
  • 1
    \$\begingroup\$ @Bas As of yesterday, that was changed. \$\endgroup\$ – Arcturus Nov 23 '15 at 17:05
4
\$\begingroup\$

PHP, 68 points

$c=tR;$h=s;$c=$h.$c._.$h.plit;echo$c($h);

Output: Array

echo quotemeta('^/]'.co.'[$');

Output: \^/\]co\[\$


I like this submission, because it relies on a few lesser know features - one might say misfeatures - of PHP. PHP allows function references to be assigned to variables, so for example:

$f = function($a, $b) { return pow($a, $b); };
echo $f(2, 4);

would do exactly what you expect. As would:

$f = pow;
echo $f(2, 4);

...except it's not doing what you think. $f = pow does not assign a function reference to $f (that would make too much sense, right?), but rather the string 'pow'. The implication is that any string may be used as a function call, if it represents the name of a defined function. Bad code waiting to happen. I don't even know why you'd want to allow this.

Another misfeature of PHP, is that function names and keywords are case-insensitive. I wish I were joking. So echo pow(2, 4), ECHO POW(2, 4), and EcHo PoW(2,4) are all functionally equivalent.

The last misfeature on showcase is that whenever an array is typed as a string, such as for printing, the result is always the amazingly helpful string Array. Take a moment to reflect on the fact that someone actually did this deliberately.

So in the first program, @insertusernamehere builds up the string stR_split, this string is used as a function reference (which, for reasons above, actually works), and the result, an array, is output.

\$\endgroup\$
  • 1
    \$\begingroup\$ Nice work that comes with a great explanation. :) \$\endgroup\$ – insertusernamehere Nov 25 '15 at 10:05
3
\$\begingroup\$

Ruby, 68 points

First:

p %w(b n n s)*?a%?}

Second:

w,=?(.ord,40,?);"jivivi{2".bytes{|b|putc b-w}

It followed pretty naturally from working out the end, with putc.

\$\endgroup\$
  • 1
    \$\begingroup\$ Whoops, I had a slightly different intended solution with one more weird syntax trick, but I guess I'll keep that in my back pocket for another challenge. Well done! \$\endgroup\$ – histocrat Nov 25 '15 at 18:51
3
\$\begingroup\$

JavaScript, 68 points

Cops thread

First program

Output: ffttff

(![]+[])[+[]]+(![]+[])[+[]]+(!![]+[])[+[]]+(!![]+[])[+[]]+(![]+[])[+[]]+(![]+[])[+[]]

Second program

Output: 1010

+!![]+[+[]]+(+!![])+(+[])

Interweaving

+     !!    []             +                [    +[]]          +      (+     !![])                 +     (+[])
 (![]+  [])[  +[]]+(![]+[]) [+[]]+(!![]+[])[ +[]]    +(!![]+[]) [+[]]+  (![]+     [])[+[]]+(![]+[]) [+[]]
\$\endgroup\$
2
\$\begingroup\$

Java, 132 points

Cops thread

First program:

interface c{static void main(String[]g){System.out.println("Hell"\u002bg.length);}}

Second program:

class i{public static void main(String[]n){System.out.print("Bye!\n");}}

The first program outputs Hell0 and the second program outputs Bye!

\$\endgroup\$
  • \$\begingroup\$ Ah, I was an hour too late. Good job. \$\endgroup\$ – Arcturus Nov 23 '15 at 19:54
2
\$\begingroup\$

Javascript, 132 points

Program 1

var x;{;alert((f=>(f.reverse(f+~~f,Math.pow(2,Math.E))))(new Array(99).fill(0).map((x,i,f)=>i/3)).join("").replace(/../g,""))}

Program 2

try{"function";Object.keys(f)}catch(e){f=s=>!s?f(1):"";alert(f(f(f(0/0) +f(7/5)))+f(f)+`${f}`.split``.map(e=>e.charCodeAt()*23))}

Whew. This was terrible.

After a lot of debugging I found out that after calling (parts of) the 2nd program, it wouldn't run again. This is because the global variable f was still assigned. Because of f being assigned, the try/catch didn't fail on Object.keys(f). I don't know if this is a sneaky trick or unintentional but it caused me a headache.

Also, I believe the output of the first program is platform specific.
/../g removes all characters on my machine, because of the regex . which means any character. Escaping it with /\../g works however, I hope someone can shed more light onto this. Also, my output is prone to rounding errors, perhaps some global javascript variable can change this?

Output

32666666666666643233333333333336323166666666666668313333333333333231306666666666666830333333333333323029666666666666682933333333333332292866666666666668283333333333333228276666666666666827333333333333322726666666666666682633333333333332262566666666666668253333333333333225246666666666666824333333333333322423666666666666682333333333333332232266666666666668223333333333333222216666666666666821333333333333322120666666666666682033333333333332201966666666666668193333333333333219186666666666666818333333333333321817666666666666681733333333333332171666666666666668163333333333333216156666666666666615333333333333341514666666666666661433333333333334141366666666666666133333333333333413126666666666666612333333333333341211666666666666661133333333333334111066666666666666103333333333333410966666666666666933333333333334986666666666666683333333333333487666666666666677333333333333337666666666666667633333333333333656666666666666753333333333333354666666666666674333333333333334366666666666666533333333333333353266666666666666523333333333333352166666666666666713333333333333331066666666666666603333333333333330

This was tested on chrome 46 (my only browser), Windows 7.

I hope this is still a valid submission, despite the different output

\$\endgroup\$
  • \$\begingroup\$ There was a slash in there, I don't know how it was missed. Good job, though! This is correct. I will update my submission when I am not on mobile ;) \$\endgroup\$ – Conor O'Brien Nov 25 '15 at 15:15
2
\$\begingroup\$

JavaScript (ES6), 68 points

Program 1

alert((c=>c.replace(/[a-z]/gi,a=>String.fromCharCode(("Z">=a?90:122)>=(a=a.charCodeAt(0)+13)?a:a-26)))("fvzcyr"))

Program 2

alert((b=>b.replace(/[a-zA-Z]/g,s=>String.fromCharCode(s.charCodeAt(0)+(s.toLowerCase()<'n'?13:-13))))("gbnfg"))

Interweaved programs

 alaelretrt((((cb=>c=>b.replace(/.replace[a-(/[azA-Z]-z]/gi/g,a,s=>String=>String.fromCharCode(s.fromCharCode(("Z">=a.charCodeAt(0)?90:122)>=(a=a.charCodeAt(0+(s.toLowerCase())+13)?a<'n'?13:-13:a-26)))))))((""gfvbznfcyrg""))))
 al e r t  ( ( c =>c             .replace   (/[a     -z]/gi  ,a  =>String                       .fromCharCode(("Z">=a              ?90:122)>=(a=a.charCodeAt(0                 )+13)?a           :a-26)))    ( "  fv z  cyr " ))
   a l e rt ( ( b   =>b.replace(/        [a-    zA-Z]      /g  ,s        =>String.fromCharCode(s                     .charCodeAt(0)                           +(s.toLowerCase()       <'n'?13:-13        )))) ( "g  b nf   g "  ))

This would've been a lot harder, had the cop torn apart the keywords. ;)

\$\endgroup\$
  • \$\begingroup\$ I manually interwove it and got lazy, but good job. I tried being sneaky. Oh well. Actually thank you for cracking this one because I lost The original unweaved programs somehow. \$\endgroup\$ – Generic User Nov 30 '15 at 23:35
1
\$\begingroup\$

PHP, 24 points

Program 1

print!0;

Program 2

print!$x;

Program 3

print print'';

Tested with http://sandbox.onlinephpfunctions.com/.

\$\endgroup\$
1
\$\begingroup\$

Python 2, 320 points

print "This"
print "hello"
print "well"
print "no"
print "alas"
print "but"
print "oh"
print "done"
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.