8
\$\begingroup\$

This is a Cops and Robbers challenge. For the Cops' thread, go here.

The Cops have three tasks.
1) Pick a sequence from the OEIS.

2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual rules.
Call this language LA and code CA.
For example, Jelly and Jelly_code.

3) Then, pick a different language (this is suggested to be a non-golflang, but doesn't have to be) and write code that takes no input and outputs code CA, again following all usual rules. (Note: this can be obfuscated code and doesn't necessarily need to be golfed, but the longer this code is the easier it will be for the robbers to crack your submission.)
Call this language LB and code CB.
For example, Python and Python_code.

The Cop's submission to this challenge is the sequence (specified whether 0- or 1-indexed), the name of the two languages LA and LB (and which one solves which part), and the byte-count of CB only. Keep the actual code of both parts, and the length of CA, secret.

The Robber's challenge is to select a Cops' entry and write code CC in the same LB language that outputs some code in the same LA language that solves the original OEIS task. The length of CC can be no longer than the length of CB as revealed by the cop (though may be shorter). Note: The code produced by CC does not have to match CA.

For our example, this means that the Robber has to write Python code that outputs Jelly code that solves the original OEIS sequence, and that Python code has to be no longer than the length revealed by the Cop.

Winning conditions

The Robber with the most cracked solutions wins.

\$\endgroup\$

6 Answers 6

6
\$\begingroup\$

Brain-Flak, 90 bytes by Mr. Xcoder

((((((((((()()()){}){}){({}[()])}{}())[(((()()()){})){}{}()]))){}{}()()())([][][]){})[][])

Try it online!

This outputs:

ÑÉ·<O

First 05AB1E answer!

How does it work?

Let's say we have 24 as input.

Ñ       # Divisors. 
        # Stack: [1, 2, 3, 4, 6, 8, 12, 24]
 É      # Odd?
        # Stack: [1, 0, 1, 0, 0, 0, 0, 0]
  ·     # Double
        # Stack: [2, 0, 2, 0, 0, 0, 0, 0]
   <    # Decrement
        # Stack: [1, -1, 1, -1, -1, -1, -1, -1]
    O   # Sum
        # Stack: -4

The brain-flak code mostly just uses tricks to push large numbers in few bytes. It was very convenient (and unintentional) that the ASCII values are mostly increasing:

209
201
183
60
79

It's also nice that 60 * 3 ~=~ 183 so tripling it and adding a few can save a ton of bytes.

((((((

    # Push 79
    ((((()()()){}){}){({}[()])}{}())
    # Minus 19 (60)

    [(((()()()){})){}{}()])
    # Push that two extra times
    ))

    # Push that ^ (60) Plus the two extras popped (60 + 120 == 180)...
    {}{}
    # + 3 (183)
    ()()())

    # Plus stack-height * 3 * 2 == 3 * 3 * 2 == 18 (201)
    ([][][]){})

    # Plus stack-height * 2 == 4 * 2 == 8 (209)
    [][])
\$\endgroup\$
3
  • \$\begingroup\$ oh nice my 05AB1E program was 8 bytes. idk any of the 05AB1E builtins /shrug :P \$\endgroup\$
    – hyper-neutrino
    Jun 6, 2018 at 17:59
  • \$\begingroup\$ Here's 80 \$\endgroup\$
    – Wheat Wizard
    Jun 21, 2018 at 3:30
  • \$\begingroup\$ Here's 72 \$\endgroup\$
    – Wheat Wizard
    Jun 21, 2018 at 3:40
2
\$\begingroup\$

Jelly, 34 bytes by Arnauld

Managed a byte shorter than his solution!

“`Ḃ|⁴ʂⱮdÐỌK_ƬƬfıæh’ṃ“fnk1()+-,=>?:

Try it online!

This outputs the JS function

f=(n,k=1)=>n>=k?f(n-k,k)+f(n,k+1):1>n

which computes A000041 (0-indexed; nn(0) returns true in place of 1).

\$\endgroup\$
2
\$\begingroup\$

TeX by Simon Klaver

g\bye

prints g, which computes the length of the input in 05AB1E.

\$\endgroup\$
2
\$\begingroup\$

Malbolge, 32 bytes by Lynn

('%$:?>7[5|981Uv.uQrq)Mnmm$Hj4ED

Try it online!

That prints the following haskell function:

gcd 2

Try it online!

I used this online tool to generate the Malbolge

\$\endgroup\$
1
  • \$\begingroup\$ I used the same tool :) I was hoping not many people know about it. \$\endgroup\$
    – Lynn
    Jun 17, 2018 at 17:59
1
\$\begingroup\$

Python, 13 bytes by HyperNeutrino

print"n=>n%2"

Try it online!

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

Triangularity by Mr. Xcoder, 36 bytes

... ...
..  "..
.aẒ;Ba.
1ÇP$#Ṁ"

Try it online!

Prints Jelly code:

..
.aẒ;Ba.
1ÇP$#Ṁ

Try the Jelly code online! It's quite slow.

\$\endgroup\$
1
  • \$\begingroup\$ Most definitely not what I was thinking of but congrats! I'll include the intended solution in my answer shortly. \$\endgroup\$
    – Mr. Xcoder
    Jun 17, 2018 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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