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!

Sociable sequences

• You probably need to describe what a proper divisor is. Separately, I'm not sure how great requiring infinite output is. I'd probably consider allowing another optional argument that limits how many sequences to output? Nov 12 '20 at 19:47
• @FryAmTheEggman I've updated the challenge to be closer to the normal [sequence] I/O rules Nov 26 '20 at 15:23
• So is 25 a 1-sociable number, since its divisors sum to 6, and then there's a cycle?
– user
Jan 6 '21 at 21:04
• @user No, $25$ is not a $1$-sociable number. "They are numbers whose proper divisor sums form cycles beginning and ending at the same number". $25$'s "cycle" is $25 \to 6 \to 6 \to \cdots$, which does not begin and end with the same numbers. I'll edit that in though Feb 22 '21 at 17:50
• That "begin and end at the same number" is unclear. (it's a cycle, it neither begins nor ends) Perhaps "the initial number is inside the cycle". Feb 24 '21 at 4:30
• Should that "given value" be interpreted as "value that will be given as input"? Feb 24 '21 at 4:31
• That "does not diverge" sounds like a terribly hard conjecture... EDIT indeed it is. en.wikipedia.org/wiki/Catalan%E2%80%93Dickson_conjecture ("likely false"), and looks like that the sequence you came up with already have a name. Feb 24 '21 at 4:32
• with that, it's problematic, you'd better specify that "If there are $n$ such numbers, the answer must provably finish printing them all without assuming the conjecture" -- although for most approaches it isn't that hard. Feb 24 '21 at 4:38

Write an interpreter generator

• Can an input contain one or more operations? like a + 1 - 4 * 8? Is input guaranteed to be valid? Mar 22 '21 at 17:11
– user100690
Mar 22 '21 at 17:12
• Another suggestion, you might make it a code-challenge, where the objective will be to generate as short output as possible (Which means to golf the generated interpreter as much as possible), where the original source code length will not matter, so people can work for their code more peacefully, But code-golf (original challenge) one is good too. Mar 22 '21 at 17:14
• @Wasif hmm... not a bad idea at all. This challenge does seem more effective with the code-challenge tag, I will edit that into the answer.
– user100690
Mar 22 '21 at 17:17
• @Wasif on second thought, I'm not really sure how you would actually test the length of the output... it would not be fair for one answerer to test with a 100-command language while another tests with a simple 1-command language. Thanks for the suggestion, but code-golf seems like the better option for now.
– user100690
Mar 22 '21 at 17:19
• OK, also how would handle destructive input like a / 0, which attempts to divide the accumulator by 0, which would result into crashing the interpreter? Mar 22 '21 at 17:22
• the input is valid doesn't seem like a good enough description, let me change that
– user100690
Mar 22 '21 at 17:22
• "each command is one letter long." so, highest number of inputs are 26? Mar 22 '21 at 17:33
• Can we pre-define the input array in the header section of Try It Online? Mar 22 '21 at 17:35
• @Wasif yes, that can be inferred from that fact. Not sure what the header is, because I don't really use tio
– user100690
Mar 23 '21 at 6:23
• Header section means the part where you write code, is not added to the byte count. Mar 23 '21 at 6:52
• Let us continue this discussion in chat. (Automatically comments were moved there because lengthy conversations cannot be run in comments) Mar 23 '21 at 6:52
• I've edited this to a stub now that it's been posted Mar 23 '21 at 15:40
• @ChartZBelatedly thank you, forgot to do that
– user100690
Mar 23 '21 at 16:05

Keep PPCG running in Game of Life

• "Minimally destroying CGCC", "Keep PPCG running". Hmm, someone doesn't like the name change :). May I ask why you have this proposal too, though?
– user
Mar 22 '21 at 19:24
• @OriginalOriginalOriginalVI Because the two tasks are different, and I very much doubt answers to the two will be trivially similar Mar 22 '21 at 19:38
• Right now you could just place a glider in the box and it would run forever. Maybe redefine 'fixed position'? Mar 23 '21 at 8:16
• @Ausername "If any spaceships or patterns of infinite growth are generated, the board will never reach a "fixed state" and such cases are invalid submissions." A glider is a spaceship Mar 23 '21 at 13:13
• Oh ok, didn't see that bit. Mar 23 '21 at 19:37

Limit of lists code-golf

You're given a never-ending sequences of lists, each of which appends some number of values to the end of the previous one. That is, each list is a prefix of the next.

3
3,1,4
3,1,4,1
3,1,4,1
3,1,4,1
3,1,4,1,5,9,2,6
...


While some steps may leave the list unchanged, its length grows unboundedly, giving an infinite list in the limit. Your goal is to output this infinite list.

Note that you can't know a-priori how many lists you must read to get, say, the 5th value in the infinite list, just that you'll eventually hit a list with 5 or more elements.

Input and output:

The list elements are digits 0-9. You may treat them as characters if you wish.

The input and output are both infinite lists. These can be represented in various ways, and may be different for the input and output.

• An infinite list or stream
• A stateful method or black-box function that produces a new value with each call
• Repeatedly reading from STDIN or writing to STDOUT, or file buffers or the like

A mapping from index to value isn't allowed for input or output. The output must be uniform, without chunks of digits grouped together.

Sandbox: Infinite list I/O is hard. Any suggestions?

• "Your goal is to output this infinite list" - can you clarify that it's by taking later elements from the lists that get later and later in the input list - I had to read this several times to understand that. Also, while I don't think there's any getting around the infinite input requirement, perhaps you could change the output to standard sequence rules to make it more flexible? Mar 27 '21 at 18:04
• Is the first list guaranteed to be one element long? Or can it be any length? Can it (and any subsequent lists) be empty? Mar 27 '21 at 18:09
• You should probably specify the intermediate output/s needs to be as soon as it's available from the input infinite lists, or at least in finite time, so noone can submit tail -1 Mar 27 '21 at 18:21

• Yay, a lisp challenge! Does each 'a' mean a car and each 'd' a cdr?
– user
Mar 24 '21 at 21:56
• @OriginalOriginalOriginalVI yeah, but I'm to lazy to have written a description in english so far. I guess I'll get to it eventually :P Mar 24 '21 at 21:58
• Fortunately the common lisp hyperspec already describes the bulk of it well. Mar 24 '21 at 22:22
• You might want to make the reference implementation a link to TIO (unless it doesn't work on TIO, of course)
– user
Mar 24 '21 at 22:23
• @OriginalOriginalOriginalVI Why? (I can't access TIO anyway) Mar 24 '21 at 22:25
• Meh, I just don't like those code snippets, and it makes it easier to pull out of the question, modify the input, and stuff. These code snippets sometimes break for me. If you can't access TIO, though, it doesn't matter, of course.
– user
Mar 24 '21 at 22:26
• posted Mar 25 '21 at 15:04
• I've edited this down to a stub now that it's been posted Mar 28 '21 at 14:01
• It's unclear what kind of expressions we have to deal with, but it looks good, and interesting . E.g. do we have to handle expr |> function(with_one_parameter)? Mar 25 '21 at 15:27
• @Wezl I was thinking the expression could be anything with printable non-whitespace ASCII but I realize now that could be problematic. I'll change it to be more restrictive. Mar 25 '21 at 15:30
• @Wezl I specified that you may assume all functions will take only one parameter, so you do not have to handle expr |> function(with_one_parameter). Mar 25 '21 at 15:39
• Why do some piped expressions have () and some do not? Are we meant to support both of these? Mar 26 '21 at 4:45
• @Ausername It's to demonstrate that both are valid, but as I state in the rules you need only support one convention. Mar 26 '21 at 13:17

What's my TIO uniqueness?

– user
Mar 23 '21 at 20:59
• Maybe you could say "undefined" instead of 0 in the sentence "The TIO uniqueness of a language for which this is impossible is 0". Also, do you want submissions to store all 680 language names in the code? Mar 24 '21 at 23:58
• @Bubbler Changed to undefined, it fits better. Yes, submissions should have some way of storing the names, be it in an external file or in the program itself etc. Mar 25 '21 at 0:02
• @FryAmTheEggman Given that there are 680, I think it may be impractical to include the full list in the question, which is why I linked to this gist with all languages and their outputs Mar 25 '21 at 0:20
• Ah, sorry, I missed the link. Mar 25 '21 at 3:44
• "subsequence" tag? Why?
– tsh
Mar 29 '21 at 8:58
• @tsh Because the TIO uniqueness depends on the shortest substring that isn't common with any other language Mar 29 '21 at 18:49
• but substring is not subsequence
– tsh
Mar 30 '21 at 0:32
• @tsh No, but [substring] isn't a tag, and [subsequence] is the best alternative Mar 30 '21 at 21:37

• You should generally include the definition of things like this directly in the challenge rather than just linking to a Wikipedia article on it, so people don't have to go to an external site Apr 8 '21 at 8:42
• I think it would be clearer if you used boolean true/false for "is this valid", rather than "invalid" vs "valid". You might also want to change classification to decision-problem Apr 8 '21 at 8:46
• @pxeger Thanks. Included both suggestions. Apr 8 '21 at 15:55
• Is this means the input should always be a string / list of characters? May I take input as an array of 4 integers / a 32 bit unsigned integer / a built-in type for IP address (if there is one)?
– tsh
Apr 13 '21 at 3:57

Interpret control characters like a terminal

• As "your program does not need to interpret backslash escape sequences - the input will contain the literal control codes themselves.", I'd suggest actually including the characters in the test cases, or at least including a TIO link (or pastebin etc.) with the literal characters Apr 12 '21 at 13:14
• @cairdcoinheringaahing \r isn't really usable on the web because it will be converted to a newline, and most languages have their own literal syntax for entering those characters anyway, so I think it wouldn't really help Apr 12 '21 at 13:18
• Suggest a aaaaaaa\b\b\b\t case, do TAB fill them space?
– l4m2
Apr 15 '21 at 4:17
• @l4m2 thanks - that helped me discover some subtle bugs in my reference implementation too Apr 15 '21 at 9:01

A Self-Referential Sentence

The Story

One day, you decide that you want a sentence that tells you where in the sentence the letter T occurs (excluding whitespace and punctuation). Out of curiosity, you try to make one. Messing around a little you get

T is the first, fourth, eleventh, sixteenth, twenty-fourth, ....

Oh dear, this sentence appears to run forever. But you now think you have an interesting number sequence, so you slap it into the OEIS search bar and lo and behold you find sequence A005224, Aronson's sequence. And better yet, an interesting code-golf problem that no appears to have posed before!

Your task is to write a program that takes in a single positive integer, n, as input and gives the position of the n-th "t" in the above sentence (indexing begins at 1 for the sake of this problem). For example, an input of 1 should return 1, while 2 should return 4. The input number will not exceed 4 decimal digits in length (i.e. the maximum input is 9999)

As always, the shortest code in bytes wins, and standard loopholes apply.

The Meta

Ok, so I have a couple of questions, since this my first sandbox post.

1. What can I do to flesh out this problem? This seems short, especially for a CGSE prompt. Should I somehow flesh out the heading fluff? Or should I add something more to the task itself?
2. I was pretty thorough in my search of the sandbox and main site for similar problems, but I could always have missed something, so please let me know if this is a duplicate.
3. Is the 4 digit input limit reasonable? Should I raise it or lower it? Remove it entirely? Since I'm not providing a file with ordinal strings, it seems like having a restriction on the size of the input is quite important.
4. Finally, please let me know if there's any other glaring problems in this prompt, this is both a first draft, and my first attempt at a code-golf prompt (since high-school).
• Nice first challenge! I'd suggest following the standard sequence I/O rules and allowing programs to output either the first $n$, the $n$th term or all terms. Additionally, forcing 1-indexing (for the sequence) doesn't improve the challenge any more than allowing either 0 or 1 indexing. I cannot find any challenge that could be a dupe through some searching, so this looks to be 100% original. Finally, I'd recommend including either test cases or the first 10 or so terms in the challenge body Apr 24 '21 at 16:21
• @cairdcoinheringaahing 1-indexing is fundamental to the recursive definition of this sequence, as “T is the zeroth, third, tenth, twelfth, seventeenth, twentieth, …” is quite a different sequence (not just off by one). Apr 25 '21 at 18:25
• @AndersKaseorg I meant 0 indexing in the input, not in the position of the T (e.g. n = 0 would output 1, n = 1 would output 4, etc.) Apr 25 '21 at 18:27

diddly darn posted

• Tag chess? Apr 12 '21 at 6:43
• My god, this is amazing. I can't wait to see the full version! Apr 12 '21 at 9:48
• It's not clear to me what should be output in the non-deterministic cases. Do we have to output all possibilites?
– kops
Apr 22 '21 at 23:35
• Addtionally, what do you want the result of this to be: ,v, \n >,A \n ^<B (pastebin; is multline code possible in a comment?) Rules as written I think it's a tie since the center cell is reached twice but it's not clear this is desirable.
– kops
Apr 22 '21 at 23:37
• @kops it's okay for the board to result in a tie. Apr 22 '21 at 23:43
• And the point is to output the result of the board, which may not be deterministic Apr 22 '21 at 23:43
• So each possibility has to be output with the correct probability in the non-deterministic cases? And for the specific board in my second comment, it's very much morally an A victory, not a tie, but the technicality of passing through the same cell going in different directions makes it a tie in these rules which I find a bit weird.
– kops
Apr 22 '21 at 23:46
• @kops no it is not the probability but the result of running it once. That result may vary. And even though that may seem like it should be a win for A, it could be the result of some clever play from B to trick A into thinking they've won Apr 22 '21 at 23:50
• @Lyxal I didn't mean to say the probability itself should be output, but that for each possibility, the probability of that possibility being output has to be correct?
– kops
Apr 22 '21 at 23:56
• @kops you only ever output one result - the winner of the game when evaluated. Because there are commands that change the direction, it can be impossible to 100% tell who wins. I was simply pointing out that there is more than one possible output for such boards. Apr 22 '21 at 23:59

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 '21 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 '21 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 '21 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 '21 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 '21 at 15:57
• @pxeger I've changed it, and I agree. Apr 25 '21 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 '21 at 18:12
• Just a note: the last 3 characters can't be either Q or I May 1 '21 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 '21 at 19:37
• There's a Q in the alphabet for the first letter, but then you say the alphabet, minus IJQTUXZ. May 5 '21 at 18:13
• @Arnauld yep, that shouldn't be there. Too much muscle memory from typing the alphabet correctly I guess :þ May 5 '21 at 19:15

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 '21 at 22:00
• Why is ([(] invalid but [(] is not? Will there ever be multiple ] in a row? Jun 1 '21 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 '21 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 '21 at 22:10
• @DJMcMayhem yes. Should I add that to the question for clarity? Jun 1 '21 at 22:12
• Yes, I think that would help. Jun 1 '21 at 22:17
• Not sure if lisp tag is appropriate, because the challenge itself doesn't have to do with lisp.
– qwr
Jun 2 '21 at 14:43
• Tag: balanced-string? Jun 3 '21 at 10:47
• @pxeger nice tag-finding skills :) I'll add that. Jun 3 '21 at 13:04
• @qwr How else do I get the tag badge :P Jun 3 '21 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 '21 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 '21 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 '21 at 6:48

Write a C++ demangler

• Is _ZN3foo3barE3baz -> foo(bar)::baz valid?
– tsh
Jun 7 '21 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 '21 at 14:27
• Won't foo::bar::baz be _ZN3fooEN3barE3baz or _ZNN3fooE3barEbaz?
– tsh
Jun 8 '21 at 6:14
• No, nested namespaces are placed together without a separator. Jun 8 '21 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 '21 at 23:55
• I've edited this down to a stub now that it's been posted to save space Jun 17 '21 at 20:30

Create word lightning ascii-artstringtree

Posted

• Trees can be taken in different formats, right? May 14 '21 at 13:35
• yes, they can be taken in any suitable format. May 14 '21 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 '21 at 12:14

Splinter metagolf

• An example for a short repetitive string would be nice Jul 12 '21 at 9:42
• @pxeger Ok, I'll have a look. Jul 12 '21 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 '21 at 8:30
• @pxeger that's a good idea Jul 14 '21 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 '21 at 23:59
• @user Done, thanks. Jul 21 '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 '21 at 11:05

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 '21 at 16:10
• are we validating or executing(akin to the gelatin challenge)? Sep 3 '21 at 7:52

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 '21 at 2:48
• @ngn Depends on what I come up with. May 26 '21 at 3:04