578
\$\begingroup\$

This "sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to main. 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.

Sandbox FAQ

Posting

To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

  • Parts of the challenge you found unclear
  • Comments addressing specific points mentioned in the proposal
  • Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts requires more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended! Be patient and try not to nag people though, you might have to ask multiple times.

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal, use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

\$\endgroup\$
3
  • 1
    \$\begingroup\$ What if I posted on the sandbox a long time ago and get no response? \$\endgroup\$ Commented May 15, 2024 at 14:05
  • 2
    \$\begingroup\$ @None1 If you don't get feedback for a while you can ask in the nineteenth byte \$\endgroup\$ Commented May 29, 2024 at 13:27
  • \$\begingroup\$ I have been once submitted a question to sandbox and downvoted to -1, but after submitting it anyway it has 8-9 score right now. \$\endgroup\$ Commented Dec 5, 2025 at 18:13

5006 Answers 5006

1
26 27
28
29 30
167
3
\$\begingroup\$

Output 5-line calendar

Given year, month and optionally weekday of 1st, output the calendar of the month.

For empty cell, fill it with the date where it's supposed to be, in last or next month, and add # to indicate gray. If last few days can't fit in 5 lines, then they share last line with 5th week, use / to separate two days.

Sample Input: Nov 2023

Sample Output:

 #28   #29   #30     1     2     3     4
   5     6     7     8     9    10    11
  12    13    14    15    16    17    18
  19    20    21    22    23    24    25
  26    27    28    29    30    #1    #2

Sample Input: Dec 2023

Sample Output:

 #26   #27   #28   #29   #30     1     2
   3     4     5     6     7     8     9
  10    11    12    13    14    15    16
  17    18    19    20    21    22    23
24/31   25    26    27    28    29    30

Outputting a 2D array of string is fine

\$\endgroup\$
3
\$\begingroup\$

Longest irreducible quine

Posted here

\$\endgroup\$
14
  • \$\begingroup\$ Would a submission be valid if it can be reduced to an improper quine, but not to a proper one? \$\endgroup\$ Commented Dec 4, 2023 at 17:17
  • \$\begingroup\$ @noodleman ty, clarified \$\endgroup\$ Commented Dec 4, 2023 at 20:33
  • \$\begingroup\$ In most languages it will be possible to make it longer by somehow splitting it, but you can't reduce it by only removing characters, but you also need to change some. I never saw a good »longest« challenge, and I doubt this will be the first. \$\endgroup\$ Commented Dec 5, 2023 at 6:40
  • \$\begingroup\$ @Philippos not quite sure how this would work, care to give an example? \$\endgroup\$ Commented Dec 5, 2023 at 12:33
  • 2
    \$\begingroup\$ @Philippos This is wrong - it easily follows from Higman's lemma that in all languages (they don't even have to be computable!) there is only a finite number of irreducible programs which perform a given task, so in particular the length must be bounded. \$\endgroup\$ Commented Dec 5, 2023 at 16:28
  • \$\begingroup\$ An example: You can split your example like v='%r;print("v="+v%%v)';print("v="+v%v) Easy to reduce, but not only by only removing bytes. \$\endgroup\$ Commented Dec 6, 2023 at 8:08
  • \$\begingroup\$ @Philippos Sure, but I don't see how this can be extended further indefinitely. (Granted, I'm not very experienced with quines/irreducible code) \$\endgroup\$ Commented Dec 6, 2023 at 15:19
  • \$\begingroup\$ You could continue like v='%r;pront("v="+v.replace(chr(111),"i")%%v)';print("v="+v.replace(chr(111),"i")%v), which of course could be repeated similarly many times without possible reduction. \$\endgroup\$ Commented Dec 7, 2023 at 7:22
  • \$\begingroup\$ @CommandMaster I don't know whether Higman's lemma can be appllied here. Even if it can, the length border could be somewhere in the thousands, millions, billions ... \$\endgroup\$ Commented Dec 7, 2023 at 7:25
  • \$\begingroup\$ @Philippos I know it can be large, but that's the point of the challenge. Why couldn't it be applied? If you look at the set of all irreducible programs performing a particular task, no element of that set is a subsequence of another element, so it must be finite. \$\endgroup\$ Commented Dec 7, 2023 at 8:42
  • \$\begingroup\$ @CommandMaster Well, math scat may give it a try, but still I believe it won't be fun, because the people will lose interest before reaching any border. Or I'm wrong (rumours claim this did already happen before ;-) \$\endgroup\$ Commented Dec 7, 2023 at 8:48
  • \$\begingroup\$ @Philippos This irreducible code bowling challenge was very well received, I don't see why this will be worse \$\endgroup\$ Commented Dec 7, 2023 at 9:37
  • \$\begingroup\$ @CommandMaster One look at the exponents is enough for me to walk away. \$\endgroup\$ Commented Dec 7, 2023 at 10:20
  • \$\begingroup\$ (at Phillipos and CommandMaster) thanks for your feedback, I do think I'll give this challenge a try though. \$\endgroup\$ Commented Dec 12, 2023 at 12:06
3
\$\begingroup\$

How long is this string, really?

\$\endgroup\$
3
\$\begingroup\$

In this challenge answers will provide three elements:

  • A programming language: \$L\$
  • An output string: \$S\$
  • And a non-empty string: \$B_n\$

You will also write, but not reveal, a program in \$L\$ which outputs \$S\$, built by concatenating copies of the \$B_n\$ strings from your answer and previous answers in any order.

For example here are two answers given in pseudocode:

Answer 1

\$S\$ = H
\$B_0\$ = print "H"

The program is print "H"

Answer 2

\$S\$ = Hiiii
\$B_1\$ = ++"i"

The program is print "H"++"i"++"i"++"i"++"i"

Robbers will try to discover a valid solution, that is a program made from the \$B_n\$ strings in your answer and previous answers which outputs your \$S\$. Your goal will be to make this as hard as possible.

States

As with any challenge, cops' posts here can have 4 different states:

  • Vulnerable
  • Cracked
  • Safe
  • Revealed

All cops' posts start as vulnerable. If a robber finds and posts a solution to a vulnerable post they will receive 1 point and the post will become cracked. If a post lasts 10 days in vulnerable without being solved it automatically becomes safe. A cop with a safe post may choose to reveal their program and their safe post will become revealed. A robber can still solve a safe post, if they do they receive a point and the post becomes revealed.

Only revealed posts are eligible for scoring. Robbers are only permitted to solve vulnerable and safe posts.

Scoring

For cops' an answer's score is the number of cops' posts before it if it is revealed and 0 if it is any other state. The goal is to get as high a score as possible.

Languages

In the interest of fairness, we are going to require that languages are free and reasonably cross platform. Both languages you choose must be freely available on Linux and FreeBSD (the two largest foss operating systems). This includes languages which are free and open source.

Your selected languages must predate this challenge.

Programs here should be complete programs not functions, expressions or snippets.

\$\endgroup\$
5
  • \$\begingroup\$ I wonder, would cops want to make writing challenges for future cops easier or harder? Also, your example challenges don't state the language, although the text above them says the cop ought to state it. \$\endgroup\$ Commented Feb 17, 2024 at 5:27
  • \$\begingroup\$ @CommandMaster I state both are in pseudocode. \$\endgroup\$ Commented Feb 17, 2024 at 7:00
  • \$\begingroup\$ Oh, I see. It's outside the answer quote, so this might be a bit confusing \$\endgroup\$ Commented Feb 17, 2024 at 10:17
  • \$\begingroup\$ Does the cop/robber need to use all of previous \$B_n\$? I suggest stating either way explicitly. \$\endgroup\$ Commented Feb 18, 2024 at 10:01
  • \$\begingroup\$ I didn't understand the question. Can i simply repeat the Bn by 1 time, 2 times, 3 times, ... and try the connected result one by one? \$\endgroup\$ Commented Mar 6, 2024 at 11:13
3
\$\begingroup\$

How many cacti can I plant here?

\$\endgroup\$
2
  • \$\begingroup\$ Hi, I like the question a lot. I would consider either sticking to edge-wrapping or not. As it is, you should specify which behavior the test cases are for, and ideally add both sets of test cases. Also, don't forget to specify that this is a code golf question. \$\endgroup\$ Commented Mar 29, 2024 at 18:04
  • \$\begingroup\$ @chunes Thank you, I'll stick to the Minecraft template. The test cases actually differ with edge-wrapping, the third one can only contain 16 instead of 17 cacti and the fourth one 76 instead of 79. \$\endgroup\$ Commented Mar 29, 2024 at 18:17
3
\$\begingroup\$

Draw a Fibonacci Swoosh

\$\endgroup\$
3
\$\begingroup\$

Scroll That Text Faster!

Lots of television news stations will show a ticker at the bottom, which can be thought of as a window into a larger string that shifts to the right by one space each cycle:

"Lorem ipsum dolor sit amet, consectetur adipiscin"
"orem ipsum dolor sit amet, consectetur adipiscing"
"rem ipsum dolor sit amet, consectetur adipiscing "
"em ipsum dolor sit amet, consectetur adipiscing e"
"m ipsum dolor sit amet, consectetur adipiscing el"

This works great if the cycle time is short and the text can scroll by quickly. But not every updating text application is so lucky. Radio Data System is used by FM radio stations to send small amounts of data, about 1.2 kilobits per second, which contains information about the station or song or what-have-you. But with such a low bitrate, updates can be quite slow, and stations I see update the text about once a second.

With small enough windows, this can be annoyingly slow if we only advance it one character at a time. But some stations use a trick: separate the message by spaces and fit as many as we can into one window. Any words longer than the window must be scrolled one character at a time.

The Challenge

Write a function f(s, w) where s is the full string to scroll through and w is the size of the window in characters. w must be an integer and greater than 0. The output is a sequence of strings (array or output to console separated by newlines or whatnot), where each line is one step of the ticker.

To build the output, we can divide the words into those that fit into the window and those that don't. Of the first kind, fit as many as you can into one window, ignoring trailing spaces. If a word is exactly 1 window wide, it is considered of the first kind. If we get to a word that doesn't fit in the window but we still have empty space in the current window, just leave the rest of the window blank.

For words that don't fit in the window, scroll through them one character at a time until the end of the word is visible as the last character of the window. Each scroll step becomes its own output line. Words that don't fit in the window never share windows with those that do - the output shouldn't be "NEVER GON", "NA ", it should be "NEVER ", "GONNA ".

Examples

s = "RICK ASTLEY - NEVER GONNA GIVE YOU UP", w = 10

 0123456789
"RICK      "
"ASTLEY -  "
"NEVER     "
"GONNA GIVE"
"YOU UP    "

s = "LUDWIG VAN BEETHOVEN - SYMPHONY NO. 7 IN A MAJOR, OP. 92", w = 6

 012345
"LUDWIG"
"VAN   "
"BEETHO"
"EETHOV"
"ETHOVE"
"THOVEN"
"-     "
"SYMPHO"
"YMPHON"
"MPHONY"
"NO. 7 "
"IN A  "
"MAJOR,"
"OP. 92"

s = "SHERMAN BROTHERS - SUPERCALIFRAGILISTICEXPIALIDOCIOUS", w = 15

 012345678901234
"SHERMAN        "
"BROTHERS -     "
"SUPERCALIFRAGIL"
"UPERCALIFRAGILI"
"PERCALIFRAGILIS"
"ERCALIFRAGILIST"
"RCALIFRAGILISTI"
"CALIFRAGILISTIC"
"ALIFRAGILISTICE"
"LIFRAGILISTICEX"
"IFRAGILISTICEXP"
"FRAGILISTICEXPI"
"RAGILISTICEXPIA"
"AGILISTICEXPIAL"
"GILISTICEXPIALI"
"ILISTICEXPIALID"
"LISTICEXPIALIDO"
"ISTICEXPIALIDOC"
"STICEXPIALIDOCI"
"TICEXPIALIDOCIO"
"ICEXPIALIDOCIOU"
"CEXPIALIDOCIOUS"

Notes

  • Words are defined as any sequence of non-space characters between space characters, at least U+0020. Word delimiters aren't dashes, commas, or punctuation.
  • ASCII support only is fine, though you can get bonus style points if it supports a broader selection of Unicode, including fancy Unicode whitespace.
  • Supporting uppercase-only, lowercase-only, or mixed case is fine.
  • Trailing whitespace in output strings to pad to the window width is optional.
  • This is code golf, so smallest program (bytes, codels, etc.) wins!
\$\endgroup\$
3
\$\begingroup\$

Count trapped self-avoiding walks

Imagine an infinite grid of square tiles. You are standing on one of the tiles. You can move to any of the four cardinally adjacent tiles in a move, but you cannot step on the same tile twice. Calculate the number of ways you can get yourself trapped, i.e. the states where all four adjacent tiles have been already stepped on, after exactly \$n\$ moves. To take symmetry into account, only count the paths where your first move is to the right, and your first vertical move is upwards.

This is sequence A077482:

1, 2, 11, 25, 95, 228, 752, 1860, 5741, 14477, 42939, 109758,
317147, 818229, 2322512, 6030293, 16900541, 44079555, 122379267,
320227677, 882687730, 2315257359, 6346076015, 16675422679,
45502168379, 119728011251, 325510252108, 857400725204, ...

This is a challenge. Submit a program that outputs the answers to the question for \$n = 7, 8, 9, 10, \cdots\$, indefinitely. The score of a submission will be the largest \$n\$ whose answer is printed in a minute on my local machine. Highest score wins; tie is broken by the time taken to output up to that term.

My local machine is a Windows 10 machine with the following specs:

  • CPU: 12th Gen Intel Core i7-12700 (2.1GHz, 12 cores)
  • RAM: 32GB

If a submission has no way to run on Windows, you can provide your own measurement, or online code execution services such as TIO/ATO/Godbolt may be used. I know this is not ideal, but I don't have other good options at the moment.

\$\endgroup\$
3
  • \$\begingroup\$ can you clarify what you mean with the tie-breaker? to me it sounds like it's the same as the score. \$\endgroup\$ Commented Jun 11, 2024 at 8:25
  • 1
    \$\begingroup\$ @Themoonisacheese A submission that computes up to n=20 in 30 seconds wins against another that computes up to n=20 in 50 seconds (if both time out before computing n=21). \$\endgroup\$ Commented Jun 11, 2024 at 23:29
  • \$\begingroup\$ i see. worth noting in your final submission that the Core i7-12700 has 8 P-cores and 4 E-cores, which will likely affect multithreading. i don't think it's relevant to say, limit answers to only use 8 cores, but I think you should still mention it. \$\endgroup\$ Commented Jun 12, 2024 at 8:30
3
\$\begingroup\$

Sorting with a deque

\$\endgroup\$
3
\$\begingroup\$

Given an integer \$n\$. Connect all pairs of points on \$\mathbb Z^2\$ whose distance is \$\sqrt n\$. Count how many connected sets remain.

In case that infinite sets exist, return something not a positive integer. (0 used below)

Test cases

1 => 1
2 => 2
3 => 0
4 => 4
5 => 1
25 => 1
\$\endgroup\$
3
\$\begingroup\$

Shift right by half a trit

\$\endgroup\$
6
  • \$\begingroup\$ I believe there is exactly one f that satisfies the properties. \$\endgroup\$ Commented Aug 8, 2024 at 3:15
  • \$\begingroup\$ Some approaches to this challenge might benefit from using [sequence] format I/O, outputting [f(0), f(1), ...] or some prefix of it. Not sure if that's consistent with your vision for this challenge, though. \$\endgroup\$ Commented Aug 8, 2024 at 5:25
  • \$\begingroup\$ @Bubbler That is correct. I decided to add an explicit description of f to make the actual task clearer. \$\endgroup\$ Commented Aug 8, 2024 at 15:01
  • \$\begingroup\$ @shapewarriort I'm not opposed to this. Would the sequence need to be up to a given length, or the input n, or what? \$\endgroup\$ Commented Aug 8, 2024 at 22:58
  • \$\begingroup\$ The most common format for sequence-output challenges based on the first page of recent challenges appears to be: take an index n (0 or 1 indexed) and output the nth term; take a length n and output the first n terms; or take no input and output the entire sequence (as an infinite list, generator, etc.). This is more or less the same as what's under the tag wiki for [sequence] (codegolf.stackexchange.com/tags/sequence/info), though that phrases the "first n terms" format as the more ambiguous "Given some index n it can return all entries up to the nth one in the sequence." \$\endgroup\$ Commented Aug 8, 2024 at 23:09
  • \$\begingroup\$ Taking 0-indexed n and outputting the nth term is the current I/O; 1-indexed n is probably not very useful, and I don't think most people would care about it. But being able to output the first n terms (or infinitely yield terms) seems like it could streamline approaches that build the entire sequence (prefix) anyway. Both brute force methods as well as constructions that build the list piece by piece. \$\endgroup\$ Commented Aug 8, 2024 at 23:20
3
\$\begingroup\$

Completely introduce your friends

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Welcome to CG&CC, and nice first challenge! You might be happy to learn that we have fairly mature community standards for reasonable I/O flexibility, so you don’t have to go out of your way to provide specific ways to “simplify” it. One nitpick I have for spec readability is the mention of “all ordered pairs” in 3 without re-stating the “different” constraint in 1–if you get rid of the formatting in 2, you could condense it to “output a permutation of all ordered pairs of unique names” then add a note that the pairs can be flattened out as desired. Also, are names guaranteed to be unique? \$\endgroup\$ Commented Aug 22, 2024 at 20:20
  • 2
    \$\begingroup\$ @UnrelatedString thanks for the welcome and helpful comments! I've edited the challenge to address your notes. Let me know what you think! \$\endgroup\$ Commented Aug 23, 2024 at 2:01
  • \$\begingroup\$ Interesting challenge, seems to boil down to finding an Eulerian path for a complete digraph if I understand Wikipedia correctly. Doesn't seem to be a duplicate, based on searching the site for "euler graph". ||| What does it mean to output as a string? Would it be okay to just return a list of ordered pairs instead? ||| Output format suggestion if it's consistent with your vision for this challenge: since the second element of each pair is always the same as the first element of the next pair (wrapping around for the last), just the first element of each pair is enough to describe a solution. \$\endgroup\$ Commented Aug 23, 2024 at 18:27
  • 1
    \$\begingroup\$ @shapewarriort Yep ultimately I think it's a graph traversal. Listing the nodes traversed in order would describe an answer but I think in the theme of the question I'd ask for all the pairs/edges instead. And a list of pairs would do too, I'll add that! \$\endgroup\$ Commented Aug 23, 2024 at 19:54
  • \$\begingroup\$ Fair enough with the challenge vision. ||| Some things on the I/O format: The test cases are in a format that, presumably, would be invalid for the actual challenge (assuming that names are not restricted to single characters). Printing a string representation of a data structure (here, a list of tuples) to STDOUT is allowed by default, so if that's what you mean by outputting "as a string", it might not be fully necessary to specify that. Both of these points are quite minor, and I don't think anything needs to be changed, but just wanted to bring them up nonetheless. \$\endgroup\$ Commented Aug 23, 2024 at 21:42
  • 1
    \$\begingroup\$ @shapewarriort thanks for the pointers! I'm understanding the I/O standards better I think. As long as these changes look OK, when am I good to post the challenge? \$\endgroup\$ Commented Aug 23, 2024 at 22:41
  • \$\begingroup\$ Happy to help! The Sandbox FAQ recommends a wait time of 72 hours and a net score of +3 as thresholds of challenge readiness. I personally don't see any more issues at this point, and doubt that immediately posting the challenge as-is would cause any significant problems, but I can't speak for other people. Looking at the newest questions on the main site that were originally posted to the Sandbox, all of them seem to have a gap of at least 3 days between initial sandboxing and main-site posting. I don't have enough experience to give any advice beyond that. \$\endgroup\$ Commented Aug 23, 2024 at 23:06
3
\$\begingroup\$

Visualize "Destroying Democracy"

This MathPickle post poses an interesting problem about gerrymandering.

An n-by-n square grid is given, and all cells are initially painted green. You can paint some cells red and partition the grid into several rectangles. The color of a rectangle is red if there are strictly more red cells than green; otherwise it is green (including when the numbers are equal). Your objective is to "win the election" by having strictly more red rectangles than green, with as few red cells as possible.

  • The rectangles must cover the grid, and may not overlap.
  • The largest rectangle's area must be strictly less than twice the smallest.

This problem has been solved for n <= 12 in this Puzzling post, and for more sizes in this OEIS entry.

Some examples: (same letter = one rectangle, uppercase = red)

n = 3: 4 red cells
AAa
BBb
ccc

n = 4: 6 red cells
AAad
BBbd
CCcd
eeee

n = 5: 8 red cells
AAafg
BBbfg
CCcfg
DDdfg
eeefg

n = 6: 11 red cells
aaaaad
bEFGHd
bEFGHd
befghd
bIIIid
bccccc

In this challenge, you don't need to minimize the number of red cells. Instead, find any one way to win the election by painting \$\frac{n^2}{2}\$ or fewer cells red and partitioning the grid following the rules.

I/O

The input is one integer n which is at least 3.

The output must be a 2D structure with n rows and n columns, where each item identifies the color and the rectangle the cell belongs to. The following are some valid outputs for n = 3:

2D array of nonzero integers, where sign = color and absolute value = rectangle ID
[[-1, -1, 1],
 [-2, -2, 2],
 [3, 3, 3]]

2D array of tuples of (bool, string)
[[(false, "A"), (false, "A"), (true, "A")],
 [(false, "B"), (false, "B"), (true, "B")],
 [(true, "C"), (true, "C"), (true, "C")]]

Strings printed over n lines
R1 R1 G1
R2 R2 G2
G3 G3 G3

Note that the "letter representation" used above is for illustration purposes and not allowed, since the number of rectangles can go over 26.

Standard rules apply. The shortest code in bytes wins.

\$\endgroup\$
2
  • \$\begingroup\$ If a rectangle has an equal amout of red and green cells, is it neither red nor green? In that case, does it contribute to neither the red total or green total? \$\endgroup\$ Commented Aug 27, 2024 at 23:13
  • \$\begingroup\$ @Lucenaposition "The color of a rectangle is red if there are strictly more red cells than green; otherwise it is green." So when the numbers are equal, the rectangle is green. Edited a bit to clarify it. \$\endgroup\$ Commented Aug 28, 2024 at 0:45
3
\$\begingroup\$

Stuck on Sokoban

\$\endgroup\$
3
\$\begingroup\$

Is it a date format of YYMMDD, MMDDYY, and/or DDMMYY?

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

Print 4 billion if statements

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Does even / odd need to end in a newline? Is casing important? What about leading/trailing whitespace? \$\endgroup\$ Commented Sep 16, 2024 at 4:02
  • \$\begingroup\$ @ATaco Leading/trailing whitespace/newlines are covered by standard I/O (yes), but I'll add those explicitly. For the sake of simplicity I'll keep casing as strictly lowercase \$\endgroup\$ Commented Sep 16, 2024 at 5:52
3
\$\begingroup\$

Draw a string as a binary tree

\$\endgroup\$
3
\$\begingroup\$

How many dots are there?

\$\endgroup\$
3
\$\begingroup\$

Implement a very tiny APL dialect

In this challenge, you implement a small variant of APL. The core feature of APL is multidimensional arrays, which are a generalization over scalars, vectors, matrices, 3d arrays, .... This challenge has intentionally lax requirements in some places and more strict ones in others to make the challenge more interesting. In this APL, all arrays only contain integers of a size suitable for your language. If you want to limit the amount of axes (i.e. the rank) of an array, this limit should at least be 10.

Concepts

The shape of an array is the amount of things on each axis: for example the scalar 1 has shape [], the vector [1, 2, 3] has shape [3], a 2x3 matrix has shape [2, 3].

Array literals

There should be a way to write an array literal, no matter its dimension. This can be done in many ways: a binary function (see below) like 3 2 makeArray 1 2 3 4 5 6, syntax specifying shape and contents like [3 2; 1 2 3 4 5 6], by providing a syntax for scalars like 1, a syntax for vectors like (1 2 3) and a syntax for combining arrays creating a new axis like [(1 2 3) (4 5 6)]. The rest of the challenge uses the latter syntax. You can choose to provide a syntax for negative numbers or just use negation (see below) to construct them.

Functions

You should provide the following functions: addition, negation, subtraction, shape. You can choose any name for these functions, but the ones for negation and subtraction must be the same and only distinguishable by context (see below). Negation negates each integer contained in the array. Addition and subtraction respectively add and subtract each item in the array, when they have the same shape; if one of the two arrays is a scalar all the values of the other arrays are operated with that scalar; otherwise the result is undefined. Shape always returns a vector containing the shape of the argument.

Examples

1 + 1                                    → 2
(1 2 3) + (4 5 6)                        → (5 7 9)
[(1 2 3) (4 5 6)] + [(1 1 1) (-1 -1 -1)] → [(2 3 4) (3 4 5)]
(1 2 3) + 5                              → (6 7 8)
(1 2) + (3 4 5)                          → undefined
(1 2 3) + [(4 5 6)]                      → undefined
(1 2 3) - (9 3 1)                        → (-8 -1 2)
-[(1 2 3) (4 5 6)]                       → [(-1 -2 -3) (-4 -5 -6)]
shape 2                                  → ()
shape (1 2 3)                            → (3)
shape [(1 2 3) (4 5 6)]                  → (2 3)

Reduce

You should also support reduction. Reduction is written after a binary function (so addition or subtraction) and reduces the first axis of an array right to left. This means that an array of shape [2, 4, 7] becomes [4, 7]. Addition reduce sums all subarrays, subtraction reduce does an alternate sum of the subarrays. Note that you may not provide a function for "add reduce" and another for "minus reduce"; in other words the syntax for add reduce and subtract reduce should respectively have a prefix of the syntax for add and subtract and share a common suffix, where the prefixes and the suffix together constitute the whole function name, ignoring whitespace. Reducing over an empty axis is undefined; reducing over a scalar returns that scalar.

Examples

+ reduce (1 2 3)           → 6
+ reduce [(1 2 3) (4 5 6)] → (5 7 9)
+ reduce 5                 → 5
+ reduce ()                → undefined
- reduce (1 2 3)           → 2

Syntax

The only thing missing is a way to combine expressions. Unary functions consume all the expression to the right as the argument; binary functions do the same for the right argument but only consume the value directly to the left of the function name. Grouping syntax using an opening and closing sequence must also be supported, this can go to the left of a binary function to give it a more complex left argument or around other expressions with no meaning. Grouping around functions or the reduction symbol is not required. Using an unary function as a binary function or vice versa is undefined.

Examples

In these examples, {/} is the grouping syntax.

1 + 2 - 3       → 1 + {2 - 3}         → 0
1--3            → 1-{-3}              → 4
shape +/(1 2 3) → shape {+/{(1 2 3)}} → shape 6 → ()
+5              → undefined
3 shape 2       → undefined
\$\endgroup\$
1
  • \$\begingroup\$ this looks cool \$\endgroup\$ Commented Oct 28, 2024 at 21:22
3
\$\begingroup\$

Make an almost-square

\$\endgroup\$
1
  • \$\begingroup\$ Instead of 'any character' I would like something more challenging, I feel the challenge as proposed here might be a bit too simple? Nothing wrong with that perse, but I'd like to spark a bit more creativity \$\endgroup\$ Commented Nov 7, 2024 at 13:05
3
\$\begingroup\$

How many 2x4s can you make from a log?

You have a pile of logs that you want to mill into two-by-four inch boards to build a new stand for your grilled-cheese sandwich business. You've counted and measured all the logs, but can you get all the lumber you need out of them?

Challenge

a program to find the number of two-by-fours you can make from a log, given the diameter of the log.

Details

Milling the logs is a two-step process: First, you cut the log into a number of parallel 2-inch planks, discarding 1 inch on either end. For example, you would get four live-edge 2-inch-thick planks from a 10-inch-diameter log (not including bark):

Logs are first milled into 2-inch thick planks, discarding 1 inch on either end. A 10-inch log makes four planks.

Then, you cut each plank into as many 4-inch wide boards as you can. Each board must be a full 4 inches on each side, i.e., you may not cut past the corner of the plank on either side.

Arrangement of 2x4s in logs of four diameters: 6" log -> 2 boards, 10" log -> 6 boards, 14" log -> 12 boards, 20" log -> 30 boards

Fortunately, every log is perfectly cylindrical, untapered, and has a diameter that is a multiple of 2 inches, and you have a saw with an infinitesimal kerf.

Input

The diameter of the log in inches. Always a positive multiple of 2.

Output

The number of two-by-fours you can make from a log of the given diameter.

Test cases

 Input Output
     2      0
     6      2
    10      6
    14     12
    20     30
    30     74
\$\endgroup\$
1
  • \$\begingroup\$ semi-related - this is effectively counting squares within the quarter-circle and doubling \$\endgroup\$ Commented Dec 7, 2024 at 22:09
3
\$\begingroup\$

Convert a parent vector to a depth vector

\$\endgroup\$
3
\$\begingroup\$

Slanted Letter Sign

I dreamed I opened a business called “The Skill Share” and the sign out front looked (sort of) like this:

      L E
     L R
  E I A
 H K H
T S S

Write a program or function that formats text like this.

Input

The input will be a non-empty string of printable ASCII characters. The only whitespace will be single, non-leading, non-trailing spaces. You may take input in any reasonable format.

Output

The output may be in any reasonable format. When printed, each word (contiguous substring of non-space characters) of the input should start on the bottom row and each character in the word should be up and to the right of the previous character by one position. The second word, if there is one, should start on the bottom row two positions to the right of the first, and so on. Leading and trailing whitespace are allowed.

Rules

Examples

  1. Input
    CHEESE & JAM
    
    Output
         E
        S
       E
      E   M
     H   A
    C & J
    
  2. Input
    Code Golf!
    
    Output
          !
       e f
      d l
     o o
    C G
    
  3. Input
    This is the end
    
    Output
       s
      i   e d
     h s h n
    T i t e
    

Sandbox questions

  • Similar challenges/duplicates?
\$\endgroup\$
5
  • \$\begingroup\$ I like the concept but its prbably already been done (in the form of some cipher or something) i think \$\endgroup\$ Commented Apr 27, 2025 at 4:21
  • \$\begingroup\$ Looks fun! Extra challenge: sample data that uses real English words, but also creates new English words read horizontally as output... \$\endgroup\$ Commented Apr 27, 2025 at 11:01
  • \$\begingroup\$ Also, why is the Cheese & Jam example output in uppercase? \$\endgroup\$ Commented Apr 27, 2025 at 11:02
  • \$\begingroup\$ @SteveBennett Good eye. Fixed. \$\endgroup\$ Commented Apr 27, 2025 at 15:27
  • 1
    \$\begingroup\$ Very similar to Draw diagonal lines of text; the diagonals are in a different direction, so I'm not sure if it's close enough to be a dupe or not. \$\endgroup\$ Commented Apr 28, 2025 at 18:29
3
\$\begingroup\$

Add sets of roots of two polynomials

Objective

Given two positive-degree polynomials with integer coefficients, output the polynomial whose roots are sums of the roots of the inputted polynomials.

Note that the outputted polynomial may have repeated roots, so may the inputted polynomials. As a consequence, provided that the degrees of the inputted polynomials are \$r\$ and \$s\$, the outputted polynomial has the degree of \$r \times s\$.

I/O format

It is assumed that each I/O-ed polynomial has coefficients that are coprime altogether (that is, have GCD of \$1\$ overall) and has a positive-coefficient leading term. Otherwise flexible.

Examples

Here, the binary operator in question is denoted \$\oplus\$.

  • \$x \oplus x = x\$
  • \$x \oplus x^2 = x^2\$
  • \$(x-1) \oplus (x-1) = x-2\$
  • \$(x+1) \oplus (x-1) = x\$
  • \$(x-1) \oplus (2x+1) = 2x-1\$
  • \$\left(x^2+1\right) \oplus (x-1) = x^2-2x+2\$
  • \$\left(x^3-1\right) \oplus (2x-1) = 8x^3-12x^2+6x-9\$
  • \$\left(x^4+2x^2+1\right) \oplus (x-1) = x^4-4x^3+8x^2-8x+4\$
  • \$\left(x^2-x+1\right) \oplus \left(x^2+x+1\right) = x^4+3x^2\$

CSV version:

Input 1, Input 2, Output

[1, 0], [1, 0], [1, 0]
[1, 0], [1, 0, 0], [1, 0, 0]
[1, -1], [1, -1], [1, -2]
[1, 1], [1, -1], [1, 0]
[1, -1], [2, 1], [2, -1]
[1, 0, 1], [1, -1], [1, -2, 2]
[1, 0, 0, -1], [2, -1], [8, -12, 6, -9]
[1, 0, 2, 0, 1], [1, -1], [1, -4, 8, -8, 4]
[1, -1, 1], [1, 1, 1], [1, 0, 3, 0, 0]

Worked example

For look at the last example above: \$\left(x^2-x+1\right) \oplus \left(x^2+x+1\right)\$.

The roots of \$x^2-x+1\$ is \$\left(1 \pm \sqrt{3}i\right)/2\$, while the roots of \$x^2+x+1\$ is \$\left(-1 \pm \sqrt{3}i\right)/2\$. Thus, the roots of \$\left(x^2-x+1\right) \oplus \left(x^2+x+1\right)\$ are:

  • \$\left(1 + \sqrt{3}i\right)/2 + \left(-1 + \sqrt{3}i\right)/2 = \sqrt{3}i\$, and
  • \$\left(1 + \sqrt{3}i\right)/2 + \left(-1 - \sqrt{3}i\right)/2 = \left(1 - \sqrt{3}i\right)/2 + \left(-1 + \sqrt{3}i\right)/2 = 0\$, and
  • \$\left(1 - \sqrt{3}i\right)/2 + \left(-1 - \sqrt{3}i\right)/2 = -\sqrt{3}i\$.

Thus, \$\left(x^2-x+1\right) \oplus \left(x^2+x+1\right) = x^2 \left(x - \sqrt{3}i\right) \left(x + \sqrt{3}i\right) = x^4 + 3x^2\$.

\$\endgroup\$
3
  • \$\begingroup\$ Seems interesting! I'm starting to intuit a sense for how this works, but an explanation and some worked examples would be much appreciated--and perhaps some insights into how the bulk of this isn't just about finding the operands' roots. \$\endgroup\$ Commented Jun 22, 2025 at 22:19
  • \$\begingroup\$ "accommodates the sum" wasn't really clear to me. I'd say "output the polynomial whose roots are sums of the roots of the input polynomials", and later be more explicit that we want every combination of pairs of roots. \$\endgroup\$ Commented Jul 11, 2025 at 22:06
  • \$\begingroup\$ Say that the output polynomial cannot be 0. \$\endgroup\$ Commented Jul 18, 2025 at 6:22
3
\$\begingroup\$

Computing Pi with iF*ck

Now live here!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ I believe this to be an interesting challenge, however, I would suggest making it based on how close it is to pi. As it stands, 3.13 and 3.17 would get the same score, but 3.13 is closer to pi than 3.17 \$\endgroup\$ Commented Jun 13, 2025 at 15:11
  • \$\begingroup\$ Also, does the output number have to be a real number, or can it be complex? \$\endgroup\$ Commented Jun 13, 2025 at 15:43
  • \$\begingroup\$ @TheEmptyStringPhotographer I've updated the requirements and changed some of the scoring. I tried to make it as fair as possible, but it does seem a bit complex currently. \$\endgroup\$ Commented Jul 13, 2025 at 3:18
  • \$\begingroup\$ I've found a handful of neat solutions as well as a very egregious one which uses \$9.75 \cdot 10^{35}\$ i's to calculate 34 digits and put them through the scoring system. Of course, the latter gives a very large negative score, but I don't really know how I could mitigate that. \$\endgroup\$ Commented Jul 13, 2025 at 3:23
3
\$\begingroup\$

Convert romanji to hiragana, one letter at a time (draft)

Duolingo's Japanese course has exercises for kanji where you type the pronunciation of kanji in romanji. As you type, romanji is replaced with hiragana as you type:

[demo]

Write the shortest program or function that replicates this behavior.

Specification

Input/Output

  • Input will be exclusively from STDIN, one ASCII character at a time.
  • Input will only contain ASCII [a-z].
  • The input/output should be displayed on the screen as it is typed.
  • The display is not flexible: you must have it be on a single, self-overwriting updating line.

Behavior

  • When typed, input letters should remain until the program detects a valid hiragana. Once it does, those letters should be replaced with the hiragana.
  • Double consonants should be replaced with small tsu .

Romanji to Hiragana

[table]

Worked examples

These examples will have the format romanji => hiragana, with following lines being the what program the program should display as the user types the romanji.

konnichiwa => こんにちわ
k
こ
こn
こんn
こんに
こんにc
こんにch
こんにち
こんにちw
こんにちわ
chikai => ちかい
c
ch
ち
ちk
ちか
ちかい
yatta => やった
y
や
やt
やtt
やった
bocchizarokkyu => ぼっちざろっきゅ
b
ぼ
ぼc
ぼcc
ぼcch
ぼっち
ぼっちz
ぼっちざ
ぼっちざr
ぼっちざろ
ぼっちざろk
ぼっちざろkk
ぼっちざろkky
ぼっちざろっきゅ
gyuunyuu => ぎゅうにゅう
g
gy
ぎゅ
ぎゅう
ぎゅうn
ぎゅうny
ぎゅうにゅ
ぎゅうにゅう
\$\endgroup\$
14
  • 2
    \$\begingroup\$ Typos: should be "romaji" (or "rōmaji" or "roomaji" etc.) instead of "romanji", and maybe this was intentional to have a sequence of three unconverted letters at the end (which you can also get with 卓球 "ping pong" etc.) but there's no きゅ in ぼっち・ざ・ろっく! Are there multiple romaji n-graphs that can correspond to one hiragana n-graph, or is it guaranteed that the input conforms to a specific one-to-one scheme? \$\endgroup\$ Commented Sep 5, 2025 at 14:58
  • \$\begingroup\$ (Also, IMHO the challenge doesn't gain much from being strictly interactive, but I've never really been one for those regardless so take my opinion with a grain of salt.) \$\endgroup\$ Commented Sep 5, 2025 at 15:00
  • 1
    \$\begingroup\$ @UnrelatedString still a draft, I'll need to get better examples. The きゅ is intentional, at least I get new examples. Still a draft, will be refined later \$\endgroup\$ Commented Sep 5, 2025 at 15:07
  • \$\begingroup\$ Ooh, also just realized an edge case while thinking of how to recommend specifying the behavior from the examples with ん--if the intended kana output ends in ん, is it represented differently (maybe n' or however else you do it for words like 今夜) in the input, or is it left unconverted at the end? \$\endgroup\$ Commented Sep 5, 2025 at 15:09
  • \$\begingroup\$ (also also it's こんにちは but also makes sense if that was intentional) \$\endgroup\$ Commented Sep 5, 2025 at 15:12
  • 1
    \$\begingroup\$ @UnrelatedString what Duolingo does is it uses nn for final ん, but it also accepts n if it's at the end of input. \$\endgroup\$ Commented Sep 5, 2025 at 15:18
  • \$\begingroup\$ ...and sorry if this is overwhelming, but if the scheme itself is still a WIP, some food for thought: should it be able to represent foreign syllables like でゅ and ふぁ? Extralinguistic productions like あっ? The obsolete kana ゑ and ゐ? The length marker? The redundant but non-obsolete kana づ and ぢ? Given the inspiration is a kanji-learning exercise, I'm guessing the answer is no to the first four and yes to the last, but the premise still reminds me of how a desktop IME works so depending on what you want the crux of the challenge to be those could spice it up or make it much much worse lol \$\endgroup\$ Commented Sep 5, 2025 at 17:56
  • \$\begingroup\$ The links don't work for me. \$\endgroup\$ Commented Sep 6, 2025 at 0:34
  • \$\begingroup\$ @Someone What links? (the stuff in square brackets is just placeholders for content that hasn't been written yet) \$\endgroup\$ Commented Sep 8, 2025 at 17:52
  • 1
    \$\begingroup\$ (also, as a surprisingly good example of how multiple romaji inputs can produce the same string of kana on the stock Microsoft IME: 「みせてねぼっちちゃんのろっく 」 can be input by micetenebottityaxnnoroltucu just as well as misetenebocchichannnorokku! Some of it verges on absurdity, but given that multiple romaji schemes exist it is sensible for it--as a real life practical IME--to be flexible among them, as well as to not limit any given character to being input only with others. What's more interesting for your challenge is a nuance only you can decide!) \$\endgroup\$ Commented Sep 8, 2025 at 18:08
  • 1
    \$\begingroup\$ Can I type ちかい as tikai? \$\endgroup\$ Commented Sep 11, 2025 at 9:19
  • 1
    \$\begingroup\$ @鳴神裁四点一号 no, that would be chikai for this challenge \$\endgroup\$ Commented Sep 11, 2025 at 17:17
  • \$\begingroup\$ You should allow n' (N followed by an apostrophe) in input to explicitly convert to ん, otherwise names like Kenichi might be mis-converted to けにち (the correct one should be ken'ichi けんいち). \$\endgroup\$ Commented Sep 25, 2025 at 17:17
  • \$\begingroup\$ The OP should consult the wāpuro rōmaji Wikipedia article to polish this challenge question. \$\endgroup\$ Commented Sep 25, 2025 at 17:23
3
\$\begingroup\$

Identify Redundant Regex

\$\endgroup\$
4
  • \$\begingroup\$ While the table looks nice, I think it would be good to include the test cases in an easily copyable format as well. Assuming I am understanding correctly, this essentially boils down to checking if any string of the input split by |s is a substring of any other string? That doesn't appear to be a duplicate, but there are some related challenges (example). \$\endgroup\$ Commented Oct 22, 2025 at 19:11
  • 1
    \$\begingroup\$ @FryAmTheEggman (1) I've included a copyable version of the test cases. (2) I believe you're correct. \$\endgroup\$ Commented Oct 22, 2025 at 19:28
  • \$\begingroup\$ Is this equivalent to "is any string a substring of another"? \$\endgroup\$ Commented Oct 23, 2025 at 0:19
  • \$\begingroup\$ @xnor I believe you're correct. \$\endgroup\$ Commented Oct 24, 2025 at 0:03
3
\$\begingroup\$

Translate BBCode into HTML

\$\endgroup\$
6
  • 1
    \$\begingroup\$ I'd like to see some more nested test-cases, including cases to test that [code] tags escape their contents. \$\endgroup\$ Commented Jan 28 at 11:06
  • \$\begingroup\$ @Themoonisacheese Done. Would appreciate a second eye to make sure my described test cases are all correct \$\endgroup\$ Commented Jan 28 at 15:54
  • 1
    \$\begingroup\$ much better. i'm not sure about the wrong order test, or as a matter of fact about the "mismastched order" rule in general, because [b][i]a[/b][/i] can ambiguously be a correct [b] tag with a garbage unclosed [i] tag inside it, in which case the output would be <strong> [i] a </strong> [/i]. I'm not sure what you should do about this, because both would technically be "correct". you can keep the rule as-is (maybe specify it a bit more), to be clear, but I don't know if you should, because that is a significant step in complexity. an option could be to allow undefined behavior. \$\endgroup\$ Commented Jan 28 at 16:20
  • \$\begingroup\$ Yeah I'll think about allowing undefined behavior \$\endgroup\$ Commented Jan 28 at 18:03
  • 1
    \$\begingroup\$ I just changed it so that inputs are always properly nesting, so no need to define undefinedness :P \$\endgroup\$ Commented Jan 28 at 20:21
  • 1
    \$\begingroup\$ yeah that's better, LGTM \$\endgroup\$ Commented Jan 28 at 21:18
3
\$\begingroup\$

Sort the Test Tubes

\$\endgroup\$
8
  • \$\begingroup\$ i'm not really sure about these scoring rules. all it takes is 1 person finding the optimal output, then it will probably be shorter to do kolmogorov-complexity on that output instead of computing it at runtime. \$\endgroup\$ Commented Feb 4 at 9:30
  • \$\begingroup\$ Idea was to suggest a challenge similar to this question : codegolf.stackexchange.com/questions/26232/… 15x15 should be too hard to brute force, so it's about trying to be creative and to find the most optimal solution (eg: technically, this mean finding the best heuristic). Do you have other scoring rules in mind ? I think this puzzle is interesting as it's not fully solved (as with all NP-hard puzzles) that why I posted it here. \$\endgroup\$ Commented Feb 4 at 9:36
  • \$\begingroup\$ I might have misread. You should probably clarify that a solution is expected to solve any solvable puzzle, but will be scored on a test-battery (which I strongly suggest you make much, much larger than n=12). the challenge you linked contains 100,000 test cases. \$\endgroup\$ Commented Feb 4 at 9:55
  • \$\begingroup\$ unrelated, but our defaults for IO are much more permissive than the formats you describe. You're free to impose such a format if you want, but i don't believe it serves the challenge. suggest you relax the formats like "input: the board to solve in a convenient format, output: pairs of tubes", our loopholes forbidden by default generally take care of trying to define an input format that trivialize the challenge (and finding a new loophole is considered a dick move). \$\endgroup\$ Commented Feb 4 at 9:59
  • \$\begingroup\$ Thanks for your suggestions. I have relaxed the input/output section. Battery test : the one I gave are manually crafted (and it take lot of time). I currently don't have an automatic way to create test cases and make sure they are solvable. I will try to improve this. \$\endgroup\$ Commented Feb 4 at 10:28
  • \$\begingroup\$ that's already much better. someone will inevitably ask whether or not we're allowed to substitue 0123456789abcdef for another encoding, such as ints, for both the colors and the tubes? \$\endgroup\$ Commented Feb 4 at 10:52
  • 2
    \$\begingroup\$ i thing hex is fine for the challenge text, but in some languages i'd be easier if you are allowed to not bother with it and use ints directly. there is much less consensus in either direction, but someone will definitely ask whether or not they can do that. \$\endgroup\$ Commented Feb 4 at 11:19
  • 1
    \$\begingroup\$ I suggest you simply use A-Z for ball colors and forget about hex numbers. Since number base is irrelevant to this challenge and writing using hex digits can be confusing to readers. \$\endgroup\$ Commented Feb 6 at 12:53
2
\$\begingroup\$

Huffman Decoding

Write a programm which takes two strings as input and prints a text.


The first argument is a Huffman Tree, serialized in the following format:

  • every ascii character except ~ is always a leaf, if ~ is the first characater it is also a leaf.
  • <tree0><tree1>~ is a tree where <tree0> is the left subtree and <tree1> is the right subtree.

Example: ab~cde~~~ generates this tree:

 ┌─┴─┐
┌┴┐ ┌┴─┐
a b c ┌┴┐
      d e

where a would have the key 00, b 01, c 10, d 110 and e the key 111.


The second argument is a text that has been compressed with with the Huffman code that is defined by the first parameter. This bit-string can contain any bit sequence (also null-bytes and non-printable characters) and is not byte aligned, therefore it has been encoded with a variation of the standard Base64 encoding:

  • the characters used for the encoding are the standard base64 characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
  • the bitstring is broken up into 6-bit chunks and mapped to this characters
  • if the last chunk is smaller than 6 bits, a character with this prefix is used, and padding characters are added to the string:
  • - : the last chunk was five bits long
  • = : the last chunk was four bits long
  • =- : the last chunk was three bits long
  • == : the last chunk was two bits long
  • ==- : the last chunk was one bit long

Example:

bits:       1 1 1 1 0 1 1 0 1 0 0 1 1 1 0 1 0 1 0 0 0 1 1 0 1
chunks:    |1 1 1 1 0 1|1 0 1 0 0 1|1 1 0 1 0 1|0 0 0 1 1 0|1[0 0 0 0 0]|
characters:       9           p           1           G           g
base64:     9p1Gg==-

Your programm has to decode the text encoded in the second parameter and print it to stdout.

You have to provide your source code encoded in the way described above. The length of your encoded source code + the length of your serialized huffman tree will be the winning criterion.

TODO: example input

\$\endgroup\$
2
  • \$\begingroup\$ It would be helpful to explicitly state the 64 characters used in the encoding. I presume they're A-Za-z0-9+/ but (especially if you're expecting people to implement that part explicitly) it's best to make the problem self-contained. \$\endgroup\$ Commented Oct 8, 2012 at 16:23
  • \$\begingroup\$ Hello! This looks like a good but abandoned meta post, would you be willing to offer it for adoption? (If you want to, you can still post to main.) \$\endgroup\$ Commented Jun 9, 2017 at 15:30
1
26 27
28
29 30
167

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.