10
\$\begingroup\$

What does "jelly" mean in the title?. Robber's thread

Jelly has an "Evaluate the argument as Python 3" atom, ŒV which takes a string as an argument as evaluates that string as Python 3 code: Try it online!.

It also has compressed strings, delimited with “...» that can compress any string containing printable ASCII (plus newlines), which can reduce the size of such programs. For example, a Hello, World! program using ŒV

Now, this is much longer that Jelly's normal Hello, World! program, by 9 bytes. But is this always the case?

Cops, you are to choose an challenge; write a Python solution to this challenge; compress that solution into Jelly and submit that as your answer.

The challenge you choose must meet these criteria:

  • It is open
  • It it unlocked
  • It has a net score of 5 or more
  • Its winning criteria is and only
  • All languages are open to compete in it (so no -only challenges etc.)
  • It is not a question
  • It was posted before the 28th of March, 2021

This is a search query that should return (mostly) valid challenges. There's no way to filter challenges on the 4th and 5th criteria, so double check the challenges you choose from this search.

Your answer should contain:

  • A piece of Jelly code in the format “...»ŒV, where the ... may be any string of characters from Jelly's code page, aside from “”‘’«»
  • A link to the challenge you solved
  • The length of your "Python to Jelly" code, in bytes

Note that your program must follow any and all rules stated in the challenge you solve, including builtin bans, strict I/O formats and whatever else. To fully cover all edge cases: Your program must be able to be posted as a valid answer to the challenge. The only exception to this rule is that if the challenge scores in characters, you should instead score in bytes.

Jelly currently is written in Python 3.7.4 (Try it online!, the same version that TIO's Python 3 uses), so your program must work in that version of Python.

You may not edit the rules of the challenge you've chosen. You may not simply compress an existing Python answer to the challenge and submit that as your own work. However, you are allowed to attempt to modify existing users' code in order to improve your score, so long as you provide proper attribution to the original answerer. Alternative wording.

Your answer is "cracked" if a Robber finds a Jelly program shorter than your "Python to Jelly" program, that completes the same task. Note that a Robber's crack is valid even if it's of the same form (compressed Python eval'ed by Jelly), so long as it's shorter.

Your answer is "safe" if it is uncracked after 2 weeks. You must mark your answer as safe to be considered so. The shortest safe answer, in bytes, wins

This is, as far as we know, the most optimal Jelly compressor which might help you

Example submission

# 17 bytes, solves https://codegolf.stackexchange.com/questions/55422/hello-world

    “¤ṙẋȯ½Ġ<rŻ£ƤḤO»ŒV

[Try it online!][TIO-kmrxghbo]

[TIO-kmrxghbo]: https://tio.run/##ASsA1P9qZWxsef//4oCcwqThuZnhuovIr8K9xKA8csW7wqPGpOG4pE/Cu8WSVv// "Jelly – Try It Online"
\$\endgroup\$
11
  • \$\begingroup\$ In Jelly, is there any way to pass arguments to the python program? \$\endgroup\$ – A username Mar 28 at 0:40
  • \$\begingroup\$ @Ausername The same way you would access arguments in a normal Python program: input() still works, as does import sys;sys.argv \$\endgroup\$ – caird coinheringaahing Mar 28 at 0:43
  • \$\begingroup\$ Must cops have a crack? \$\endgroup\$ – Jonathan Allan Mar 28 at 1:10
  • 1
    \$\begingroup\$ @JonathanAllan No. I'd consider this more of a "Python + compression vs Jelly golfing competition", rather than a typical CnR, I just chose that competition type because it fits best. There might be a few questions on the site that are downright impossible in Jelly but doable in Python, but I'm not sure that's the case, so I think every Cop answer should be doable in Jelly, but not necessarily in a shorter way \$\endgroup\$ – caird coinheringaahing Mar 28 at 1:16
  • 1
    \$\begingroup\$ You may want to limit the ... to Jelly's base 250 characters to prevent Jelly injection. \$\endgroup\$ – xigoi Mar 28 at 7:06
10
\$\begingroup\$

21 bytes, solves Shortest code to throw SIGILL (safe)

“A{gœỴ¹⁻ėe⁾÷ỤḞḂ4ḷ$»ŒV

Try it online!

This decompresses to the following Python 3 code (which is 22 bytes long, only one byte longer than the compressed version):

import os
os.kill(0,4)

Try it online!

The basic idea is to pick a task that's completely out of scope for Jelly; in this case, we're interacting with the OS, something that Jelly doesn't have builtins for (short of ŒV). So this probably isn't solvable in Jelly without shelling out to Python, and hopefully isn't solvable any more tersely than this.

(In case you're wondering how it works: 4 is the signal number for SIGILL, and os.kill appears to just copy its arguments to the kill(2) system call literally. 0 means "send this signal to every process in my process group", which if the program is run from a shell, will raise a SIGILL in the Python/Jelly program and nothing else. On TIO, the program is being run from TIO's runner, so the SIGILL happens in the runner rather than in the program itself, but there's still a SIGILL being raised.)

\$\endgroup\$
7
\$\begingroup\$

25 bytes, solves We had a question once which only failed on Sundays - Cracked (Razetime)

“ÇṄṚ,Ḣ¢;Xv^wME ṖƘżẓ⁸9!»ŒV

Try it online!

The compressed code is heavily based on Mr XCoder's submission:

exit('Su'in time.ctime()<_)

Notes:

  • There's no need to import time since Jelly's interpreter does that, but not much is exposed, just sleeping and simple time formating (and no other date or time functionality exists).
  • Something is required to do both of these, I chose exit:
    • not return False on non-Sundays (since a bool is not jellify-able)
    • not print to STDOUT on non-Sundays
\$\endgroup\$
2
  • \$\begingroup\$ Cracked (I think) \$\endgroup\$ – Razetime Mar 28 at 3:09
  • \$\begingroup\$ Ah, nice use of X! \$\endgroup\$ – Jonathan Allan Mar 28 at 3:11
4
\$\begingroup\$

132 bytes, solves this - Non-competing

“ßẏƊḢ⁵'ĠȦṫ-ỵḲ²ƘçẠaðṁ¹ĠẊḊƝ;ɠ)ṭKpƭȯVsRDỤ⁵ṾḶĿṇƈ>bỴøỴ⁻Ñy1®ḶṪ\ḷ⁶ḋẇƊ⁾L⁼ṀHṃYṘZ1ẏ1ʋḤFTʠzɱĊȦṁƈṠ!ỌẎḌʂ&B?o#Ṗ³⁻Eḋ4ỤṙṃɲɼĖṬƘmẏġ^wp=ạİQƊ)Ḅı/ẉNẊ`»ŒV

I don't really know Python, so I used Javascript, executed by Python, executed by Jelly. Try it online!

The Python code:

import os
os.system("node -e \"console.log((x=>+x.replace(/(.*)(0|1)(.*)/,(m,a,b,c)=>(((c?1:b)*2-1)*((-1)**a.length)+1)/2))(process.argv[1]))\" "+ input())

And finally the Javascript:

console.log((x=>+x.replace(/(.*)(0|1)(.*)/,(m,a,b,c)=>(((c?1:b)*2-1)*((-1)**a.length)+1)/2))(process.argv[1]))

I expect this to be very easy to beat, but I wanted to have a go.

\$\endgroup\$
8
  • \$\begingroup\$ VeMḂ$, apparently. \$\endgroup\$ – rak1507 Mar 28 at 1:05
  • \$\begingroup\$ @rak1507 See my comment at the end. \$\endgroup\$ – A username Mar 28 at 1:06
  • 10
    \$\begingroup\$ pro tip: don't submit answers to challenges that already have jelly answers lol \$\endgroup\$ – rak1507 Mar 28 at 1:07
  • \$\begingroup\$ I should've looked. Oh well. \$\endgroup\$ – A username Mar 28 at 1:08
  • 2
    \$\begingroup\$ Wait, did I crack this without even posting in the robber's thread?! \$\endgroup\$ – Jonathan Allan Mar 28 at 2:51

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.