# Sandbox for Proposed Challenges

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

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
• 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 needs more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended!

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".

Get the Sandbox Viewer to view the sandbox more easily!

# CDGLF:TMN2APL

## Meta questions:

• Is this a duplicate? (I've looked and there are several challenges with operator precedence, but there are large differences such as floor/ceiling and the output format)
• How can I objectively define "equivalent expressions"? Should I write a reference interpreter or answer?
• Would it be more interesting going the other way?
• Should answers be required to reject invalid input? Seems not
• Should I I've replaced the unicode operators ×÷⌈⌉⌊⌋ with ascii symbols */{}[].
• Is the exponentiation operator necessary? (It might just make the challenge more cumbersome because of its different associativity)
• It was previously APL2TMN. I'm changing it to TMN2APL to make it more interesting. Apr 22 at 14:42
• TMN's +-×÷ are left-associative, but in APL everything is right-associative. The equivalent of TMN 3-5÷2+1 in APL is (3-5÷2)+1; APL 3-(5÷2)+1 is 3-((5÷2)+1). Apr 22 at 23:41
• Thanks, I completely forgot about associativity. I don't think my grammar handles it, however, so I'm not sure exactly how to resolve this. Apr 22 at 23:44
• Also, I suggest to state the output format (APL) in the same way as you did for the input format (TMN), and state the precedence and associativity (for both TMN and APL) separately in plain English for those who are not familiar with parser grammars. And I think input validation is unnecessary here. Apr 22 at 23:52
• I think the Unicode operators definitely should be replaced with ASCII, because otherwise it's 10 bytes used on every answer. This would require you to remove or change the output syntax of exponentiation, but I don't really feel like it adds much tbh. Apr 24 at 15:57
• @pxeger I've changed it, and I agree. Apr 25 at 0:53

# Distance between vowels

## Objective

Given two vowels represented in single IPA characters, calculate the distance between them.

## Vowels

Vowels are characterized by three factors: Height, backness, and roundedness. Here, all vowels have the three characteristics as integers.

### Unrounded vowels (z = 0)

    x=0       x=1       x=2       x=3       x=4
y=6 i(U+0069)           ɨ(U+0268)           ɯ(U+026F)
y=5           ɪ(U+026A)           ʊ(U+028A)
y=4 e(U+0065)           ɘ(U+0258)           ɤ(U+0264)
y=3                     ə(U+0259)
y=2 ɛ(U+025B)           ɜ(U+025C)           ʌ(U+028C)
y=1 æ(U+00E6)           ɐ(U+0250)
y=0 a(U+0061)                               ɑ(U+0251)


(I know, Wikipedia states ʊ as rounded, but official IPA doesn't specify the roundedness of ʊ. It will be considered unrounded for this challenge.)

### Rounded vowels (z = 1)

    x=0       x=1       x=2       x=3       x=4
y=6 y(U+0079)           ʉ(U+0289)           u(U+0075)
y=5           ʏ(U+028F)
y=4 ø(U+00F8)           ɵ(U+0275)           o(U+006F)
y=3
y=2 œ(U+0153)           ɞ(U+025E)           ɔ(U+0254)
y=1
y=0 ɶ(U+0276)                               ɒ(U+0252)


## Metric

Your metric $$\d\$$ shall fit the usual definition of metric:

• $$\d(v,w)=0\$$ if and only if $$\v=w\$$

• For all $$\v\$$ and $$\w\$$, $$\d(v,w)=d(w,v)\$$

• For all $$\v\$$, $$\w\$$ and $$\x\$$, $$\d(v,x)≤d(v,w)+d(w,x)\$$

As an additional constraint, the norm $$\\Vert\cdot\Vert\$$ induced by $$\d\$$ shall satisfy:

• For all $$\x≠0\$$, $$\y\$$ and $$\z\$$, $$\\Vert(0,y,z)\Vert<\Vert(x,y,z)\Vert\$$

• For all $$\x≠0\$$, $$\y\$$, $$\z\$$ and $$\k>1\$$, $$\\Vert(x,y,z)\Vert<\Vert(kx,y,z)\Vert\$$

• Analogous rules for the y-axis and z-axis

All of these apply only to the vowels above. All other inputs fall in don't care situation.

## Rules

• Input format is flexible. It may be two chararacters, or a single string containing two charcters. In any case, every input that doesn't fit in your format falls in don't care situation.

• Output format is also flexible.

# Generate a UK number platecode-golfstringdaterandom

• I'd suggest saying AANNXXX or something like that instead of AA12XXX so it's clear the age identifier isn't always 12 (that's clarified later, but still).
– user
Apr 28 at 18:12
• Just a note: the last 3 characters can't be either Q or I May 1 at 18:13
• @cairdcoinheringaahing I thought that too, but I found no mention of it in the government document so I kept it as the whole alphabet. shrug May 1 at 19:37
• There's a Q in the alphabet for the first letter, but then you say the alphabet, minus IJQTUXZ. May 5 at 18:13
• @Arnauld yep, that shouldn't be there. Too much muscle memory from typing the alphabet correctly I guess :þ May 5 at 19:15

# Worst time complexity for an irreducible program

Time complexity, typically represented in Big O notation, represents how long a program will typically take to run given some input(s), ignoring constants.

Your task is to do one of the following things, with the worst time complexity possible:

• Sort an array of integers
• Find duplicates in an array
• Find longest strictly increasing slice of an array of integers

All of the tasks involve taking one input, an array of items, in any reasonable format, and returning an array. If your language supports mutable array data types, this is an allowed output format. Assume all items in the arrays will be (not necessarily positive) integers.

If you choose sorting: You may choose to sort the array by minimum or maximum.

If you choose listing duplicates: You may include a duplicate item any number of times in the output; [1, 2, 2, 3, 4] could result in [2, 4], [2, 2, 4], or even [2, 4, 4, 4].

If you choose longest strictly increasing slice: Duplicate items do not count as increasing, so [1, 2, 2, 4] is not strictly increasing. The items do not have to increase by a steady amount; [-1, 4, 14, 16, 17] is strictly increasing.

Rules:

Your program must be irreducible. This means removing any slice of the program, other than the whole thing (or nothing), will cause it to no longer perform the required task. Your program should terminate in a finite amount of time. You can assume your program will never run out of memory, and it does not have to terminate before the heat death of the universe.

This is a . The winner will be based on the average time complexity, with slower being better, followed by the minimum and then maximum for ties.

• Unfortunately, this answer broke all "irreducible" challenges. You can execute (almost) arbitrary code unrelated to the task without breaking the "irreducible" requirement. Apr 22 at 0:16
• @Bubbler Hmm, and I don't think irreducible is a sensible requirement for this either. It definitely makes more sense with bytes than time, along with pristine. I'll have to think about some creative limitations. Maybe unique bytes only? Apr 22 at 0:22

# I'm Lazy: Close my Parens

• It's clear what to do with ], but what does [ represent? Is it the same as just (? Jun 1 at 22:00
• Why is ([(] invalid but [(] is not? Will there ever be multiple ] in a row? Jun 1 at 22:05
• @DJMcMayhem ([(] is invalid because it is the same as [(] but with an unmatched ( at the beginning since the ] only closes the [. There may be multiple ] in a row. Jun 1 at 22:08
• So basically ] matches as many open parens as possible until it hits a [ at which point it has to stop? Jun 1 at 22:10
• @DJMcMayhem yes. Should I add that to the question for clarity? Jun 1 at 22:12
• Yes, I think that would help. Jun 1 at 22:17
• Not sure if lisp tag is appropriate, because the challenge itself doesn't have to do with lisp.
– qwr
Jun 2 at 14:43
• Tag: balanced-string? Jun 3 at 10:47
• @pxeger nice tag-finding skills :) I'll add that. Jun 3 at 13:04
• @qwr How else do I get the tag badge :P Jun 3 at 13:07

# But, Is It Art?

• I think it is clear, but the second example of "is not equivalent to" is a little unnecessary in my opinion. Jun 2 at 10:03

# Generalised multi-dimensional chess knight's moves code-golfcombinatoricschessarray-manipulation

Posted

• You know that the necessary conclusion is we do all the pieces - take my +1 and start the chain. Jun 14 at 6:26
• @StackMeter I don't think most of the pieces would be very interesting. Pawns in combination with details of what pieces are already on the board, maybe. Otherwise, it's just this challenge with some slightly simpler vectors Jun 14 at 6:48

# Write a C++ demangler

• Is _ZN3foo3barE3baz -> foo(bar)::baz valid?
– tsh
Jun 7 at 8:39
• That would be foo::bar::baz. The base identifier is baz, and it is prefixed with the namespace foo::bar. Jun 7 at 14:27
• Won't foo::bar::baz be _ZN3fooEN3barE3baz or _ZNN3fooE3barEbaz?
– tsh
Jun 8 at 6:14
• No, nested namespaces are placed together without a separator. Jun 8 at 12:39
• Decided to remove the "if it doesn't start with _Z, then it is to be printed as-is" as that adds unnecessary complexity. Jun 13 at 23:55
• I've edited this down to a stub now that it's been posted to save space Jun 17 at 20:30

# Create word lightning ascii-artstringtree

Posted

• Trees can be taken in different formats, right? May 14 at 13:35
• yes, they can be taken in any suitable format. May 14 at 13:47

# Reconstruct a recursively prime-encoded integer

• Looks great! At first glance seems easy but it's actually a little more difficult. I think it's ready to post, although you might want to wait a day or so.
– user100690
Jun 20 at 12:14

# Splinter metagolf

• An example for a short repetitive string would be nice Jul 12 at 9:42
• @pxeger Ok, I'll have a look. Jul 12 at 9:43

## Which character to change (Robbers)

• I think cops should definitely be able to choose what strings they print (they obviously should reveal them to the robbers) Jul 13 at 8:30
• @pxeger that's a good idea
– math
Jul 14 at 13:45
• Minor suggestion: Move the expected outputs to the start, because you have to scroll all the way to the end to see them.
– user
Jul 19 at 23:59
• @user Done, thanks. Jul 21 at 4:36

# Visual Encoding

I want to create a program to randomize certain words, however, I would like all the swapped letters to have the same form factor as the previous one.

#### Challenge

Given a string of only lowercase letters (and no spaces), randomize its letters according to the following groups:

1: acemnorsuvwxz
2: bdfhiklt
3: gpqy


Each letter cannot be transformed into the same letter as it started as. Additionally, choosing the new character must be uniformly random (within codegolf guidelines).

One final thing is that for the letter j, it must be transformed into either group 2 or group 3, and this can be done by either:

Uniformly choosing between each group and then uniformly choosing a letter or Uniformly choosing between any of the letters in both groups

Note that nothing can turn into j itself.

#### Examples

helloworld -> kadfrszmhl
jamaica -> genokac
jamaica -> penokac
abpj -> odyt


This is so the goal is to create the shortest answer in bytes.

# Find the necessary Files

Let's assume you have program that needs some of the files in a given folder to run. But not all the files in this folder are actually necessary. You can only find out which are necessary be removing/adding files from/to that folder, running the program and then observing whether it runs or throws or fails. The goal is finding exactly the necessary set of files with the minimial number of calls to the program.

Let's formalize it a little bit:

You are given a black-box-function $$\ f: \{0,1\}^n \to \{0,1\} \$$ that is of the form $$\f(x_1, \dots, x_n) = \prod_{i \in I} x_i\$$ where $$\I\subseteq \{1,2,3,\ldots,n\}\$$.

Your goal is finding $$\I\$$.

Your program may only interact with $$\f\$$ by evaluating it at various $$\x \in \{0,1\}^n\$$.

Your score is $$\ S= \prod_{m=1}^M (1+s_k)\$$ where $$\s_k\$$ is the number of evaluations of $$\f\$$ you needed for the example $$\k\$$ in the test battery. The least score wins.

### Test Battery

META: Not sure yet if I should explicitly define a test battery or just let participants iterate through all possible functions up to some $$\n\$$.

In the following list, the first column represents $$\n\$$ (the number of arguments) followed by the set $$\I\$$:

n  | I
3  | 1
3  | 1 3
3  | 1 2 3
4  | 2 3 4
10 | 1 3 5 6 7 9


The last entry for instance represents the function $$\ f(x_1, x_2, \ldots x_{10}) = x_1 \cdot x_3 \cdot x_5 \cdot x_6 \cdot x_7 \cdot x_9\$$

• Could the title have the "files" removed to be more abstract (or use another analogy)? On the surface this might look like a filesystem question Aug 10 at 11:05

# IATA Airport Codes code-golfdecision-problemstringkolmogorov-complexitycompression

Out of 17576 alphabetical triplets, to this day, 9144 are used as IATA airport codes.

Given a 3-letter string, tell whether it appears in the list.

• The input string is mixed-case by default, but you can restrict it to non-mixed-case or lower-case or upper-case

• To output the affirmative/negative outcome you should use:

• truthy/falsy according to your language's convention (swapping is allowed), or
• one consistent value as either affirmative or negative, and any other value as the other
• This is

The list was scraped from iata.org on 2021-08-07

## Meta

• Is there something that needs to be specified/clarified?
• What is uniform case? Add the kolmogorov-complexity tag since there's a limited input domain? GitHub Gist is an alternative that's well-trusted by this community, I'd say Aug 8 at 17:05
• @pxeger I want to say a string where all the letters are uppercase or lowercase, contrary to mixed-case Aug 8 at 17:07
• @pxeger maybe non-mixed-case would be more direct? Aug 8 at 17:25

# Parse some Husk (WIP)

Husk is a "functional golfing language inspired by Haskell." Its syntax is prefix, albeit with a twist: Husk's functions can be curried: so uses its static typing to determine how many arguments a function should take at a time. For example, Husk can tell that m+2:2;3 should be parsed as m(+2)(:2(;3)) and not, say, m(+2(:2(;3))) or m(+)(2:2;3), which are meaningless.

This challenge involves validating a subset of Husk that has 5 functions and two types: integers 0-9 or lists of those integers. It also does not have parentheses or overloading. Your submission will take a string consisting only of the characters mo;:+0123456789 and determine whether it is a valid program according to the rules below.

In the following descriptions, "unary integer function" refers to a function that takes an integer and outputs another. It's a made-up term, let me know if there's a better one. "list" refers to a list of integers, and "integer" refers to an integer 0-9. You don't need to understand the purposes of each function, just the types of their inputs and outputs.

• 0-9 are values/integers.
• ; is the unary function singleton. Its argument is an integer x, and it returns a list ([x]).
• : is the binary function prepend. Its first argument is an integer x and the second is a list l. It returns x prepended to l ([x, ...l]).
• m is the binary function map. Its first argument is a unary integer function f and the second a list of integers l. It returns [f(l[0]), f(l[1]), ..., f(l[-1])].
• o is the trinary function compose. Its first argument is a unary integer function f and the second a unary integer function g. The third is an integer x. It returns f(g(x)).

Here is what their types might look like in Haskell:

(;) :: Int -> [Int
(:) :: Int -> [Int] -> [Int]
m :: (Int -> Int) -> [Int] -> [Int]
o :: (Int -> Int) -> (Int -> Int) -> Int -> Int


Here is pseudo-pseudo-pseudo-not-even-BNF-anymore:

<int> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | + <int> <int>
<list> ::= ; <int> | : <int> <list> | m <unary-int-int> <list>
<unary-int-int> ::= o <unary-int-int> <unary-int-int>
<valid-husk-program> ::= <int> | <list>


# Questions for Meta:

• Is this collection of functions okay? Should I add more or replace/remove some?
• Is this challenge interesting?
• Is this a dupe?
• Is the explanation good enough? How can I make it clearer?
• This currently doesn't have a lot of variety in the currying. Should the functions given to map/compose also be allowed to input/output lists? (and if so, would lists be allowed to be nested?)
• Can Perl regex do this? I'm making this challenge hoping that it can't.
• You haven't really specified what the output is. The closest is saying the task is to "validate", but what do we actually need to do? Aug 20 at 16:10
• are we validating or executing(akin to the gelatin challenge)? Sep 3 at 7:52

# Distances between keys on a QWERTY keyboard

• fro kolmogorov i suggest keeping everything in the same unit. Aug 19 at 3:58
• All jokes aside, this is a well specified challenge. Aug 19 at 14:05

# Fastest untyped lambda calculus evaluator fastest-codefunctional-programminglambda-calculusinterpreter

## Challenge

What it says on the tin. Mainly because googling "fastest untyped lambda calculus" gives almost zero meaningful results.

Each submission is expected to take a lambda term from STDIN and print its normal form to STDOUT. The lambda term is represented using de Bruijn indexes, and we will use prefix notation for this challenge. Since a de Bruijn index may have multiple digits, each token will be separated by a single space. The input will have no surrounding whitespace, but you may output any amount of whitespace before and after the formatted lambda term.

LambdaChar = "\"             // single backslash
DeBruijnIndex = [1-9][0-9]*  // a positive integer
ApplyChar = "@"
Term = DeBruijnIndex | LambdaChar " " Term | ApplyChar " " Term " " Term


For example, \ \ @ 1 @ 2 1 represents lambda x. lambda y. y (x y).

The evaluation semantics to implement is normal order beta-reduction (no eta-reduction).

The test cases will be hand-crafted so that it takes significantly more time to evaluate the expression than to parse the input and format the output. Also, they will involve various kinds of Church- and Scott-encoded terms, so optimizing for any specifically encoded data (hopefully) has less effect than optimizing for general improvement. It is guaranteed that the test cases have a normal form and do not contain free variables.

Good starting points include this PEPM '17 paper and my Haskell implementation which was modified from the paper's algorithm to actually return the normal form. Other notable keywords: graph reduction, supercombinators, G-machine, TIGRE, STG (spineless tagless G-machine). Note that, if your submission has separate compilation and execution phases, both phases count towards the total execution time (which may negatively impact your score).

The submissions will be scored within WSL (Ubuntu 20.04) on my Windows 10 PC, which has Intel Core i7-6700 CPU (3.40GHz) and 8GB of RAM. The score is the sum of the timings measured for all the test cases. Lowest score wins.

## Meta

• Todo: write example and actual test cases.
• Should I include a description about how the "normal order beta reduction" works for de Bruijn indexes?
• are you planning to actually test with >9 levels of lambda nesting?
– ngn
May 26 at 2:48
• @ngn Depends on what I come up with. May 26 at 3:04

# Display a number in Toki Pona

• Welcome to Code Golf and nice first question! Thank you for using the Sandbox first :) I've done some minor edits to add capitalisation and formatting. Tags wise, [integer-partitions] and [natural-language] both apply. This is a similar challenge, but that uses US coins Aug 12 at 22:49

# Volume of a 3d model

In this challenge, you'll take a shape as input, consisting of a number of triangles forming an outer shell. Your task will be to find the volume of the resulting shape.

You can assume the triangles all connect to exactly one other triangle per side, and the surface does not cross over itself. You will not get an input where two separate solids touch only at points or edges.

Test cases and sample implementation coming soon

• I like this one. I think that its got some tricky bits to it, like getting the normals for the triangles and ensuring that they are facing the right way. As far as input format goes, an Ascii stl file may be a good option, as it breaks down the meshes into faces and provides the normals as well. Oct 15 at 19:36
• is the winding of the input going to be consistent or could it be random? also what is the error bound for the output? Oct 18 at 3:15
• @donbright Random, I'm thinking. For the output, floating point errors are fine, as long as the calculations would theoretically return the correct result. Oct 18 at 13:27
• sounds like a good bit of fun but i kind of predict people will ask for some kind of precise bounding on the error like +/- 1 percent or something. Oct 19 at 2:07
• @donbright The answer could be off by a thousand percent, if I reimplemented the language with arbitrary precision floats and it worked, I'm fine with it. That's way easier for everyone. Answerers don't need to worry about weird floating point tricks, and I don't need to tell them their answer's invalid :) Oct 19 at 4:15
• i mean the question is how do you know the algorithm works without running it and comparing the result to the known correct value? Oct 20 at 2:31
• @donbright Probably a mix of trust, and it most likely being close enough to the correct answer that anything other than floating point errors is unlikely Oct 20 at 2:34

# Converting Pinyin to Zhuyin or vice versa

## Challenge

Pinyin and Zhuyin are systems that are used to help people pronounce characters in Mandarin Chinese. Write a function/program that converts Pinyin to Zhuyin or vice versa (clarify which one you are doing) according to the tables below. You are not required to deal with tones or incorrect inputs (including edge cases such as ḿ(呣), ǹg(嗯), and ê̄(诶/誒)).

### Pinyin to Zhuyin

Pinyin Zhuyin
b
p
m
f
d
t
n (at the beginning)
l
g (at the beginning)
k
h (at the beginning)
j
q
x
zh (except in zhi)
zhi
ch (except in chi)
chi
sh (except in shi)
shi
r (at the beginning)
ri
z (except in zh, zi)
zi
c (except in ch, ci)
ci
s (except in sh, si)
si
a (at the end)
o (except in ao, ou, ong)
e (except in ei, en, eng, er, ie, ue, üe, ye)
e (only in ie, ue, üe, ye)
i (except in ai, ei, ui, iu, iong, yi, zhi, chi, shi, ri, zi, ci, si)
y (except in yong, yi)
yi
u (except in ou, iu, wu, ue and except after j, q, x, y)
w (except in wu)
wu
o (only in ong except in iong, yong)
u (right after j, q, x)
ü
yu
io
yo (only in yong)
ai
ei
i (only in ui)
ao
ou
u (only in iu)
an (except in ang)
ang
en (except in eng)
n (only in in, un except in ing)
eng
ng (only in ing, ong)
er

### Zhuyin to Pinyin

Zhuyin Pinyin
b
p
m
f
d
t
n
l
g
k
h
j
q
x
ㄓ (by itself) zhi
ㄓ (not by itself) zh
ㄔ (by itself) chi
ㄔ (not by itself) ch
ㄕ (by itself) shi
ㄕ (not by itself) sh
ㄖ (by itself) ri
ㄖ (not by itself) r
ㄗ (by itself) zi
ㄗ (not by itself) z
ㄘ (by itself) ci
ㄘ (not by itself) c
ㄙ (by itself) si
ㄙ (not by itself) s
a
o
e
e
ㄧ (at the beginning, not by itself, and not before ㄣ, ㄥ) y
ㄧ (after ㄐ, ㄑ, ㄒ) i
ㄧ (by itself or before ㄣ, ㄥ and at the beginning) yi
ㄨ (not at the beginning) u
ㄨ (at the beginning except by itself) w
ㄨ (by itself) wu
ㄨ (before ㄥ and not at the beginning) o
ㄩ (after ㄐ, ㄑ, ㄒ) u
ㄩ (after ㄋ, ㄌ) ü
ㄩ (by itself or before ㄝ, ㄢ, ㄣ and at the beginning) yu
ㄩ (not at the beginning and before ㄥ) io
ㄩ (at the beginning and before ㄥ) yo
ai
ㄟ (not after ㄨ unless ㄨ is at the beginning) ei
ㄟ (after ㄨ unless ㄨ is at the beginning) i
ao
ㄡ (not after ㄧ unless ㄧ is at the beginning) ou
ㄡ (after ㄧ unless ㄧ is at the beginning) u
an
ang
ㄣ (not after ㄧ, ㄨ, ㄩ unless ㄨ is at the beginning) en
ㄣ (after ㄧ, ㄨ, ㄩ unless ㄨ is at the beginning) n
ㄥ (not after ㄧ, ㄨ, ㄩ unless ㄨ is at the beginning) eng
ㄥ (after ㄧ, ㄨ, ㄩ unless ㄨ is at the beginning) ng
er

This is code-golf, so the answer with the least bytes wins.

## Test Cases

Pinyin Zhuyin
chuang ㄔㄨㄤ
xue ㄒㄩㄝ
diu ㄉㄧㄡ
juan ㄐㄩㄢ
ri
song ㄙㄨㄥ
ㄌㄩ
qiong ㄑㄩㄥ
zhen ㄓㄣ
huo ㄏㄨㄛ
ying ㄧㄥ

• Am I required to support single characters or a word / sentence? Also, there are some edge cases as I know, for example, ḿ(呣), ǹg(嗯), ê̄(诶/誒). Would these be excluded from testcases? May I assume no erhua (儿化/兒化) would be applied?
– tsh
Oct 12 at 6:44
• There are far more rules than testcases. I would suggest to add more testcases as many rules are not ever touched by any testcases here.
– tsh
Oct 12 at 6:54
• @tsh Single characters. The edge cases would not be required to check for as inputs. No erhua. I will try to add some more testcases to cover the other rules. Oct 12 at 11:19
• Suggest a whole list, it's likely just 300+ possible inputs
– l4m2
Oct 12 at 18:13
• The number of rules makes this an intimidating task to write and golf. Consider limited to a simpler subset of rules or situations.
– xnor
Oct 13 at 7:12
• @xnor It's not actually as many rules as it looks like. A simple regex can be used for most of them. Oct 13 at 21:41

# Light it up

Imagine you have a grid where some squares are walls, some are empty, and some are lights that shine for arbitrary distances in the four cardinal directions until they meet walls:

####.####
##..L....
####.##.#
####.##L.
##......L


In the above grid, the lights cover all the tiles. But in some cases, they may not be:

###
.#L
###


Your challenge is, given a grid like the one above, determine whether all empty tiles are lit up. You may take input as a matrix, a list of lines, newline-separated lines (as above) with any three distinct characters, etc.

An input may contain none of a type of cell.

# Testcases (Given in above format)

Truthy:

L

L.
.L

L....
..#L.
....L
.L...

#

L...L...L

#####.###
#L...L...
##.####L.
#.L..####


Falsey:

.

.#

L#.

.#.
.L.
.#.

L...
L...
L.#.
L...

• Maybe you can fill empty cells by some characters like . in your examples and testcases. Or it could be confusing: L.#. is falsy but L.# is truthy, but it is hard to see the difference.
– tsh
Nov 2 at 1:53
• @tsh Ok, thanks! Nov 2 at 2:02
• "some squares are walls, some are empty, and some are lights". Since there are testcases where only empty cell is there, will there be any testcases like ####?
– tsh
Nov 2 at 5:23
• @tsh Yes, see the fourth truthy one. I'll be more explicit that some may not occur at all. Nov 2 at 6:13

# Simulate weathering

Inspired by my geography class

Simulate weathering / erosion.

### Input

Input will be given as a string of any 2 character you like in the shape of the rock (here i use space and hashtag):

   ###
####
######
########
#######
#####


Or if your language doesn't support strings, a square matrix of 1s and 0s, a matrix of chars, whatever makes your answer more golfier.

# Process

The rock will erode until it disappears completely. Lets take example of input:

    ##
## ### #
#########
###########


First we find which part of the rock is exposed (that is there is no rock particle directly above / below / left / right) to the air (i use @ to show such particles here):

    @@
@@ @#@ @
@##@###@@
@########@@


NOTE: The bottom most rock particles are touching the ground and they are not touching air, hence we don't count these particles.

Then we randomly (50% chance) remove the rock particles (here #) (apply gravity similar to this challenge, this is not minecraft) that are exposed to the air:

    #
##
### ### #
#########


And be repeat the process until the rock disappears and output the rock in between each iteration (including the original input). In this case we output:

    ##
## ### #
#########
###########
#
##
### ### #
#########

## ##
#########

#  #
## #### #

#
#  # # #

#    #


This is code-golf, answer in the shortest amount of bytes wins.

## Meta

• Is this clear?
• Is this a duplicate?
• Do I need test cases?
• I like this idea. I'd suggest extending the example for another iteration or two, and it wouldn't hurt to add other test cases. Just a thought (no strong opinion either way): you could remove the second input ($n$) and have the simulation run until the rock disappears, with the shape being printed at each iteration. Nov 4 at 22:57
• @Dingus edited. removed the second input since outputing until the rock disappears makes more sense. Nov 5 at 4:54
• First, I'd be more fluid with the I/O format - allow a bit matrix, char matrix, list of strings, etc. Also, a different idea that might warrant its own challenge: What if you just removed one rock at a time? Nov 5 at 7:18

## Leave ABACABA on the tape

Note that will be removed post sandboxing: This challenge is Brainfuck-specific, but I hope that its contents make the reason why sufficiently clear.

Write a brainfuck program which leaves the following sequence on the tape:

0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 ...


This sequence may be familiar to some as ABACABADABACABA... or A007814.

Assume an implementation of BF with an endless tape and arbitrarily large (but not arbitrarily small) integers.

You should link to a visualizer to prove that your program works as you say it does, but if this isn't fast enough to witness the first few (say 4) numbers in ABACABA you'll have to explain it yourself.

This is code-golf, so the shortest program operating within these rules wins. Have fun!

• Because a BF program would likely do destructive edits to the previous terms or add scratch data to the end while advancing the sequence, I'd propose a more rigorous definition: "Write a BF program where, given any prefix of the ABACABA sequence, running the program for some finite number of steps will give the pattern at the start of the tape." Nov 18 at 1:32