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

Get the Sandbox Viewer to view the sandbox more easily!

• Welcome to CGCC, and thanks for using the Sandbox! This looks like an interesting challenge. You'll need to specify a winning criterion; it looks like you're interested in fastest-code (code should run as fast as possible), but we normally don't combine that with restricted-time (code must take less than an hour to run). fastest-code without the 1-hour restriction is one option; code-golf + restricted-time is another. If you're not sure which to choose, I recommend code-golf, since it's easier to calculate the score for submissions. Mar 1 at 23:21
• @DLosc I wanted this "1 hour" part to be just a kind of side note for people to know what to expect regarding the performance. I changed my question to make it seem less like a winning requirement Mar 1 at 23:32
• You need to objectively specify what does "as fast as possible" mean. See codegolf.stackexchange.com/tags/fastest-code/info and refer to other fastest-code challenges for inspirations: codegolf.stackexchange.com/questions/tagged/… Mar 2 at 7:51
• @pajonk is it better? I edited it Mar 2 at 14:31
• @ordptt for me it would be enough. Also, do I understand "There are no operators in sequence" correctly that this applies only to successive operators like 1*-1, but -1+2=1 is ok? What about 1-2=-1 - is this valid? Or 1*(-1)? Mar 2 at 19:07
• @pajonk it means that there cannot be any *,+,-,/ adjacent to each other, so I believe you got it right. So 1*-1 is not valid but -1+2=1, 1*(-1) are. 1-2=-1 is not valid because the RHS is negative. Mar 2 at 20:30

# Guessing on straws

Dedicated to Martin Gardner, taken from his book

## Background

In the old days, the Slavs had such divination. One girl was clutching six straws in her fist, and her friend was pairing first the top and then the bottom ends. If all straws were ring-tagged, the girl would be married.

## Goal of challenge

Having the number of straws and the binding schemes, determine whether the single hole cycle will result.

## Input

• Number of straws N, even integer >= 2
• Two nested lists as top and bottom links, for instance [[1, 4], [2, 5], [6, 3]]

Schemes may be valid or invalid! On one hand, it is guaranteed that are used only positive integers not more N; no self-links ([1, 1]), no tautologies ([[1, 2], [2, 1], …]), no broken lists ([[1], [ ], …]) etc.

Please note, that pairs are unordered, so eg [[1, 4], [2, 5], [6, 3]] and [[4, 1], [2, 5], [3, 6]] both valid (and equivalent) schemes.

But due to the girl’s inattention, followed cases can take place:

• Missing pair (one or more): [[1, 4], [6, 3]], [[1, 10], [4, 5], [3, 7]] etc.
• More than two binding straws: [[1, 4], [1, 5], [2, 6]] (and as result, free straws)

All of these inputs are invalid, your program must detect them and stop with appropriate message (see below).

## Output

Any three distinct symbols for "Invalid input", "No loop", "Has loop" cases. Suitable for golfing on your language:

• -1 for invalid input, 0 for "No loop", 1 for "Loop"
• None, False and True respectively
etc.

## Test cases

N: 2, TopLinks: [[1, 2]], BottomLinks: [[2, 1]]  → True

N: 4, TopLinks: [[1, 2], [3, 4]], BottomLinks: [[2, 1], [3, 4] ]  → False

N: 4, TopLinks: [[1, 2], [2, 4]], BottomLinks: [[2, 1], [3, 4], [3, 2] ]  → Invalid

N: 8, TopLinks: [[1, 2], [3, 4], [6, 5], [7, 8]],
BottomLinks: [[8, 1], [3, 2], [4, 5], [7, 6] ]  → True

• We usually try to avoid requiring input validation, and I feel like in this case it doesn't make the challenge any more interesting. Is there a particular reason you want it? Additionally, I'll suggest allowing other reasonable input formats, for example a list of values from 1 to n/2 where paired indices have the same value. Mar 8 at 11:12
• @CommandMaster Well, I thought without validation this is a very simple challenge. But I will take into account your proposal, I will probably remove validation when publishing Mar 8 at 11:17

# Shortest Code to Implement a Simple Encryption Algorithm

Write a program or function that implements a simple encryption algorithm. The algorithm takes in a string of ASCII characters and a key, and outputs an encrypted string.

## Encryption Algorithm

1. Convert each character in the input string to its ASCII value
2. XOR each ASCII value with the corresponding byte in the key (cycling through the key if necessary)
3. Convert the resulting XOR values back to ASCII characters
4. Concatenate the ASCII characters into a single string and output the result

Your program or function should take in two inputs:

A string of ASCII characters (up to 1024 characters in length) A key string (up to 1024 characters in length) Your program or function should output a single string representing the encrypted message.

## Test Cases

Input:
message: "Hello World"
key: "secret"
Output:
"UW]cU\xf3M]Z]^Y"

Input:
message: "12345"
Output:
"^%-'#" Input: message: "This is a test message" key: "key" Output: "\x03\x1a\x1c\x17\x02\x0eP\bI\x11\x07\x14N\x1d\x10M\r\b\x1f"  This is a codegolf challenge, so the goal is to write the shortest possible implementation of the encryption algorithm. The winner will be determined based on the length of their code, with ties broken by earlier submission time. • first time with sandbox :/ Mar 8 at 12:04 • Very similar Mar 8 at 12:11 # Mapping Passing Through Point • Maybe I'm just missing something, but this function doesn't seem very well-specified. Since you don't have to handle f(x1) or f(x2), isn't f(x)=y0 allowed? Mar 9 at 17:44 • @Bbrk24 The image of the function has to be over the whole range -- in other words, for every $y \in (y_1, y_2)$, there must be some $x \in (x_1, x_2)$, such that $f(x) = y$. Mar 9 at 17:55 • Ah, that makes more sense. I'd be a bit more direct about it in the question, then. Mar 9 at 17:56 • Is it guaranteed $x_1 < x_0 < x_2$? Mar 10 at 4:56 • Do you have to return $f$? Can you take $x_0, x_1, x_2, y_0, y_1, y_2, x$ and return $f(x)$ (deterministically)? Mar 10 at 4:59 • @CommandMaster I thought this is part of the open-ended-function tag, but yeah, you can do it that way. Mar 10 at 17:26 • @CommandMaster Yes -- and $y_1 < y_0 < y_2$. Mar 10 at 17:26 # Validate Einstein Notation This challenge was not really appropriate for golfing, and I have scrubbed it to make room in the thread. I will leave this up for a while in case someone wants it to be restored and posted, but after that I will delete it. • After having struggled to write a program of reasonable size that does this I do not believe it is a good fit for golfing. If anyone disagrees leave a comment, otherwise I will delete this post in a few days. Jan 30 at 15:58 # Optimize Distance Travelled By Thrown Object (With Air Resistance) Suppose you're on a flat surface, then throw an object with some velocity $$\v_0\$$ at an angle $$\\theta\$$ above the ground. Assuming the only forces on the object are (constant) gravity and air resistance, we can model the horizontal and vertical components of the acceleration (the instantaneous change in velocity in the x and y direction) as follows: $$a_x = v_x^2 * \delta$$ $$a_y = v_y^2 * \delta + g$$ Where $$\v_x\$$ and $$\v_y\$$ are the horizontal and vertical components of velocity, $$\g\$$ is acceleration due to gravity, and $$\\delta\$$ is the coefficient of acceleration due to drag (which is a single number which depends on the drag coefficient, cross-sectional area, and the density of the fluid, and the mass). The initial x and y components of velocity are $$v_x = v_0 \cos \theta, v_y = v_0 \sin \theta$$ The object stops moving when it hits the ground again (when its $$\y\$$ position becomes 0 again). We want to find the angle $$\\theta\$$ which maximizes the horizontal distance $$\x\$$ that the object travels. Your challenge is, given the initial velocity $$\v_0\$$, acceleration due to gravity $$\g\$$, and coefficient of acceleration due to drag $$\\delta\$$, output the angle $$\\theta\$$ (in either degrees or radians) which maximizes the horizontal distance travelled, within one percent of the true maximum. Standard loopholes are forbidden. Since this is , the shortest program wins. TODO: Test cases • Can the person who down-voted explain why? yesterday # Vertically Aligned JSON formatting We have a question on JSON formatting on this site before, however, this one requires a different formatting convention. Arrays should be formatted with the first element on the same line as the opening [, and the final ] should be on the same line as the ]. All other elements should be on separate lines, aligned with the first. Commas go on the end of each line except the last. like this: ["alpha", "beta", "gamma", "delta"]  Objects are mapped the same, but the values must also be aligned. There must always be at least one space between the : and the value, like this: {"alpha": "beta", "gamma": "delta", "upsalon": "sigma", "iota": "zeta"}  When structures are nested, they are aligned with their first element, like this: [{"iota": "beta", "gamma": "sigma"}, {"zeta": {"meena": "kim", "vot": "dilinia"}}]  Note how separate objects do not need to align with each other, only keys in the same object align. We will consider only 3 types: arrays, objects, and strings. Handing of numbers and null is optional. Input is a mimified JSON string, you should output a vertically aligned JSON string with the same data. You do not need to preserve key order. This is . Shortest answer in each language wins. • Related yesterday • It's vaguely similar for array formatting but completely different for object formatting yesterday • That's why I said related. yesterday Your bots went to the mall together, but they got lost! Worse, they didn't agree on any strategy to find one another again. Here's what they do know: • There are $$\n\$$ stores, and bots can only meet each other in the stores. • Each time step, each bot must choose one store to be in. • Two bots go to the mall simultaneously. Their score for the outing is the number of time steps it took for them to find one another. • The mall closes after $$\n^2\$$ time steps. If some bots are still at the mall, they will receive a score of $$\n^2+1\$$. Bots must be written in Javascript. Your bot must be a generator function, receiving a single input $$\n\$$ (the number of stores) and output at least $$\n^2\$$ integers in the range $$\[0..n-1]\$$. Your bot's score will be the average of its scores when played with all of the other bots. The stores will be scrambled - what is room 1 for one bot may be room 5 for another. There will be many rounds of the game (1000 right now, but if there are lots of entries and it takes longer than an hour, I may lower that number), and each round will be a round-robin with a set number of stores. $$\n\$$ will be in the range $$\[4..25]\$$. There are better and worse strategies, but optimal strategies (when symmetric) are only known for $$\n=2\$$ and $$\n=3\$$. An example bot (which will be playing): function* randomSearchBot(n){ while (true){ yield Math.floor(Math.random() * n); } }  Here is the controller: function shuffle(array) { for (let i = array.length - 1; i > 0; i--) { let j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } } function runRound(bot1, bot2, n){ let b1 = bot1(n), b2 = bot2(n); let stores = Array(n).fill(0).map((_, i) => i); shuffle(stores); let turn = 0; while (turn++ < n ** 2){ if (b1.next().value == stores[b2.next().value]) break; } return turn; } function runAllRounds(...bots){ const nameLength = Math.max(bots.map(b => b.name)); bots = bots.map(b => { return { bot: b, totalScore: 0 }; }); const rounds = 1000; let round = rounds; const pairs = bots.map((b, i) => bots.slice(i + 1).map(w => [b, w])).flat(); while (round--){ const n = Math.floor(Math.random() * 22) + 4; // [4..25] for (let [a, b] of pairs) { const score = runRound(a.bot, b.bot, n); a.totalScore += score; b.totalScore += score; } } bots.forEach(b => { b.totalScore /= rounds * (bots.length - 1); console.log(b.bot.name.padEnd(nameLength) + ": " + b.totalScore.toFixed(5)); }); }  The main feedback I'm looking for here is whether people think there's a big enough strategy space for it to be worth playing. # Bike saddle drawn through a fractal Based on the Mandelbrot image in every language, and on the observation the 3rd layer (0 indexed) always looks like a bike saddle, I had a little bit different challenge: • Language must be capable of graphical output or drawing charts (saving files disallowed) • Render a window or control that is resizable by mouse action. As example, it can be a typical GUI Window with the typical frame that allows resizing • After resizing the GUI element, the fractal should be updated according to the new pixel space • The fractal coordinates range from approximately -2-2i to 2+2i • The pixels outside of the 3rd layer (0 indexed) of Mandelbrot set should have one color; the ones inside 3rd and inner layers should have another. The only two colors used should be clearly distinguishable • At least 99 iterations • ASCII art not allowed Winning conditions: Shortest version (size in bytes) for each language will get a mention in this post, ordered by size. No answer will ever be 'accepted' with the button. • @Mark Jeronimus: credits to you. May 27, 2017 at 8:48 # The 2017 Loader contest Here's a thing: Let's do the bignum bakeoff again. Because why not. ### What to do Write a program in less than 256 characters that outputs the biggest number you can. Yep, that's it. Biggest return value wins. We'll run the program on a VM with infinite memory. (How do we do this?) ### Rules • 256 chars max, excluding whitespace • Different leagues for each language • Output however you want • No explicitly printing numbers until your loop runs out. Print the number you generate directly. {1} • Program must terminate • No implementation-dependent shenanigans. • Implementation-independent shenanigans is encouraged. • ints are infinite. • Program must return the same number every time • Submission must include the approximate return value in any suitable googological notation. • Whitespace is space, tab, newline, formfeed, and return • BrainF***: Whitespace is all non-[]+-<> characters {1} Allowed ways to return: printf("%d", num); return num;, etc. Banned ways to return: for(;num>0;num--)printf("99999");, etc. ### This is not a dupe of... This because you can put any characters you want, not just non-digits; because we're hard-limiting the characters. ### Suggested rules • No floats: float double long double, etc • No strings or chars • No bitfeilds • No looking at Command-line args Next year's contest will be named after this year's winner, for no particular reason. http://djm.cc/bignum-rules-posted.txt ### Sandbox • How do you even test these programs? • What other rules should we have? • You don't actually explain the rules of the challenge, we would have to go to that link to find out what we are supposed to do. Aside from that, I think this has a lot of problems with your typing restrictions if these are not limited to C, but limiting it to C wouldn't really fit the spirit of the site. I think you may want to rethink how you want to approach this question. May 29, 2017 at 16:43 • @FryAmTheEggman "Typing restrictions"? (Added proper instructions) May 29, 2017 at 16:45 • Your post doesn't describe how people win. Is it by the largest possible number? Anyway, the problems are things like not counting whitespace, which can easily result in degenerate answers, as well as things like I/O streams and whatnot. All of your extra rules seem entirely based around C with no regard for other languages, which will not go well. May 29, 2017 at 16:48 • In answer to "Because why not": because it will be closed as a dupe. May 29, 2017 at 17:59 • Here's a couple of rules I would consider. 1. Program must generate the same result every time (e.g. not based on timer, probability, or the like). 2. Submissions should include, if not the exact resulting number, at least a best estimate, in scientific notation if need be. May 30, 2017 at 18:32 • Scientific notation? People will post answers that far, far exceed that. In fact, Mathematica, 22: Fold[Power,2~Range~9999] It's 2^3^4^...^9999. That's not being represented anytime soon. May 31, 2017 at 3:31 • This is a duplicate, and is also going to come down a lot to whether or not you allow programs that exceed the computational capacity of any existing computer. (If you require programs to work on a physical computer, the best they can possibly do is to use the entirety of memory as a counter and print out 9s over and over again. If you don't, the answers can easily be large enough that you need to use notation invented specifically for describing the number, because all other notations are not enough.) – user62131 May 31, 2017 at 22:40 • If your code can simulate a Turing machine, it becomes hard to judge who the winner is, and whether an answer is valid at all. Jun 1, 2017 at 20:35 • Re your latest edit: you're wrong. The question it's a dupe of also has a hard limit to the number of characters; in fact it's a harder one, but the best answers could be copied with slight tweaking to take advantage of the extra space. And the digit restriction turned out not to be a serious problem: the winning answer would gain extremely little from being able to use digits. Jun 2, 2017 at 9:07 # Do nothing Write a program which terminates normally (not in an error), producing no output on the standard output stream (or the language's closest equivalent), nor on the standard error stream, regardless of what content is present on the standard input stream. (Note that this is intentionally overriding the normal I/O defaults; this is a challenge entirely about input/output handling.) Additionally, your program may not have any other side effects (e.g. writing files, changing persistent state), unless they're an unavoidable consequence of running a program on the operating system you're using (e.g. on Linux, it's OK to change the "next process ID number to be assigned" value inside the kernel, because that happens whenever you run a program). Finally, to avoid numerous uninteresting 0-byte (or boilerplate-plus-0-byte) solutions, you may not use a language in which the shortest program that does nothing (i.e. complies with the above specification) is also the shortest (or tied for the shortest) program which runs without error (but possibly reacts to input or produces output). In other words, you can't use a language unless doing nothing is more verbose than doing something. ## Clarifications • Intentionally exiting the program early is permitted. If you do exit the program manually, on a system that uses exit codes, you may do so with any exit code. • Crashing the program is not permitted, even if it (for some reason) exits with a "success" code after the crash. • "No output" means 0 bytes of output, not even a trailing newline. • Likewise, your program must be able to handle any finite sequence of bytes on the standard input stream, even if it isn't, say, made of characters in the current encoding (but rather of arbitrary octets). You do not need to handle infinite input, though (e.g. your program won't be connected to /dev/zero or the like). • You don't have to actually read input; it's your choice as to whether you want to read and discard it, or not read it at all. ## Victory condition As a challenge, shorter is better, measured in bytes. (Remember that if you need to run the program in an unusual way, that incurs a byte penalty, under standard PPCG rules.) Because languages which are particularly suited for this task (such as Perl and Python) are excluded by the rules, there's not much point in talking about the best answer cross-language; rather, the aim is to find the best answer you can in the language which you submit in. (Historically, on this sort of challenge, answers that are more unusual, interesting, or better-explained have tended to get more votes.) ## Sandbox questions Is this too trivial? We were discussing it in chat as a joke, and realised that it's actually possibly more interesting than it sounds. I'm fairly sure the spec's correct (although would definitely appreciate knowing if something's wrong here!), but would appreciate feedback on how much people would hate me if I posted it to main. • you can't use a language unless doing nothing is more verbose than doing something.you can't use a program unless your program is more verbose than any other program which does something. You must provide a shorter program which does something to prove your solutions validity. – Adám Jun 8, 2017 at 1:03 • @Adám: If you did that, people would just add a comment byte or two to create a program of the shortest possible length that was longer than a program that did something. That isn't particularly interesting. – user62131 Jun 8, 2017 at 1:21 # Plan and Chain a route through OEIS Your Task is to reach so many OEIS sequences you could make with chaining your last sequence with a operation to a new sequence. You must avoid last sequence minus last sequence plus first sequence or something similar that your new sequence is based on the first sequence except to make the second sequence. Your starting OEIS sequence is in every case https://oeis.org/A001477 Given as Input an positive Integer and a Letter that matches [A-Z] or [a-Z] ## Example # PHP, 171 bytes for(a=0;$a<=$argv[1];$a++)$r[]=[$a,$b=$a&1,$c=$a+!$b,$d=(($c-!$b)/2^0)+$b,$A[$b]=$e=$d*$c,$f=$e+$A[!$b],$g=$a?$g*sqrt($f):1,$h=$g%2];echo$r[$argv[1]][ord($argv[2])%32-1];


Try it online!

The example gives back the n value of a OEIS sequence for the following letters. A letter greater h is for this example a invalid input

• a https://oeis.org/A001477 numbers
$a Valid first sequence • b https://oeis.org/A000035 mod 2 $b=$a&1 Valid use the variable in the sequence before • c https://oeis.org/A109613 odd numbers $c=$a+!$b Valid Can use sequences before

• d https://oeis.org/A110654 a(n) = floor(n/2) + n mod 2
$d=(($c-!$b)/2^0)+$b Valid an invalid example is $d=(($a/2)^0)+$b cause it not use the sequence before • e https://oeis.org/A000217 triangular $A[$b]=$e=$d*$c Valid you can create help variables

• f https://oeis.org/A000290 square
37 %
38 &
39 '
40 (
41 )
42 *
43 +
44 ,
45 -
46 .
47 /
48 0
49 1
50 2
51 3
52 4
53 5
54 6
55 7
56 8
57 9
58 :
59 ;
60
63 ?
64 @
65 A
66 B
67 C
68 D
69 E
70 F
71 G
72 H
73 I
74 J
75 K
76 L
77 M
78 N
79 O
80 P
81 Q
82 R
83 S
84 T
85 U
86 V
87 W
88 X
89 Y
90 Z
91 [
92 \
93 ]
94 ^
95 _
96
97 a
98 b
99 c
100 d
101 e
102 f
103 g
104 h
105 i
106 j
107 k
108 l
109 m
110 n
111 o
112 p
113 q
114 r
115 s
116 t
117 u
118 v
119 w
120 x
121 y
122 z
123 {
124 |
125 }
126 ~
127 DEL


# Test Cases

[0, 97, 7, 22] -> [NUL, a, BEL, SYN]


More to come...

# Meta

• Would it be more interesting to use the UTF-8 names for the printable characters (0x20 - 0x7E), and the ASCII names for the control characters?
• hand copy the table from the website please dont. Try a Google search: theasciicode.com.ar/ascii-codes.txt Jul 23, 2017 at 22:39
• @StepHen good call, thanks Jul 23, 2017 at 23:24
• Downvoter: I would much like your feedback rather than just your vote Jul 24, 2017 at 1:39
• IMO just have take a letter and output the code. Since that part is boilerplate str.chars.map( real program ). Also for ASCII char names NUL is it ok is we output them in lower case? e.g. nul (obviously ascii letters would have fixed case) Jul 24, 2017 at 1:42

# Lennyface parser and selector

Create, in the language of your choice, a program that outputs a randomly selected lennyface (artistic minifigures, see this) from an input - a string composed of numbers and lennyfaces. You will have to : first, parse this input; second, extract a probability mass function f from the parsed input; third, select and output a lennyface respecting f. Read the rules for more details.

## Rules

• Input : A string with lennyfaces and numbers (positive AND negative integers), separated by newlines. You may take input by STDIN or function parameter for example.
• Output (STDOUT for example) : the randomly-selected lennyface, as a string.
• The input creates a probability mass function f. If l is a lennyface, then f(l)=(sum of all numbers since the previous lennyface)/x where x is obtained afterwards by summing each of those numerators. @Sandbox : is it clear enough?
• If (sum of all numbers since the previous lennyface) is equal to zero or negative, you must do as if the numerator is equal to 1 in f's definition.
• A line with a number contains only this number ; same for a line with a lennyface. So you can assume there will never be a number in a lennyface.
• If there is nothing on a line (two newlines in a row), you must consider it as a lennyface.
• You must consider that the last line of the string is directly before its first line. See Test 1 for an example.
• You can assume there will be at least 1 lennyface in the list; it cannot be composed just by numbers (don't forget that an empty line is a lennyface too).

## Example

Given this input list :

( ͡° ͜ʖ ͡°)
2
¯\_ツ_/¯
34
-4
8
└[⸟‿⸟]┘

1


You must have 1/42 chances of outputting ( ͡° ͜ʖ ͡°), 2/42 chances of outputting ¯\_ツ_/¯, 38/42 chances of outputting └[⸟‿⸟]┘ and 1/42 chances of outputting nothing (line 7).

## Test cases

Test 1

(⌐■_■)
3


Must output (⌐■_■) with 3/3 chances.

Test 2

ʢ◉ᴥ◉ʡ


Must output ʢ◉ᴥ◉ʡ with 1/1 chance.

Test 3

0
\(ᗝ)/


Must output \(ᗝ)/ with 1/1 chance.

Test 4

( ͡° ͜ʖ ͡°)
2
¯\_ツ_/¯
34
4
☞   ͜ʖ  ☞

0


Must output ( ͡° ͜ʖ ͡°) with 1/42 chance, ¯\_ツ_/¯ with 1/21 chance, ☞  ͜ʖ  ☞ with 19/21 chances and nothing with 1/42 chance.

Test 5

1

( ͡° ͜ʖ ͡°)


Must output ( ͡° ͜ʖ ͡°) with 1/4 chance and nothing with 3/4 chance, since there are 3 empty lines.

Test 6

42

-1
( ͡° ͜ʖ ͡°)



Must output nothing with 43/44 chance and ( ͡° ͜ʖ ͡°) with 1/44 chance.

@Sandbox : should I add test cases?

This is , so shortest code in bytes wins. Standard loopholes apply.

Note : Please do not be discouraged if the parsing is difficult to handle in your language, or if testing is hard because of randomness. Your solution might be very interesting algorithmically, not obviously in terms of golfing. Just please explain in your answer why it works.

Moreover, this is the first code-golf I create, so please let me know if something is not appropriate or if I should give more details on a point. And overall, if you downvote, explain me why so I can improve it.

• Yours tests seems a bit contraditory. The number is the chance of the next face (line), so what's the point of the empty line in the example / test 4? By the same logic, the test1 should have a 3/4 of outputting nothing? What is the point of the 0 in the test 4?
– Rod
Jul 3, 2017 at 14:03
• Why is the chance of outputting ( ͡° ͜ʖ ͡°) 1/42 and not 0 ? (since there are no numbers above it)
Jul 3, 2017 at 14:04
• Sorry ! I forgot to copy paste the fact that the minimal chance is 1! Jul 3, 2017 at 14:05
• Also, a common thing to do on challenges involving randomness, and therefore, hard to test, is to ask people to provide a mandatory explanation, or at least ask them to show why it works.
Jul 3, 2017 at 14:05
• @Dada thanks. I note this. Jul 3, 2017 at 14:06
• @Rod the empty line is a lennyface, as said here : If there is nothing on a line, you must consider it as a lennyface. Jul 3, 2017 at 14:08
• @V.Courtois I meant and empty line without a preceding number
– Rod
Jul 3, 2017 at 14:09
• As I said, the minimum is one (sorry again for forgetting it). Jul 3, 2017 at 14:10
• If only positive integers are to be expected, you should write it. Otherwise, give some details and examples about what you consider "numbers".
Jul 3, 2017 at 14:12
• @Dada editing. In fact I said the minimum is 1, but you can have things like 2,-1,-3,17 and then your lennyface ; that means the probability is 15/ total. Jul 3, 2017 at 14:14
• @V.Courtois just a small suggestion, to make the "list as circle" more explicit you could change the value to something else than 0 or 1, this way it would not overlap the "missing number" rule
– Rod
Jul 3, 2017 at 14:15
• @Rod does it? Sorry if I'm not getting what you are saying, but the list is always a circle, meaning if your list is 2,3,( ͡° ͜ʖ ͡°),4,5,☞  ͜ʖ  ☞,6, you have 6+2+3 chance of getting ( ͡° ͜ʖ ͡°) and 4+5 chance of getting ☞  ͜ʖ  ☞. Jul 3, 2017 at 14:18
• thanks for editing @musicman523 Jul 4, 2017 at 7:21
• KISS. This is far more complicated than common sense would require. Deliberately overcomplicating things to make it "more difficult" is a guaranteed method to make a bad question. Jul 4, 2017 at 7:32
• The challenge has two parts as far as I can tell. a) Create a probability mass function from an input by parsing b) sample from the probability mass function. Part a) needs to be rewritten as it is at best ambiguous and at worst just incorrect.
– user9206
Jul 5, 2017 at 7:50

# Golf Cubically code code-challengefgitw

Your task is to optimize Cubically source code using one or more optimizations in this post.

How this challenge works:

• You will choose one or more optimizations below and write a program (in the language of your choice) that performs those optimizations on a Cubically program.
• Your program will take a Cubically program as input using any allowed input methods, and output a Cubically program using any allowed output methods.
• The first answer to successfully perform all optimizations wins!

# Optimizations

### 1. Face turn arguments

Before a face turn is performed, the interpreter calculates turns = turns mod 4. So R5 would be equivalent to R1 which is equivalent to R, R7 is equivalent to R3 which is equivalent to R', etc. Also note that R11111 is equivalent to R5, and R22 is equivalent to nothing at all.

Performing this optimization will mean evaluating all arguments to an R, L, U, D, M, E, or S command and shortening them as much as possible.

Test cases:

Relevant code -> Optimization
R11           -> R2
R1            -> R
L33           -> L2
U22           ->
D222          -> D2
M11111        -> M
E00001        -> E
S9            -> S


### 2. Repeated face turn

When multiple calls to the same face turn command are present right next to each other, they can clearly be golfed. For example, R2R1 is equivalent to R3. UUU is equivalent to U3. F2F2F2F2 is equivalent F8.

Test cases:

Relevant code -> optimization
R2R2R2        -> R6            (R2 if you also choose optimization 1)
LLL           -> L3
UU            -> UU or U2
D3D2D1        -> D6            (D2 if you also choose optimization 1)


### 3. "Set notepad to" commands

There are some commands that, instead of adding to/subtracting from/multiplying by/dividing by the notepad, just assign to it. Here are all such commands:

_^=<>⊕«»·|:


When called with multiple arguments, since each argument calls the command separately, only the final argument is relevant. So =123 is equivalent to =3, _00000 is equivalent to _0, and :12345678987654321 is equivalent to 1.

Test cases:

Relevant code -> Optimization
_333          -> _3
=12321        -> =1
+54321        -> +54321
:55           -> :5
/55           -> /55


### 4. Repeated non-face-turn commands

When multiple face turn commands are present right by each other, their arguments can simply be added together. Commands do not act this way. While R2 calls R with 2, =2 calls = with the face sum of the front face (face index 2).

To perform this optimization, when multiple commands outside of RLUDFBMES appear next to each other, simply remove the duplicated commands without removing the arguments.

Relevant code -> Optimization
_1_1_1_1      -> _1111         (_1 if you also choose optimization 3)
%11%22%33     -> %112233       (%3 if you also choose optimization 3)
+12345+67+8   -> +12345678


### 5. Nonexistent commands

Go check out the Cubically commands page and you'll see that there are plenty of characters that are not commands. For example, there are no commands that are lowercase letters.

To perform this optimization, remove all nonexistent commands and their arguments from the Cubically source. If the commands also have arguments, you must remove the arguments so that they are not passed to the previous command.

Test cases:

Relevant code -> Optimization
moo cow moo   ->
moo2cow2moo   ->
misteR2 FOO   -> R2F
FEAR ME.      -> ERME
u1U2u3U4u5U6  -> U2U4U6   (nothing if you also choose optimization 1, U12 if you also choose optimization 2)


There are lots of implicit commands in Cubically (RLUDFBMES()$~&E!), but there are plenty that need to be called with arguments. So %%%% is equivalent to nothing at all while %%2%% is equivalent to %2. Test cases: Relevant code -> Optimization %%%% ->  ->  ++2++2++2 -> +2+2+2 (+222 if you also choose optimization 4) +++>--<- -> Not Brainf**k, sorry! (:P)  # Sandbox I'll add more optimizations later. • Clarification on R123: That's the same as R6 and R2, not R3, right? Digits are summed, there are multidigit numbers? That would be better to specify Aug 17, 2017 at 20:13 • A few things: first, I can't find the tag "fgitw", is there a typo? Second, does optimization 1 require handling F and B as well, or just the currently listed ones? Third, in optimization 3 most of the listed commands seem invalid because the notepad is used in calculation and then overwritten with the output; for example =11 is not the same as =1 in most circumstances. In fact, I think only _: are valid. Fourth, is the winning answer one which performs all optimizations in a single program, or one which contains a separate program for each optimization? Aug 18, 2017 at 18:03 # Hungry for Apples? This challenge is simple, given an integer 0 <= n or 0 < n, output an ASCII-apple with that many bites taken out of it. No bites (0):  // .-.:|.-. .' '' '. ; ; : : : : : : : ; '. : '-_.._-'  Bite 1:  // .-.:|.-. .' '' '. ; ; '-. : } : .-' : : ; '. : '-_.._-'  Bite 2:  // .-.:|.-. .' '' '. '-. ; } : } : } : .-' ; '. : '-_.._-'  Bite 3:  // .-.:|.-. .' '' '. '-. ; } .-' } { } '-. .-' ; '. : '-_.._-'  Bite 4:  // .-.:|.-. .' '' '. '-. .-' } { } { } { .-' '. '. : '-_.._-'  Bite 5:  // .-.:|.-. .' '' '. '-. .-' }". { } } { } } { .-'" '. '. : '-_.._-'  Bite 6:  // .-.:|.-. .' '' '. '-. .-' }"~". { } } } { } } } { .-'"~" '. '. : '-_.._-'  Bite 7:  // .-.:|.-. .' '' '. '-. .-' }"~"~".{ } } } }{ } } } }{ .-'"~"~" '. '. : '-_.._-'  Bite >7: [empty output]  # Rules • You may have trailing spaces, make it consistent though. • You may have exactly 1 trailing newline. • You are NOT doing an animation here, you are taking in n and outputting an apple. • You may error on integers less than 0, as the spec provides n > 0. • You must have empty output (no error) on n > 7/8. • You threw out the core; you didn't error the core into non-existence. • I feel this would be better if there was some more symmetry in the 5, 6, and 7 bytes so that people could possibly make better compression. Aug 4, 2017 at 18:26 • @AdmBorkBork better? Aug 22, 2017 at 21:26 • Yes, much better. Aug 23, 2017 at 12:33 # Proper Kerning Kerning is the adjustment of spacing between pairs of letters in order to obtain an aesthetic result. When kerning is applied automatically by a program (typically whatever editor you're using), it is said to be automatic. There are two types of automatic kerning. The one used in this challenge is metric kerning. With metric kerning, the amount of space between pairs of letters is dictated by the kerning tables found in the font file. Given a TrueType font file, output the kerning values for each mapping in the kerning table for ASCII characters 48 - 122 inclusive. ## Example calibri.ttf l="A" r="C" v="-15" l="A" r="G" v="-15" l="A" r="J" v="23" l="A" r="O" v="-23" l="A" r="Q" v="-23" l="A" r="T" v="-160" l="A" r="U" v="-32" l="A" r="V" v="-89" l="A" r="W" v="-80" l="A" r="Y" v="-150" l="A" r="t" v="-52" l="A" r="v" v="-38" l="A" r="y" v="-41" l="A" r="?" v="-68" l="B" r="A" v="-20" l="B" r="T" v="-48" l="B" r="V" v="-25" l="B" r="W" v="-24" l="B" r="X" v="-44" l="B" r="Y" v="-57" l="B" r="Z" v="-20" l="B" r="f" v="-20" l="B" r="t" v="-20" l="B" r="v" v="-20" l="B" r="x" v="-15" l="B" r="y" v="-20" l="C" r="G" v="-18" l="C" r="J" v="12" l="C" r="O" v="-18" l="C" r="Q" v="-18" l="C" r="T" v="10" l="D" r="A" v="-30" l="D" r="J" v="-22" l="D" r="T" v="-23" l="D" r="V" v="-24" l="D" r="W" v="-14" l="D" r="X" v="-31" l="D" r="Y" v="-39" l="D" r="Z" v="-22" l="E" r="A" v="-22" l="E" r="C" v="-24" l="E" r="G" v="-24" l="E" r="O" v="-32" l="E" r="Q" v="-32" l="E" r="S" v="-20" l="E" r="Z" v="-10" l="E" r="a" v="-34" l="E" r="c" v="-28" l="E" r="d" v="-30" l="E" r="e" v="-37" l="E" r="f" v="-64" l="E" r="o" v="-37" l="E" r="q" v="-30" l="E" r="t" v="-24" l="E" r="v" v="-48" l="E" r="w" v="-34" l="E" r="y" v="-48" l="F" r="A" v="-115" l="F" r="C" v="-18" l="F" r="G" v="-18" l="F" r="J" v="-109" l="F" r="O" v="-18" l="F" r="Q" v="-18" l="F" r="S" v="-29" l="F" r="X" v="-22" l="F" r="Z" v="-11" l="F" r="a" v="-55" l="F" r="c" v="-28" l="F" r="d" v="-20" l="F" r="e" v="-30" l="F" r="o" v="-28" l="F" r="q" v="-20" l="F" r="s" v="-35" l="G" r="T" v="-10" l="G" r="V" v="-10" l="G" r="W" v="-9" l="G" r="Y" v="-30" l="G" r="v" v="-29" l="G" r="w" v="-22" l="G" r="x" v="-14" l="G" r="y" v="-30" l="J" r="A" v="-35" l="J" r="X" v="-20" l="K" r="C" v="-78" l="K" r="G" v="-80" l="K" r="O" v="-97" l="K" r="Q" v="-97" l="K" r="S" v="-18" l="K" r="U" v="-29" l="K" r="W" v="-34" l="K" r="a" v="-34" l="K" r="c" v="-40" l="K" r="d" v="-33" l="K" r="e" v="-37" l="K" r="f" v="-25" l="K" r="m" v="-32" l="K" r="n" v="-32" l="K" r="o" v="-37" l="K" r="p" v="-32" l="K" r="q" v="-33" l="K" r="r" v="-32" l="K" r="s" v="-18" l="K" r="t" v="-38" l="K" r="u" v="-32" l="K" r="v" v="-101" l="K" r="w" v="-95" l="K" r="y" v="-85" l="L" r="C" v="-22" l="L" r="G" v="-47" l="L" r="J" v="25" l="L" r="O" v="-45" l="L" r="Q" v="-45" l="L" r="T" v="-150" l="L" r="U" v="-44" l="L" r="V" v="-147" l="L" r="W" v="-118" l="L" r="Y" v="-167" l="L" r="f" v="-23" l="L" r="t" v="-38" l="L" r="v" v="-78" l="L" r="w" v="-72" l="L" r="y" v="-79" l="O" r="A" v="-23" l="O" r="J" v="-27" l="O" r="T" v="-55" l="O" r="V" v="-25" l="O" r="W" v="-22" l="O" r="X" v="-64" l="O" r="Y" v="-55" l="O" r="Z" v="-38" l="O" r="x" v="-12" l="O" r="z" v="-10" l="P" r="A" v="-151" l="P" r="J" v="-140" l="P" r="T" v="-9" l="P" r="V" v="-10" l="P" r="X" v="-35" l="P" r="Y" v="-11" l="P" r="Z" v="-29" l="P" r="a" v="-44" l="P" r="c" v="-43" l="P" r="d" v="-34" l="P" r="e" v="-41" l="P" r="f" v="12" l="P" r="o" v="-41" l="P" r="q" v="-34" l="P" r="s" v="-32" l="P" r="t" v="12" l="P" r="y" v="12" l="Q" r="J" v="41" l="Q" r="T" v="-47" l="Q" r="V" v="-25" l="Q" r="W" v="-12" l="Q" r="X" v="12" l="Q" r="Y" v="-46" l="Q" r="g" v="59" l="Q" r="j" v="79" l="Q" r="x" v="31" l="Q" r=";" v="60" l="Q" r="]" v="32" l="R" r="C" v="-18" l="R" r="G" v="-19" l="R" r="O" v="-20" l="R" r="Q" v="-20" l="R" r="S" v="-27" l="R" r="T" v="-20" l="R" r="V" v="-28" l="R" r="W" v="-18" l="R" r="Y" v="-30" l="R" r="e" v="-36" l="R" r="o" v="-42" l="R" r="v" v="-26" l="R" r="w" v="-33" l="R" r="y" v="-33" l="S" r="A" v="-15" l="S" r="J" v="-9" l="S" r="T" v="-14" l="S" r="V" v="-14" l="S" r="W" v="-15" l="S" r="X" v="-13" l="S" r="Y" v="-20" l="S" r="v" v="-23" l="S" r="w" v="-17" l="S" r="y" v="-25" l="T" r="A" v="-160" l="T" r="C" v="-42" l="T" r="G" v="-59" l="T" r="J" v="-65" l="T" r="O" v="-58" l="T" r="Q" v="-58" l="T" r="S" v="-10" l="T" r="T" v="28" l="T" r="a" v="-160" l="T" r="c" v="-177" l="T" r="d" v="-147" l="T" r="e" v="-182" l="T" r="g" v="-151" l="T" r="m" v="-127" l="T" r="n" v="-127" l="T" r="o" v="-182" l="T" r="p" v="-127" l="T" r="q" v="-147" l="T" r="r" v="-127" l="T" r="s" v="-153" l="T" r="u" v="-127" l="T" r="v" v="-92" l="T" r="w" v="-86" l="T" r="x" v="-90" l="T" r="y" v="-93" l="T" r="z" v="-142" l="T" r=";" v="-114" l="T" r=":" v="-134" l="U" r="A" v="-45" l="U" r="J" v="-40" l="V" r="A" v="-96" l="V" r="C" v="-18" l="V" r="G" v="-25" l="V" r="J" v="-80" l="V" r="O" v="-27" l="V" r="Q" v="-27" l="V" r="S" v="-12" l="V" r="V" v="9" l="V" r="a" v="-114" l="V" r="c" v="-103" l="V" r="d" v="-87" l="V" r="e" v="-102" l="V" r="g" v="-100" l="V" r="m" v="-50" l="V" r="n" v="-50" l="V" r="o" v="-86" l="V" r="p" v="-50" l="V" r="q" v="-87" l="V" r="r" v="-50" l="V" r="s" v="-90" l="V" r="u" v="-50" l="V" r="y" v="-35" l="V" r="z" v="-82" l="V" r=";" v="-108" l="V" r=":" v="-73" l="W" r="A" v="-93" l="W" r="C" v="-22" l="W" r="G" v="-22" l="W" r="J" v="-88" l="W" r="O" v="-22" l="W" r="Q" v="-22" l="W" r="S" v="-10" l="W" r="X" v="-13" l="W" r="a" v="-71" l="W" r="c" v="-78" l="W" r="d" v="-72" l="W" r="e" v="-75" l="W" r="g" v="-54" l="W" r="m" v="-60" l="W" r="n" v="-60" l="W" r="o" v="-86" l="W" r="p" v="-60" l="W" r="q" v="-72" l="W" r="r" v="-60" l="W" r="s" v="-73" l="W" r="u" v="-60" l="W" r="v" v="-34" l="W" r="y" v="-53" l="W" r=";" v="-156" l="X" r="C" v="-57" l="X" r="G" v="-65" l="X" r="O" v="-57" l="X" r="Q" v="-57" l="X" r="S" v="-20" l="X" r="d" v="-44" l="X" r="e" v="-39" l="X" r="g" v="-9" l="X" r="o" v="-38" l="X" r="q" v="-44" l="X" r="t" v="-31" l="X" r="u" v="-38" l="X" r="v" v="-55" l="X" r="w" v="-49" l="X" r="y" v="-43" l="Y" r="A" v="-152" l="Y" r="C" v="-67" l="Y" r="G" v="-67" l="Y" r="J" v="-112" l="Y" r="O" v="-66" l="Y" r="Q" v="-66" l="Y" r="S" v="-17" l="Y" r="Z" v="-10" l="Y" r="a" v="-134" l="Y" r="c" v="-159" l="Y" r="d" v="-131" l="Y" r="e" v="-147" l="Y" r="f" v="-62" l="Y" r="g" v="-142" l="Y" r="i" v="-32" l="Y" r="j" v="-49" l="Y" r="m" v="-94" l="Y" r="n" v="-94" l="Y" r="o" v="-153" l="Y" r="p" v="-94" l="Y" r="q" v="-131" l="Y" r="r" v="-94" l="Y" r="s" v="-115" l="Y" r="t" v="-44" l="Y" r="u" v="-94" l="Y" r="v" v="-69" l="Y" r="w" v="-62" l="Y" r="x" v="-70" l="Y" r="y" v="-65" l="Y" r="z" v="-100" l="Y" r=";" v="-138" l="Y" r=":" v="-154" l="Z" r="A" v="-11" l="Z" r="C" v="-25" l="Z" r="G" v="-24" l="Z" r="O" v="-24" l="Z" r="Q" v="-24" l="Z" r="W" v="-7" l="Z" r="Y" v="-7" l="Z" r="a" v="-10" l="Z" r="c" v="-12" l="Z" r="d" v="-18" l="Z" r="e" v="-31" l="Z" r="o" v="-29" l="Z" r="q" v="-18" l="Z" r="v" v="-45" l="Z" r="w" v="-38" l="Z" r="y" v="-37" l="a" r="f" v="-12" l="a" r="t" v="-19" l="a" r="v" v="-34" l="a" r="w" v="-14" l="a" r="x" v="-19" l="a" r="y" v="-38" l="b" r="f" v="-17" l="b" r="s" v="-10" l="b" r="t" v="-9" l="b" r="v" v="-10" l="b" r="w" v="-10" l="b" r="x" v="-41" l="b" r="y" v="-10" l="b" r="z" v="-28" l="c" r="a" v="-17" l="c" r="o" v="-17" l="e" r="f" v="-18" l="e" r="t" v="-11" l="e" r="v" v="-10" l="e" r="w" v="-10" l="e" r="x" v="-31" l="e" r="y" v="-13" l="e" r="z" v="-20" l="f" r="a" v="-40" l="f" r="c" v="-45" l="f" r="d" v="-53" l="f" r="e" v="-51" l="f" r="f" v="-20" l="f" r="g" v="-60" l="f" r="o" v="-43" l="f" r="q" v="-53" l="f" r="s" v="-27" l="f" r="v" v="13" l="f" r="w" v="6" l="f" r="y" v="10" l="f" r="z" v="-20" l="g" r="a" v="-38" l="g" r="c" v="-12" l="g" r="d" v="-19" l="g" r="e" v="-17" l="g" r="g" v="19" l="g" r="o" v="-14" l="g" r="q" v="-19" l="g" r="t" v="-31" l="h" r="f" v="-12" l="h" r="t" v="-19" l="h" r="v" v="-34" l="h" r="w" v="-14" l="h" r="x" v="-19" l="h" r="y" v="-38" l="k" r="a" v="-35" l="k" r="c" v="-48" l="k" r="d" v="-56" l="k" r="e" v="-66" l="k" r="o" v="-69" l="k" r="q" v="-56" l="k" r="s" v="-19" l="k" r="t" v="-10" l="k" r="u" v="-26" l="m" r="f" v="-12" l="m" r="t" v="-19" l="m" r="v" v="-34" l="m" r="w" v="-14" l="m" r="x" v="-19" l="m" r="y" v="-38" l="n" r="f" v="-12" l="n" r="t" v="-19" l="n" r="v" v="-34" l="n" r="w" v="-14" l="n" r="x" v="-19" l="n" r="y" v="-38" l="o" r="v" v="-9" l="o" r="w" v="-8" l="o" r="x" v="-40" l="o" r="y" v="-11" l="o" r="z" v="-27" l="p" r="f" v="-17" l="p" r="s" v="-10" l="p" r="t" v="-9" l="p" r="v" v="-10" l="p" r="w" v="-10" l="p" r="x" v="-41" l="p" r="y" v="-10" l="p" r="z" v="-28" l="q" r="g" v="10" l="r" r="a" v="-42" l="r" r="c" v="-30" l="r" r="d" v="-28" l="r" r="e" v="-27" l="r" r="g" v="-28" l="r" r="o" v="-33" l="r" r="q" v="-28" l="r" r="s" v="-35" l="r" r="v" v="19" l="r" r="w" v="11" l="r" r="y" v="10" l="s" r="f" v="-19" l="s" r="t" v="-23" l="s" r="v" v="-31" l="s" r="w" v="-10" l="s" r="x" v="-22" l="s" r="y" v="-37" l="s" r="z" v="-18" l="t" r="a" v="-25" l="t" r="c" v="-25" l="t" r="d" v="-23" l="t" r="e" v="-22" l="t" r="o" v="-20" l="t" r="q" v="-23" l="t" r="t" v="-29" l="v" r="a" v="-30" l="v" r="c" v="-25" l="v" r="d" v="-20" l="v" r="e" v="-20" l="v" r="f" v="11" l="v" r="g" v="-28" l="v" r="o" v="-19" l="v" r="q" v="-20" l="v" r="s" v="-9" l="v" r="t" v="10" l="v" r="v" v="12" l="v" r="w" v="12" l="v" r="y" v="12" l="v" r="z" v="-26" l="w" r="a" v="-23" l="w" r="c" v="-20" l="w" r="d" v="-18" l="w" r="e" v="-18" l="w" r="f" v="6" l="w" r="g" v="-18" l="w" r="o" v="-19" l="w" r="q" v="-18" l="w" r="s" v="-18" l="w" r="t" v="4" l="w" r="v" v="12" l="w" r="w" v="8" l="w" r="y" v="12" l="w" r="z" v="-17" l="x" r="a" v="-37" l="x" r="c" v="-46" l="x" r="d" v="-44" l="x" r="e" v="-54" l="x" r="o" v="-55" l="x" r="q" v="-44" l="x" r="s" v="-12" l="x" r="t" v="6" l="x" r="u" v="-20" l="y" r="a" v="-31" l="y" r="c" v="-26" l="y" r="d" v="-24" l="y" r="e" v="-25" l="y" r="f" v="10" l="y" r="g" v="-26" l="y" r="o" v="-24" l="y" r="q" v="-24" l="y" r="s" v="-19" l="y" r="t" v="10" l="y" r="v" v="12" l="y" r="w" v="8" l="y" r="y" v="10" l="y" r="z" v="-17" l="z" r="a" v="-34" l="z" r="c" v="-45" l="z" r="d" v="-46" l="z" r="e" v="-46" l="z" r="f" v="-10" l="z" r="g" v="-17" l="z" r="o" v="-45" l="z" r="q" v="-46" l="z" r="s" v="-22" l="z" r="u" v="-10" l="z" r="v" v="-18" l="z" r="w" v="-22" l="z" r="y" v="-18"  ## Scoring This is , so the shortest answer (in bytes) wins. ### Meta I know this challenge is going to need a lot of work before it's ready for main. Please hold criticisms for now. Helpful ideas and thoughts are welcome. • I'm not sure that the problem is well defined. There's a reason it's called font hinting: the rendering application is free to take it into account or not, or even to apply more complex logic. E.g. some fonts have multiple sets of font hints for different contexts. There are other complex issues. A font can have Latin and Cyrillic letters and define hints for kerning between pairs of Latin and pairs of Cyrillic but not between Latin and Cyrillic; however, some letters may have identical glyphs, so a judgement on whether the kerning is "correct" might be ambiguous. Then there's antialiasing. May 24, 2017 at 6:15 • @PeterTaylor Good notes. I will likely restrict the character set. I just wanted to start getting ideas down in the sandbox. – Poke May 24, 2017 at 6:51 • Very ambiguous. May 25, 2017 at 17:48 • @Mendeleev It's not done yet. I'm aware it's ambiguous. – Poke May 26, 2017 at 16:10 • Looking at developer.apple.com/fonts/TrueType-Reference-Manual/RM06/… I can see a number of issues to address. 16- vs 32-bit entries? Should multiple tables be combined or printed separately? All tables or only tables with certain coverage values? Which of the four defined formats need to be supported? Do you have a test case which covers glyph index differing from codepoint? Sep 16, 2017 at 17:28 • @PeterTaylor I have a proof of concept that I wrote (it's the reason I have taken so long to update this) and I'm planning to address all of your questions. Thanks for doing a bit of research to help me out, though :] – Poke Sep 16, 2017 at 18:57 • Downvoter, why? – Poke Oct 4, 2017 at 21:03 Six Flags over HTTP Let's say you need to transmit six boolean flags in a URL string. Obviously you could do it with six ones or zeroes, but you want better compression. With a little math you can pack them into two characters using 0-7 octal. How about mapping all six to a single ASCII character? Here we have a problem: you are not allowed to use , / ? : @ & = +$ # or space. Now the range of printable ASCII no longer has 64 valid characters in a row.

In Javascript (or another language that can run from a web page, if any), what is the shortest code for a pair of functions to encode and decode this data, between an array of six booleans and a single character?

• -1 language restriction, most languages have HTTP libraries so I think any language should be allowed Sep 24, 2017 at 13:11
• This challenge could be improved by rephrasing it to: "Write a bijective function between an array of six booleans and a single printable character excluding the characters ,/?:@&=+$# ". Mentioning that the encoder and decoder should be separate programs/functions would be helpful. Also, may the encoder and decoder share code? Sep 24, 2017 at 22:08 # Count letter frequency Inspired by question Tweetable hash function challenge, you should take the English dictionary used there and produce a program or function that outputs the the absolute and relative frequency of each character. It is CASE SENSITIVE and the APOSTROPHE is also accountable as a real letter. Example of a valid output format (but with stupid guessing values): A 5566 20% ... Z 60 0.2% a 27000 30% ... z 120 0.01% ' 450 3.5%  It is , but no answer will be accepted. Wanna know shortest script for each language. • -1 (01) Don't rely on another challenge to define yours; include all the information we need in your write-up. (02) Make an effort to come up with some actual test cases - do you honestly expect us to verify our solutions against "stupid guessing values"? Sep 30, 2017 at 0:55 # Is it a perfect loop? test-batterydecision-problem Your task is to take a GIF or an animated image in any reasonable format as input (including taking the file name of a GIF in the current directory), and output whether it is a "perfect loop" - that is, the frames transition seamlessly from the end to the start, and a human cannot notice where it starts and ends at first glance. Return or print a truthy value if it is a perfect loop, otherwise print or return a falsy value. ## Scoring Winners will be determined from the percentage of test cases they get correct. In the event of a tie, highest votes wins. You can view test cases at https://ghostbin.com/paste/m3yaw. Show your score against the test cases when you post. ## Input If you are not taking input in a GIF, please provide a program that will convert a GIF to your desired format. Images corresponding to a truthy value have been taken from /r/perfectloops and for falsy test cases, /r/almostperfectloops and /r/gifs. ## Restrictions • Hard coding is not allowed (violates standard loophole 1 and 2). • You must provide consistent results for the same GIF (no randomness) • Remember, this is not , so byte count is not needed in your solution. Just post the language name and add the percentage correct when I comment. • I'm not sure it's as simple as comparing the first to the last frame, if it is we'd have duplicate frames. is this challenge allowing HTTP requests? Oct 17, 2017 at 21:15 • If hashing the inputs is not allowed, then you should clearly define what constitutes a “perfect loop”. It's not good to extrapolate from a handful of test cases where the pass/fail cases are very similar. – japh Oct 18, 2017 at 14:31 # Highest code size∕output ratio to generate a large executable section inside an elf file. Your challenge is to create the shortest code in your language of choice or the tools of your choice (like objcopy) that will create an elf file with a the executable section as large as possible. I mean that if I extract the.text section of the elf binary, the resulting extracted file should be at least 90% of the elf binary. # Requirements • The program should takes the desired section size as input. • The .text section name needs to corresponds to the executable section. • The type of the .text section should bePROGBITSand it should contains instructions. • The elf file should have a .shstrtab section. • The .text section should be readable and writable. • The target architecture should be Pnacl or armelv7 or x86_64. • The elf file should be valid and pass Google nacl’s validation whitelist in order to be loaded (but I don´t care if the sandbox segfault). If you have no idea about what Google native client is, just create a script that call the patched version of binutils from the nacl_sdk, or make sure the elf file is valid and can be executed on Linux. Of course, you normally can’t use a compiler because it would takes too much computational years in order to finish. # Winner The answer with the highest code size∕program output ratio. • Why not make scoring output size / code size? Apr 4, 2017 at 3:49 • Make it a code-challenge Apr 4, 2017 at 3:49 • This is essentially the same challenge as this one, and would be closed as a duplicate. Although it's not exactly the same, some answers to the previous question would require very little modification and answers to this question would also require very little modification to be answers to the other one. Apr 4, 2017 at 8:37 • @Alt-F4 : it was a code challenge. Apr 4, 2017 at 21:52 • @PeterTaylor : they were no answer to the previous question. In order to be closed as a duplicate the target needs to be already answered. You known it was closed an unclear, so please suggest change to make this answer clearer. Apr 4, 2017 at 21:54 • Huh? It's open and has 15 answers. Apr 4, 2017 at 22:09 • @PeterTaylor sorry, I thought to an another question that was closed as unclear and didn’t take time to read your link. In that case NO, the aim is to not use the compiler in order to actually build the file. This normally can’t be done with a compiler or an assembler. Apr 4, 2017 at 22:16 • Can't it? Why not? Dec 16, 2017 at 19:55 • Wait... shortest code that generate any program? Or what? Don't think this is a good idea... Jan 6, 2018 at 12:10 # Removing a Letter adds a Letter Your program should output nothing when unaltered, however, when any single character is removed it should have an output length of 1. This extends to any number of characters being removed from the program, as long as there is, at minimum, a single character remaining. For example, if my program were abcdefg, it should output nothing if unaltered. However, if I were to remove a and d from this program to get bcefg, it should output any two printable characters that represent 16 bytes of information (2 characters for 2 characters removed). • So if bcefg outputs (00,AA,etc...) this is valid. Taking this further, if we were to remove all but the letter g we'd need an output of 6 characters. • So if g outputs ('000000','@$^%@(',etc...) this is valid.

Your program must function for all possible combinations of removals that are possible, that is to say each single letter in your program should be a valid program.

# Rules

• You may "lock" pieces of the code, each locked byte counts for 2-bytes instead of 1-byte.
• Locked bytes will never be removed.
• For instance, if my program was abcdefg and bcd is locked, the shortest program we'll get is abcd,bcde,bcdf and bcdg.
• If bcd was locked in abcdefg it'd be 10 bytes, not 7.
• The program may output any byte to represent 1 removed character, N-bytes for N removed chars in the code itself.
• The rule only leads to totally locked code
– l4m2
Mar 13, 2018 at 0:13
• @l4m2 hah. I disagree. Mar 13, 2018 at 0:58
• But more constructively, increase the penalty? Limit locked chars? Mar 13, 2018 at 1:04
• Maybe require an unlocked percent?
– l4m2
Apr 6, 2018 at 10:52

Sandbox:

Is this question already available (duplicate)?

Are things too vague?

Does providing the example help or hinder?

# Tidy the Pantry (easy)

I hate grocery shopping, particularly the part where I put groceries away--so I'm calling upon the collective hive-mind to handle that.

## Challenge

Your challenge is to take a 1D-list of groceries and a 2D pantry as input; and output an newly assorted pantry. The two variables can be of your type choice, and in any order, but please specify what item types your program requires (e.g. string, array, etc.).

### Scoring

• This is code golf, so the shortest answer in bytes wins

### Rules

• The pantry should be ordered alphabetically (A - Z, left to right, top to bottom)
• For simplicity, the pantry is case-insensitive
• The pantry must retain its horizontal size (but trailing newlines are optional)
• "Pockets" (empty spaces) should be filled between items (i.e. only the last item is allowed to have a trailing pocket)
• If the pantry is too small for the incoming groceries, then the pantry must replace older items (Z being the oldest, A the youngest)
• Z from groceries is younger than A in pantry
• Standard loopholes are forbidden

## Examples ([ and ] are used for readability)

Input (4x4 pantry):

[A][A][ ][ ]
[ ][ ][B][ ]
[C][ ][ ][ ]
[ ][ ][ ][D]



Output:

[A][A][A][A]
[B][C][D][D]
[ ][ ][ ][ ]
[ ][ ][ ][ ]


Input (2x2 pantry):

[A][B]
[C][D]

XYZ


Output:

[A][X]
[Y][Z]


# JavaScript ES6 (989 bytes)

// (String, String) -> String
let organise = (pantry, groceries) => {
let n = pantry.split("\n").sort((a, b) => b.length - a.length); // used at the end of the function for horizontal sizing
n = n[0].length;

pantry = pantry
.replace(/\W/g, "") // get rid of all non-alphanumeric characters
.split("");         // turn the string into an array

// we need the properties of the new array
// so the extra pantry = pantry is needed
pantry = pantry
.slice(0, pantry.length - groceries.length) // go ahead and remove the last overlapping elements
.concat(groceries)                          // add the groceries to the pantry
.join("")                                   // turn into a string
.split("")                                  // turn into an array
.sort()                                     // sort the array
.join("");                                  // turn into a string

return pantry.replace(RegExp((.{${n}}), 'g'), "$1\n");
};

/** Testing below **/

console.log("Test #2:\n" + organise(
AJCHDJE
JJ   JA
ASD
OOQ I U
Q     W
R,

'AHJBCJHDHHATTGEH'
))

## Test Cases:

### Test #1, 4x4 pantry

TVCX <- pantry
ABCD
ATDJ
UAIK

XYXY <- groceries
----
AAAB <- expected output
CCDD
IJKT
XYXY


### Test #2, 7x6 pantry

AJCHDJE
JJ   JA
ASD
OOQ I U
Q     W
R

AHJBCJHDHHATTGEH
-------
AAAAABC
CDDDEGH
HHHHJJT
T


### Test #3, 10x10 pantry

AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA

ZZZZZZZZZZZZZZZZZZZZ
----------
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
ZZZZZZZZZZ
ZZZZZZZZZZ


# Test #4, 16x16 pantry pantry

ASDFGHJKLZXCVBNM
QJKAJ  KAKSJD  J
KJASDKFHI YOIER
W   OSDOFJ    DK
E PPPASP     AS
R
TASD
YAAAAAAAAAAAA
U          JHOLK
IIAUSHODUYOAISUO
OASD  AUSODI
PIASND JUASJNOIJ
A ASJDH PPOIO
QHIAIUSOIUOOO
WYYAIUSNNAJSDASD
EAISDUUIOPJPIJPJ
ROQPEWIHRNXCAISD

QWERTYUIOP
----------------
AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA
ABCCDDDDDDDDDDDD
DDDEEEEEFFFGHHHH
HHHIIIIIIIIIIIII
IIIIIIJJJJJJJJJJ
JJJJJJKKKKKKKKLL
MNNNNNNOOOOOOOOO
OOOOOOOOOOPPPPPP
PPPPPPQQQQRRRRRS
SSSSSSSSSSSSSSSS
SSSTTUUUUUUUUUUU
UVWWY


# Test #5, 2x2 pantry

HE
LO

[no groceries]
--
HE
LO

• why divide the program score? Feb 26, 2018 at 19:03
• I recommend you do count by bytes otherwise someone is just going to encode their entire program in Chinese characters and win.
– hyper-neutrino Mod
Feb 26, 2018 at 19:09
• @labela--gotoa To get a golfed score (smaller programs get a smaller score), should I change it? Feb 26, 2018 at 19:13
• @EphellonDantzler I don't understand why not just normal scoring...? Feb 26, 2018 at 19:14
• LOL, that's why I set in in Sandbox first @labela--gotoa Feb 26, 2018 at 19:16
• Some notes on your reference implementation: 1 It appears far too soon in the challenge. 2 It's not 1768 bytes. 3 You need to ungolf it and make it readable or it's not much use. 4 As it's JS, create a Snippet for it. 5 Is it necessary? It seems to be thrown in there to try to patch over any holes in the challenge spec. Feb 26, 2018 at 23:17

# Interpret pseudocode

Wikipedia says pseudocode

and

A program in pseudocode is not an executable program.

I don't care.

Make a pseudocode interpreter that can run pseudocode that fits the rules described below*. This is based on the IB pseudocode guide, but it is simplified quite a bit to make it fit for the challenge.

# Pseudocode specifications

This is a simplified pseudocode to make the challenge less tedious. The pseudocode language has no strings, no arrays, no classes, no methods, and no variables other than integers.

## Basic syntax

Comments that start at // and end at a newline (like java one-line comments). // is not necessarily followed by a space, and the comment may be empty. Example:

A = 2 + 3 // I can't write five because my keyboard is broken


Statements are separated by newlines. Lines may be empty (without statements). The exact number of spaces doesn't matter, and spaces are not required. The language is case sensitive.

## Variables

All variables are global, and can be accessed anywhere. They do not need to be declared. To keep things simple, all variables can be assumed to be integers. All variable names are UPPERCASE, and consist only of letters. Your program should at least handle integers from -256 to 256. A wider range is not a requirement.

Variables are assigned values using this syntax:

VARIABLE = Expression


Where VARIABLE can be any uppercase name and expression can be any integer expression, as discussed below.

Examples:

A = 5
B = A + 3
NUMBER = A * B


## Expressions

An expression can be:

• An integer, like 42
• A variable, like NUMBER
• A binary operation on two other expressions, like NUMBER + 5. There are only four operations: +, -, *, /. Division rounds integers down.

Expressions can be surrounded by parentheses to indicate that they need to be evaluated first. To keep things simple, all expressions are evaluated from left to right no matter what the operations are (unless there are parentheses that specify otherwise), so

A = 2 - RM * 9 + 3 / NUMBER
B = 1 + 2 * (3 - 4) / 6


is equivalent to

A = (((2 - RM) * 9) + 3) / NUMBER
B = ((1 + 2) * (3 - 4)) / 6


## Boolean expressions

Boolean expressions can compare two expressions using == (equality), != (not equal to), < (less than), and > (greater than). They are only used for control flow, as discussed below (there are no boolean variables).

## Control flow

There are four types of control flow. They can be infinitely nested in all combinations.

### If

if (booleanExpression) then
// statements (discussed below)
endif


### If-else

if (booleanExpression) then
// statements (discussed below)
else
// other statements
endif


### Loop while

loop while (booleanExpression)
// do stuff
endloop


Where booleanExpressions are boolean expressions. The ifs work the same as in normal programming languages. The while loop is a simple while loop.

The booleanExpressions will always be surrounded by (). The pseudocode is very flexible with spaces, and any number of spaces is valid.

### Loop for

loop VARIABLE from Expression1 to Expression2
// things to do over and over again
end loop


Where Expression1 and Expression2 are expressions that are evaluated before the loop begins and their values are stored until the loop finishes. The content of the loop is executed for every integer from the result of Expression1 to that of Expression1, inclusive. At every iteration, the index variable (VARIABLE in this case) is updated.

Example:

loop I from 3 to 5
output(I)
endloop


Outputs:

3
4
5


## Statements

### Output

output(Expression) outputs the evaluated expression. It's like println in programming languages. So:

output(1+1)


prints 2, followed by a newline.

output() with no arguments should print a newline.

### Other statements

If the interpreter encounters any other statement that looks like a method call with no arguments, it should pretend it's executing it. For example,

lightsoff()
gohome()


should print (together with a newline):

executing lightsoff
executing gohome


In other words, executing [Method name] should be printed. All statements will be lowercase and will consist entirely of letters.

Keywords cannot be statements. You do not have to deal with the following (it will not appear in the pseudocode): - if() - endif() - loop() - while() - etc.

However, statements that start with keywords are valid. For example, loophole() should print executing loophole, even though loop() itself is not valid.

# Challenge rules

• Your program should take a string as input. It can also take something equivalent, like an array of characters. But you can't take an array of strings; your program must itself separate the lines and tokens. You can also take a file as input.
• Your program should print the output of the pseudocode in any reasonable form.
• No standard loopholes.
• There are no restrictions on what your program should do when given invalid pseudocode.
• This is code golf. The shortest code in bytes wins.

# 1

A = 3
output(A) // prints 3
B = 4 + A * 2
output(B)
helloworld()
output(A + B + 1 * 3)


Should give:

3
14
executing helloworld
54


# 2

loop NUM from 2 to 20 // cycle through possible prime numbers
COUNT = 0
loop DIV from 2 to NUM // cycle through possible divisors
if(NUM/DIV*DIV == NUM) then // if the number is exactly divisible
COUNT = COUNT + 1
endif
endloop
if (COUNT == 2) then // if number is prime
output(NUM)
endif
endloop


Should give:

2
3
5
7
11
13
17
19


# 3

Tricky cases that your interpreter should handle:

// empty comment:
//
// empty line:

// more comment testing // ///
////

if     (3<4) then
endoftheworld() // a statement
ifff()
endifnot()
// endif in a comment doesn't count
endif
// loops can be empty:
loop I from 0 to 10
endloop
output(I) // variables are global
if(1<2)
if(3<4) // nesting is ok
ok()
endif
endif
// spacing doesn't matter:
output   (2+   8   - 1   )
loop             while(2<1)
neverhappened()
endloop


Should output:

executing endoftheworld
executing ifff
executing endifnot
10
excecuting ok
9


*Technically, once pseudocode follows rules as strict as those described here, it is arguably not pseudocode anymore. Wikipedia says it's called skeleton code.

Any suggestions?

I double-checked all the specifications, but if anything seems reasonably unclear, please let me know.

• Actually that's because the challenge is uninteresting. May 3, 2018 at 2:11
• @Akangka thanks for the feedback. How do you think it could be made more interesting? May 3, 2018 at 16:47
• Unfortunately, there is nothing to improve. You have to find other challenge. Also, it is not pseudo-code. May 4, 2018 at 3:03
• @Ok, thanks. I'll try to think of something. Also, read the *note. :) May 5, 2018 at 19:39

# Common Logic Gates

Given positive integer n, make a common n-to-1 gate with fewest input, i.e. make a function f: {0,1}k ↦ {0,1} with smallest k that, for each function g: {0,1}n ↦ {0,1}, there exists {ak}, such that each element ai in the sequence map to one of 0, 1, x1, x2, x3, ..., xn, satisfying that, for each {xn}, g(x1, x2, x3, ..., xn) = f(a1, a2, a3, ..., an).

Samples:

To make a common 1-to-1 gate, your circuit must take at least 2 input:

f(A,B) = A XOR B


For a buffer gate (g = x1 ↦ x1), let A=0 and B=Input (a1 = 0, a2 = x1); for a not gate (g = x1 ↦ ¬x1) , let A=1 and B=Input (a1 = 1, a2 = x1).

Alternatively, you can use f(A,B) = A AND NOT B. For a buffer gate, let B=0 and A=Input; for a not gate, let A=1 and B=Input.

To make a common 2-to-1 gate, the circuit must take at least 4 input bits: (The two inputs are represented as a and b)

f(A,B,C,D) = ((A AND B) OR (C AND NOT B)) XOR D

(ab)
00 01 10 11 A B C D
0  0  0  1  a b 0 0
0  0  1  0  0 b a 0
0  1  1  0  a a a b
0  1  1  1  1 b a 0
1  0  0  0  1 b a 1
1  0  0  1  0 a 1 b
1  1  0  1  0 b a 1
1  1  1  0  a b 0 1


Output can be an boolean expression with reasonable logic gates, or just the output corresponding to all possible input of the n-to-1 function f (the truth table of f). If there are more than one possible functions, you can output any of them.

Shortest code in bytes win.

Code that matches the requirement:

function solve(n) { // n positive int
var res = [], tmp=[], inmap=[], need=[];
for (var i=1; ; i++) {
for (var _res=0; _res<2**(2**i); _res++) {
var valid = 1;
for (var j=0; j<2**i; j++)
tmp[j] = Math.floor(_res/2**j)%2;
for (var _need=0; _need<2**(2**n); _need++) {
for (var j=0; j<2**n; j++)
need[j] = Math.floor(_need/2**j)%2;
var valid2 = 0;
for (var _inmap=0; _inmap<(n+2)**i; _inmap++) {
var valid3 = 1;
for (var j=0; j<i; j++)
inmap[j] = Math.floor(_inmap/(n+2)**j)%(n+2) - 1;
for (var j=0; j<2**n; j++) {
var bits = 0;
for (var k=0; k<i; k++) {
if (inmap[k]==-1 || (inmap[k] && (j>>(inmap[k]-1))%2))
bits |= 1 << k;
}
if (tmp[bits] != need[j])
valid3 = 0;
}
valid2 |= valid3;
}
if (!valid2) valid = 0;
}
if (valid)
res.push (tmp.slice());
}
if (res.length)
return res[AnyNonNegativeIntegerLessThan(res.length)];
// binary index input
}
}

function AnyNonNegativeIntegerLessThan(x) { if(R>=x) throw ("end"); return R;}
for (R=0; ; R++) { console.log (solve(1)); }

• You don't define what an n-to-1 gate is anywhere in your question.
– Wheat Wizard Mod
Mar 27, 2018 at 1:00
• @user202729 @user56656 n-to-1 gate means a gate with n input and 1 output. common n-to-1 logic gate mean a logic gate that can be used to replace any n-to-1 gate with some proper wiring. You can treat a logic gate as a ROM(so you can decide for each input what the output is)
– l4m2
Mar 27, 2018 at 1:15
• Output gates or ROM
– l4m2
Mar 27, 2018 at 1:25
• You should put the definitions in the challenge. "that can be used to replace any n-to-1 gate with some proper wiring" is still not very clear, you should define more carefully what you mean by proper wiring.
– Wheat Wizard Mod
Mar 27, 2018 at 3:22
• I assume you mean functions g: {0,1}^n -> {0,1}`, right? Why do you specify x_0 and x_-1? Shouldn't x just be a vector with indices 1,2,3,...,n? Mar 27, 2018 at 14:07
• Is {a_k} just a subset of {1,2,3,...,n}? Or can we have a_1=a_2=a_3=1 for example? Mar 27, 2018 at 14:09
• {a_k} seems not a multiset. It should be an array or say a sequence of numbers
– l4m2
Mar 27, 2018 at 14:43
• So you're asking for something which outputs answers to codegolf.stackexchange.com/q/24983/194 ? Mar 28, 2018 at 11:33
• @PeterTaylor No. it requires to use NAND gate to make up one circult that do the thing. Also 24983 is a 1-of-4 (74LS153), not a 4-to-1 gate common 2-to-1
– l4m2
Mar 28, 2018 at 12:41
• (+) Any reason for downvoting? Downvoting in the sandbox indicates that the challenge is incomplete, if you don't leave a comment the OP can't know what is wrong. Mar 29, 2018 at 4:48
• @user202729, there are already comments indicating that this question is going to attract close votes as unclear if it's posted to main in the current state. Mar 29, 2018 at 10:59
• @user56656 Are the issues fixed now? Mar 31, 2018 at 15:16
• @flawr Are the issues fixed now? Mar 31, 2018 at 15:16
• No I still think the explanation is quite bad and the notation is not very clear Mar 31, 2018 at 16:15
• A reference implementation is no substitute for a clear specification. The first paragraph is where you need to focus your efforts. Mar 31, 2018 at 19:32