# 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!

# An approximation for factorials of reals

One approximation for factorial function of reals is the following function:

$$\ F_0(x) = \lfloor x \rfloor ! { \lceil x \rceil } ^ { x - \lfloor x \rfloor } \$$

The function is less inaccurate for higher values of $$\ x \$$, meaning that you can get better approximations using the following recursive definition:

$$\ F_{n+1}(x-1)=\frac1x{F_n(x)} \$$

Examples:

$$\ F_0(\frac72)=3!\times4^{1/2}=12 \$$

$$\ F_1(\frac52)=12/\frac72=\frac{24}7 \$$

$$\ F_2(\frac32)=\frac{24}7/\frac52=\frac{48}{35} \$$

$$\ F_3(\frac12)=\frac{48}{35}/\frac32=\frac{32}{35} \$$

$$\ F_4(-\frac12)=\frac{32}{35}/\frac12=\frac{64}{35} \$$

Given non-negative integer $$\n\$$ and real (well, floating-point) $$\x>-n\$$, please calculate $$\ F_n(x) \$$.

This is , so the shortest program or function that breaks no standard loopholes wins!

Bonus brownie points for using your code to approximate $$\ \lim_{n\to\infty}F_n(-\frac12) \$$:

$$\ F_1(-\frac12)=2 \$$
$$\ F_2(-\frac12)\approx1.89 \$$
$$\ F_3(-\frac12)\approx1.85 \$$
$$\ F_4(-\frac12)\approx1.83 \$$
$$\ F_5(-\frac12)\approx1.82 \$$
$$\ F_6(-\frac12)\approx1.81 \$$
$$\ F_7(-\frac12)\approx1.80 \$$
$$\ F_{10}(-\frac12)\approx1.79 \$$
$$\ F_{18}(-\frac12)\approx1.78 \$$
$$\ F_{88}(-\frac12)\approx1.77 \$$

Posted

• Maybe consider order testcases simply from -4 to 16? (Without sorted on their output length) Also, maybe add some larger testcases (no need to list all possible solutions if there are too many. maybe you can show one possible solution, and answers need to having same length output) – tsh May 14 at 4:01
• @tsh I can add slightly bigger test cases, but there are no known efficient algorithms to calculate it, so I'm bounded by about 100 – Command Master May 14 at 4:14
• Okay, after larger testcases added, it is not equal to oeis.org/A056792 now. :) – tsh May 14 at 5:30
• I believe that one can construct the answer without brute force search. So don't worry about it bound. It is up to you to decide if brute force search is allowed: If allowed, you may say "your program should be able to calculate answers for |n| < 100, and your algorithm should apply to any size n in theory"; If not, you could say "your program should be able to compute up to $\pm 10^8$ in reasonable time (not time out on tio for example)" in the question. – tsh May 14 at 5:45
• @tsh from wikipedia: "the determination of a minimal addition-subtraction chain is a difficult problem for which no efficient algorithms are currently known" – Command Master May 14 at 5:47
• If i understand that statement correctly, it means an efficient (or polynomial) algorithms in $O(P(\log_2 n))$ is not exist. But A solution works under, say, $O(n)$ or maybe $O(n^2)$ is still possible. – tsh May 14 at 5:58
• Maybe, but I'm also not aware of any pseudopolynomial algorithm which solves it – Command Master May 14 at 6:01

# Convert version string to pack_format code-golf

Posted

• @Arnauld thanks, fixed – Command Master May 16 at 16:52

### Telephone Cipher Encoder

The telephone cipher is a relatively basic cipher originating from the book The Terrible Two. The cipher is explained here as follows:

Does this keypad (below) look familiar? It does? Good. You’ve seen a phone before.

Now, in the telephone cipher, there are two numbers for each letter. The first digit corresponds to the number on a telephone, while the second digit corresponds to the position on the key.

For example:

21 = A

Why? Because A is located on the number 2 on the keypad and A is in the first position of that particular key.

22 = B

B is located on the 2 key and is in the second position of that key.

53 = L

L is located on the 5 key and is in the third position on that key.

Given an input string s, the program should output the string encoded with the telephone cipher.

s may contain single spaces between words, but will not have leading or trailing whitespace and will use only lowercase letters a-z. s will always have a length greater than or equal to 1.

The output should contain no whitespace and be properly encoded with the telephone cipher as described above.

As an example, the following input:

hello world


Should result in:

42325353639163735331


All usual loopholes are disallowed. This is code golf so shortest answer in bytes wins. May the odds be ever in your favor!

• What about the evens? :P – Makonede May 18 at 21:15
• Back to the days mobile didn't have a touch screen, I typed 4433555 555666 instead of 4232535363 for hello... – tsh May 19 at 2:58

# Memory KoTH

Memory is a game where a bunch of pairs of identical cards are laid upside down, and you try to find pairs while only looking at two at a time.

In this KoTH, the way it will work is:

The game will be played on a 4096-item array, and the "cards" will be integers 0-2047.

Each bot takes its turn in order. It has access to the results of previous moves (Up to its previous turn), but their only storage is a single integer.

# Spec

The controller will be written in Javascript.

The bot has a move function, which must return two integers: The positions of both its guesses, in the form [g1, g2], where both are integers between 0 and 4095, and must not be gone already (see below).

The most recent move of every bot, including itself, in the form of an array of [g1,g2,r1,r2], where r1 and r2 are the first and second values revealed. The first item of this will be your bot's most recent guess, and the rest will be the other bots. This will be the global variable prev, and is readonly.

A picture of the entire grid, as a 4096-item array, left to right and top to bottom, where 0 means gone and 1 means still there. This will be the global variable grid, and is readonly.

An array of values that are gone. This will be the global variable gone, and is readonly.

A single ArrayBuffer(50), a 50-bit set of raw binary data. See the docs for help on how to access this. This will be the property this.storage, and can be used to store data.

Writing to globals is banned.

# Game

The bots will take their turn in a predetermined randomised order.

If a bot's moves are two tiles with the same value, those tiles are removed from the game area, and that bot gets a point.

The game ends when all tiles are gone, and the bot with the most points wins. In case of a tie, the bot that is last in the randomised order wins.

Bots should be a Javascript object like:

{
name: "A bot",
move(){
// insert code here
}
}


# Meta

Should I change storage limit or grid size?

• Shouldn't the bot be able to see the values of gone items? – Command Master May 15 at 9:03
• @CommandMaster True, will add. – A username May 15 at 21:02
• This doesn't really matter too much but if it were up to me, personally, I would change the storage limit from $[1,2^{50}]$ to $[0,2^{50}-1]$ so it's a bitstring of length 50 – hyper-neutrino May 18 at 6:10
• @hyper-neutrino Oh yes, that's what I intended. – A username May 18 at 6:11
• What if two bots tie? – StackMeter May 18 at 8:18
• @StackMeter The one that is last in the randomised order wins. I'll add that. – A username May 18 at 8:41
• Wouldn't it be easier to use a Uint8Array rather than a Bigint? Purely for ease of use. – EnderShadow8 May 20 at 12:51
• Also need to make it clear that writing to globals is banned, since that's a legal play right now – EnderShadow8 May 20 at 12:52
• @EnderShadow8 Yes, writing to globals is banned. – A username May 20 at 20:07
• @EnderShadow8 How would I format this Uint8Array? Like how many items would it need to be restricted to? – A username May 20 at 20:07
• Up to you. It's just a more convenient method of storing data that's a certain size. – EnderShadow8 May 20 at 23:32
• @EnderShadow8 Actually, I think a BigInt would be better for this challenge, as remembering a single tile is 23 bits, which would be confusing to fit into a Uint8Array. – A username May 21 at 4:22
• Just make it a plain ArrayBuffer and DataView. That's easier. I don't like using bit operations to extract data from integers. – EnderShadow8 May 21 at 4:42
• Are you considering giving the bot the result of its first guess before asking for its second? That would introduce a new layer to the strategy. Eg. explore on the first move and defend or attack on the second – EnderShadow8 May 21 at 5:04

# Calculate $$\ \lfloor n \log_2(n) \rfloor \$$, exactly

Given an integer $$\ 2 \le n \$$, you need to calculate $$\ \lfloor n \log_2(n) \rfloor \$$, assuming all integers in your language are unbounded.

However, you may not ignore floating-point errors - for example, in python lambda n:int(n*math.log2(n)) is an invalid solution, because for example for n=10**15, int(n*math.log2(n)) is 49828921423310432, while the actual answer is 49828921423310435.

## Test cases

2 -> 2
3 -> 4
4 -> 8
5 -> 11
6 -> 15
7 -> 19
8 -> 24
9 -> 28
10 -> 33
100 -> 664
1000 -> 9965
10000 -> 132877


10 brownie points for beating my 4 byte 05AB1E answer.

This is code golf, so the shortest answer wins. Good luck!

# Symmetrical Triangles, posted

## Meta Questions

• Dupe?
• More tags?
• Should I allow/disallow more output formats?
• Is "An equilateral triangle array" clear, or is there a way I can clarify it?
• Especially relevant test cases?
• Is there an easy way to take up less vertical space and still have a good amount of test cases?
• This might not actually be more clear, but I think you can describe it as "output w lists of sizes [1, 2, ..., w] of 1/0s such that the total number of 1s is equal to n and each sublist is a palindrome". – hyper-neutrino May 17 at 20:51
• – pxeger May 19 at 15:29
• @hyper-neutrino it doesn't have to have each sublist a palindrome to be symmetrical – pxeger May 19 at 15:30
• When I first read this, I thought that it only took one input n, and had to output a n-sized triangle with n 1s. Now I realise that the size is a different input, but I think it could be more interesting if n == w? – pxeger May 19 at 15:31
• @pxeger I don't think that makes it more interesting, especially since it removes the point of the challenge (arranging the 1s), by allowing them to be always placed at the bottom of the triangle. – Wzl May 19 at 15:34
• @Wzl ah, I didn't think of that – pxeger May 19 at 15:43

## Split a list into maximal equal-sum sections

• May I suggest limiting to digits 1-9 to allow interesting trickery? – pxeger May 31 at 18:58
• @pxeger Sure, I'll allow it. – hyper-neutrino May 31 at 19:00

# Prime Factorization - but on the exponents too

• There seems to be a stray double-quote here: "2^(2^2^2)*(3^2). Should it be removed, or should there be a matching one at the end? – pxeger May 28 at 8:57
• There shouldn't be in the output - it was just to show the string format – StackMeter May 28 at 8:58
• I've edited this down to a stub now that it's been posted to save space – caird coinheringaahing Jun 1 at 23:12

# Road golf through the mountains

• this is a horizontal-vertical version of the challenge, but there are no obstacles. I think this is novel enough. – Razetime Jun 4 at 9:18
• @Razetime And it has stricter rules. So is this good otherwise? – A username Jun 4 at 9:19
• Can answers use vertical tabs instead of space padding? Also, I'd suggest saying that "$n$ will be a positive integer", as "integer" could be zero/negative – caird coinheringaahing May 31 at 15:22
• edited: hopefully makes sense – PyGamer0 May 31 at 15:37
• We usually allow a wide range of I/O methods. It is recommended to rethink your I/O restriction (mainly because it will get downvotes if people think the I/O restriction is unnecessary). Also, is it allowed to print trailing spaces after the backslashes on each line, or a trailing newline after the last line? (I guess yes to the latter from your code, but it's always better to be explicit) – Bubbler Jun 1 at 4:34
• Strictly speaking, that line you are drawing actually has a length of sqrt(32). I think you should make it clear that the length refers to the number of non-whitespace characters. Also, "use a constant in your code" seems to be frowned upon as a method of input. – Recursive Co. Jun 1 at 15:57
• how is the length $\sqrt{32}$??? – PyGamer0 Jun 2 at 13:53
• Good challenge as a new user. – qwr Jun 2 at 14:14
• The challenge is easy enough that it should not be necessary for answers to explain themselves. Answerers will do this voluntarily if they think it is necessary. – qwr Jun 2 at 14:16
• @MaanasB pythagorean theorem. sqrt(4^2 + 4^2) = sqrt(32) – Recursive Co. Jun 4 at 17:36

# Combinatorial Pipes

You're a plumber working on a house, and there's some pipes that must be connected at odd angles. You have 8°, 11.25°, 22.5°, 45°, and 90° fittings at your disposal, and you want to use as few as possible to match the angle as closely as possible.

# Goal

• Match the desired angle as closely as possible, with as few fittings as possible. It can be over or under the desired angle.
• Accuracy is more important than the number of fittings
• In the case of two different sets of fittings with the same resulting angle, whichever has the fewest number of fittings should be selected.
• If the two sets use different fittings, match the same angle, and have the same number of fittings, either may be chosen.

# Input

Your input is a random integer between (non-inclusive) 0 and 180, which represents the desired angle.

# Output

Your output should be an array where [0]-># of 8° fittings, [1]-># of 11.25° fittings, etc. If your language does not support arrays, you may output a comma separated list, where the first value represents the number of 8° fittings, and so on and so forth.

Test Cases

90° ->[0,0,0,0,1]
24°-> [3,0,0,0,0] ([0,0,1,0,0] uses less fittings, but is less accurate and therefore incorrect)
140°->[2,1,2,0,1]
140°->"2,1,2,0,1" acceptable if language does not support arrays


# Scoring

Lowest byte count for each language wins a high five from me if we ever bump into each other (and the challenge).

## Sandbox Questions

Howdy! I feel like this could be an interesting golf, but I'm unsure if the language is clear and concise enough to get the idea across.

• Might be interesting to make it more general, give a list of possible pipe fittings as an argument? – rak1507 8 hours ago

# Decode USB packets code-golfbinarycoding-theoryencoding

Posted

• Does this not basically boil down to base-conversion? – pxeger Jun 9 at 12:59
• @pxeger Base conversion will not work. For one base conversion generally ignores leading zeros, while 00010 /= 10, so its not a bijection. But even if you ignore that it's nowhere near monotonic. 11 > 100 but f(11) = 10 < 11 = f(100). – Wheat Wizard Jun 9 at 13:25

# Shuffle a contiguous subset of a list code-golfarray-manipulationrandom

Idea shamelessly stolen from caird and rak1507

Shuffle a contiguous subset of a list of unique, positive integers randomly, given the start and end indices of that subset. For example, given the list $$\[A, B, C, D, E, F, G, H]\$$ and the indices 0 and 5 (0-indexed, with an exclusive end), you would extract the sublist $$\[A, B, C, D]\$$, shuffle it, and insert it back. Some possible results are $$\[D, C, B, A, E, F, G, H]\$$, $$\[D, B, A, C, E, F, G, H]\$$, and $$\[A, C, B, D, E, F, G, H]\$$.

## Rules

• Every possible rearrangement of the list should have a non-zero chance of being chosen.
• You may use zero- or one-indexing, but please specify which you use.
• You may also choose if the end indices are inclusive or exclusive.
• If the end index is exclusive, the start index is guaranteed to be less than the end index. Otherwise, the start index is guaranteed to be less than or equal to the end index (an empty subset). Both indices are also guaranteed to be within the bounds of the list.
• This is , so least number of bytes wins.

## Test cases

All of these use zero-indexing, and the end indices are exclusive.

List
Start,end
Possible output

[1,2,3,4,5]
2,4
[1,2,4,3,5]

[1,2,3,4,5]
[2,2]
[1,2,3,4,5] (only possible output)


## Questions for Meta:

• How do I enforce randomness?
• Is this a dupe?
• Is this uninteresting?
• Will it always be the case that the integers in the list are different? You should clarify or add a test case in which they are not. If they are not, there are several rearrangements that happen to be the same, so "equally likely" can be confusing. It's probably best to restrict the input to have different integers – Luis Mendo Jun 4 at 22:41
• @LuisMendo Yes, I should clarify that. – user Jun 4 at 22:41
• I don't see what value this challenge adds to existing shuffle challenges. It's just l[:a] + shuffle(l[a:b]) + l[b:] – pxeger Jun 12 at 13:35
• @pxeger I guess you're right :/. I'll try to think up a way to make it more interesting later. – user Jun 12 at 14:01

# Floating Point Prisoners Dilemma

## Background

So, nowadays the popular Prisoner's Dilemma variant is the Prisoner's Trilemma, where there are three options. I can easily see that being increased, so I figured

Why settle for three options, when we can have INFINITE options?

Therefore, I created the Floating Point Prisoner's ?Lemma.

## Technical Stuff

Create a bot that can play this Python implementation of the Prisoner's ?Lemma. Make two functions, strategy and plan, that are in a similar format as the below examples.

def strategy(is_new_game):
# Put Stuff Here™. is_new_game tells the function if it's a new game. returns a value between 0 and 1, where 1 = coop and 0 = defect, and in-between stuff correlates to probability of coop or defect.
def plan(opmove):
# opmove is the opponents move last round. This function shouldn't return anything. Put pass here if you don't use this.


## Forbidden Stuff

• Standard Loopholes are forbidden.
• No interacting with the controller other then by returning values in the strategy function.
• No interference with other bots (with global variables, other stuff) (You can have your bot interact with itself through global vars, for example, for communication)
• More stuff may be added

## Generic Stuff

Global vars are allowed. It uses an equation from the wonderful fellows at https://math.stackexchange.com to determine what to do, with the floating point numbers correlating to probability of coop or defect. However, the controller is deterministic in terms of the scoring stuff, and the probabilities are not treated as probabilities. The equations are in the play function in the controller.

## Example Bots

♫Coop Bop Bot♫

#Example Contestant
def strategy(is_new_game):
return 1

def plan(opmove):
pass


Random

#Example Contestant
import random
def strategy(is_new_game):
return random.random()
def plan(opmove):
pass


Controller is at https://github.com/4D4850/KotH-Floating-Dilemma

• Looks intriguing! How does each round work though? So one is coop, zero is defect, but what do the floats in between do? Look forward to hearing! – AviFS Jun 11 at 2:33
• It uses an equation from the wonderful fellows at math.stackexchange.com to determine what the in-between states should do. I'm bad at explaining, so the equations in my (probably horrible) code are in the play function of the controller class in controller.py – 4D4850 Jun 11 at 2:46
• @4D4850 Would you link to the question if you have it still? – math Jun 11 at 17:46
• It was actually closed, but here it is: math.stackexchange.com/questions/4152360/… – 4D4850 Jun 11 at 18:27
• Understood it now, good challenge! – math Jun 12 at 8:39
• You may want to say that now the floats inbeetween is the probability of coop or defect. That way it is more understandable, you see. The guy in math.stackexchange explained it too – math Jun 13 at 8:39
• @AviFS It is just the probability of coop or defect – math Jun 13 at 8:40

# Is there a left-right connection?

Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, but not diagonally. Every symbol on the path must be a 1, and it must start somewhere in the first column and end somewhere in the last column.

Shortest code in each language wins.

## Examples

000
111   ->  True
111

110
110   ->  False
110

101
010   ->  False
101

0     ->  False

1     ->  True

11110
00010
01110 ->  True
01000
01111

11110
00010
01100 ->  False
01000
01111


## Notes

The array may be represented in any reasonable form, such as a list of lists [[0,0,0],[1,1,1],[1,1,1]] or a string '000 111 111'. It can optionally be in transposed form (so that the roles of rows and columns are exchanged; equivalently the code can instead determine whether there is a top-bottom connection). Any two distinct symbols can be used in place of 0 and 1. The output can be in any truthy/falsy form.

New contributor
aeh5040 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

# Consecutive Distance Rating code-golfarray-manipulationinteger

Posted

• This is really neat! Simple, elegant, but nontrivial. It'd be interesting to look at the sum and its growth given an (OEIS) sequence. – AviFS Jun 12 at 1:25

# Square chunk my matrix

## I've Got The Key, I've Got The Secret

A cryptography challenge in 2 parts.

## Part 1

Implement a pair of programs in any language (the two programs could be in different languages if you wanted) to encode and decode a string of plaintext.

## Input and Output

The encoder must take the plaintext (and an optional key) and return an encoded string. The decoder must take the cyphertext (and an optional key) and return the plaintext exactly as it was given to the encoder.

## Restrictions

• The encoding and decoding code must be entirely implemented in the language - no libraries or cryptography functions may be used.
• The code (encoder+decoder) cannot be longer than 1024 characters.

The cyphertext.

## Output

The plaintext that generated the ciphertext.

## Scoring

I will upvote all answers to part 1 which have working encryption and have obviously made an attempt at golfing their answer.

In order to be eligible to win, an entrant will have to have taken part in both parts of the question. Overall score will be (length of shortest program that cracks your code-(length of encoder+length of decoder)). Highest score wins and winning entrant's entries will be accepted on both questions.

• The obvious place for this to fall flat on its face is if someone is able to implement AES or something similar within the 1024 character restriction. – Gareth Jun 13 '12 at 13:06
• Probably better if the methods of the part one programs are disclosed in non-obfuscated language, though with the short length restriction this may not be necessary. – dmckee --- ex-moderator kitten Jun 13 '12 at 15:23
• Forget AES: RSA is easily doable. That aside, you need to define "crack" in part 2. – Peter Taylor Jun 13 '12 at 15:35
• Also, it's not clear whether "optional key" means that it's optional to make the algorithm unkeyed (doesn't make much sense, I admit) or optional to supply it, in which case it uses a default key. – Peter Taylor Jun 13 '12 at 15:42
• @PeterTaylor I just put optional in to leave it up to the implementer whether or not they wanted to have the key input or hard-coded (or use no key). I'd have thought everyone would have the key input into their program, but I didn't want anyone to feel forced into it by the spec. Hmm, if RSA is doable within the character restriction I'll end up with a load of unbreakable codes which would make for a pretty crap part 2. By crack I meant cyphertext goes in, some time later plaintext comes out. Would restricting the character count further help, or is this question beyond help? – Gareth Jun 13 '12 at 16:05
• On that definition of crack, I can brute force for the length of the decoder plus a few bytes to iterate over all keys of the right length and some heuristics to check plausibility of the plaintext. The brute force cracker might even be shorter than the decoder if the decoder wasn't written in GolfScript... I think this question may be beyond help. – Peter Taylor Jun 13 '12 at 16:28
• @PeterTaylor Okay, thanks. I like the 'build your own - knock everyone else's down' aspect of this question though. I'll have to find another area where it could apply. – Gareth Jun 13 '12 at 16:34
• @Gareth I too like the competitive nature of this idea. I'm looking forward to a question with this plan in mind! – Gaffi Jun 13 '12 at 19:31
• I think it would be better to split this into a "cops" post and a "robbers" post. – wizzwizz4 Feb 16 '17 at 9:46
• @wizzwizz4 Wow, this is another blast from the past. I think this pre-dates the cops-and-robbers tag. I always seem to be ahead of my time. :-) – Gareth Feb 16 '17 at 9:49

# Countability of Sets of Finite Sets

The aim of this challenge is to code-golf a program which returns an iterator that will iterate over all possible non-empty finite sets of positive integers.

So if running long enough, this iterator should eventually touch on {1}, {2, 5}, {3, 6, 112} (ie none of these should occur "at infinity")

You may choose the order in which you iterate over these sets, but the order must satisfy the following requirement:

Under a particular ordering, if S is the i'th set to be returned by the iterator, then we shall call i the index of set S.

Let a restriction (k,T) be an assertion about a set S that says S has size k and T is a subset of S.

For a given restriction (k,T) and iterator IT, let the restricted iterator be the iterator which takes sets returned by IT and filters out sets that don't satisfy the assertion, iterating only over the ones that do. In other words, if IT iterates over the sequence of all sets, the restricted iterator iterates over the subsequence satisfying (k,T). Now if S is the n'th set returned by the restricted iterator, then we'll call n the restricted index of S with respect to (k,T)

Your ordering must satisfy the property that for any restriction there exists a polynomial P(x) such that for any set satisfying the restriction (with index i and restricted index n), i < P(n)

Note that the following ordering is not acceptable:

{1} {2} {1, 2} {3} {1, 3} {2, 3} {1, 2, 3} {4} {1, 4} {2, 4}...

This is the sequence that comes from counting 1, 2, 3, 4, 5, 6... and listing the set bits in the binary representation of each number.

This is because the restriction (1, {}) satisfies only the sets {1}, {2}, {3}, {4}... whose index i as a function of their restricted index is i=2^(n-1) which is not bounded by any polynomial

## Sandbox Questions

The reason for the strange requirement at the end is to disqualify any variants on the most natural ordering which simply counts upwards from 1 and enumerates the set bits in each number. In this ordering, the n'th set of length-one occurs at index 2^n which is non-polynomial.

I posted this problem originally, but didn't think of the obvious solution and so I left out the final restriction. I'd like to re-post it with the extra restriction. But first I'd like to know what people think. Is there a better way I can word that restriction or a more natural restriction I could impose instead?

• I don't understand the extra restriction, so I can't suggest a rewording, but I can say that it needs one. (In particular: what is k? And what function does T serve? Is it really a parameter of the property?) – Peter Taylor Jun 18 '12 at 8:25
• I don't understand it either. Maybe a sample of an ordering, satisfying the requirement, and another one, violating it, would help. – user unknown Jun 18 '12 at 15:31
• I understand the restriction now, although I haven't worked through the full implications. Does allowing T to be non-empty make a significant difference at all? – Peter Taylor Jun 19 '12 at 6:52
• I don't know. It may not. I guess the size part is the important part. I was just thinking that the ordering should be such that you run into all kinds of sets frequently. – dspyz Jun 20 '12 at 7:17

## The One with Two Parts

The aim of this challenge is to create a pair of functions which scramble and unscramble any given piece of text.

Part 1

In part one you post your scrambling function, along with the length in characters and language of your unscrambling function (but NOT its code). The length of the scrambler does not affect your score so you needn't golf it unless you want to. The two functions may be written in different languages if you wish.

Input/Output

The scrambling function should take one argument only - a string containing the input text - and return a string containing the scrambled text. The unscrambling function should also take only one argument - the scrambled text - and return the original text. The input text will be limited to characters in the ASCII set range from 0 to 127.

Part 2

In part two you try to beat your opponents' scores for their unscrambling functions. You MUST use the language they specify for their unscrambler in part one. Please give just one answer to this question containing all your unscrambling functions making it clear which question in part one each function unscrambles (maybe each answer in part one should give its scrambler a name for identification?).

Once the closing date (TBA) has passed all participants should post their unscrambling functions in their answer to part one to prove the length, language and functionality of their function.

Scoring The participants score will be calculated as follows: (unscrambler length from part one) - (shortest unscrambler length from part two). The participant with the lowest score wins and will have their answers accepted on both parts of the challenge. To be eligible to win a participant must have taken part in both parts of the question.

Example

In part 1:

• Bob posts a Python answer and says his unscrambler is a 165 character Python function.
• Fred posts a GolfScript answer and says his unscrambler is a 59 character GolfScript function.
• Joe posts a JavaScript answer and says his unscrambler is a 180 character PHP function.
• Jim posts a Ruby answer and says his unscrambler is 163 character Ruby function.

In part 2:

• Bob posts an 82 character GolfScript function to unscramble Fred's scrambled text. He also posts a 175 character PHP function to unscramble Joe's scrambled text.
• Fred posts a 181 character PHP function to unscramble Joe's scrambled text.
• Joe posts a 150 character Python function to unscramble Bob's scrambled text.
• Jim posts a 156 character Python function to unscramble Bob's scrambled text. He also posts a 91 character GolfScript function to unscramble Fred's scrambled text.

The scores:

• Bob scores 165 - 150 = 15
• Fred scores 59 - 82 = -23
• Joe scores 180 - 175 = 5
• Jim scores 163 - 0 = 163

so Fred wins.

Miscellaneous

I suggest that the closing date be two weeks after the challenge begins, and that unscramblers be posted to part one within 48 hours of closing date in order to be eligible.

• Are there any rules regarding scrambling? i.e. is "Stockholm"->"Stockhoml" a valid scramble? (it may not matter, but I'm curious. And to be clear, the scoring is the difference between your opponent's unscrambler length and your own for the same language? – Gaffi Jul 16 '12 at 16:39
• @Gaffi No, you scramble however you want. If you want to just output the text as given that's ok, but you probably won't win with that strategy. The aim is to do it in a way that is easy for you to unscramble but difficult for all the others. That way your score will be smaller. Yes, the score is the difference between your score and the score of the best of your opponents' attempts. I'll add an example to make that bit clearer I think. – Gareth Jul 16 '12 at 21:27
• I think this gives an advantage to people who use (relatively) obscure languages. If the scrambler is written in J and the descrambler in GolfScript then only people who know both can realistically attempt a descrambler. (NB the rules don't say how the score works if no-one attempts a particular unscrambler). – Peter Taylor Jul 17 '12 at 6:59
• I did consider saying that programs that had no attempts at beating them were not eligible to win, but then I thought that if they were scored as though the shortest attempt to beat them was 0 then they wouldn't have much of an advantage. I'll add that into the example scoring. What do you think? I want to encourage answers that are clever or well obfuscated rather than written in Malbolge or something like that. – Gareth Jul 17 '12 at 7:28
• Does it mean that since no one attempts to solve Jim's Ruby challenge his chances are minimal that he'll win? That would discourage complicated scramblers or difficult languages. – Howard Jul 17 '12 at 17:12
• @Howard As it stands, yes that's how it would work. The alternative, as Peter Taylor points out, is that people using obscure languages have an advantage. I'm not sure how else I might score unscramblers that no-one has attempted to beat. Maybe give them a score of 0? Please, if you or anyone else has any suggestions for making the challenge as inclusive as possible, let me know. – Gareth Jul 17 '12 at 17:51

## Compile BF to TM

Your task is to write a compiler accepting a Brainfuck program (previous challenge: Interpret Brainfuck, wikipedia: Brainfuck) as input and outputting a Turing Machine which produces identical output when supplied with the same (correct) input.

You may select the output format from among the various formats accepted by the answers to Turing Machine Simulator.

The following links may also be useful.
An introduction to programming in BF
BF is Turing-complete
Programming a Turing Machine
Programming Praxis: Turing Machine Simulator

Equivalently, you may write a Brainfuck interpreter in TM, or any partial compilation/interpretation which results in a TM program as described above.

If we consider squares of the TM tape to represent bits (blank=0, mark=1) of the BF memory, then eight squares represent a cell. Each BF instruction translates to a minimum of 8 states of the Turing Machine.

'>' "advance" (++ptr) could be implemented by eight states (sixteen transitions):

adv8 _ adv7 R _


where 'link' represents the first state of the following instruction.

'<' "rewind" (--ptr) can be implemented similarly by making leftward movements and rewriting the same symbol just read.

'+' "increment" (++*ptr) can be implemented by a ripple-carry from the Least Significant Bit to the Most Significant Bit, borrowing "rewind" states to back-up to normal position. If the LSB is on the left, it would look something like this:

inc8 _ link N 1
inc8 1 inc7 R _
inc7 _ rew1 N 1
inc7 1 inc6 R _
inc6 _ rew2 N 1
inc6 1 inc5 R _
inc5 _ rew3 N 1
inc5 1 inc4 R _
inc4 _ rew4 N 1
inc4 1 inc3 R _
inc3 _ rew5 N 1
inc3 1 inc2 R _
inc2 _ rew6 N 1
inc2 1 inc1 R _
inc1 _ rew7 N 1
inc1 1 overflow N 1


where overflow is a HALT state.

For I/O, the simplest way I can think is to place all input on the tape after the memory area, and expand the alphabet to include a symbol indicating the dividing line between the memory portion and the input portion of the tape. In fact, by expanding the cell size to nine squares, this symbol can serve as an input pointer, advancing as the input is consumed. (So "advance" and "rewind" now need 9 states each.) And another new symbol is written in front of the current memory cell to serve as the memory pointer. Inputting a byte therefore consists of schleping each bit over the entire space between the two tape positions with something like this:

input _ set-memptr L _
input 1 set-memptr L 1
set-memptr _ find-inptr R *
find-inptr _ find-inptr R _
find-inptr 1 find-inptr R 1
find-inptr $schlep-bit R$
schlep-bit _ schlep-blank L _
schlep-bit 1 schlep-one L 1
schlep-blank $schlep-blank L$
schlep-blank _ schlep-blank L _
schlep-blank 1 schlep-blank L 1
schlep-blank * deposit-blank R *
schlep-one $schlep-one L$
schlep-one _ schlep-one L _
schlep-one 1 schlep-one L 1
schlep-one * deposit-one R *
deposit-blank _ etc R _
deposit-blank 1 etc R _
deposit-one _ etc R 1
deposit-one 1 etc R 1


where "etc" represents going to get the next bit in similar fashion.

To perform a loop (all BF loops are "while" loops, so the exit control is at the beginning and the end has a simple goto back to the beginning), we need first to check is the current cell is zero,

zero8 _ zero7 R _
zero8 1 body R 1
zero7 _ zero6 R _
zero7 1 left1 L 1
zero6 _ zero5 R _
zero6 1 left2 L 1
zero5 _ zero4 R _
zero5 1 left3 L 1
zero4 _ zero3 R _
zero4 1 left4 L 1
zero3 _ zero2 R _
zero3 1 left5 L 1
zero2 _ zero1 R _
zero2 1 left6 L 1
zero1 _ exit-loop R _
zero1 1 left7 L 1
left7 _ left6 L _
left7 1 left6 L 1
left6 _ left5 L _
left6 1 left5 L 1
left5 _ left4 L _
left5 1 left4 L 1
left4 _ left3 L _
left4 1 left3 L 1
left4 _ left3 L _
left4 1 left3 L 1
left3 _ left2 L _
left3 1 left2 L 1
left2 _ left1 L _
left2 1 left1 L 1
left2 _ loop-body L _
left2 1 loop-body L 1
...
loop-body-final _ zero8 N _
loop-body-final 1 zero8 N 1


So assuming the machine starts at tape-location 0, and the input is on the tape starting at 0 and going to the right, the "startup code" for this arrangement would be

startup _ place$L _ startup 1 place$ L 1
place$_ left270000 L$
left270000 _ left269999 L _
...


Jeez! The output is going to be HUGE! It might be better to treat the BF memory as negative-indexed and reverse all the _L_s and _R_s in 'advance', 'rewind', 'increment', and 'decrement'.

Questions:

Bonuses for optimizations? If I can implement this myself and provide a complete example output, The bonus could be "subtract the difference between your program's output for the example input with the example output". So eliminating states would be far more valuable than shrinking the code. One could possibly achieve a negative score!

Edit: Actually I think this is unreasonable unless the Turing Machine is augmented with non-reading (movement-only or epsilon) transitions. Duplicating every letter of the alphabet just to move over one square is just ridiculously painful. That means this challenge won't link-up nicely with the other one. :(

What about, instead of implementing the compiler, just devise a translation scheme (as above) that leads to a smaller output for a trivial sample program (based on calculating, rather than coding)? "Back of the envelope" compiler.

• "How much detail on BF do I need to supply? Can I simply reference the BF question?" A link to almost any site that describes the language will do. – dmckee --- ex-moderator kitten Nov 5 '12 at 16:52
• Winning condition? – Peter Taylor Nov 6 '12 at 13:43
• "Longest prefix containing syntactically-correct Malbolge!" :) ... I'd say have none at all. Perhaps the questioner should be required to accept their own example answer? – luser droog Nov 6 '12 at 18:08
• @PeterTaylor Apologies for my last comment. I thought we were on my other answer about the [fun] tag. . . . This one would be a golf: shortest code by character count. But I think a clever system of bonuses could make it interesting. – luser droog Nov 7 '12 at 10:06
• The "Equivalently, you may write a Brainfuck interpreter in TM" option doesn't play very well with being a code golf - how are you going to count the length of the TM? – Peter Taylor Nov 7 '12 at 11:15
• @PeterTaylor Since the TM question specified 5-tuples, I think it's sufficient to count the tuples (== transitions). You can reduce states by increasing the alphabet (or vice versa), but the transitions would remain constant, I think. – luser droog Nov 8 '12 at 5:25
• I'd like to adopt (work on and post) this challenge if you don't want to. Would I be able to? If you do not respond to this message within two weeks, by community guidelines, I am allowed to take it over. – MD XF Aug 18 '17 at 3:23
• Yes, please. If you can do something with it, strike while the iron is hot. – luser droog Aug 18 '17 at 4:19

# Graphical Output -- Esoteric Artifacts -- The Glass Bead Game

## Draw the Cabalistic Tree of Life

Simply described, the Tree of Life is an undirected network of nodes representing the conduit between matter and higher forms of spiritual energy. It has an upper face arranged in a hexagon, and a lower fact built from equilateral triangles adjacent to the lower two edges of the upper face. Don't label the paths, paths may overlap however you wish, may be single (thick) lines, even. Code Golf. Bonus -100 for labels on the Sephiroth (nodes); Bonus -150 for Hebrew labels.

## Draw a Mandala for each Natural Number

Draw a circle with interesting visual patterns using the input N [ 1 .. \inf ) to determine the number of points around the circle to anchor figures whose shape is also modified by the input N. Actually, 12 seems like a good max: they're pretty much a blur after that no matter what.

//lotsoflines n = 1 ..12

(doesn't need to be this elaborate, This is >600 lines of showing-off.).

. . . need good images for these . . .

## Draw the Ptolemeic System of the Universe

All the stuff I could find is animated already. Maybe this one's done-to-death. :(

Update: Found good stuff on Alchemy. The "Keplar Platonic" model could be fun (3D and all). This one looks good, too. And this.

## Draw the Pythagorean Monochord

aka pre-classical nomogram. I misplaced my Pythagoras books, I know I've got a picture somewhere.

This is the one I was thinking of.

But I think this one's even cooler

## Draw the I-Ching Hexagrams in King Wen Sequence.

I suppose I need to implement this first to avoid copyright issues! :)

• The I-Ching one would have to be in standard order to be remotely interesting, and then becomes as much about kolmogorov-complexity as graphical-output – Peter Taylor Nov 22 '12 at 21:24
• For the others: images, please! – Peter Taylor Nov 22 '12 at 21:25
• I've emailed the owner of the Alchemy pages asking for permission to use his copyrighted images. Awaiting response. – luser droog Jan 28 '13 at 8:25

## Polygon prefixes

Polygons are named after the number of sides that they have. A pentagon has 5 sides, an octagon has 8 sides. But how are they named? What's the name for a 248-sided polygon?

All polygons are suffixed with -gon. There are specific prefixes for each polygon depending on the number of sides. Here are the prefixes for the lower numbers:

3 - tri
4 - tetra
5 - penta
6 - hexa
7 - hepta
8 - octa
9 - nona
10 - deca
11 - undeca
12 - dodeca
13 - triskaideca
20 - icosa


Polygons with 21 to 99 sides have a different system. Take the prefix for the tens digit (found on the left column), the ones digit (right column below), and then stick a "kai" between them to get (tens)(ones)gon.

20 - icosi       | 1 - hena
30 - triaconta   | 2 - di
40 - tetraconta  | 3 - tri
50 - pentaconta  | 4 - tetra
60 - hexaconta   | 5 - penta
70 - heptaconta  | 6 - hexa
80 - octaconta   | 7 - hepta
90 - nonaconta   | 8 - octa
| 9 - nona


The 3-digit sided polygons are named in a similar fashion. A 100-sided polygon is called a hectogon. Take the hundreds digit, find it on the column for ones digits, then stick a "hecta" to its right. Now number off the tens and ones like above: (hundreds)hecta(tens)(ones)gon. If the hundreds place digit is a 1, don't put the prefix behind "hecta".

So, given an integer (3 <= n <= 999), return the name of an n-sided polygon. n-gon is not a valid answer :P

As with all code golf, shortest code wins.

Is the description good? Would it be harder if I instead asked for the number of sides, given a name?

• What is a 101-sided figure called? "hectahenagon"? Is "hena" from the column for ones digits you mention? If so, then what is a 111-sided figure called? I'd say "hectaundecagon", but then that comes from a column where "hena" is not present. – Gaffi Feb 11 '13 at 11:15
• @Gaffi: Yep, it's hectahenagon, from what Google says. – beary605 Feb 11 '13 at 16:03
• I am going to take this if you allow me or if you don't respond – Christopher May 30 '17 at 1:13

## Self-Golfing Code?

I don't know if I just didn't search hard enough, but I couldn't find any challenge regarding self-golfing code, or rather, any code that can deterministically reduce another set of text code to a much smaller program, yet still compile/run.

For example, take this:

int main() {
std::cout<<"Hello world 1!"<<std::endl;
std::cout<<"Hello world 2!"<<std::endl;
std::cout<<"Hello world 3!"<<std::endl;
std::cout<<"Hello world 4!"<<std::endl;
std::cout<<"Hello world 5!"<<std::endl;
}


And output this (as one possible solution):

#define A std::cout<<"Hello world
#define B !"<<std::endl;
#define C B A
int main() {
A 1 C 2 C 3 C 4 C 5 B
}


Alternative:

Sub MySub()
Dim aNumber As Integer
Dim someString As String
aNumber = 123
someString = "abc"
MsgBox aNumber
MsgBox someString
End Sub


into (again, as one possible solution)

Sub m()
Dim a As Integer
Dim s As String
a = 123
s = "abc"
MsgBox a
MsgBox s
End Sub


Do we have a challenge for this?

If not, here are some rules I envision:

• Golfing code need not be in the same language as code to be golfed.
• Since compilers/running of code varies, newly golfed code must still run under same environment.
• Possible challenge scoring (multiple options -- thinking code golf):
• 1: Shortest golfing code wins (not my favorite, since you can minimally shorten the base code, yet still write the shortest program).
• 2: Shortest output of a set of pre-defined code (potentially limiting if participants are unfamiliar with the options available)
• 3: Combination of length of golfing code and the output result of the same as input. (Ratio, summation, etc.) -- This I think is my preferred option.
• 4: Multi-player Ratio of golfed size of other participants' own code versus their original submission. (Similar limitations to that of point #2.)
• Sounds more like an auto-golfer than obfuscation. Seems like it would be very hard to make it a fair contest unless you pick a language to golf, and even then it had better be a simple language (no platform dependency issues or compiler options). – Peter Taylor Feb 13 '13 at 15:15
• @PeterTaylor My examples are golfing, but either would work. Perhaps golfing would be simpler, then? I agree that the options for usable languages makes this a bit messy... Would one challenge per language be acceptable? (i.e. aligned with most challenges that are language-agnostic) – Gaffi Feb 13 '13 at 17:36
• Language-agnostic to mean means that you can write a program to do it in any language. Since the language to be golfed can be different from the submitted program, I don't see any incompatibility between making the problem "Write a program to golf Piet" and being language-agnostic. – Peter Taylor Feb 15 '13 at 0:18
• @PeterTaylor So then you see no problem with one question per language on which to operate? Are there any proposed scoring algorithms you particularly like/dislike? – Gaffi Feb 15 '13 at 12:02
• That depends on what you mean. If you're planning to post 10 questions at once, yes, that would be a problem. But I don't see a problem with posting a well-defined "Auto-golf Piet" and following it up two months later with "Auto-golf Perl 5". – Peter Taylor Feb 16 '13 at 10:19
• Scoring is an issue. The halting problem means that it's impossible to write an optimal solution, so the scoring must take into account how good the solution is. I think option 3 is the best, and you'll want a big test set (maybe a few kB taken from a real-world open source project) with coverage of the language features. – Peter Taylor Feb 16 '13 at 10:22
• Btw, your first example doesn't work. You can't have unmatched quotes in preprocessor directives. Don't know why. – MD XF Jan 13 '18 at 18:03
• I honestly think this would be fine if you did something like solely maco-golfing, making it somewhat language agnostic because of gcc -E. – Adalynn Nov 10 '18 at 14:36

## DeCSS

It is known that the DVD Content Scrambling System can be deciphered with a rather short program (434 bytes of C, 472 bytes of Perl). Can you do better?

<< Test cases go here >>

I don't plan to include a more detailed spec, because it will just wind up duplicating some of the code. The test cases would be in the form of (key, link to data file, md5sum of the deciphered stream).

• And the winning criterion is who is the first to get post from the courts? – celtschk Oct 3 '15 at 20:18
• @celtschk, I think that would be unfair. Winning criteria shouldn't really depend on where people live... – Peter Taylor Oct 10 '15 at 20:56
• I think you should at least explain the general concept of the spec. – Rohan Jhunjhunwala Aug 2 '16 at 22:53
• This actually sounds interesting. @PeterTaylor Perhaps you could use (and link to) Charles Hannum's explanation of the algorithm and post this. (It would be fun to have it as a popularity contest for a program that looks like it's nothing DeCSS related, or a program that furthers the gallery's point about the text vs source code arbitrary distinction - but I don't know if popularity contests are popular any more!) – sundar - Remember Monica Jun 25 '18 at 8:25

## Write a compiler/interpreter for ...

Inspired by the lisp challenge here.
It is a series of puzzles.

I don't like to see a simple eval solution, so:

• interpreting the language is fine
• translating the language to a different language is fine.

I think this is specific for each language.

Only the syntax and the basic commands.
Also specific.

Winning criteria should not be code golf.
The goal should be that you can "learn" an other language by looking at the code.

Languages that might be good candidates:

• Lisp
• APL
• J
• Whitespace
• Forth
• This only works for languages which are small and well defined. BF fits those criteria. Whitespace does too. The others may not. Lisp and Forth have so many dialects that you would have to specify exactly which dialect to support; Lisp, Forth, APL and J might have too many built-ins to fit in an answer: there are character limits. – Peter Taylor May 12 '13 at 15:16
• You don't have to provide all the built-ins, but that is why it is here. – Johannes Kuhn May 12 '13 at 15:38
• What defines the "basic commands"? – ASCIIThenANSI Aug 31 '15 at 17:54
• I don't know? Maybe that you can do the basic stuff with it like +,-,print,... – Johannes Kuhn Aug 31 '15 at 18:22
• I suggest a programmer can implement the tiniest subset of those languages in order to be Turing-complete, as these are non-trivial subsets that can theoretically simulate the rest of the language... – user85052 Jun 28 '19 at 4:17
• Which human is learning the programming language by looking at the code? – MilkyWay90 Aug 26 '19 at 3:23

# Missile Command

I'm making this CW, because it needs lots of help. I've been toying with this idea for a while. Think "battleship" to get in the right mind-frame. But, instead of ships, what you lay down are tiles which represent a Befunge-style program. This program controls the behavior of guided missiles ejected from the spawn tile. The goal is to program a missile which will obliterate an opponent's program block, as well as guard its own control block.

Haven't nailed-down the board size. 20x20 seems a little cramped.

         1         2
12345678901234567890
____________________1  4x20 program block
____________________2
____________________3
_______@____________4
....................5  12x20 arena
....................6
....................7
....................8
....................9
....................01
....................1
....................2
....................3
....................4
....................5
....................6
___________@________7  4x20 program block
____________________8
____________________9
____________________02


## Tiles

@ spawn

Program control.

I'm imagining these to change direction of the code for "boustrophedon" writing.

this,then\
txen,siht


haven't thought it all though, yet.

/

\

Movement.

F forward move forward one square

B back move back one square

L left turn left 90°

R right turn right 90°

So the submissions would be 4x20 code blocks which compete in a king-of-the-hill style.

• If this is deterministic, won't it be "Last person to submit their program wins"? – Peter Taylor Jun 7 '13 at 8:39
• That is a danger, yes. I'm hoping ways around it can be found. There could be a random operator. And proximity detection, or something. – luser droog Jun 7 '13 at 8:46

## Find all of the Scrabble numbers:

A scrabble number is a number n whose scrabble representation can score n points. As an example consider 12: its English spelling twelve has value 12 when it is placed on a stretch of six blank tiles. Since the highest ever reported 1 word scrabble score barely exceeds 2000 points, that will be the upperbound for this challenge.

Score and quantities for English:

2 blanks |  x1  |  x2  |  x3  |  x4  |  x6  |  x8  |  x9  |  x12 |
1    |      |      |      | LSU  | NRT  | O    | AI   | E    |
2    |      |      | G    | D    |      |      |      |      |
3    |      | BCMP |      |      |      |      |      |      |
4    |      | FHVWY|      |      |      |      |      |      |
5    | K    |      |      |      |      |      |      |      |
8    | JX   |      |      |      |      |      |      |      |
10    | QZ   |      |      |      |      |      |      |      |


Considerations for either bonus points to scoring or extra requirements:

• Respect the board, only using gaps between double/triple letter and double/triple word scores that occur on a standard scrabble board.
• Respect the tile count for each letter.
• There are non-English versions of scrabble, maybe it should be 'language-agnostic' (lol, but seriously is there a reason to accept only English submissions?).
• Should the 2 blanks be allowed?
• What about tiles which were already on the board and so wouldn't score anything? As for language: one approach would be to make it take the names of the tiles (and perhaps the values and counts of the letters) as input; this would also prevent the problem from being effectively one of Kolmogorov complexity. – Peter Taylor Jun 19 '13 at 22:50
• I don't believe that tiles on the board already would pose an issue. If you assume that the board may be prepared with any subset of the tiles beforehand (some may be impossible, but checking that is out of scope) all that is relevant to the problem is which are placed to complete the word. All the tiles points are counted, even the earlier placed, but only the new 7 (or less) tiles may qualify for triple/double-word/letter scores. w.r.t. kolmogorov, If I wanted to make it programming challenge instead of codegolf (so that isn't an issue) then there needs to be a scoring system right? – Kaya Jun 19 '13 at 23:33
• Yes, if it isn't codegolf then it needs a scoring system. I'm not sure what you could use as an alternative scoring criterion, though: it's simple enough logic that pretty much any implementation would be IO-bound, so speed doesn't work; and big-O based tends to be less straightforward than you might think. – Peter Taylor Jun 21 '13 at 11:05