What is the Sandbox?

This "Sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to the main page. This is useful because writing a clear and fully specified challenge on your first try can be difficult, and there is a much better chance of your challenge being well received if you post it in the Sandbox first.

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

Divisor chains

Definition

A simple path in the divisor graph of {1,...,n} is a sequence of distinct numbers between 1 and n such that if k immediately follows m, then either k divides m or m divides k.

(1) Return a list of integers that represents the lexicographically earliest longest, simple path in the divisor graph of {1,...,n}.

Implement a named function with one argument, f(n), n a positive integer; you can assume n <= 33. The function takes the argument for input.

No print statements (or other I/O-statements) are allowed in the function; the return is a list (or tuple or array). The use of external library functions is not allowed.

(2) A print statement that prints the output of (1): print(f(n)). The function name print is not obligatory and the print function can use standard libraries.

Test

(1) For n = 10 the call f(10) returns [4, 8, 1, 5, 10, 2, 6, 3, 9].

(2) print(f(10)). We do not fix the format of the returned list. The output might also look like 4 8 1 5 10 2 6 3 9 or any other convenient way.

Challenge

This is code-golf with restricted-time, so the shortest code in bytes wins if it can run the test above on TIO https://tio.run/ without timing out. Only the code of the generating function f is counted, without the print statement.

Tags: code-golf, restricted-time, math, sequence

Lazy Robot Monkey Problem

Question Summary

You have made a robot monkey. The purpose of the robot is to move through the trees and try to reach as many as possible monkeys before running out of battery. You have to follow some rules while moving.

You are give a interlinked tree in the following format :

Here each 1 is a monkey and each 0 is an empty place.

Each note can have multiple parents and Childs but unlike a Graph its direction is downward.

The robot monkey has a initial energy value.

The robot Monkey can move through the nodes following certain rules:

• Going up to the parent node needs 4 units energy.
• Going down to the child node needs 2 units energy.
• There may be some food at some nodes. Each times the monkey eats its energy increases by food value.
• The monkeys energy can never be negative.
• The monkey cannot eat more than the initial energy value.

What to do?

You are given the initial node (where your robot monkey is initially sitting).

The node is in the following format :

class Node:
parents = [] # Will have all the parents
children = [] # Will have all the children
isMonkey = 1 # May be 0
foodValue = 0 # May be anything


You are also given a initial food value and the number of monkeys in the tree.

You now have to find how many monkeys can you maximum meet with before your battery dies.(by going to the same position)

def monkeyMeet(initialNode, energy, totalMonkeys):
pass


Or in any other programming language.

The size of the tree may be huge.

• Is this code golf? You need to have a way to have entries be compared (within a language). – xnor Jan 12 at 9:10

SimpleHearts KOTH

SimpleHearts

SimpleHearts is a four player trick-taking card game similar to Hearts, with a few simplifications. Hearts has several possible rule variations, and the rules I will use are outlined here.

For each game, each of the four players are dealt 13 of the cards in a standard deck. After that, there will be 13 "tricks", and during each trick the players will take turns playing exactly one of their cards. Each trick will consist of the following:

• One player leads the trick by playing a card. The suit of this card is the "led suit". On the first trick the player with the 2 of clubs must lead with the 2 of clubs, on the following tricks whoever won the previous trick will lead.

The leader may not lead a heart until another player has played a heart or the Qs (Queen of Spades). Exception: if the leader only has hearts in their hand, they may lead one of their hearts. The leader may lead the Qs at any time.

• In a clockwise fashion, each player will take their turn playing one card in their hand of the led suit. If the player has no cards of the led suit, they may play any card. Exception: On the very first trick, no one after the leader may play a heart or the Qs, unless all of their cards are hearts or the Qs (obviously absurdly unlikely).

• After all four players play a card, whichever player played the highest value card of the led suit wins the trick. Ace is highest value and 2 is lowest. The winner of the trick receives 1 point for every heart played by anyone in the trick, and 13 points if the Qs was played in the trick.

• Repeat, with the winner leading the next trick.

The objective of the game is to receive as few points as possible. After all 13 tricks are played, the score of each player is the total number of points they took during gameplay. Important exception: if one player takes all possible points, i.e. the 13 hearts and the Qs, they receive 0 points and all other players receive 26 points (this is called "shooting the moon").

Key differences from standard Hearts:

• There is no passing cards

• Scores are not cumulative in the standard way (the scoring system of this particular challenge will be explained next).

Gameplay and Scoring

This is a KOTH challenge, meaning the objective is to create a bot (in this case a Python function) which will compete against other submitted bots in the game of SimpleHearts. All subsets of size 4 of the set of submissions will play against each other in N matches of 4 games each. For sandbox: N is tbd, should be as high as reasonably possible.

The dealing of the cards will be identical in each of the 4 games in a match, except rotated. For example, suppose the players are A, B, C, and D. In the second game player B will have the same hand player A had in game 1, C will have B's game 1 hand, etc. This is to reduce the impact of random chance, as one player being dealt a bad hand will affect all players equally in theory.

Each submission's final score will be the sum of their scores in all the games they played. The winner will be the submission with the lowest final score. In the case of a tie, the oldest submission will win.

Technical Requirements

Each submission will be a Python function (for sandbox: this is an arbitrary choice, is there a better one?) which takes as parameters:

• A list of 2-tuples representing the cards in their hand. Each tuple will be of the form (12, 's') with the number representing the value of the suit and the string representing the suit, being one of s, h, d, c. For simplicity's sake the numbers are from 2 to 14, and we do not care about encoding "Queen" or "Ace". Therefore the Queen of Spades is (12, 's'), Ace of Diamonds is (14, 'd'), and the 2 of clubs is (2, 'c').

• A list of 4 integers representing the scores of each player so far in the current game. The first element of the list is your score, then the player to your left, then the player across, then the player to your right.

Note: leading with hearts is allowed if and only if you only have hearts, or someone has a nonzero score.

• A list of 4 lists of tuples representing which cards have been played and by whom. The first list will be the cards you played, in order. The second list will be the cards played by the player on your left, in order. Etc.

• A list of 0-3 tuples representing the cards that have been played in the trick, in order.

As output, the submission must return a single tuple representing a card in its hand, which is legal to play according to the rules of SimpleHearts. Of course, the function may choose to ignore any of these inputs but if it makes an illegal output, it is disqualified. In testing, I will force whoever has the 2 of clubs to lead with it on the first hand, ignoring the contents of the function.

The submission must be deterministic, i.e. will always produce the same output on the same input (so pseudorandom numbers with a set seed are allowed).

All submissions must be at most 100 000 characters.

The challenge will end 14 days after this prompt is posted, after which I will test all valid submissions against each other in the manner I described.

For sandbox

This prompt is still WIP, but I appreciate any comments. I intend to create a controller and some example submissions, but only after Sandbox folk deem the challenge to be good enough.

Is there any reasonable way to make the requirements easier or the game simpler? Cause this post is kinda long.

• 1. You should probably forbid tampering with the environment/other bots. 2. You probably should clarify what happens if a bot throws an exception, and what happens during a disqualification (do the round with the disqualified bot simply not count or does a dummy bot come into play) 3. There is nothing wrong with a python function but it is worth noting that most koth competitions are either a JS function or a Java abstract class. 4. Also, it might be worth adding some sort of timeout for the bots. – Aiden4 Jan 20 at 18:25
• So you're not playing with the rule that if one player wins all 124 points, then their score changes to 0 and the other players get 124 each instead? The risk there the most fun part of hearts! – pxeger Jan 21 at 10:06
• @pxeger I'm not sure what you mean. I did mention shooting the moon, but what do you mean winning all 124 points? – 79037662 Jan 21 at 14:52
• @79037662 I missed that because I've never heard it described as "shooting the moon". 124 is the sum of the available points in the scoring system I know (2+3+4+5+6+7+8+9+10+10(J)+10(Q)+10(K)+15(A)+25(QS)) – pxeger Jan 21 at 15:00
• @pxeger In the standard ruleset, all hearts are worth 1 each and QS is worth 13 :) – 79037662 Jan 21 at 15:15

The UTM theorem

Let ℕ denote the set of natural numbers. Let A × B denote the Cartesian product of A and B. Let A ⇀ B denote the set of partial functions from A to B.

The UTM theorem says that there exists a computable function u : ℕ × ℕ ⇀ ℕ such that, for every computable function f : ℕ ⇀ ℕ, there exists a p : ℕ such that, for every x : ℕ, u(p, x) ≃ f(x). That is, there exists a universal computable function (analogous to the universal Turing machine).

Implement such a function in your language. Shorter is better.

Example: Python (57 chars)

lambda p,x:eval(p.to_bytes(p.bit_length()//8+1,'big'))(x)

• Are you sure you can emulate a while loop in Python eval? – Bubbler Jan 19 at 6:33
• Also, this has the same problem as your other sandboxed challenge in that eval does the job in many languages. – Bubbler Jan 19 at 6:41
• @Bubbler It should be able to emulate (some variant of) the lambda calculus, which requires only pure functions. – user76284 Jan 19 at 7:05

The radical of an integer (written as $$\\mathrm{rad}(n)\$$) is defined as the product of all prime numbers that divide it. This it A007947.

For example, since $$\ 504 = 2^3 \cdot 3^2 \cdot 7 \$$, $$\ \mathrm{rad}(504) = 2 \cdot 3 \cdot 7 = 42 \$$.

Challenge

Your task is to write a function or a program which takes a number as the input, and output its radical.

You don't have to handle any cases where the input isn't an integer or isn't positive (you don't have to handle 0).

Test cases:

504 -> 42
6 -> 6
57 -> 57
1024 -> 2
9 -> 3
1 -> 1


This is code-golf, so the shortest answer in bytes wins. Good Luck!

• I think you can omit the "input/output in any base" part ("the output base must match the input base" is especially unnecessary) and let the answers use any sensible, consistent integer I/O as allowed in our defaults. Other than that, nice challenge. – Bubbler Jan 19 at 7:02
• Suggested test case: 1 -> 1. – Bubbler Jan 19 at 7:03
• What is the behaviour for negative numbers and zero? – pxeger Jan 19 at 11:15
• @pxeger You don't have to handle any cases where the input isn't an integer or isn't positive (you don't have to handle 0). – Command Master Jan 19 at 12:16
• @CommandMaster whoops, missed that – pxeger Jan 19 at 13:49
• This is A007947, which describes it as "Largest squarefree number dividing n". – xnor Jan 20 at 10:27
• Duplicate – caird coinheringaahing Jan 20 at 20:55
• Dang, I should stop using built-in SE search for finding duplicates. – Bubbler Jan 21 at 0:24
• @Bubbler I was pretty sure I recognized the challenge, it was xnor's comment that lead me to it (searched "squarefree number is:q") – caird coinheringaahing Jan 21 at 9:07

Cosmic ray hacking

Cosmic background radiation can cause random bit flips in electronics. For this reason, some mission-critical computers undergo radiation hardening. Your task is to use your magic bit flip gun to hack in to a program and make it print something different.

Cops' challenge

• Write a program or function that outputs a determinate, non-empty string of your choice (which you should specify).
• Choose a different, determinate string of your choice (which you should specify).
• Also specify a number n which is the number of bit flips the robbers should perform on your answer in order to get it to output the second string.

Robbers' challenge

Choose an uncracked cop submission written by another user. Find a program that differs by exactly n bit flips from the original cop's program, and outputs the string s (where n and s are specified by the cop). First valid crack for each cop answer wins.

Rules

• Your program must be written in the same language and version as the cop's
• Your program must use the same I/O method as the cop's, unless they specify otherwise
• Flipping the same bit twice (which does nothing to the whole string) is allowed, but it takes up 2 of your available bit flips.

Example

Cops - Python 3, 8 bytes

Prints 5.

print(5)


Using 1 bit flip, change this program to print 4.

print(4)


Because the ASCII digit 5 is 00110101, and 4 is 00110100 (the last bit has been flipped)

Meta

• Should I change the scoring system?
• This is related to , but I don't think it actually is. Is this right? Or maybe or would be better? (?)
• refers to the limit that the cop imposes on the robber, rather than the scoring system - is this an acceptable use of the tag?
• Is this clear enough?
• Is this a duplicate of an existing challenge?
• Any other feedback?
• How are cops' answers scored? – the default. Jan 21 at 14:11
• @thedefault. code-golf; it's in the cops' rules section – pxeger Jan 21 at 14:45

Write a Brainfuck compiler + decompiler!

Many Brainfuck compilers will convert to a different language instead of compiling directly.

Your job is to write not only a compiler in language X which compiles Brainfuck to the same language as the compiler, but also a decompiler which takes code compiled with said compiler and outputs equivalent Brainfuck.

Rules

• No embedding the original/stripped source code or similar loopholes. You know what I mean.
• Additionally, no outputting an interpreter with the original source code.
• The compiler must accept whitespace and comments
• Optimizations are allowed and encouraged, as long as you can convert these back to Brainfuck.
• The input will always be a valid Brainfuck program
• You are not required to print comments in the decompiler, however, excess comments and whitespace are allowed in the output as long as the program is valid. However, these lower your score. 🙂
• You do not need to handle excess whitespace or comments in the decompiler, you can assume it was code directly generated by your compiler.
• Therefore, it is also guaranteed to be valid code.
• No executing the compiled code.
• The compiler must generate correct code and run without any helpers.
• You are allowed to be flexible with the cell size as long as it is at least 8 bits.
• You are allowed to be flexible with the tape size as long as it is at least 30,000 elements. A wrapping tape is not required.
• EOF can store either 0, -1, or leave unchanged

Your score will be the following:

(compiler size in bytes + decompiler size in bytes) × (compiled size of factor.bf in bytes ÷ size of factor.bf in bytes)

This is , so the most votes wins. This is because there can be some creative and boring solutions. Golfing is still encouraged.

• Couldn't there be multiple BF programs that compile to the same "byte code" due to optimisations? – Adám Jan 20 at 14:38
• Good catch. I added a note about that. I emphasized that you are decompiling YOUR code, and optimizations are not required, and if you do add optimizations, they must decompile to the same code (so basically, don't optimize if you want to win 😏) – EasyasPi Jan 20 at 14:41
• Am I allowed to add hints in my code that identify what the original BF was? – Adám Jan 20 at 15:13
• Hmm..yeah that is kind of difficult to rule out. I am going to change it to include the size of the code output in the score to discourage it. – EasyasPi Jan 20 at 15:18
• So is the total score the size of the compiler plus the size of the decompiler? Can they be a single program doing both? – Adám Jan 20 at 15:21
• Any restrictions on what target languages are allowed? – Adám Jan 20 at 15:22
• So am I understanding it right that the compiler and the target language must be identical? – Adám Jan 20 at 15:22
• Can the decompiler be a macro? Also, I know it's not recommended often, but this wouldn't be too bad as a popularity challenge. – user Jan 20 at 16:22
• Should the cells be wrapping or not? – Aiden4 Jan 20 at 16:28
• I don't think it's possible to support comments without embedding them into the code. – the default. Jan 21 at 4:31
• I mean that your compiler must accept comments, but it is not required to preserve them. I also made some of the changes suggested in the comments – EasyasPi Jan 21 at 12:39
• Can we have EOF as no change? That's a somewhat common way of handling EOF – Jo King Jan 23 at 5:03
• Note that if it's too hard then it won't be popular anyway. (writing an optimizing compiler alone is a very difficult task, and who would read that?) – user202729 Jan 28 at 9:30
• Still not quite understand about what "embedding" means here. The program translated / synthesized is required to include what the source code do. So it will always embedding the source code by some how. Is it valid if I simply replace +-<>[],. by 01234567 and then convert it back? May I simply submit a brainf**k (or bf variance) program say ,[.,]? – tsh Feb 5 at 2:32
• Yeah I should try to clarify that. – EasyasPi Feb 5 at 2:36

Introduction

This challenge was originally the "Among Us" challenge in the "Misc" category of YASCON CTF 2020. (The link includes an answer to that challenge. Click at your own risk.)

You're given a lot of files, only 1 of which is different from every other files. Your job is to find that 1 different file.

Challenge

• Input: the file names of all the files to be searched through.
• Output: the name of the 1 different file.

Avoid burying the important details of your challenge in a mound of unimportant details. Be concise. Include what needs to be included.

It is guaranteed to have $n+1$ files, of which $n \ge 2$ files are the exact same, and 1 different file.

This is a . Least bytes wins.

Example Input and Output

Input:

1.txt 2.jpg 3.png 4.mp3

Output:

(3.png is different)

3.png

• 'Answer the following questions for your readers . . . Avoid burying the important details of your challenge in a mound of unimportant details. Be concise. Include what needs to be included.' This is what you are supposed to do as the challenge writer, not part of the spec. – Dingus Jan 26 at 22:30
• Do you have permission to repost this challenge here? – Dingus Jan 26 at 22:30
• Well I got permission to upload the challenge and its files anywhere from that CTF, so yes. – John Zhau Jan 27 at 3:10

Create a playable, unbeatable Tic Tac Toe game

The challenge is to write the smallest possible Tic Tac Toe game where the opponent is an unbeatable AI. The requirements are as follows:

• The opponent should be an unbeatable AI (self-playing opponent that can't lose)
• The game should be able to detect win/draw/loss and end if this happens (without crashing)
• The input should be the player move (square index or something like that)
• The game should be able to handle invalid input and act appropriate if this happens (ask for input again)
• The game must be displayed graphically on a classic 3x3 format with X:s, O:s and empty squares. The display should be in line vertically and horizontally, se below examples. The display needs to happen after at least every human move to be able to follow the progress.

As long as these conditions are fulfilled you are free to solve it in any way you'd like.

Rules of Tic Tac Toe: Each player (X and O) takes turn placing their marker on the 3x3 board. The game ends in a win if the player gets 3 in a row, loss if opponent gets 3 in a row, and draws if the board gets full.

Challenge winning criterion: Smallest code in bytes.

Example view of a valid input/output gameplay:

[' ', ' ', ' ']
[' ', ' ', ' ']
[' ', ' ', ' ']

[' ', ' ', 'X']
[' ', ' ', ' ']
[' ', ' ', ' ']

[' ', ' ', 'X']
[' ', 'O', ' ']
[' ', ' ', ' ']

[' ', ' ', 'X']
[' ', 'O', 'X']
[' ', ' ', ' ']

[' ', ' ', 'X']
[' ', 'O', 'X']
[' ', ' ', 'O']

[' ', ' ', 'X']
[' ', 'O', 'X']
[' ', 'X', 'O']

['O', ' ', 'X']
[' ', 'O', 'X']
[' ', 'X', 'O']


Example of invalid gameplay (not horizontally or vertically in line and not using X and O as markers, which makes it hard to see what is going on):

Your move: 4
[, , ]
[0, , ]
[, , ]

[1, , ]
[0, , ]
[, , ]

[1, , ]
[0, , ]
[, , 0]


Suggested tags: tic-tac-toe, code-golf

• Good draft. Now you're well on the way to a properly specified challenge. Thank you for using the sandbox! – Adám Feb 2 at 7:45
• I assume that by "graphically" you include e.g. text-based in a console. You might want to make that clear. – Adám Feb 2 at 7:45
• Who makes the first move? – Adám Feb 2 at 7:46
• Thanks, updated. I don't udnerstand what you mean with the text based comment though. I feel like this thing is getting worse than writing for some government, really killing the joy to be honest. – eligolf Feb 2 at 7:53
• It is stricter than government writings; the latter can be vague and instead rely on the courts to disambiguate later. We don't have that luxury here. But while painful for the challenge writer, it is exactly what makes it enjoyable for the challenge answerer. I highly recommend that you answer a few existing challenges before attempting the, frankly monumental, task of writing your own. This will give you an appreciation for well-specified challenges. I've been here for years, and have an order of magnitude more answers than challenges, and yes, my early challenges were problematic too. – Adám Feb 2 at 8:00
• Updated with tags and winning criterion – eligolf Feb 2 at 8:05
• Suggested tags (remember that the max is 5): interactive, game, board-game, grid, ai-player. – Adám Feb 2 at 8:09
• I'd suggest paring down this challenge to what I think is the most interesting part, making the unbeatable AI. That is, just require writing a function/program that takes in a single game state and outputs an optimal move, without needing to handle the game flow. – xnor Feb 2 at 20:28
• @xnor, that could also be an idea! – eligolf Feb 3 at 5:00
• @Adám, could I try that or xnors idea in the real questions thread now? – eligolf Feb 3 at 5:40
• @eligolf I like xnor's idea, as game flow as already been done before, e.g. here. However, I generally recommend allowing at least a week in the sandbox (wait for a couple of upvotes here) since some people visit the site on a weekly schedule (e.g. only on weekends, or only during work). It's code golf ― what's the rush? If, after a week, you've not gotten enough feedback here, consider asking for more feedback in the chat room. – Adám Feb 3 at 6:57
• I found a similar challenge: codegolf.stackexchange.com/q/152064/20260 – xnor Feb 3 at 7:26

Ratios to Ben Johnston's Notation

Given a just intonation ratio, express it as a note name in Ben Johnston's notation relative to C.

You can take your input as a rational number (if your language has a rational type) or as a pair of integers. You have to handle ratios with a prime limit of 19, or in other words, ratios whose prime factorizations don't contain any primes above 19.

Use the following characters for the accidentals:

+ - 81/80
# b 25/24
7 L 35/36
^ v 33/32
13 _13 65/64
17 _17 51/50
19 _19 95/96


Output them in the following order:

• 7, ^, 13, 17, 19
• #, b
• L, v, _13, _17, _19
• +, -

7, 13, 17, and 19 should be separated by commas when they occur adjacently in order to avoid ambiguity.

Test cases:

1/1 -> C
2/1 -> C
3/2 -> G
4/3 -> F
5/4 -> E
5/3 -> A
6/5 -> Eb
7/4 -> B7b
7/5 -> G7b
9/5 -> Bb
9/8 -> D
10/9 -> D-
11/8 -> F^
16/9 -> Bb+
17/16 -> C17#
21/16 -> F7+
25/24 -> C#
32/27 -> Eb-
34/19 -> A17_19#
78/77 -> C13Lv
81/64 -> E+
160/147 -> C#LL-
323/280 -> D17,19L-
416/405 -> D13bb-
441/440 -> Db7v+
1029/1024 -> Db777+
6144/6125 -> CbLL-
531441/524288 -> B#+++
4194304/4117715 -> A#LLLLLLL---

• Same issue as the other challenge, I didn't read the link and the question is not self-contained. – user202729 Feb 8 at 2:42

Find all enharmonic equivalences of an arbitrary EDO

Given integers n and s, print all pairs of enharmonically equivalent pitch classes in n-EDO, such that each note of a pair has at most s sharps and flats.

Note names are assigned such that F, C, G, D, A, E, and B form a chain of n-EDO's best approximation to 3/2 (that is, $$\n \log_2(3/2)\$$ steps, rounded to the nearest integer, or the "fifth"). "#" adds seven fifths, and "b" subtracts seven fifths; you can have as many of one as you want or none at all. (Note that in some EDOs, such as 24, there are some pitches that can't be written with only sharp and flat accidentals.)

Note that C# = Db means the same thing as Db = C#. Your code should output only one of these, but which one you output is up to you.

Be prepared to handle these situations:

• # and b might not raise or lower the pitch
• # might lower the pitch
• E and F might be the same note
• F might be lower than E

Your code should work for at least all integers n in [1, 200] and all integers s in [0, 50].

Test output

(12, 1)

F# = Gb
Fb = E
F = E#
C# = Db
Cb = B
C = B#
G# = Ab
D# = Eb
A# = Bb


(19, 1)

Fb = E#
Cb = B#


(19, 2)

F# = Gbb
F## = Gb
Fbb = E
Fb = E#
F = E##
C# = Dbb
C## = Db
Cbb = B
Cb = B#
C = B##
G# = Abb
G## = Ab
D# = Ebb
D## = Eb
A# = Bbb
A## = Bb


(22, 2)

Fbb = C#
Fb = C##
F## = Bbb
Cbb = G#
Cb = G##
Gbb = D#
Gb = D##
Dbb = A#
Db = A##
Abb = E#
Ab = E##
Ebb = B#
Eb = B##


(31, 3)

Fbbb = D#
Fbb = D##
Fb = D###
F## = Abbb
F### = Abb
Cbbb = A#
Cbb = A##
Cb = A###
C## = Ebbb
C### = Ebb
Gbbb = E#
Gbb = E##
Gb = E###
G## = Bbbb
G### = Bbb
Dbbb = B#
Dbb = B##
Db = B###


(32, 3)

F## = Dbbb
F### = Dbb
Fbbb = A#
Fbb = A##
Fb = A###
C## = Abbb
C### = Abb
Cbbb = E#
Cbb = E##
Cb = E###
G## = Ebbb
G### = Ebb
Gbbb = B#
Gbb = B##
Gb = B###
D## = Bbbb
D### = Bbb


(53, 4)

F#### = Dbbbb
Fbbbb = A###
Fbbb = A####
C#### = Abbbb
Cbbbb = E###
Cbbb = E####
G#### = Ebbbb
Gbbbb = B###
Gbbb = B####
D#### = Bbbbb


(5, 0)

F = E
C = B


(7, 1)

Fb = F
Fb = F#
F = F#
Cb = C
Cb = C#
C = C#
Gb = G
Gb = G#
G = G#
Db = D
Db = D#
D = D#
Ab = A
Ab = A#
A = A#
Eb = E
Eb = E#
E = E#
Bb = B
Bb = B#
B = B#


(9, 1)

Fb = G
F = G#
Fb = A#
F# = Eb
Cb = D
C = D#
Cb = E#
C# = Bb
Gb = A
G = A#
Gb = B#
Db = E
D = E#
Ab = B
A = B#


(11, 1)

F# = Db
Fb = A
F = A#
C# = Ab
Cb = E
C = E#
G# = Eb
Gb = B
G = B#
D# = Bb


(13, 1)

F# = Cb
Fb = B
F = B#
C# = Gb
G# = Db
D# = Ab
A# = Eb
E# = Bb

• I think most people prefer that questions should not include background knowledge that not most people know without explanation. – user202729 Feb 3 at 0:58
• Do you have any ideas about reducing the amount of background knowledge required and making the question more accessible? – bb94 Feb 3 at 1:49
• I didn't read it... – user202729 Feb 3 at 1:51

Implement bottom (encode)

• The general policy is to provide an explanation for concepts that most people don't know inside the question itself. [please review other sandbox posts] – user202729 Feb 3 at 14:02
• @user202729 Is this better? – Orangutan Feb 3 at 17:58
• Suggested test case: invalid utf8, invalid surrogate, empty string, some char with unicode value > 0x10000, combined emoji, combining mark in unicode. – user202729 Feb 3 at 23:22
• Generally people don't like things like "must take input on stdin, must take output on stdout, must take input in UTF8 encoding, must check for invalid UTF8, must return exit code 1". You can still keep it, but I did warn you. – user202729 Feb 3 at 23:28
• I removed the full program requirement and the UTF-8 validation so there also shouldn’t be any need for an exit code. I also added some more test cases and a rule on an empty string – Orangutan Feb 4 at 2:16
• Since I don't have emoji font installed, you can include a textual explanation on the input/output pairs. (like AB (byte value: 65, 66) -> 50, 10, 5, byte-separator, 50, 10, 5, 1, something like that) – user202729 Feb 4 at 2:18
• I'm not sure how much this would help as you still need the endpoints/emoji in the source. Maybe having an emoji font installed isn't too strict of a requirement? If you still want to test would string comparisons work? That way you don't even need to look at any of the outputs, just see if tests pass – Orangutan Feb 4 at 11:43
• It's recommended that you delete the sandbox post and edit it into a link to the main post after you post it. – user202729 Feb 4 at 14:19
• By the way, the sandbox FAQ recommends that people leave posts in the sandbox for at least 72 hours (apparently nobody reads that?) – user202729 Feb 4 at 14:19

Is the Skat null game safe? [WIP] skatcode-golf

For everyone who knows the card game Skat. Did you ever wondered when playing a null game: is this really safe to win regardless the other player cards? Well, let's try to solve this question with code.

The Skat game

Skat is card game with 32 cards. There are four colours: Diamonds ♦️, Hearts ♥️, Spades ♠️ and Clubs ♣️. Each colour has: Ace, King, Queen, Jack, 10, 9, 8 and 7. Three players are playing, so each one get 10 cards. The remaining two cards are called Skat and remain covered. Before each game it is to decide which of the three players plays alone against the other two which play together. The alone player gets the possibility to exchange one or two of his cards against one or two of the covered cards in the Skat. More about Skat can be read on Wikipedia.

The null game

There are times when get so bad cards, i.e. no Aces and no Jacks, that they will indeed really good, namely when you can't make any points, not even a trick with the cards.

Write a program that will determine if an input of ten cards of the 32 cards will guarantee that the player will win the null game, i.e. the player won't get any tricks regardless how the other 22 cards are distributed for the other two players and whether or not the alone player is in forehand. You can assume any reasonable input and output that suits you. For convenience a reasonably sorting of the cards can also be assumed.

One note to the forehand rule: it is assumed that the alone player wants to win so he or she won't sabotage the game with drawing an Ace or similar high cards.

Test cases

Let's assume an array of two character strings where the first represents the colour (D for Diamond, etc.) and the second the value (7, 8, 9, X, J, Q, K, A) E.g ['D7','D8','D9','H7','H8','C7','C8','CX','CQ','CA'] will result in true indicating that this null game cannot be lost.

[more to come]

This is code-golf so the shortest code wins.

• (you didn't specify what's the condition for winning in the game...) – user202729 Feb 7 at 16:11
• I enjoy playing Skat, so this challenge looks promising even though it still misses some important parts in order to be accessible for people who have never heard about Skat. For the sake of simplicity (as the challenge already looks rather hard) I'd suggest to drop the forehand part (and assume one of the opponents plays first). Otherwise it needs to be specified which cards are allowed to be played. – Laikoni Feb 15 at 22:33
• Thanks for the comments. Will try to find some time for improving this. – jmizv Feb 19 at 9:14

Colorize a diff, unified format

• Print to stdout? What about displaying it on the screen or write an image? (you know there are standard output formats... – user202729 Feb 5 at 17:11
• @user202729 They will print to stdout with ANSI escape sequences, I have edited my question. – Deadbeef Feb 5 at 17:16
• (just noticed that you're a new user. Anyway) people generally don't like restrictive input/output format. (codegolf.meta.stackexchange.com/questions/2447/…) And the command-line parsing appears to be unrelated to the challenge (except making it "looks like a typical Unix tools") – user202729 Feb 6 at 0:38
• @user202729 I agree, I changed it so it doesn't have the restriction anymore – Deadbeef Feb 7 at 2:42
• you may want to ban usage of git tools from shell for this challenge. – Razetime Feb 8 at 2:52
• @Razetime "Do X without Y" (including banning built-ins) is not recommended. Boring answers will usually be downvoted anyway. – user202729 Feb 8 at 11:46

Catch the fruit (Abandoned) graphical-outputgame

I feel that this is too complex to be a good code-golf question, and has too many things to specify for it to be anywhere near serviceable. Anybody willing to make this idea into a proper question can do so.

Implement a osu!catch style game.

Introduction

osu!catch is a rhythm game where the player moves a "basket" to catch "fruits" falling from the top of the screen to the beat of a song. Think pong, but with timing.

It is highly recommended to watch this video before reading the question.

Here's a gameplay example from Bubbler: [osu!catch] Hitsuji to Ojisan - XENO [Spec's Overdose]

Input

You are required to take the following inputs:

• Time: How long your program is supposed to run.

• Approach Rate: This is the speed at which the "fruits" are supposed to fall down.

• Beatmap: An array of [time, x position, value] triplets where:

• Time: you must support time in seconds, at the very least. Higher precision is encouraged.
• X position: Where it will fall from.
• Value: The size of the "fruit" will decrease with it's value.

Gameplay

Play area

• The canvas must be in a 4:3 aspect ratio.
• The score must be displayed at the top of the screen, in the middle. You do not need to align it.
• The score starts at 0.
• Use a dark background(#222222, preferably).

The player

• The player must be of a rectangular shape, white in color.
• Height: 1/50 of canvas height, Width: 1/6 of canvas width.
• The player must be at the bottom of the screen, movable using any two keys of your choice.
• The player must have a "dash" button. Their speed must increase 0.5x when they hold the dash button.
• When the player collects a fruit, it must disappear, and it's value must be added to the score.
• When the player misses a fruit, there should be an indicative visual cue where the fruit fell.(a small red square, preferably)
• The player must be constrained within the canvas.

Fruits

• Fruit must be square in shape, and red in color.
• Fruits must fall from the top of the screen, outside the viewport(unless unsupported).
• Max fruit size is 0.1 × height. Size scales inversely with value.
• Fruit speed must be related to the approach rate i.e. Higher approach rate must make the fruits fall faster. You may do this however you like, but please be reasonable.
• The lower edge of the fruit must touch the bottom of the screen at it's time value.

Scoring

This is . Shortest answer in each language wins.

Meta

• Is the specification simple enough?
• I am planning on making a separate challenge for this. Is that a better idea?
• Is the specfication clear?
• Any further feedback?
• You most likely already have this in mind, but you can add the game tag. Also, I think you should not leave too many stuff to the golfers, as they could do anything with the oppurtunities (e.g they could just increase the speed by 0 by pressing the dash button). What happens when the player goes outside the canvas? – SunnyMoon Nov 18 '20 at 20:50
• @SunnnyMoon Good points. I've changed those things, and I'll proofread it again to see if there are any more mistakes. Thanks a lot. – Razetime Jan 28 at 2:48

Which Ninjutsu am I casting? code-golfstring

Posted

• Bad title considering that validation is the smallest part of the challenge, but it looks pretty good otherwise – Unrelated String Feb 9 at 12:58
• @UnrelatedString I changed the title. – SjoerdPennings Feb 9 at 13:08
• (note that it's recommended (in the sandbox FAQ) to leave sandbox posts for at least 72 hours. – user202729 Feb 11 at 6:31

Trilobaccis' speed

The challenge is inspired by this beautiful one: Speed of Lobsters. And it's similar to this other one: Is it a lobster number?.

The word Trilobacci is a blend of Tribonacci and Lobster.

The tribonacci numbers are like the Fibonacci numbers, but instead of starting with two predetermined terms, the sequence starts with three predetermined terms and each term afterwards is the sum of the preceding three terms.

Regarding lobsters and speed, they refer to this subreddit where people have fun editing the text of images to create new phrases.

The challenge

The challenge is to "blank out" the digits of given numbers (let's say a,b,c) using the digit of other numbers (say x,y,z) which you have to find by yourself, and then tell whether you could use all the digits from x,y,z to blank out some (or even all) of the digits from a,b,c.

Being more specific: given three positive integers in ascending order, which are necessarily part of a tribonacci sequence (at least the one they can generate), find the three numbers that generated the sequence and use them to blank out the original input numbers according to the lobsters rules.
Then output a truthy value if you used all the digits from the found numbers, or a falsy value if you are left with digits that couldn't be used to blank out the input digits.

For the numbers generating the sequence, I mean the the three smallest non-negative integers being part of the sequence.

Lobsters rule!

Start taking the first digit of the first number of x,y,z and blank out its first occurrence in the digits of a,b,c. Then proceed with the next digit from x,y,z looking for its first occurrence in a,b,c, starting from where you left.

Examples

Given

[ 13, 23, 43 ]


you'll find out that they are part of a sequence generated by

[ 1, 3, 3 ]


so then you can proceed at the speed of lobsters:

[ 1, 3, 3 ]   --->   [ 13, 23, 43 ]
||
_||_
\  /
\/
[ X, 3, 3 ]   --->   [ *3, 23, 43 ]

[ X, X, 3 ]   --->   [ **, 23, 43 ]

[ X, X, X ]   --->   [ **, 2*, 43 ]


And in this case you output a truthy value because you used all the digits from [ 1, 3, 3 ].

The numbers [ 903, 1661, 3055 ] are also generated by [ 1, 3, 3 ], but the output for them is a falsy value:

[ 1, 3, 3 ]   --->   [ 903, 1661, 3055 ]
||
_||_
\  /
\/
[ X, 3, 3 ]   --->   [ 903, *661, 3055 ]

[ X, X, 3 ]   --->   [ 903, *661, *055 ]

[ X, X, 3 ]   --->   [ 903, *661, *055 ] can't find any 3 after the last blanked digit


Input

Three integers. (One by one, into an array, as one or more a strings, split like bananas, etc.)
You can even take them in descending order if like.

Output

Choose a truthy and a falsy value and be consistent with them.

Standard rules apply for your answer, with standard I/O conventions, while default Loopholes are forbidden.

It would be nice if you could provide an easy way to try your program and possibly an explanation of how it works.

This is , the shortest wins.

Soon...

Meta

• Any feedback / suggestion?
• I thought about considering the digits of x,y,z as always, but blanking out their occurrence in a,b,c from right-to-left, so that who participated to the previous lobster challenges would have to renew this part of the answer. Do you think it would be a good thing?
• Nice challenge, maybe a bit convoluted but I like it. I'd mention somewhere that the numbers in a tribonacci sequence need to all be positive, otherwise for example [1,3,3] could come after [-1,1,3] and there would be no beginning. I believe going left-to-right or right-to-left in the last step does not make any difference, if one of them is possible the other one will be as well – Leo Feb 10 at 5:30
• @Leo I am going to highlight "For the numbers generating the sequence, I mean the the three smallest non-negative integers being part of the sequence." And I'll specify that the input is positive. Regarding the right-to-left, thing, I expressed it so badly: I meant considering the digits of x,y,z LtR as always, but blanking their occurrence in a,b,c in RtL direction. Since you are already finding the sequence in reverse, it could make sense to rename the challenge like Retrolobacci and do the LtR thing, but I don't know. – Sheik Yerbouti Feb 10 at 11:25
• Oh, sorry, I had missed the part about non-negative integers! To make it completely dumb-proof (read: Leo-proof) you could add a "positive" also to the input description section. Also, some people will probably want to take the input numbers backwards, I don't know if this is already a default but it may be worth explicitly allowing it in the text. I think Trilobacci sounds better than Retrolobacci, but other than that I have no opinion on LtR vs RtL :) – Leo Feb 10 at 22:07
• @Leo I added the backward input, thank you! I don't like Retrolobacci either, it could be "Trilobaccis' speed, when running backwards", maybe too long but somehow funny. – Sheik Yerbouti Feb 10 at 22:23

Challenge

Print all the Tamil characters in any order you like. They should be 12 vowels, 18 consonants and the special symbol ஃ .

Your code should not print anything except for those letters but it can print one letter per line.

The consonants are: க் ங் ச் ஞ் ட் ண் த் ந் ப் ம் ய் ர் ல் வ் ழ் ள் ற் ன்

The vowels are: அ ஆ இ ஈ உ ஊ எ ஏ ஐ ஒ ஓ ஔ

Shortest code wins

• @user Done. I hope it helps. – Anush Feb 11 at 14:59
• There isn't really a point in doing this: 31 bytes, copy-paste the letters. – fasterthanlight Feb 11 at 21:19
• @fasterthanlight if you add the print statement do you think you won’t be able to do any better? Also, how would you do it in C for example? – Anush Feb 11 at 21:25
• I don't specialize in C. For example, in O5AB1E, you can just do ,"க் ங் ச் ஞ் ட் ண் த் ந் ப் ம் ய் ர் ல் வ் ழ் ள் ற் ன் அ ஆ இ ஈ உ ஊ எ ஏ ஐ ஒ ஓ ஔ ஃ in 33 bytes, excluding spaces – fasterthanlight Feb 11 at 21:30
• @fasterthanlight and no more compact way to go over the relevant Unicode characters? – Anush Feb 11 at 21:32
• @fasterthanlight what about if I changed it to printing all the Unicode Tamil symbols? – Anush Feb 11 at 21:35
• Could you also include the Unicode codepoints of the characters? I think that would make it easier for solvers to consider strategies for generating them. – xnor Feb 11 at 22:40
• @xnor yes I will do that. Do you think 31 characters is too few for it to be interesting? – Anush Feb 12 at 8:39
• @Anush I think it depends how the code points are distributed, whether they're not too random or too ordered. – xnor Feb 12 at 21:12

Generate a "Pi-ey" number

Generate the smallest integer of the form $$\x^x\$$ with $$\10^{n-1}\cdotπ\$$ digits, rounded down, given $$\n\$$. If there is no such number, take the nearest number that has as many digits of $$\π\$$ in its digit count. For example, if $$\n=5\$$, then the number of digits would be 31415. If there was no such number of form $$\x^x\$$, then take the nearest digit count similar to 31415, like 31414 and 31416.

If there are multiple values of $$\x\$$ that will work, whichever one is closer to $$\3.1415926e3141...\$$ will be the chosen value. For instance, if two solutions for $$\n=5\$$ were $$\1.234e31414\$$ and $$\1.234e31416\$$, we would select the former, as it is closer to $$\3.1415926...e31415\$$.

Test cases:

Rules:

• Shortest amount of bytes of code wins
• Please post the number of bytes as well as the runtime for $$\n=5\$$.
• It is recommended that you post your score (below), but is not required.

Scoring

• Your score will be based on your program time and length. $$\\text{score} = \text{program length in bytes} + 10 \times \text{time to execute in seconds}\$$
• The first paragraph seems unclear to me. For the $n\pi$ digits, do we round that down, or to the nearest integer? The second sentence seems a little unclear as well, do you mean to find the number that's closest to having $n\pi$ digits? If so, if there are multiple (let's say $1.1234e313$ and $1.1234e315$), which one should be chosen? – Redwolf Programs Feb 11 at 21:20
• @RedwolfPrograms For the $n\pi$ digits, round down. For you second question, if $n=5$, you would find the closest number of form $x^x$ with 31415 digits. If there is no such number, with 31415 digits, then find the nearest number with a digit count closest to 31415 (i.e. 31414, 31416, etc). To answer your last question, the number that is closer to $3.141926535...e314$ will be selected if there are multiple. – fasterthanlight Feb 11 at 21:24
• I'd recommend editing that into the post, when you include that information it's much more clear. Also, you might want to put the test cases in as text rather than an image to make them easier to copy-paste. Other than that, it looks clear to me, but I'd wait a day or two to make sure nothing else is unclear. (Don't worry, it's way better than my first post :p) – Redwolf Programs Feb 11 at 21:28
• Program length plus time in what? Seconds? On what machine? Combining length and speed in this way is very sensitive to how the speed is measured. Taking a step back, getting this tradeoff to be balanced and interesting for golfers is very hard, possibly impossible across a wide range of languages of varying golfiness and speed. I'd strongly recommend against this, especially for your first challenge. I think either code-golf or fastest-code would be better. – xnor Feb 11 at 22:09
• @xnor I have changed my post so that it will be easier, with point bonuses as needed – fasterthanlight Feb 11 at 22:20
• @fasterthanlight Bonuses have fallen really out of favor with the community. Including this many large bonuses is virtually guaranteed to get your challenge downvoted. – xnor Feb 11 at 22:22
• Thanks for moving your post to the sandbox. I generally agree with xnor that trying to score in this way is ill-advised, but if you want to continue with it you should decide for which values you will test the speed. In addition, assuming I am understanding correctly, the output is the full value $x^{x}$. I think it is possible that an efficient answer will spend more time printing out this number than it would take to calculate it, which seems to somewhat defeat the purpose. – FryAmTheEggman Feb 12 at 0:27
• @FryAmTheEggman So how can you tell when a program is done calculating something? – fasterthanlight Feb 12 at 1:28
• Ah, sorry I meant to suggest that just asking for $x$ should solve the problem. – FryAmTheEggman Feb 12 at 3:50

Compute the analysis spectrum

This is based on a task I had in work a few years back.

A diode-array detector (DAD) is a kind of chromatography detector which fires light into a sample and detects the strength of the light that passes through it at different wavelengths. From this you can determine, among other things, the contents or the purity of the sample.

Most detectors can only detect on one wavelength. A DAD however can scan across a spectrum of wavelengths, typically from 190nm to 650nm. From that spectrum we can then pick out the wavelengths that we're interested in. Maybe for our sample we want to analyse it at wavelengths 300nm, 350nm, and 550nm. These are called 'channels'.

Each wavelength may also have a bandwidth across which the signal strength is averaged. If we have analyse on wavelength 420nm, with a bandwidth of 10nm, the range for that channel would be from 415nm to 425nm (5nm lower, 5nm higher than the base wavelength). However, this bandwidth is optional.

The DAD we'll be working with does not take a set of channels, but rather we must provide it with a minimum wavelength and a maximum wavelength to detect across. This will be our task.

The Challenge

Write a program or function that, when given a collection of channels, determines the lowest and highest wavelength to analyse across for these channels.

For this challenge, a channel consists of an integer wavelength, and an optional integer bandwidth. The wavelength can be positive or negative, but the bandwidth is always positive.

Bandwidths can be odd numbers, but in that case you would then shrink it down to an even number.

The upper limit can be the same as the lower limit, but can never be smaller.

Also, you can safely assume that at least one channel is given to your code.

Example 1

Channel 1
Wavelength = 420
Bandwidth = 10


For channel 1, the base wavelength is 420 and the bandwidth is 10.

Channel 1's lower range is the base wavelength minus half of the bandwidth. In this case, it's 420 - (10 / 2) = 415. The upper range is the base wavelength plus half of the bandwidth: 420 + (10 / 2) = 425.

Answers: Lower = 415, upper = 425

Example 2

Channel 1
Wavelength = 394
Bandwidth = 19

Channel 2
Wavelength = 500
Bandwidth = N/A


For channel 1, the base wavelength is 394 and the bandwidth is 19. Because the bandwidth is an odd number, and our DAD cannot accept floating-point numbers, we can round it down to 18.

Channel 1's lower range is the base wavelength minus half of the bandwidth. In this case, it's 394 - (18 / 2) = 385. The upper range is the base wavelength plus half of the bandwidth: 394 + (18 / 2) = 403.

Channel 2 has no bandwidth, so it's range is just at its base wavelength: 500.

Comparing the channel ranges, channel 1 has the minimum lower limit with 385. Channel 2 has the maximum upper limit, with 500.

Answers: Lower = 385, upper = 500

Test cases

Test case 1:

Wavelength 1 = 400
Bandwidth 1 = N/A

Answers: lower = 400, upper = 400

-------------------------------------

Test case 2:

Wavelength 1 = 200
Bandwidth 1 = 15

Answers: lower = 193, upper = 207

-------------------------------------

Test case 3:

Wavelength 1 = 394
Bandwidth 1 = 19

Wavelength 2 = 500
Bandwidth 2 = N/A

Answers: lower = 385, upper = 500

-------------------------------------

Test case 4:

Wavelength 1 = 394
Bandwidth 1 = 40

Wavelength 2 = 500
Bandwidth 2 = 10

Wavelength 3 = 380
Bandwidth 3 = 5

Answers: lower = 374, upper = 505


Rules

The range that you must produce must consist of an integer lower limit and an integer upper limit. This particular DAD cannot accept decimal numbers, so while your code may accept and output floating-point types, the values themselves must be whole numbers.

Computing this range is important for other settings on the DAD. Therefore, you may not take just any input and return an extremely small lower limit and/or an extremely large upper limit. Your outputs must be based on your inputs.

Standard rules apply, including the default I/O rules. Similarly, default loopholes are forbidden.

Finally, this is so shortest answer in bytes wins.

Sandbox Questions

• Is the challenge itself too complex or too easy?
• Is the requirement for whole-numbered outputs valid, or does it seem a little bit arbitrary?
• Are the examples and the test cases useful?
• Finally, would this be an interesting challenge?
• Some notes: (1) is it guaranteed that the outputted "lower value" will always be strictly greater than zero? (2) It appears that most people will want to take N/A bandwidth as zero. (3) of course requiring floor/ceil is "valid", whether it's arbitrary is up to people. (4) while I can understand the challenge, it's mainly because I read the provided example explanation, so I can't be entirely sure that the rules part is clear enough. [please review other sandbox posts] – user202729 Feb 13 at 2:44

Print the nth sequence from oeis

The input is one natural number n - the sequence number

Examples:

n -> sequence
1 -> 0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2
2 -> 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2
3 -> 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 3, 2, 2, 4, 2, 2, 4, 2, 3, 4, 4, 2, 3, 4, 2, 6, 3, 2, 6, 4, 3, 4, 4, 4, 6, 4, 2, 6, 4, 4, 8, 4, 3, 6, 4, 4, 5, 4, 4, 6, 6, 4, 6, 6, 4, 8, 4, 2, 9, 4, 6, 8, 4, 4, 8, 8, 3, 8, 8, 4, 7, 4, 4, 10, 6, 6, 8, 4, 5, 8, 6, 4, 9, 8, 4, 10, 6, 4, 12, 8, 6, 6, 4, 8, 8, 8, 4, 8, 6, 4
4 -> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
5 -> 1, 2, 2, 3, 2, 4, 2, 4, 3, 4, 2, 6, 2, 4, 4, 5, 2, 6, 2, 6, 4, 4, 2, 8, 3, 4, 4, 6, 2, 8, 2, 6, 4, 4, 4, 9, 2, 4, 4, 8, 2, 8, 2, 6, 6, 4, 2, 10, 3, 6, 4, 6, 2, 8, 4, 8, 4, 4, 2, 12, 2, 4, 6, 7, 4, 8, 2, 6, 4, 8, 2, 12, 2, 4, 6, 6, 4, 8, 2, 10, 5, 4, 2, 12, 4, 4, 4, 8, 2, 12, 4, 6, 4, 4, 4, 12, 2, 6, 6, 9, 2, 8, 2, 8
6 -> 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18
7 -> 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
8 -> 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 11, 12, 15, 16, 19, 22, 25, 28, 31, 34, 40, 43, 49, 52, 58, 64, 70, 76, 82, 88, 98, 104, 114, 120, 130, 140, 150, 160, 170, 180, 195, 205, 220, 230, 245, 260, 275, 290, 305, 320, 341, 356, 377, 392, 413, 434, 455, 476, 497, 518, 546
9 -> 1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18, 22, 27, 32, 38, 46, 54, 64, 76, 89, 104, 122, 142, 165, 192, 222, 256, 296, 340, 390, 448, 512, 585, 668, 760, 864, 982, 1113, 1260, 1426, 1610, 1816, 2048, 2304, 2590, 2910, 3264, 3658, 4097, 4582, 5120, 5718, 6378

• The issue with the requirement is that it's non-observable. While it's true that sometimes we judge answers by understanding it (especially when answerers have to prove something about the answers), most people consider it problematic. – user202729 Feb 12 at 13:13
• Language having no random function a problem, we have rules for that. – user202729 Feb 12 at 13:13
• Meta post about non-observable requirement: codegolf.meta.stackexchange.com/questions/11197/… – user202729 Feb 12 at 13:19
• You could make it observable by requiring that the results of intermediate steps be output. – xnor Feb 12 at 20:31
• even in this case people can still always output the sum... (although it will probably not save that much) (besides you can remove the "rules" part) – user202729 Feb 13 at 5:43
• Remark: by default "random" means "all values are possible in theory". codegolf.meta.stackexchange.com/questions/17563/… [please review other sandbox posts] – user202729 Feb 13 at 5:45
• Maybe I didn't understand you properly @user202729, but the elements in a do cover all values possible in theory, as long as their sum is 1. – SketchySketch Feb 13 at 10:42
• Yes, generally it's not a problem. – user202729 Feb 13 at 10:45
• As I 've said above , people might skip the final compare solution, although I see no way to enforce it. Otherwise clear enough [please review other sandbox posts] – user202729 Feb 15 at 2:06
• I think your "print" in step 3 and "return" in step 5 is to say that both these results should be output, but it should allow both to be printed or returned in a pair. I'd suggested rewording to say that these two things need to be "output", which is generic enough to cover both functions and programs. The short-circuiting in step 1 of outputting a negative number is not ideal because it's Requiring multiple types as return value. I'd suggest thinking if there's a way to avoid that. – xnor Feb 15 at 4:36
• It's not clear to me in step 2 what is required for a random array of non-negative reals summing to 1. Must it be uniform on that (n-1)-dimensional space? See this meta post. I think you should say explicitly what is expected -- the meta post that user202729 linked to isn't really definitive. – xnor Feb 15 at 4:40
• Fixed @xnor, is it okay now? – SketchySketch Feb 15 at 7:00
• Yes about the randomness, but see my other comment. – xnor Feb 15 at 7:28
• @xnor What about changing the negative number in step 1 into throwing an error / exception? For step 3 & 5, what about saying "output" these two results? – SketchySketch Feb 15 at 7:56
• @SketchySketch Throwing an error/exception might also be too language specific. Maybe just allow any behavior that's not output of the form in the later steps? Though, is this complication of checking n>=4 even worth having in the challenge? Its seems like a straightforward extra bit to add in. You could just have the input guarantee that n>=4. – xnor Feb 16 at 6:17
• The main issue with fastest-code is that you need to specify the specification of a machine to judge solutions on, and a set of test cases. (note that 8x8x8 is probably too small for meaningful timing) (There's also golf-cpu and atomic-code-golf, but I don't see the former used much) [please review other sandbox posts] – user202729 Feb 13 at 2:40
• @user202729 Thank you for the comments. Already updated. – JimmyHu Feb 13 at 11:03
• I can't tell if N=16 is sufficient (the input data size is N^3, the time complexity is probably O(N^3 log(N)) -- or O(N^6)? I don't know), but because of the fluctuation in runtime because of various reasons, make sure that the run time of the fastest solution on the largest test case is at least a few seconds so it can be reliably measured. – user202729 Feb 13 at 11:11
• @user202729 Thank you for the mentioned point about the fluctuation in runtime. I choose N = 16, 25 and 30 for measuring. If there is any other issue of this challenge, please let me know. – JimmyHu Feb 15 at 1:44
• there might be several languages with built in for this. // there might be n^3 log n solutions which will be very fast anyway, but (I think) it's okay to fix the test cases later (I assume you're solving it in n^6?) -- but in this case whether the challenge is interesting is another matter. // Otherwise looks good. [please review other sandbox posts] – user202729 Feb 15 at 3:07

Introduction

Book cipher

A Book cipher is a very unique method of a encipher. Here's how's it done:

• You have a book / a document or a article (something full of text, the more pages of text the better).
• You have a message to convey (a secret, of some sort)
• You simply-put read trough the text and the secret message (may come from input, or reading it from 2 separate files) - split it into words (so, separate spaces, commas and [dots]) so, ',' , '.' and spaces is the only requirement, how is not really that hugely important and you keep the count of how many words there are in the text, now input the secret message (note, the secret's words must be in the text, so if you secret was "My Secret" then, the words "My" and "Secrets" must both exist in the text.) and output the position of the inputted secret message. (E.g if the word "My" was nearly at the first page, maybe the 20th Word in the text, the program should print out '20'. Same with the word "Secrets", if that maybe were later, (let say the 93th word in the text) then your program should print out '93'.

Note the data type of input and output:

output numbers: Integers.

Input numbers: Integers

( Excluding if the secret actually contains a number, then it does not need to be treated as a int. Can be a plus if it does but is not necessary.)

Mini Example:

document.txt - file that contains text.

Secret: "My Secret"

(in the text, this is the 20th and the 93th word) (Note, this is only a made up secret, it is not from a real file, or a real input) a more better example is below.

Program input:

You enter "My Secret"

Program output:

20

93

And, again - you enter those numbers(**Integers**):

20 93

Program outputs:

My

Secret

this is just to show how input and outputs are related to each other.

For reference (if needed) You have a Python3 implementation available at my GitHub page, to see a book cipher in action here: GitHub - Book cipher in Py3

• Why is this challenge interesting?

I personally think this is a educational (and interesting) challenge ( one might also exercise, because of how simple it might seem to make, but really took myself - literally years to even know how to implement this correctly)

Interesting article to get some background of what Cicada3301 is (not my site) - https://www.clevcode.org/cicada-3301/

I created this challenge both to, see other peoples methods of solving this (you are free to use any programming language!) and also - how long it would take others (For me, really I think it took more than 4 years actually - even in Python3. It looks simple but, for me - really not)

• A motivating fact: There are still so little info (especially on example codes) on the internet(at least by the time writing this challenge) about just, book cipher implementations

Challenge

I would highly suggest making dedicated functions for this challenge

• (instead of writing all code in the main() function - but it's totally fine to have it all in main!)

Operation:

Here's how the program should read, process, and output the result:

First, take the text (the book/document, with the lots of text, (not the secret)) and:

Note: The text can either be entered or read from a file. You choose this.

1. read it (From a file, or enter it as input)
2. split it into words (by, I.e detecting '.', spaces(' '), and commas ',') (Or if you already have split the input & are ready to move on to step 3, do that :) )
3. count the number of words.

Repeat this process with the Secret input part.

So, the input secret part should be:

• read it (from, again a file or enter it as input)
• split it (i.e if your input was "My Secret" - split it into words like so: "My" "Secret")

My Python3 implementation only separate spaces.

The Key sequence - this is the nth words your text contains, e.g the 93th word in above example "Secrets".

Example Input and Output

example file used 'document1.txt'in this section is available at the GitHub page.  as well as the Python3 file used in the example below.

The output of your program should match the output of the Python3 program.

Input:

python3 bookcipher.py

input text: a house with a Bob inside

Output:

you entered these words: ['a', 'house', 'with', 'a', 'Bob', 'inside']

2

3

5

2

0

30

Input again: (decrypting)

input key-sequence sep. With spaces: 2 3 5 2 0 30

a

house

with

a

Bob

inside

• I am new, this is the first challenge, but feel free to edit/ask for clarification/ anything! Thanks, I hope the guys at the orig. Post led me to the right place; if this is not the correct place(or way!) to add proposal; please tell me how I would go around of doing that! //Have a Corona Free week! – William Martens Feb 17 at 11:34
• You're in the right place. Well done! – Adám Feb 17 at 12:14
• @Adam thanks; I am still a bit new here, but should I wait now - or what specifically should I do ? – William Martens Feb 17 at 17:56
• Welcome to Code Golf, this is a pretty good challenge! I would suggest being a bit more liberal with the input format (allowing solutions to read from STDIN or take the "book" as a function argument instead of reading from a file). I would also suggest splitting this up into two challenges - encrypting and decrypting - but that's up to you. As for what you should do now - just wait a few days so you can get feedback and modify your question, and then you can post on the main site. – user Feb 17 at 19:42
• If your proposal goes unnoticed for a really long time, you might also want to ask others to review it in the site's chat room. – user Feb 17 at 19:50
• I generally recommend leaving challenges here for minimum a week as people ave various schedules, e.g. only visiting on weekends or only on (certain) weekdays. – Adám Feb 17 at 20:11
• Just to make sure... did you address all the problems raised in the comments under the main site post? – user202729 Feb 18 at 13:02
• @user202729 Oh, maybe not - fixed now though, thanks for pointing it out, and okay with the chat - got it :) – William Martens Feb 18 at 19:24
• (note that I'm not the same user as [user]. Even the chat highlight is wrong) – user202729 Feb 19 at 9:09
• The text could be more concise and flow more logically. Right now I see five sections: (1) description of the cipher, (2) example (3) personal background, (4) requirements for the code, (5) more examples. I think you should aim to merge (1) and (4) where possible (there's some redundancy there), and likewise (2) and (5). (3) is not really relevant and should (I think) be deleted. – Dingus Feb 20 at 1:15
• I also suggest formatting the examples using code blocks instead of block quotes. – Dingus Feb 20 at 1:15

Subbasis. Generate. Discrete?

Objective

Given finitely many finite sets, interpret them as a subbasis to generate a space, and decide whether the resulting topology is discrete.

Introduction to Topology

Given a set $$\X\$$, a topology $$\\mathcal{T}\$$ over $$\X\$$ is a subset of the power set $$\\mathcal{P}(X)\$$ such that:

• $$\\emptyset, X \in \mathcal{T}\$$.

• For all $$\\space \mathcal{U} \subset \mathcal{T}\$$, $$\\bigcup\mathcal{U} \in \mathcal{T}\$$.

• For all $$\Y_1, Y_2 \in \mathcal{T}\$$, $$\Y_1 \cap Y_2 \in \mathcal{T}\$$.

Members of a topology are said to be open. So the rules above in plaintext are:

• The empty set and $$\X\$$ itself are open.

• The union of arbitrarily many open sets is open.

• The intersection of finitely many open sets is open.

Endowed with a topology, $$\X\$$ is said to be a (topological) space.

If $$\\mathcal{T} = \mathcal{P}(X)\$$, $$\\mathcal{T}\$$ is said to be discrete.

Basis and Subbasis

A subset $$\\mathcal{B}\$$ of the power set $$\\mathcal{P}(X)\$$ is said to be a basis (pl. bases) of a set $$\X\$$ if:

• For all $$\x \in X\$$, there exists $$\B \in \mathcal{B}\$$ such that $$\x \in B\$$.

• For all $$\B_1, B_2 \in \mathcal{B}\$$, there exists $$\C \in \mathcal{B}\$$ such that $$\C \subset B_1 \cap B_2\$$.

We take every subset $$\\mathcal{U} \subset \mathcal{B}\$$ and declare $$\\bigcup\mathcal{U}\$$ to be open to generate a topology $$\\mathcal{T}\$$. Note that $$\\mathcal{B} \subset \mathcal{T}\$$ always holds.

If we omit the second requirement, we have a subbasis of $$\X\$$. A subbasis generates a topology by also declaring the intersection of finitely many members to be open.

Input and Output

Given a set of finitely many finite sets $$\\mathcal{S}\$$, $$\X\$$ shall be implicitly defined as $$\\bigcup\mathcal{S}\$$. Note that by this, the first requirement for bases always holds.

The input/output format is flexible. In every case, inputs that don't fit in your input format fall in don't care situation.

Examples

Truthy

• $$\\emptyset\$$ (Generates $$\X = \emptyset\$$ and $$\\mathcal{T} = \{\emptyset\}\$$)

• $$\\{\emptyset\}\$$ (Ditto)

• $$\\{\{0\}\}\$$ (Generates $$\X = \{0\}\$$ and $$\\mathcal{T} = \{\emptyset, \{0\}\}\$$)

• $$\\{\emptyset,\{0\}\}\$$ (Ditto)

• $$\\{\{1\}\}\$$ (Generates $$\X = \{1\}\$$ and $$\\mathcal{T} = \{\emptyset, \{1\}\}\$$)

• $$\\{\{0\},\{1\}\}\$$ (Generates $$\X = \{0,1\}\$$ and $$\\mathcal{T} = \{\emptyset, \{0\},\{1\},\{0,1\}\}\$$)

• $$\\{\{0\},\{1\},\{0,1\}\}\$$ (Ditto)

• $$\\{\{0\},\{1\},\{2\}\}\$$ (Generates $$\X = \{0,1,2\}\$$ and $$\\mathcal{T} = \{\emptyset, \{0\},\{1\},\{2\},\{0,1\},\{0,2\},\{1,2\},\{0,1,2\}\}\$$)

• $$\\{\{0,1\},\{0,2\},\{1,2\}\}\$$ (Ditto)

Falsy

• $$\\{\{0,1\}\}\$$ (Generates $$\X = \{0,1\}\$$ and $$\\mathcal{T} = \{\emptyset,\{0,1\}\}\$$)

• $$\\{\{0,1\},\{1\}\}\$$ (Generates $$\X = \{0,1\}\$$ and $$\\mathcal{T} = \{\emptyset,\{1\},\{0,1\}\}\$$)

• $$\\{\{0\},\{1,2\}\}\$$ (Generates $$\X = \{0,1,2\}\$$ and $$\\mathcal{T} = \{\emptyset, \{0\},\{1,2\},\{0,1,2\}\}\$$)

• $$\\{\{0,1\},\{1\},\{2\}\}\$$ (Generates $$\X = \{0,1,2\}\$$ and $$\\mathcal{T} = \{\emptyset, \{1\},\{2\},\{0,1\},\{1,2\},\{0,1,2\}\}\$$)

• This looks math-heavy. To get a better chance of having it reviewed (because people, including me, tend to skip long sandbox posts) you can ask in chat and leave it in for a while. – user202729 Feb 18 at 3:28
• So, if I'm understanding correctly, defining U(S) as the union of all members of S and P(S) as the powerset of S, you are asking whether {U(x) for x in P(X)} == P(U(X))? In this case a more to the point description like this one could be useful... You can leave the math background in (maybe shorten it a little bit) for people interested, but it shouldn't be the only description for the challenge. – Leo Feb 19 at 1:08
• @Leo Figuring out a simple algorithm to solve the challenge can be part of it. (although after the first answer is posted people can just use the same algorithm, however nobody is forced to look at the answers; besides the "original" answer tend to be upvoted proportionally anyway) – user202729 Feb 19 at 9:13
• @Leo (your notation is confusing because you use X for the input while OP uses it for U(input), but it looks correct) [please review other sandbox posts] – user202729 Feb 19 at 9:31
• @user202729 I agree that figuring out the algorithm is part of the challenge, but having to understand several paragraph of relatively advanced math concepts is a bit detrimental to the challenge itself, in my opinion. Moreover, mine is not necessarily the best algorithm, just a simpler description of the requirements. You are right about the different notation, sorry for the ambiguity – Leo Feb 19 at 12:37

Decode an 8086 MOD R/M

I think this might be fun. Or, it might be torture, idk. 😛 If this is popular, I might add a sequel for the significantly more complex 32-bit encoding 😏

Time for a mini objdump.

An 8086 MOD R/M field is laid out like so:

MOD  REG  R/M |  OPTIONAL DISPLACEMENTS
mm   rrr  rrm | (iiiiiiii) | (iiiiiiii)
76   543  210 |  76543210  |  76543210


REG is a register. Quite unintuitively, the register names are not in alphabetical order.

Note that you can safely assume a word register, not a half byte register, and that the destination is a register.

REG |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |
Name| AX | CX | DX | BX | SP | BP | SI | DI |


MOD determines the length and format of the instruction.

MOD | FORMAT
1  | [MEM+/-disp8] (signed 8-bit immediate)
2  | [MEM+/-disp16] (signed 16-bit little endian immediate)
3  | REG


MEM is parsed as so:

MEM  |    0    |    1    |    2    |    3    |   4  |   5  |   6   |   7  |
Name | [BX+SI] | [BX+DI] | [BP+SI] | [BP+DI] | [SI] | [DI] | [BP]* | [BX] |
*when MOD==0, [BP] is replaced by an absolute 16-bit address.

Just [BP] is encoded as [BP+0].


I am going to represent MOD R/M as octal, and addresses/displacements as hex. It really bugs me how few people write it this way, as it makes much more sense.

So, for example:

MOD  r  r/m
3   0    0
reg  |    |
AX,  AX

0   2    0
mem  |    |
DX,[BX+SI]

1   3   7 , 23
M+D8 |   |   |
BX, [BX+0x23]

2   2   1 , BC 6A
M+D16|   |    | /
DX,[BX+DI+0x6ABC]



Rules:

• You may take your input as a packed integer, byte array, string in any mix of bases, or whatever. I'm not picky. I personally wrote them as mixed hex and octal.
• You will always get 3 bytes, however, in true objdump spirit, those extra bytes will be random. The first byte is all you need to determine the length.
• Not all cases will be the most efficient encoding.
• In the output:
• It may be returned as a single string, or printed.
• It is case insensitive
• It can have excess spaces or tabs, but it must be on one line.
• It can have an optional trailing newline
• Displacements and addresses can be in any base, however, do note that displacements are signed two's complement and will be subtracted if negative. So, for 100 FF, AX,[BX+SI+0xFF] is wrong.
• Leading zeroes and displacements of zero are fine.

Test cases (irrelevant bytes are in italics):

300 73 A2 -> AX,AX
312 01 82 -> CX,DX
337 3E 1C -> BX,DI
020 24 AF -> DX,[BX+SI]
137 23 6B -> BX,[BX+0x23]
066 34 21 -> SI,[0x1234]
166 00 10 -> SI,[BP+0x00]
221 BC 6A -> DX,[BX+DI+0x6ABC]
124 FF EF -> CX,[SI-0x01]
224 FF FF -> CX,[SI-0x0001]
240 00 00 -> SP,[BX+SI+0x0000]
• How is "300" 3 bytes? It looks like 3 octal digits. – user202729 Feb 20 at 9:43
• Is that better? – EasyasPi Feb 20 at 10:43
• What is R/M? Why is MEM 3 bits long? – user202729 Feb 20 at 11:25
• Since you list out the bytes as bits (appropriately), it would probably be clearer if you also included the binary values in the tables for reg/mod/mem. Using the octal/hex format is probably also going to confuse people - I think labeling your examples with what base is being used may help. – FryAmTheEggman Feb 20 at 18:19

Create a QR quine

(a "qruine" if you will)

Design a QR code that legibly spells with its pixels (or the space between them) the text that it scans to.

For example, this QR code scans to the letter A, and also spells out A in white:

It does not matter what the scanned and displayed text is; it does not have to be coherent or readable.

The winner is the person with the longest text.

• This is a really cool idea, but I'm not quite sure what you mean. (pulls out qr code scanner) Oh, never mind, it really does just scan as 'A'. This surprises me for how big it is. – Beefster Feb 24 at 22:55
• Does this count as code-golf? – A username Feb 25 at 4:08

• The test cases are rather confusing. Are they missing the expected output? In addition, your statement about "dots" is rather odd - do you mean all non-letter characters should be ignored, or just punctuation, or just periods? You should definitely also specify what characters can appear in the input. – FryAmTheEggman Feb 22 at 17:32
• I think I get it, but it needs to be explained better. For each value of n less than the length of the word, the letters that are n slots from the beginning and n slots from the end of the word should both be made uppercase if either of them is upper case. – Xcali Feb 22 at 19:04
• Perhaps replacing "slot" by "position"/"character" is easier (perhaps it's a perl term? I don't know), but otherwise clear enough. [please review other sandbox posts] – user202729 Feb 24 at 4:27

Write a Deadfish~ writer & golfer code-golfmetagolfinterpreter

Deadfish~ is a language with a couple of basic commands, and an accumulator which starts at 0:

i - increment accumulator
d - decrement accumulator
s - square accumulator
{...} - repeat the statement inside 10 times.
(...) - if accumulator = 0, skip statement
o - output accumulator as number
c - output result as number
w - output "Hello, world!"
h - halt


Additionally, if at any point the accumulator is -1 or 256, it is reset to 0.

Your challenge is to write a program that, when given a string containing valid ASCII only, outputs a valid Deadfish~ program that outputs the given string.

Scoring

Your score is the size (in bytes) of your program plus the size of the program generated by plugging The quick brown fox jumps over the lazy dog into your program. This can't be hard-coded. E.g. if your program is 200 bytes and it outputs a 300-byte program for The quick brown fox jumps over the lazy dog, your score is 500.

Lowest score wins.

Testcases:

Greetings, world!

A man, a plan, a canal, panama!

qwertyuiopasdfghjklzxcvbnm

X X X X X X X X X X X X

Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo


For each of these, your program should output a valid Deadfish~ program that outputs the given string.

• This isn't very different from bfcat, and I'm not sure it's more interesting. – Wezl Feb 25 at 14:58
• You're right, but this is also judged by the efficiency of your program, which changes it a lot. – A username Feb 26 at 3:07

Is this code in the same language as my answer? (WIP)

Probably a bad idea, but the goal here is to output a truthy value if a given input string is valid syntax in the same language as your answer.

• Maybe use neural networks and allow answers to have approx. 80% accuracy? I personally don't think this is all that interesting (and it would be very hard to score), but that's completely subjective. – user Feb 26 at 21:00
• Terrible question in most languages. Either they use compile (eval might loop infinitely) or they just print a truthy value (in esoteric languages where all programs are valid) – user202729 Feb 27 at 12:21
• nop in languages with no syntax – l4m2 Mar 16 at 2:06