# What is the Sandbox?

This "Sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to the main page. This is useful because writing a clear and fully specified challenge on the first try can be difficult. There is a much better chance of your challenge being well received if you post it in the Sandbox first.

See the Sandbox FAQ for more information on how to use the Sandbox.

## Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

# Bucket and Minimize

Post here

• @FryAmTheEggman thanks for the info. updated – scrawl Jan 21 at 9:40
• "floor(12%5)+1 into 12 mod 5 buckets, and floor(12%5) in the rest". Shouldn't those floor(12%5) be floor(12/5) based on your $\left\lfloor\frac{|L|}{N}\right\rfloor+1$ formula? – Kevin Cruijssen Jan 22 at 10:40
• @KevinCruijssen er, yes. keeping things conventional. in my preferred language (k4) % is float division. i'll update it to avoid confusion. thanks! – scrawl Jan 22 at 12:27
• Ah ok. In most languages I know % is modulo and / is division. :) I thought maybe % was integer-division in your language of choice, making the floor obsolete. But your edit is indeed clearer. – Kevin Cruijssen Jan 22 at 12:47
• I would recommend cleaning the body of this answer and linking to the actual challenge: codegolf.stackexchange.com/q/198406/75323 – RGS Feb 2 at 21:07
• @RGS cleaned up – scrawl Feb 2 at 23:55

Posted to main; thanks for input provided!

• this looks perfect for fastest-code. with fastest-algorithm it's difficult to do complexity analysis on the solutions. – ngn Jan 4 at 23:53
• @ngn thanks, I’ve amended the alternative suggestion – Nick Kennedy Jan 5 at 0:23
• it may be good to mention explicitly that all blocks must form a single connected component, otherwise 2 separate 1x1x2 pieces would technically satisfy rules 1-4 – ngn Jan 5 at 1:47
• Is this basically $a_n = \sum_{i=1}^n polyminoNumber(i)\cdot i^{n-i}$? – the default. Feb 3 at 14:56
• @mypronounismonicareinstate no it's not, though it is related to the polyomino numbers. I've posted to main (sorry for not updating Sandbox post), so please see there for two implementations of code. – Nick Kennedy Feb 3 at 17:35

# Parse Iota

Iota is a simple programming language, considered the "sister" of the language Jot. More info can be found here Every Iota program consists of either an i, or a * followed by two Iota programs. In BNF, this is:

iota ::= i | *<iota><iota>


# Challenge

Your task is to, given any input, output a truthy or falsy value based on whether or not it is a valid Iota program.

• Your program may take input in any form agreed upon by the community here. It just has to be able to take input from the user in some form.
• The same rule goes for output. See the post above for valid output methods. Output may be any truthy or falsy value in your language, including integers, strings, arrays, or objects. If it can be converted to a Boolean, it is OK.

# Example I/O

Input: i
Output: 1

Input: hello
Output: 0

Input: *i*i*ii
Output: 1

Input: i*i
Output: 0

Input: ***
Output: 0

Input: *
Output: 0

Input: iiiiiiiii
Output: 0;

Input: i
Output: 1

Input: *ii
Output: 1

• Suggested test cases: *, ***, iiiiiiiiiii – 79037662 Feb 12 at 23:27
• Ok, I added those @79037662 – sugarfi Feb 13 at 0:37
• I don't get how i*i*i*ii is produced. If I understand the grammar right, this is equivalent to checking if parens are matched after removing the final i that must come at the end, using *i as (). – xnor Feb 13 at 7:12
• @xnor - sorry, my bad. i fixed that. – sugarfi Feb 13 at 12:02
• I think that despite the different presentation, this would be similar enough to checking paren matching to be a duplicate. – xnor Feb 14 at 11:22

# The uniquely solvable sudoku code-golfdecision-problem

Given a standard 9x9 sudoku board, output a Truthy value if that sudoku admits one and only one solution. Output a Falsy value if the sudoku has a number of solutions other than one. This means 0 solutions and two or more solutions.

# The input

The board can be given in any sensible format. Some come to mind, and I'll exemplify for a 4x4 sudoku.

• a 2D array with the state of the board, with any placeholder value for non-filled cells (including the digit 0, or no value at all if your language supports it): [[1,2,#,4],[#,4,1,2],[2,1,4,#],[4,#,2,1]]
• a string of the digits row by row or column by column, so "12#4#412214#4#21" or "1#24241##14242#1"

# The output

A Truthy value if the sudoku puzzle has a unique solution, Falsy otherwise.

# Test cases

### Falsy

• Hmm, I'm surprised this isn't a duplicate with the amount of Sudoku-related challenges we have. Closest related challenge I could find is perhaps this one. – Kevin Cruijssen Feb 18 at 16:21
• @KevinCruijssen Thanks for your search! I can link this one, but this is still a new challenge, right? :) – RGS Feb 18 at 17:44

## Square Deltas code-golfsequence

Given an strictly positive integer n, output all numbers in the sequence up to the index n. For the current test cases of the current challenge numbers are one-indexed. However, other formats are allowed as default.

## Base sequence

We start from this sequence:

1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, ...


The sequence is described as follows: 1, 2 (xN), 1 repeated arbitary times. There are 2 more 2's than the previous 2-set, and the 2-sequence starts at 1. i.e.:

1,       2,       1,
1,    2, 2, 2,    1,
1, 2, 2, 2, 2, 2, 1,
and so on ...


However, our point is not to output this sequence. For every item in this sequence, add the item by that item of that sequence.

Here's an example of adding the sequence. Here, our sequence starts with 0:

  The sequence
|
v
0 + 1 = 1
1 + 2 = 3
3 + 1 = 4
4 + 1 = 5
...

Our generated sequence is therefore

0, 1, 3, 4, ...



## Example test cases

Here is a sample program outputting the sequence up to the input.

3 -> [0, 1, 3]
10 -> [0, 1, 3, 4, 5, 7, 9, 11, 12, 13]


## Sandbox

• Can the challenge be clarified?
• Why is the task asking for infinite output after index n, rather than a standard sequence challenge? A "standard sequence challenge" usually allows several I/O formats in a single challenge, including "input n -> the number at index n", "input n -> first n numbers", "no input -> infinite output of the sequence". – Bubbler Mar 6 at 4:49
• No, you don't need to make it harder. And even if it is too easy, please don't try to fake up the difficulty by enforcing unnatural I/O requirements. – Bubbler Mar 6 at 4:56
• Are you sure that you want to override the default sequence IO? Do you actually have a good reason for doing so? – Jo King Mar 12 at 4:36

## Pendulum Encoding code-golfarray-manipulationsorting

Given an array as an input (which can be any acceptable/convenient format in your language), implement pendulum encoding.

## How do I do that?

The current iteration index starts at 0.

• If the iteration index is even, append the current item onto the output list.
• If the iteration index is odd, prepend the current item onto the output list.

## An example

The input is [a b c d e f g].
Note that the letters a-g are atoms, to prevent confusion from the iteration index.
N: the iteration index

N:0 Out:      [a]
N:1 Out:    [b a]
N:2 Out:    [b a c]
N:3 Out:  [d b a c]
N:4 Out:  [d b a c e]
N:5 Out:[f d b a c e]
N:6 Out:[f d b a c e g]


The output should be [f d b a c e g].

# Another example

The input is [u d l n u e m p].

N:0 Out:        [u]
N:1 Out:      [d u]
N:2 Out:      [d u l]
N:3 Out:    [n d u l]
N:4 Out:    [n d u l u]
N:5 Out:  [e n d u l u]
N:6 Out:  [e n d u l u m]
N:7 Out:[p e n d u l u m]


## Test cases

Here's a sample program doing this encoding.

Take note that the atoms in the list aren't always unique.

[a,b,c,d,e,f,g]   -> [f,d,b,a,c,e,g]
[]                -> []
[a]               -> [a]
[a,b,c,d]         -> [d,b,a,c]
[a,b]             -> [b,a]
[a,b,d]           -> [b,a,d]
[a,b,a,c,b,c]     -> [c,c,b,a,a,b]
[a,a,b,b,c,c]     -> [c,b,a,a,b,c]
[u,d,l,n,u,e,m,p] -> [p,e,n,d,u,l,u,m]

• I can't see any issues with this challenge apart from the usual "make sure that you specify that output and input can be taken in any reasonable and convenient format". – Lyxal Mar 18 at 0:00
• The "example" in the first paragraph is confusing. It seems to be example input, but it deson't have clear context. If feels very out of place. – Wheat Wizard Mar 20 at 15:16
• Are the "atoms" unique? If not, you should at least include a test case where they aren't. – FryAmTheEggman Mar 20 at 20:20
• Naming a generic array a, then redefining a as a generic atom and never referring to the original array is not very helpful in an explanation. – Jonathan Frech Mar 21 at 0:09

## Join by intersection code-golfstring

Given a list of strings, output these strings joined by their largest intersecting parts. Your output has to be optimal. Strings have to be joined in the order given.

## What is an intersection anyway?

Suppose you have two strings:

"abcbc" "bcbcd"


You extract all suffixes of the first string, as well as all prefixes of the second string:

["abcbc", "bcbc", "cbc", "bc", "c"]
["bcbcd", "bcbc", "bcb", "bc", "b"]


We trunctuate both of these lists to the length of the list of the smaller length (it's an identity in this current case).

Then, we find all items at the same index which are equal to the other item at the same index:

["bcbc", "bc"]
["bcbc", "bc"]


We return the longest string of the output. Therefore, the intersection is:

"bcbc"


## How to join two strings by the intersection

To join by the intersection you simply

1. Append the first string without the intersection to the output string
2. Append the intersection to the output string
3. Append the second string without the intersection to the output string

For example, in our example case:

"abcbc" "bcbcd"
(The intersection is "bcbc")

Step 1. Out:"a"
Step 2. Out:"abcbc"
Step 3. Out:"abcbcd"


## Reducing a join over a list

If you want to reduce a join over a list

["abc","bcd","rfh","hal"]


You connect them by their longest common substring:

abc
bcd
rfh
hal
=========
abcdrfhal


Therefore the expected output is abcdrfhal.

## Further walkdown

You cannot join two strings if their substring can be found in the middle. For example:

["aXc","bXd"]


If you try to match them by the middle substring:

aXc
bXd


You would realize that the other overlapping characters are not equal to each other. That is, a is not equal to b, and c is not equal to d. In that case you simply append the string in the join:

aXc
bXd
======
aXcbXd


Likewise, if either of these strings contain each other, but isn't equal to the other string, you should simply append the string. E.g.

["abcd","bc"]


would give

abcd
bc
======
abcdbc


Substrings can overlap past each other. E.g.

["abc","bcd","cde"]


would result in the following join:

abc
bcd
cde
=====
abcde


which would evidently make the output abcde.

Strings have to overlap as much as possible. That means, in this example:

["abcbc","bcbcd"]


This is not okay (even if they do overlap):

abcbc
bcbcd
========
abcbcbcd


abcbc
bcbcd
======
abcbcd


The join is consecutive based on the consecutive inputs. For example:

abcde
cde
abcde
==========
abcdeabcde


## Test cases

A program is worth a thousand words. Here 's a reference implementation that I use to check the test cases.

["abc","bcd","rfh","hal"] -> "abcdrfhal"
["mmm","qqq","rrr"] -> "mmmqqqrrr"
["abcbc","bcbcd"] -> "abcbcd"
["aXc","bXd"]    -> "aXcbXd"
["abc","bcd","cde"] -> "abcde"
["abcd","bc"] -> "abcdbc"
["abcde", "cde", "abcde"] -> "abcdeabcde"

• How would you join aXc and bXd? They have the common substring X in the middle. – Bubbler Mar 25 at 2:24
• Can strings overlap past each other like abc,bcd,cde->abcde? – xnor Mar 25 at 2:25
• Do strings have to overlap as much as possible, or just overlap any amount? For example, for abcbc and bcbcd, is either of abcbcd or abcbcbcd OK? – xnor Mar 25 at 4:43
• Do strings have to be joined in the order given? I feel like the answer is surely "yes", but the text doesn't say outright. Really, I think all these Sandbox questions come from the fact that the task is never actually stated precisely, and doing that would probably head off any further question. – xnor Mar 25 at 4:49
• Along these lines, what happens if one string contains another? Do we do abcd,bc->abcd? – xnor Mar 25 at 4:51
• Suggested test case: abcde, cde, abcde. – Jonathan Frech Mar 25 at 4:52
• @JonathanFrech Well, what's the expected output? I thought it was abcde in this case. – user92069 Mar 25 at 6:00
• I was not completely sure what the output would be. abcdeabcde does seem reasonable. – Jonathan Frech Mar 25 at 7:40
• I still don't actually understand how the task works precisely. A reference implementation isn't a replacement for a specification. – xnor Mar 25 at 23:09
• @xnor I've added back the spec, can you understand it now? – user92069 Mar 26 at 6:24
• Not really, sorry. I still wouldn't know what abcd,bc would give. – xnor Mar 26 at 6:29
• @xnor Are there any more test cases you don't understand? – user92069 Mar 26 at 6:35
• This seems to be related to the shortest superstring problem for two strings, but you don't have to handle the case where one of the strings is a substring of another, and the joining order is fixed. Is that correct? Just informing that the specification spans four pages on my laptop, with default browser font size. – the default. Mar 26 at 6:55
• – the default. Mar 26 at 6:58
• @mypronounismonicareinstate Ah, it's a duplicate. Thank you for the mention. – user92069 Mar 26 at 6:58

## Sum in 2540 Sums code-golfpristine-programmingcode-shuffleboard

This is my attempt to pair with .

You need to write a program that sums all codepoints of the input string.

## Rules

• The input will always be in printable ASCII.
• The sum of the codepoints of your source must be exactly 2540.

• You are allowed to use your language's own code page to calculate your program's codepoints.
• Null bytes (which don't contribute to your codepoint sum) are banned.

• The program must not work with any consecutive substring removed.
• This is . Your score is the length of your source code, the shorter being better.
• You defined the "base score" only to reference that term exactly once. It seems to be move confusing than helpful. Wouldn't "The sum of the codepoints of your source must be exactly 2540" be clearer and shorter? – Wheat Wizard Apr 9 at 21:18
• Although I am neither suggesting nor recommending against, this could also work as code-bowling if you either outlaw null bytes or sum up the (codepoints+1). – Wheat Wizard Apr 9 at 21:22
• @AdHocGarfHunter The rules are a lot simpler if it were code-golf, and we haven't paired codepoint sum with code golf before. Also I need to fullfill a goal to pair code-bowling with code-golf. This analysis says that there are 11 tags not paired with code-golf, I'm going to make it 10. – user92069 Apr 9 at 21:24
• As far as I know, [pristine-programming] is the tag for programming with the substring removal restriction here. (I think this would work as a [code-bowling] as well as well) – the default. Apr 10 at 0:12
• @mypronounismonicareinstate So which side are you for? Code golf or code bowling? – user92069 Apr 10 at 0:53
• Probably code-golf. – the default. Apr 10 at 1:07

# Will this simplified befunge-93 program terminate? code-golfdecision-problem

The challenge today is to solve the halting problem for simplified befunge-93.

Simplified befunge-93 has exactly four instructions - > v < ^ @. The program is restricted to a 80x24 grid. Each of the commands modifies the instruction pointer (so that, for instance > makes the instruction pointer start executing commands to the right), except of the @ instruction, which terminates the program.

When the instruction pointer reaches the end, it wraps around (imagine the snake game).

You may read input in form of a string or a two-dimensional array using any reasonable device. The output may be either a truthy value if the program terminates, or a falsy value if the program doesn't terminate.

## Example data

Input:
>v
^<

Output: Doesn't terminate.
----------------------------------------
Input:
> v
@
^ <

Output: Doesn't terminate.
----------------------------------------
Input:
v@
[23 newlines]
>v

Output: Terminates.
----------------------------------------
Input:
v @
[23 newlines]
>v

Output: Doesn't terminate.
----------------------------------------
Input:

Output: Doesn't terminate.

• Possibly dupe? – null Apr 27 at 8:47
• is the instruction ptr initially at 0 0 and moving to the right? – ngn Apr 27 at 8:55
• yes, I maybe forgot to state that. But it's most probably a dupe right now, so I don't think I should push it forward anymore :P – Kamila Szewczyk Apr 27 at 8:56
• For the sake of completion: can I give my output as a list of strings? – Lyxal Apr 29 at 23:02
• @Lyxal Seeing as that's a generally accepted I/O method, yes. – sporeball Apr 30 at 0:09

# Complete a sequence using its distances code-golfsequenceinteger

Given $$\A = (a_1,\dots,a_k)\ k\ge2 \$$ a nonrepetitive sequence of positive integers.
Starting from $$\i=2\$$, while $$\a_i\in A:\$$

• If $$\d=|a_i-a_{i-1}|\$$ is not already in $$\A\$$, append $$\d\$$ to $$\A\$$
• Increase $$\i\$$

Output the completed sequence.

## Example

In:  16 20 13 3

16 20 13 3 4
--^
16 20 13 3 4 7
--^
16 20 13 3 4 7 10
--^
16 20 13 3 4 7 10 1
--^
16 20 13 3 4 7 10 1
--^
16 20 13 3 4 7 10 1
--^
16 20 13 3 4 7 10 1 9
--^
16 20 13 3 4 7 10 1 9 8
--^
Out: 16 20 13 3 4 7 10 1 9 8


This is

• You could define the self-distances completion for a sequence of positive integers instead of a k-permutation. I believe it would be clearer that way. Also, is the input guaranteed to be duplicate-free? – Zgarb Jun 1 at 20:15
• @Zgarb Yes, you're right, for the purpose of this challenge refer to a sequence would be totally ok, I've copied this def from the linked challenge where since it's fundamental to consider the max in the input sequence, this number in the context of k-permutation of n - containing n - will naturally be n... But that's not a problem, a k permutation is also a sequence of positive integer. And yes, I forgot to require the input to be duplicate-free – Domenico Modica Jun 1 at 20:44
• @Zgarb what do you think about the name? Does it make sense? It's a bit too bulky? – Domenico Modica Jun 1 at 20:53
• "append d to (the end of) A" could be clearer to programmers than "prolong A with d". Using "the end of" is optional. – Hiatsu Jun 2 at 3:05
• The name could be "Complete a sequence using its distances" if you want to go for maximum clarity. – Zgarb Jun 2 at 8:08

## _

• @mathjunkie then the codepoints given are incorrect. – Lyxal May 24 at 22:43
• @Lyxal Why are they incorrect? I wrote a program to generate the codepoints. – user92069 May 25 at 8:15
• Oh wait. I thought they were in binary. – Lyxal May 25 at 8:18
• As in, you were using the binary representation of each ordinal value. – Lyxal May 25 at 8:19
• @Lyxal No. I was using the decimal expansion of the ord codes. I am going to clarify that. – user92069 May 25 at 8:19
• I cam see that now. I just assumed those numbers were base 2,rather than base 10 – Lyxal May 25 at 8:20
• Seems pretty clear, but would benefit from test cases with odd-length strings. For example, 'rim' (false) and 'rum' (true) illustrate the 'first half longer' splitting rule. (Truthiness for these two words would be swapped if the rule were second half longer.) – Dingus May 29 at 7:24

# Bot Duels KOTH king-of-the-hilljavascript

Obligatory blurb adding story fluff. Or, maybe a self-referential paragraph about meta-self-referential blurbs? Or: <announcer voice> Will your bot survive... The Arena? </announcer voice>. Yes, I think a good non-self-referential (such as this) short paragraph full of short sentences without run-ons or many, many, many, many commas will suffice.

## Overview

This is a King-of-the-Hill challenge. Bot with the most wins wins. You may submit multiple bots as long as they differ in strategy. Bots will play against every other bot. The bot who is currently playing against every other bot goes first, and goes second when their opponent is playing against every other bot. Bots will face off in an arena with x boundaries of 10 and -10 and y boundaries of 10 and -10. Bots will either start at (-5, 0) or (5, 0). Your goal is to defeat the other bot by reducing it's HP to 0 or less. Bots start with 20+armor modifier HP and do not regenerate health. Your bot defeats the other bots using weapons, which have damage, range, and cooldown. Armor has speed.

## Submissions

Submissions should be a JS function that takes the following parameters:

• curr_x - the current x coordinate of your bot
• curr_y - the current y coordinate of your bot
• enemy_x - the current x coordinate of your opponent's bot
• enemy_y - the current y coordinate of your opponent's bot
• enemy_armor - the armor that your enemy is wearing
• storage - a storage object you can use to store data between function calls

The function should return an array with 3 items (in the following order):

• desired x - the x coordinate you want to move to
• desired y - the y coord you want to move to
• use weapon? - if true, and desired x and desired y are Infinity, then you use your weapon

Submissions should be structured as

function definition
block


Explanation underneath, if any.

## Armor

(currently designing new weapons and armor) The types of armor available are:

• Light - increases HP by 3, has a speed of 3
• Medium - increases HP by 5, has a speed of 2
• Heavy - increases HP by 7, has a speed of 1

## Weapons

The types of weapons are:

• Laser - High-range, high-damage, low ROF. 5 points of damage, 5 rounds to cool down, and a range of 6 units
• Rifle - General-purpose weapon. 5 damage, range of 4, 3 rounds to cool down.
• Sword - High-ROF, high-damage spiky thing. 5 points of damage, really low range of 1, and a rather quick 2 rounds to cool down.

## Turns

On your turn, you can either move or use weapon (or do nothing, if that's what you really want to do).

• If you move, you can move a distance (computed using the Euclidean Distance formula) less-than or equal-to (<=) your armor's speed.
• If you choose to use weapon, and if the enemy is in range of your weapon, then you deal damage equal to your weapon's damage and the weapon goes into cooldown. A weapon in cooldown can't be used. Weapons can be used after a number of turns equal to their cooldown property has passed after being used.
• To do nothing, simply return your current x and y coordinates, like so: return [curr_x, curr_y, false].

## Rules

• If you try to use a weapon during cooldown, nothing happens and your turn ends
• If you try to use a weapon and your opponent is out of range, nothing happens and your turn ends.
• If you try to move more than your armor's speed, nothing happens and your turn ends
• If you try to move out-of-bounds, same thing
• If you move into another bot's space, then the bot with the lowest HP loses and the bot with the highest HP wins, making this a viable strategy.
• All standard loopholes (accessing controller, duplicate bots, suicide bots, etc.) are, of course, disallowed.

## Examples

TowerDefense Weapon: Laser
Armor: Heavy

function(curr_x, curr_y, enemy_x, enemy_y, enemy_armor, storage) {
let actions = [Infinity, Infinity, true];
return actions;
}


Just sits and shoots, lol. A perfectly viable strategy (and a rather strong one, too, while weapons are still being reworked). Takes the highest-hp armor available because it doesn't need to move at all.

## DumbBot

Weapon: Rifle
Armor: Medium

function(curr_x, curr_y, enemy_x, enemy_y, enemy_armor, storage) {
let actions = [curr_x, curr_y, false];
// if storage is empty
if (!storage.data) {
// then write our starting loc
storage.data = curr_x.toString() + " " + curr_y.toString();
}

// if we're starting at x = -5
if (storage.data.includes("-5")) {
if (curr_x < 3) {
// move right
actions[0] += 2;
actions[1] = curr_y;
}
// otherwise we must be close enough
else {storage.data = "shoot";}
}


Assumes enemy doesn't move (such as TowerDefense). Moves to the enemy's starting location, then shoots. As such, takes the Medium armor and the Rifle. Kind of a generic all-purpose bot, like the weapons and armor it uses.

## Controller

The controller can be found here. Run all current submissions here.

Best of luck, and, may the odds be ever in your favor (even though this is a 1v1 and not a FFA)

## Sandbox

• Are the rules explained thoroughly? Is anything unclear?
• Is the game (armor, weapons, punishment for breaking rules, etc.) balanced well? Are there any strategies that dominate?
• Would this KOTH be fun?
• Would you participate in the competition?
• Any obvious bugs in the (horribly messy) controller code?
• Create a simple submission similar to something that you would actually submit and test it against the example bots. Is the code still working?
• An arena that contains the points (-5, 0) and (5, 0) would be larger than 10x10. Isn't the heavy armor creating more health that can be removed in a turn? – the default. Jun 15 at 17:07
• Armor adds health at beginning of game. It’s a one-time buff. And yes, I messed up the field size. It’s 20x20 – nope Jun 15 at 21:32
• If armor is one-time, then the Light armor is strictly better than Medium because both last only for one shot, leading to various weirdness. – the default. Jun 16 at 1:41
• a) How much health does each bot start with? b) Are you sure the arena is supposed to be 20x20? Not 21x21 or 19x19? As it is one of the bots will have to start closer to the edge (and which one it is isn't specified as far as I can tell). c) Is there a reason why some disallowed actions cause an immediate forfeit while others only make the offending bot skip a turn? d) The "Stuff Not Allowed" and "Other viable strategies" are confusing. Namely, under the first one you list a viable strategy, and under the second - something that's disallowed. – Alion Jun 16 at 12:02
• b.2) On further inspection, is this game grid-based or played on a continuous arena? As in, can you move in fractions? In the second case, (b) becomes irrelevant. – Alion Jun 16 at 12:40
• e) What's the mysterious "Distance formula"? Plain old euclidean distance? Taxicab? Chebyshev? f.1) How do you "include [what weapon and armor your bot is using] in your submission"? f.2) More generally, is there a specific submission format? Or will anything human-readable do? g) Are bots allowed to act randomly with the help of Math.random, for example? h) Is it really necessary to override this loophole? – Alion Jun 16 at 13:06
• i) Have you considered adding more weapon types or modifying the current set? Currently the choice is pretty one-dimensional, since you avoid varying the damage property. – Alion Jun 16 at 13:07
• As for whether this KotH is fun or not - it seems okay, but I think it lacks variety. Addressing (i) would probably help with that. I would definitely give this challenge a try regardless if it hit main (perhaps as a result of me being a JS KotH junkie). – Alion Jun 16 at 13:18
• Just an observation: the table is almost antisymmetric reading top-down vs bottom-up. That is, if you split the table in half based on the value of A, then the X value in any row in the top half of the table is mostly the opposite of the X value in the same row (reading upwards from the bottom) in the bottom half. Whether that simplifies the problem at all, I'm not sure. – Dingus Jun 15 at 0:23
• I think the [kolmogorov-complexity] tag should apply here, and the [number] tag doesn't seem very helpful. – the default. Jun 16 at 5:58

# Polyglot: Convert Case

Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of the detailed cases below. You must remove non-alphabetic characters, except   (space), _ and -, split on these, or differences in case (e.g. bA), and either join on the desired chars or join on the empty string and capitalise the first char of each word (or not the first of doing camel case). Your program must be a polyglot in at least two different languages. For example, running your code in Python 2 transforms input to snake_case, running it in JavaScript transforms to kebab-case, Ruby transforms to PascalCase and 05AB1E transforms to camelCase.

The following case conversions must be completed:

### camelCase

this is a test         thisIsATest
camelCaseTest          camelCaseTest
PascalCaseTest         pascalCaseTest
snake_case_test        snakeCaseTest
kebab-case-test        kebabCaseTest
Testing!!one!!!1!!!    testingOne1
aBCDef                 aBCDef
ABCDef                 aBCDef
a_b_c_def              aBCDef
a-b-c-def              aBCDef


Try it online!

### PascalCase

this is a test         ThisIsATest
camelCaseTest          CamelCaseTest
PascalCaseTest         PascalCaseTest
snake_case_test        SnakeCaseTest
kebab-case-test        KebabCaseTest
Testing!!one!!!1!!!    TestingOne1
aBCDef                 ABCDef
ABCDef                 ABCDef
a_b_c_def              ABCDef
a-b-c-def              ABCDef


Try it online!

### snake_case

this is a test         this_is_a_test
camelCaseTest          camel_case_test
PascalCaseTest         pascal_case_test
snake_case_test        snake_case_test
kebab-case-test        kebab_case_test
Testing!!one!!!1!!!    testing_one_1
aBCDef                 a_b_c_def
ABCDef                 a_b_c_def
a_b_c_def              a_b_c_def
a-b-c-def              a_b_c_def


Try it online!

## UPPER_SNAKE_CASE

this is a test        THIS_IS_A_TEST
camelCaseTest         CAMEL_CASE_TEST
PascalCaseTest        PASCAL_CASE_TEST
snake_case_test       SNAKE_CASE_TEST
kebab-case-test       KEBAB_CASE_TEST
Testing!!one!!!1!!!   TESTING_ONE_1
aBCDef                A_B_C_DEF
ABCDef                A_B_C_DEF
a_b_c_def             A_B_C_DEF
a-b-c-def             A_B_C_DEF


Try it online!

### kebab-case

this is a test         this-is-a-test
camelCaseTest          camel-case-test
PascalCaseTest         pascal-case-test
snake_case_test        snake-case-test
kebab-case-test        kebab-case-test
Testing!!one!!!1!!!    testing-one-1
aBCDef                 a-b-c-def
ABCDef                 a-b-c-def
a_b_c_def              a-b-c-def
a-b-c-def              a-b-c-def


Try it online!

## Rules

• Your code should produce the same output as the linked examples.
• Entries with the most conversions win, with code length being a tie-breaker.

# Questions for sandbox

• Have I missed any other major naming schemes?
• in the example, at the start, you said python 2 and javascript, while below there are 4 conversions. Must you do all of them in a different language each? Also, do language versions (python 2 / python 3) count as different languages? – Command Master Jul 3 at 3:27
• @CommandMaster It was just a cut down example to explain the concept of a polyglot. I'm still unsure whether it makes sense to allow two or more languages or require all four. I feel like allowing two or more would enable more elegant solutions as snake Vs kebab is the same bar the delimiter and Pascal Vs camel is the same bar leading capitalisation. What're your thoughts? – Dom Hastings Jul 3 at 6:28
• Different language versions count as different languages (not sure of there's a relevant meta post. I'll try and look for it when I'm not on mobile.) – Dom Hastings Jul 3 at 6:29
• If the usual 'different command-line flags count as different languages' rule applies, then is there a risk that the snake vs kebab cases could be trivially solved using the command-line flag to specify the delimiter...? – Dominic van Essen Jul 6 at 11:23
• Yeah, I guess so. Something like Perl's -i flag could enable using ^I to be either - or _. Although then doing the same would probably be tricky and potentially still at least a little ingenious. – Dom Hastings Jul 6 at 12:46 • "Have I missed any other major naming schemes?" Yes: Ada_Ninety_Five_Case, Title Case, and (jokingly) StRaNgEcAsE. What's wrong with UPPER_SNAKE_CASE? – fireflame241 Jul 9 at 5:55 • @fireflame241 I think that converting back from upper snake case might be slightly more tricky than just snake case, as checking for an underscore might not be enough to see if there's more transformation necessary, if for example there was already an underscore in normal text... I could state that isn't a problem though I guess? Adding more cases might make me lean towards mandating only a minimum of two transformations required as well and changing the scoring to number of transformations with code length as a tie-breaker... Thanks again, will think on this a bit. – Dom Hastings Jul 9 at 6:16 • If you restrict words to be composed only of letters, then you could avoid that issue, and a few others. For example, how would aB_Cd be handled? It could be snake case, where the _ separates the words, or camel case, where the _ is the start of the second word. I think right now there's too many test cases, too little explanation. – fireflame241 Jul 9 at 6:32 • @fireflame241 Yeah, I think you're right. Ok. I'll work on this. Thanks! – Dom Hastings Jul 9 at 6:45 • Re: flags as languages again. I was more thinking of a program 'checking' to see what flags had been used (even if they have no direct effect), and modifying its behaviour accordingly. For instance, perl -m foo + then checking whether foo is loaded. This would also be similar to language+library = different language. Worst cheat of all would be awk -v mode=1... – Dominic van Essen Jul 9 at 16:03 • Along the same lines, it would be important to specify that it isn't Ok to just run different versions of a language (which currently 'count' as different languages), and for the program to determine the version & modify its behaviour. – Dominic van Essen Jul 9 at 16:10 • I don't think it's possible to rule out different language versions for polyglot challenges, and using flags to classify as different languages might be questionable too. I guess if the answers aren't in the spirit of the task or are a little boring they'll be voted on accordingly. I'm open to more input on this though! Thank you for the feedback! – Dom Hastings Jul 9 at 21:13 • "polygot in at least two different languages" so we must write 4 programs, how can there be fewer than 4 languages? – qwr Jul 9 at 22:46 • @qwr I just amended the rules to allow 2 or more languages, you don't have to have all 5. I'm hoping this will allow some creative solutions. If I missed a reference to that I'm struggling to see it, but morning eyes... – Dom Hastings Jul 10 at 6:07 • For some reason I thought there were 4 programs. So to clarify, the minimum is two languages / two conversions? – qwr Jul 10 at 6:11 • What's the upper limit of the output string Y? – user92069 Jul 25 at 5:24 • @Third-party'Chef' Y is a programming language not a string. – Wheat Wizard Jul 25 at 12:31 • Sorry, I meant X. – user92069 Jul 25 at 12:32 • @Third-party'Chef' I didn't put an upper limit, but its length is your score so longer means worse score. Is there some issue I am not seeing that means an upper limit is needed. – Wheat Wizard Jul 25 at 12:36 • Now that this has been posted to main, could you delete this proposal to create more space for new answers? – caird coinheringaahing Sep 25 at 0:51 • @cairdcoinheringaahing you know that that takes up more space right? – Wheat Wizard Sep 25 at 4:04 • Deleting the post? How does it take up more space? It's no change from 10k+ users and it removes an answer for <10k users – caird coinheringaahing Sep 25 at 12:28 • @cairdcoinheringaahing It does increase the size for users above 10k. You can test it for yourself if you want. Further comments also increase the size. – Wheat Wizard Sep 25 at 18:53 # Is this Chessboard Reachable? The goal of this challenge is to determine, given the state of a chessboard, whether or not that chessboard can actually be reached in the course of standard play. Of course, doing this in general is a rather hard problem, so we'll be simplifying the problem to a set of a few rules which should approximate the "reachability" constraint. Your input will be a chessboard, specifying what pieces are at what positions on the 8x8 board. At each position, there can be either nothing or a piece. If there is a piece, it is either a pawn, bishop, knight, rook, queen, or king, and it is either white or black. Input can be taken in any reasonable form. Your output should be truthy or falsy, indicating whether all of the below rules are satisfied. For the below rules, I'll be using standard chess notation to refer to the squares on the board. That is, I'll be referring to squares on the board by their rank (1-8) and their file (a-h), as such  8........ 7........ 6........ 5........ 4........ 3........ 2........ 1........ abcdefgh  where the white player starts on ranks 1-2 and the black player starts on ranks 7-8. Obviously, you don't have to use the same notation, and if it's easier for you to take the board input flipped or rotated, that's fine too as long as you specify it in your answer. For one of the rules, you have to distinguish between white and black squares on the board. The board is layered with a checkerboard pattern, so white squares are always immediately surrounded by black on all four sides, and vice versa. In typical chess, the a1 square is black, but that doesn't really matter for the below criteria. ## The Rules In order for a board to be considered reachable, it must satisfy all of the following rules. This is , so you don't have to tell me which rule an unreachable board violated; all I expect of your output is a "yes" or a "no". 1. White and black each have exactly one king on the board: no more, no less. 2. Pawns cannot appear on rank 1 or rank 8. 3. Each player has a maximum of 16 pieces on the board total. These pieces must be a subset of the following: 2 bishops, 2 rooks, 2 knights, 1 queen, 1 king, and 8 wildcards. The "wildcard" pieces can be any piece they please (since we assume pawns could have been promoted). 4. For either player, if that player has at least two bishops, and those two bishops cannot have been promoted from pawns (i.e. they must be the "bishops" in rule 3, not the "wildcards"), then that player must have at least one bishop on a white square and at least one bishop on a black square. 5. All of a player's pawns must be able to reach the square they're occupying. More formally, for each player, there must be an assignment (an injective function) from the set of that player's surviving pawns to the files (a-h) they started on, such that each pawn can reach its current position from its starting position with only forward and forward-diagonal movements. ## Pawn Movements Rule 5 may require some elaboration. Suppose a white pawn is on d5. Then it could have come from the following places (indicated by X)  8........ 7........ 6........ 5...♙.... 4..XXX... 3.XXXXX.. 2XXXXXXX. 1........ abcdefgh  So it could have started on a2, b2, c2, d2, e2, f2, or g2, but not h2. There must be an assignment of pawns to starting positions such that no two pawns started at the same position and every pawn can reach its current position from where it began. A black pawn follows the same rules but started on rank 7 and moves down rather than up. So a black pawn at the same position could have come from b7, c7, d7, e7, or f7, as follows.  8........ 7.XXXXX.. 6..XXX... 5...♟.... 4........ 3........ 2........ 1........ abcdefgh  ## Notes • Only the rules above apply. Other complexities of a standard game of chess (in particular, castling or en passant) are not part of this problem and should not be considered. • This is , so the shortest solution wins. • Input can be taken in whatever form is most convenient. Output follows the usual rules, so any two distinct outputs for truthy/falsy are acceptable. • This is an oversimplification of the reachability problem in chess. As such, an answer which provably enumerates every chessboard and tests for membership is not correct. ## Examples Reachable chessboards (true):  8♜♞♝♛♚♝♞♜ 7♟♟♟♟♟♟♟♟ 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1♖♘♗♕♔♗♘♖ abcdefgh 8........ 7........ 6........ 5........ 4........ 3........ 2..♚..... 1.....♔.. abcdefgh 8........ 7.....♚.. 6.♛...... 5...♟.... 4........ 3.....♕.. 2........ 1...♔.... abcdefgh 8.....♚.. 7♟♟♟♟♟♟♟♟ 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1....♔... abcdefgh 8.....♚... 7♟♟♟♟♟♟♟♟ 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1....♔... abcdefgh 8........ 7.♚...... 6...♕♕♕♕. 5..♕....♕ 4..♕..♔.♕ 3.......♕ 2........ 1........ abcdefgh 8........ 7...♚.♟.♙ 6.♙.♙..♙. 5.....♘.. 4.♕..♕♘♗♖ 3.....♘♗♖ 2..♕....♖ 1......♔. abcdefgh 8♜..♛♚♜♜♜ 7♟♟♟♟♟♟.. 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1♖♘♗♕♔♗♘♖ abcdefgh 8♜♞♝♛♚♝♞♜ 7♟♟♟♟♟♟♟♟ 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙. 1♖♗♘♕♔♗♘♖ abcdefgh 8♛♛♛♛♛♛.♛ 7........ 6......♚. 5.♝.♝.... 4.....♟.. 3........ 2..♖♖♖.♔. 1........ abcdefgh 8.....♚.. 7........ 6........ 5........ 4........ 3.♙♙..... 2..♙♙♙♙♙♙ 1.....♔.. abcdefgh 8.....♚.. 7........ 6........ 5........ 4........ 3.....♙.. 2...♙♙♙.♙ 1.....♔.. abcdefgh 8.....♚.. 7........ 6.♟♟♟♟... 5.♟♟..... 4........ 3........ 2........ 1.....♔.. abcdefgh  Unreachable chessboards (false): (Rule 1: Not enough kings)  8........ 7........ 6........ 5........ 4........ 3........ 2........ 1........ abcdefgh  (Rule 1: Too many kings)  8♚♚♚♚♚♚♚♚ 7♚♚♚♚♚♚♚♚ 6♚♚♚♚♚♚♚♚ 5♚♚♚♚♚♚♚♚ 4♚♚♚♚♚♚♚♚ 3........ 2........ 1...♔.... abcdefgh  (Rule 2: Bad white pawn placement)  8.....♚.. 7♟♟♟♟♟♟♟♟ 6........ 5........ 4........ 3........ 2.♙♙♙♙♙♙♙ 1♙...♔... abcdefgh  (Rule 2: Bad black pawn placement)  8.♟...♚.. 7♟.♟♟♟♟♟♟ 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1....♔... abcdefgh  (Rule 3: Too many white queens)  8........ 7.♚...... 6...♕♕♕♕. 5..♕....♕ 4..♕..♔.♕ 3..♕....♕ 2........ 1........ abcdefgh  (Rule 3: Too many black pieces)  8♜♞♝♛♚♝♞♜ 7♟♟♟♟♟♟♟♟ 6......♟. 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1♖♘♗♕♔♗♘♖ abcdefgh  (Rule 3: Too many white pieces)  8........ 7...♚.♙.♙ 6.♙.♙..♙. 5.....♘.. 4.♕..♕♘♗♖ 3.....♘♗♖ 2..♕....♖ 1......♔. abcdefgh  (Rule 3: Too many black rooks)  8♜..♛♚♜♜♜ 7♟♟♟♟♟♟♟. 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1♖♘♗♕♔♗♘♖ abcdefgh  (Rule 4: White bishops are the same color)  8♜♞♝♛♚♝♞♜ 7♟♟♟♟♟♟♟♟ 6........ 5........ 4........ 3........ 2♙♙♙♙♙♙♙♙ 1♖♗♘♕♔♗♘♖ abcdefgh  (Rule 4: Black bishops are the same color)  8♛♛♛♛♛♛♛♛ 7........ 6......♚. 5.♝.♝.... 4.....♟.. 3........ 2..♖♖♖.♔. 1........ abcdefgh  (Rule 5: White pawn placement is impossible)  8.....♚.. 7........ 6........ 5........ 4........ 3..♙..... 2.♙♙♙♙♙♙♙ 1.....♔.. abcdefgh  (Rule 5: White pawn placement is impossible)  8.....♚.. 7........ 6........ 5........ 4........ 3.....♙.♙ 2...♙♙♙.♙ 1.....♔.. abcdefgh  (Rule 5: Black pawn placement is impossible)  8.....♚.. 7.♟♟♟♟... 6........ 5.♟♟..... 4.♟♟..... 3........ 2........ 1.....♔.. abcdefgh  ## Example Implementation (Python 3) # Takes input from stdin in the form shown above (a grid of Unicode # chess characters and dots). Prints True if reachable. Prints False # and the first rule number which is violated if unreachable. import sys from collections import defaultdict, namedtuple Piece = namedtuple('Piece', ['color', 'type']) # Read in the data from stdin. data = [] for line in sys.stdin: chars = list(filter(lambda x: x in ".♟♙♝♗♞♘♜♖♛♕♚♔", line)) if chars: data.append(chars) if len(data) == 8: break assert len(data) == 8 for line in data: assert len(line) == 8 # Parse it into a more convenient format. translation = { ".": None, "♟": Piece('black', 'pawn'), "♙": Piece('white', 'pawn'), "♝": Piece('black', 'bishop'), "♗": Piece('white', 'bishop'), "♞": Piece('black', 'knight'), "♘": Piece('white', 'knight'), "♜": Piece('black', 'rook'), "♖": Piece('white', 'rook'), "♛": Piece('black', 'queen'), "♕": Piece('white', 'queen'), "♚": Piece('black', 'king'), "♔": Piece('white', 'king'), } for rank in data: for i in range(8): rank[i] = translation[rank[i]] # Count the number of each piece that each player has, slotting # necessary pawn promotions into their own category. allowed = { 'bishop': 2, 'rook': 2, 'knight': 2, 'king': 999, 'queen': 1, 'pawn': 0 } pieces = defaultdict(lambda: 0) for rank in data: for piece in rank: if piece is None: continue if pieces[piece] >= allowed[piece.type]: # Already have too many; it's a promoted pawn pieces[Piece(piece.color, 'pawn')] += 1 else: # Count it normally pieces[piece] += 1 # Rule 1: Each color should have exactly one king. if pieces[Piece('white', 'king')] != 1 or pieces[Piece('black', 'king')] != 1: print(False, 1) exit(0) # Rule 2: Pawns cannot appear on rank 1 or rank 8. for piece in data[0] + data[7]: if piece is not None and piece.type == 'pawn': print(False, 2) exit(0) # Rule 3: Since we already put any "overflow" pieces at the pawn key, # we just need to make sure we have at most eight pawns. for color in ['white', 'black']: if pieces[Piece(color, 'pawn')] > 8: print(False, 3) exit(0) # Rule 4: If we have both bishops and our pawns are all accounted for, # then we have to have a bishop in each color. for color in ['white', 'black']: if pieces[Piece(color, 'bishop')] >= 2 and pieces[Piece(color, 'pawn')] >= 8: squares = { 'white': False, 'black': False } for y, rank in enumerate(data): for x, piece in enumerate(rank): square_color = 'white' if (x + y) % 2 == 0 else 'black' if piece == Piece(color, 'bishop'): squares[square_color] = True if not (squares['white'] and squares['black']): print(False, 4) exit(0) # Rule 5: All pawns must be able to get to where they are. I solve # this here by brute force (simply trying every possible permutation), # which is exponentially inefficient, but it'll do for this example. def recursive_assign(taken, choices, i): if i >= len(choices): return True current = choices[i] for x in current: if x not in taken: if recursive_assign(taken + [x], choices, i + 1): return True return False for color in ['white', 'black']: starting_file = 6 if color == 'white' else 1 choices = [] for y, rank in enumerate(data): for x, piece in enumerate(rank): if piece == Piece(color, 'pawn'): possibilities = range(8) possibilities = filter(lambda i: abs(i - x) <= abs(y - starting_file), possibilities) choices.append(list(possibilities)) if not recursive_assign([], choices, 0): print(False, 5) exit(0) print(True)  ## Proposed Tags ## Sandbox Concerns • I worry Rules 4 and 5 are still not clear enough. I tried to write them in a way that was as clear as possible while still being mathematically unambiguous. • too long. try to combine rules or at least don't draw so many of them in a column – Noone AtAll Aug 4 at 9:06 • If you're going to use unicode chess symbols, use a double-wide filler character instead of .. The alignment in your examples is off, making it very distracting. I'd recommend switching them to ASCII letters using the typical KQRBNP convention. – Beefster Aug 4 at 16:40 • To add to Beefster's comment, in some fonts the chess symbols are not even double wide, they're somewhere in between. So double-wide fillers won't work either. +1 for ASCII notation. – Bubbler Aug 4 at 23:43 • if I recall correctly, you can have two bishops of the same color. Up to nine. By promoting pawns to bishops. Very rare indeed, but legal. I want this to main page, though. – V. Courtois Aug 14 at 15:19 # Road Sort Order In Britain, road identifiers use a scheme of a letter, followed by a 1-4 digit number. From Most-Important to Least-Important, the letters are: M A B C D U The numbers also represent further assumptions around the importance of the road, such that a 1-digit number is more important than a 4-digit number. Thus, the M898 is less important than the M8, but more important than the A8. interesting but not relevant for the challenge - Roads are also sorted into nine Zones, of equal importance. The first number in each road identifier gives the Zone that the road starts in (e.g. A8 starts in Zone 8 - although there are exceptions where one Motorway spurs off of another, e.g. M48 is so named because it is a spur of the M4 even though it is officially in Zone 5). ## The challenge Given a pair of road identifiers, identify and output which is the most important road. Where there is no difference in importance by the above rules (e.g "B4063" and "B1234") then either output is acceptable. Usual I/O rules apply, this is so lowest bytes wins. There will be two inputs, and no invalid inputs (i.e. they will follow the rules, although they may not be actual real-life roads). If you say so in your answer, you may instead output the least significant road (i.e. as long as I know which it is, you can do either). You may take the input as a string, array of strings, or array of strings and integers as follows: "M123M223" ["M123","M223"] ["M",123,"M",223] #SANDBOX# If there are input formats that you think should/n't be allowed, let me know. ## Examples • A11,M2 -> M2(Motorways come before A roads) • M823,M89 -> M89 (two-digit roads are more important than 3-digit roads, even though 89 alphabetically comes after 823) • A1262,A150 -> A150 • U6340,D6340 -> D6340 • M1,M2 -> Either • B100,C99 -> B100 • I'd suggest simplifying sorting to just comparing two distinct values. Or even, mapping a value to a number so that the comparisons are right. – xnor Aug 4 at 19:56 • @xnor sorry I'm not sure what you mean. Do you mean only ever have two inputs? – simonalexander2005 Aug 5 at 7:25 • Yes, like have a possible input be like f("A11","M2") with it being a decision problem to tell if the first or second one is more important. Or, just have us write a function g producing a number so that, say, g("A11")>g("M2"). – xnor Aug 5 at 21:11 • @xnor how's that? I've made it return the most (or least) significant road of a pair – simonalexander2005 Aug 6 at 7:34 • Looks good! I'm a bit worried about the "any sensible format" since counting digits is important. Like, would a length-four array padded with nulls for missing digits count as acceptable? I think this would be you compare the number parts as a direct list comparison in some languages. – xnor Aug 7 at 3:15 ## Posted ## Shift Tac Toe code-golfgridtic-tac-toe Shift Tac Toe is a game that combines Tic Tac Toe and Connect 4 together. In this game, you start with a 3 by 3 board, and each row is connected to a slider that you can move left and right. At the start, the sliders all start to the very right(this means that you can't move the slider to the right on the first turn). Each slider can hold a total of 5 pieces. Each turn, the player can drop an O or a X in one of the 3 columns of the Tic Tac Toe grid depending on which turn it is, or the player can move one of the sliders one spot to the left or to the right. All pieces fall to the bottom most space that is unoccupied. The pieces can also fall from one slider to another outside the 3 by 3 grid. If a piece is outside the 3 by 3 grid and doesn't fall into the bottom slider, then the piece is taken out. If it does reach the bottom slider, it will stay in play. A notable example of this is shown in the following grid:  --- --- --- --- --- | | | | - O - --- --- --- --- --- --- - | | | | - --- --- --- --- --- --- | | | | - - --- --- --- --- --- In the grid above, the dashes(-) indicate the part of the sliders that are outside of the 3 by 3 grid and the vertical bars(|) indicate the 3 by 3 grid. As you can see, this is the starting board except that the middle slider is one spot over to the left, and that there is an O at the very top right. What happens in this scenario? There is nothing immediately underneath it, so does it go out of play? No. This is because it still falls into the bottom slider, which means that it is still in play. The final grid is this: --- --- --- --- --- | | | | - - --- --- --- --- --- --- - | | | | - --- --- --- --- --- --- | | | | - O - --- --- --- --- ---  Pieces can also stack outside of the 3 by 3 grid. Players will alternate between O and X, with the O player going first. ## Example game: Start with 3 by 3 grid with sliders all the way to the right: --- --- --- --- --- | | | | - - --- --- --- --- --- | | | | - - --- --- --- --- --- | | | | - - --- --- --- --- --- The O player places an O in the middle column of the 3 by 3 grid and it falls to the bottom: --- --- --- --- --- | | | | - - --- --- --- --- --- | | | | - - --- --- --- --- --- | | O | | - - --- --- --- --- --- The X player then places an X in the middle column: --- --- --- --- --- | | | | - - --- --- --- --- --- | | X | | - - --- --- --- --- --- | | O | | - - --- --- --- --- --- The O player then pushes the middle row slider one space to the left. Notice that after the slider moves, there is nothing under the X anymore, so it falls down. Also note that the slider has moved one space to the right as indicated below: --- --- --- --- --- | | | | - - --- --- --- --- --- --- - | | | | - --- --- --- --- --- --- | X | O | | - - --- --- --- --- --- The X player places a X in the rightmost column: --- --- --- --- --- | | | | - - --- --- --- --- --- --- - | | | | - --- --- --- --- --- --- | X | O | X | - - --- --- --- --- --- The O player then moves the bottom slider one spot to the left. Notice that all the pieces shift one place to the left, and the leftmost X is now out of the playing field: --- --- --- --- --- | | | | - - --- --- --- --- --- --- - | | | | - --- --- --- --- --- - X | O | X | | - --- --- --- --- --- The X player places a X in the leftmost column: --- --- --- --- --- | | | | - - --- --- --- --- --- --- - | X | | | - --- --- --- --- --- - X | O | X | | - --- --- --- --- --- The O player places an O in the leftmost column: --- --- --- --- --- | O | | | - - --- --- --- --- --- --- - | X | | | - --- --- --- --- --- - X | O | X | | - --- --- --- --- --- The X player shifts the top slider one place to the left. Notice that the O falls one place down because there is nothing beneath it: --- --- --- --- --- - | | | | - --- --- --- --- --- - O | X | | | - --- --- --- --- --- - X | O | X | | - --- --- --- --- --- The O player is not very good at this game, so he shifts the middle slider one place to the right. This shifts all the pieces in the middle row one place to the right: --- --- --- --- --- - | | | | - --- --- --- --- --- --- | O | X | | - - --- --- --- --- --- --- - X | O | X | | - --- --- --- --- --- The X player wins the game by placing a X in the middle column: --- --- --- --- --- - | | X | | - --- --- --- --- --- --- | O | X | | - - --- --- --- --- --- --- - X | O | X | | - --- --- --- --- ---  Your job is to take in a string or array of any length that only consists of 9 unique characters(you choose the characters). Three of the characters will choose which column you place the X or O(depending on whose turn it is), three of them will choose which slider to move right, and the last three will choose which slider to move left. You can assume that the input only has these 9 characters. The output should be a 3 by 3 matrix or some kind of list/string that clearly shows the final position of the grid upon following the instructions of the input. You can assume that all inputs are valid. Each character takes up a turn. Also, if any move results in a winning move(forms 3 in a row in the 3 by 3 grid like regular Tic-Tac-Toe), then ignore the rest of the input. Note that the pieces that form the winning 3 in a row all have to be in the 3 by 3 grid. The two example grids below are NOT winning positions: Grid #1: --- --- --- --- --- | | | | - - --- --- --- --- --- | | | | - - --- --- --- --- --- | | | O | O - O - --- --- --- --- --- This is not a winning move because two of the O's are outside the playing field, despite the fact that it forms a 3 in a row. Using the character assignment stated below, this grid pattern can be achieved with 99372467643. Grid #2: --- --- --- --- --- | | | | - O - --- --- --- --- --- | | | | O - X - --- --- --- --- --- | | | O | X - X - --- --- --- --- --- This is not a winning position because two of the O's are outside the playing field. Using the character assignment below, this grid pattern can be achieved with 939318836537734654  In the examples below, 1, 2, and 3 mean drop in the leftmost, middle, and rightmost column respectively. 4, 5, and 6 mean to move the top, middle, and bottom slider to the right respectively, and 7, 8, and 9 mean to move the top, middle, and bottom slider to the left respectively. ## Examples Input will be in the form of a string Output will be a list of lists, with each sub-list representing a row(I'm Python programmer so this list format might not be compatible with all languages). The first, second, and third sub-list correspond to the top, middle, and bottom row of the 3 by 3 grid respectively. The output will have 'O' for the O pieces, 'X' for the X pieces, and an empty string for empty spaces. Input: 123332 Output: [['','','O'], ['','X','X'], ['O','X','O']] Input: 33387741347 Output: [['','',''], ['','','O'], ['X','O','X']] Input: 2283911752 Output: [['','X',''], ['O','X',''], ['O','X','']] Input: 228374739 Output: [['','',''], ['','',''], ['X','X','X']] Input: 8873334917349 Output: [['','',''], ['','','O'], ['X','X','O']] Input: 799333466 Output: [['','',''], ['','',''], ['','','']] Input: 99372467643 Output: [['','',''], ['','',''], ['','','O']] Input: 939318836537734654 Output: [['','',''], ['','',''], ['','','O']]  This is , so shortest code wins! ## My concerns about this challenge: Are the rules of this game explained enough? Do you understand this game? Is this a good challenge overall? Are the examples correct(if you understand the rules)? Should I put more examples(or if you understand the rules, could you supply me with some)? What other tags can this challenge fit into? • Welcome to the site! Generally it's a good idea to leave challenges in the Sandbox for at least a few days to give people time to review. Even more so if you have questions/concerns about your challenge. – Dingus Aug 2 at 4:51 • @Dingus The problem is I already posted it so what do I do now? – Aiden Chow Aug 2 at 7:01 • Actually I was referring to future challenges. For this one, there are probably two options: 1. Leave it on main, responding to feedback in the comments. 2. Delete the main post, wait a while (maybe a week) for more feedback here, then repost/undelete on main. The choice really depends on how much needs to be done to iron out the kinks. – Dingus Aug 3 at 0:11 • If the moves result in any unpermitted moves, then output any falsey value challenges usually assume only valid input unless the challenge itself is to determine only if the input is valid or not. – Noodle9 Aug 4 at 19:30 • @Noodle9 Ok so should I take that out? – Aiden Chow Aug 5 at 2:04 • Make it one or the other, either assume valid input and output grid. Or determine whether or not input is valid as the challenge. – Noodle9 Aug 5 at 9:30 • @Noodle9 Ok edited. – Aiden Chow Aug 5 at 18:02 # Generalized Game Theory KOTH king-of-the-hill Game Theory is a field of mathematics that is concerned with strategic interactions among 'rational decision-makers'. The main focus of game theory is the payoff-matrix. A payoff matrix represents an interaction between two parties, and shows how many points a party can get if they choose different strategies. Here is an example of a payoff matrix:  Player 1 A | B Player 2 +------+------- A | 3, 3 | 5, 1 +------+------- B | 1, 5 | 2, 2  In this example, if player 1 chooses A and player 2 also chooses A, they would both get 3 points. If player 1 chooses B but player 2 chooses A, player would get 5 points but player 2 would only get 1. The above payoff matrix is an example of the prisoners dilemma ## The challenge Programs will face off in a round-robin tournament. Each round will consist of a randomly generated payoff matrix, with both programs choosing either strategy A or strategy B. Programs will earn points accordingly. The winner will be the program with the most points, with ties broken by source code length. ## Questions for meta: • best practices for creating KOTH challenges? • language considerations? I'm most comfortable with javascript but am also capable of writing in python • is it better to limit a KOTH to one language? it's easier to manage but limits who can submit • or allow multiple languages? It allows more people to compete but is more difficult to judge • Any comments about the overall problem? • Has this been done before? • 1-1) Either JS or Python should be fine. Both are popular here and you can share the controller's code on TIO so that others can easily run it. Some other KOTH writers tend to provide a visual interface, but it's completely optional. 1-2) KOTH is usually limited to one language since they have to compete through the controller. 2) I don't think it's done before. But tie-breaking by code golf is not a good idea (in fact, tie breaking is not necessary at all). – Bubbler Aug 19 at 0:29 • Also, if you're planning to run through hundreds of payoff matrices, it will be more interesting to allow the programs to remember previous matches, so the whole competition looks like a generalized repeated game. – Bubbler Aug 19 at 0:32 • @Bubbler In that case I will probably make the controller in javascript. And yes, the game will definitely be repeated and programs will be able to access the past history. thank you for your feedback :) – thesilican Aug 19 at 0:40 # Is my triangle on the lattice? decision-problemcode-golfgeometry Write a program or function which takes three positive integers $$\a^2, b^2, c^2\$$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose sides' lengths are $$\a, b, c\$$. (Note that the side lengths are the square roots of the numbers read.). By "on the square lattice" I mean that its vertices are in the $$\xy\$$ plane, and their $$\x\$$ and $$\y\$$-coordinates are all integers. Test cases: • 16 9 25: true (3-4-5 triangle) • 8 1 5: true (e.g. (0,0), (1,0), (2,2)) • 5 10 13: true (e.g. (0,1), (1,3), (3,0); sides needn't be on grid lines) • 10 2 1: false (not a triangle: long side is too long for short sides to meet) • 4 1 9: false (not a triangle: three points in a straight line) • 3 2 1: false (triangle is on the cubic lattice but not the square lattice) • 3 7 1: false (triangle is on the hex lattice but not the square lattice) • 25 25 25: false (no such triangle on this lattice) • 5 5 4: true (isosceles is OK) • 15 15 12: false (OK shape, wrong size) • 25 25 20: true (OK shape and size; common prime factor 5 is OK) # The Turing Text Tape Posted here: TTT: Turing Text Tape • If you have a reference implementation, please do add it in. – Razetime Sep 23 at 4:43 • I already did, there's a link to a python 3 implementation... – mindoverflow Sep 23 at 20:45 # Number size Size Up a Number Posted. • Why isn't 3 "tre"? (also, I don't understand the "remove each of the characters uniformly" part) – the default. Aug 31 at 16:27 • I shuld keep that separate. three can be the or tre. – Razetime Aug 31 at 16:28 • Is fivie a valid output for 5? – Bubbler Sep 1 at 2:40 • "so long as the order of the letters in the string remains the same." so no. @Bubbler – Razetime Sep 1 at 3:22 • What do you mean by "duplicate uniformly"? Should all letters be repeated by the same amount (±1)? – Zgarb Sep 1 at 7:43 • yes, that is pretty close to what I mean, @Zgarb. I'll make it clearer. – Razetime Sep 1 at 7:44 • It's still not clear what is meant: the text says "uniformly" but also "in whatever way you like", and the example does it in a cyclic order. – Zgarb Sep 1 at 13:51 • I hope it makes more sense now. @Zgarb – Razetime Sep 1 at 15:36 • I suggest something like this: "If the string's length is lower than the number, repeat some of its characters in place until the length matches the number. The first and last characters should not be repeated, and the numbers of repetitions of the other characters should differ by at most one (so you can repeat some of them 5 times and others 6 times, for example; it doesn't matter which ones exactly). If the string's length is greater, remove any of its characters except the first and last to make the length match the number." – Zgarb Sep 2 at 10:25 • Thanks for the modification. I've put it in bullet points. – Razetime Sep 2 at 10:40 • sorry about that, fixed it, – Razetime Sep 3 at 11:13 • Do we really have to support the edge case 100? – Arnauld Sep 3 at 11:25 • It doesn't make too much of a change from the challenge, I'll keep it till 99. – Razetime Sep 3 at 11:26 • Looks pretty good. A few small things: (1) 'write it in words(without spaces)' do you mean with or without spaces? You have both 'fifty three' and (later) 'sixtyone'. (2) 'Taking 20 as an example' -> 'Taking 11 as an example'. (3) For the 61 example, 5 letters must be duplicated 10 times and 1 character must be duplicated 9 times. – Dingus Sep 4 at 1:24 • It's unfortunate that answers will probably spend most of their bytes getting the word for the input number, rather than the actual stretching. I'd consider having the word being stretched be a separate input or something. – xnor Sep 6 at 8:33 ### I have abandoned this challenge. If you would like to take it over, feel free to take the idea, and maybe leave a comment so people know you've taken over. # King of the Hill: Avalon king-of-the-hill (See revision history) # The Great Code Golf Heist Alternatively, the most literal cops'n'robbers you'll ever see ## Backstory Sandbox Note: This part will be specific to each thread, so I've provided each version ### Robbers For the last few years, you and your team of robbers have been planning to rob the International Code Golf Museum (ICGM) of some of it's most prized possessions (rumour has it, they have a rare transcript of Dennis being outgolfed!). Tonight is the night that your plans will be put into action... tonight you will walk away with glorious riches and legendary artifiacts of code golf history. That is, if you can actually manage to get in, loot the rooms and get back out without getting caught. ### Cops Tonight has been a quiet night at the Internation Code Golf Museum (ICGM)...too quiet for one's liking. Of course, that's probably due to the fact that a bunch of robbers are rumoured to strike tonight and steal the most priceless artifacts from the ICGM's collections (we can't have them finding out the fact that Arnauld is a machine learning algorithm designed to answer challenges with Javascript, can we. [that's a joke we love you Arnauld!]) It's your job to stop the robbers and make sure that not a single thing leaves the museum. ## The Museum Sandbox Note: This part is common to both cops and robbers Here is a map of the museum: You may be wondering "hang on, what are the dimensions of that map?". Well the answer is simple: you don't need to know. Movement around the ICGM is analogous to a Henry Stickmin game: in each room, you can either move to an adjacent room, or perform an action in that room. Robbers start at the Getaway Car and can enter through either Hallway A or Hallway B. They then move through Hallway A.A then Hallway A.B or move through Hallway B.A and then Hallway B.B. Either way, they end up at the exhibition room. From the exhibition room, robbers can move to any of the treasure rooms which is where all the valuables are stored. After that, they make their way back to the getaway car to, well, escape and get away. Cops are randomly allocated a position at the start of the heist, and can move wherever they need to. Sandbox Note: There's going to be a system where each room takes a certain number of "strides" to get from one end to another. This way, robbers with stolen items are "slowed down" a little and the cops have a bit of a chance to catch up ## Stealing Treasures Sandbox Note: Robber specific Once you reach a treasure room, you have the oppourtunity to get your hands on some of the finest works the ICGM has to offer. There will be a selection of items to choose from, each with different values. Sandbox Note: I might add a part where there is a limit on how much robbers can carry However, items with more value impact how fast you can move through. Sandbox Note: Something relating to the stride system here. But being the sneaky robbers you are, you have a few tricks up your sleeve(s). When moving through the ICGM, you can: • Activate a trap that will slow down the cops (avaliable only once Sandbox Note: Subject to change) • [Other things coming soon] Once you get back to the getaway van, everything you have stolen is considered "safe" and counts towards your team's score. But once you're in the van, that's it... you can't go back for more. Your team wins if you manage to steal items with a combined worth of insert value here ## Protecting the ICGM Sandbox Note: Cop specific In order to protect the artifacts of the ICGM from being stolen, you have a few abilities you can use against the robbers. You can: • Apprehend a robber if they are in your proximity • [Other things coming soon] For your team to win, the total value of items stolen must not exceed insert value here ## The Catch Sandbox Note: Common to both threads The heist program will only be simulated once. That means that if your submission errors, you're out of the game for good. I mean, you don't see criminals replace the things they stole just to rerun the heist over and over to see how good they are ;P. The heist will occur on insert date here. You can edit your submissions all you like until the time of running. ## The Controller Coming soon. # Feedback • Seeing as how this is a first draft, there are bound to be flaws with things like the movement mechanics and cop/robber interactions. I'm more looking for first impressions and overall flaws in the challenge. • I can't wait to see the valuables you place in the treasure room. – RGS Oct 13 at 17:13 # Political Simulator (Taken over from HyperNeutrino) It's election time, and your job is to beat your competitor in a head-on rivalry! You are both trying to win over a city of 256 people in a 16x16 grid. Right now, the city hasn't been divided into voting regions yet, but that's where your gerrymandering skills come in! You can also campaign in arbitrary areas of the city to gain support. ## General All bots will be run against all other bots once per game. In each game, the city will start out with all voters being neutral. The game will keep track of a number for each voter, determining who they support. From a particular bot's perspective, a positive number means that voter will vote for them, while a negative number is a vote for the opponent. Zero is neutral. Both bots start with100, and can move once per turn. These moves are run effectively simultaneously, so there is no first turn advantage. Moves fall into four categories:

• Campaigning: This will cause every person in a specific area to increase their support for the candidate who is campaigning. The amount it changes depends on their neighbors.
• Polling: This will get the average support for the candidate in a specific area.
• Bribing: This will cause a particular person to increase their support for the candidate.
• Region Merging/Unmerging: This will reshape voting regions.

At the end of each turn, after both candidates have moved, both will recieve $25. ## Details The following moves are allowed. If an invalid move is given (insufficient money or invalid coordinates), the bot's turn will be skipped. All coordinates should be within 0 <= n < 16, and for the second pair in rectangular bounding areas 0 <= n <= 16 (as these are exclusive). • campaign([x, y], [x, y]): Campaign within the boundary determined by the two coordinate pairs • Costs$1 per person affected
• Each person within the area will change their support according to the following rules:
• For all neighbors orthogonally (including diagonals) adjacent and within the boundary, add 0.05 support for whichever candidate they support, or 0.15 if their support is at least 1.5 for that candidate
• Add 0.25 for the candidate who is campaigning
• poll([x, y], [x, y]): Poll within the boundary determined by the two coordinate pairs
• Costs $0.25 per person polled, rounded up • On the next turn, the following information is given about each person in the area (after the opponent's move): • Their support for the polling candidate, where positive numbers indicate a vote for them, and negative numbers being a vote for the opponent • bribe([x, y]): Bribe the person at the location determined by the coordinate pair • Costs at least$5
• For every time a person within the voting block (not the voting region) has been bribed, add $0.25 (and round down) • Add up to 3.5 support for the bribing candidate • For every time a person within the voting block has been bribed, the support added is decreased by 0.15 • Eventually, this can cause bribing someone in a voting block to reduce their support for the candidate • merge([x, y], [x, y]): Merge the voting regions determined by the two coordinate pairs • Costs$25 for every block in the larger region
• Requires the regions which contain the two people specified to be touching
• Note that the coordinates correspond to people, not blocks. To reference a block, just multiply its coordinates by 4
• unmerge([x, y]): Unmerge the voting region determined by the two coordinate pairs
• Costs \$15 for every block in the region
• Every block in the region becomes its own region

## Winning

At the end of each turn, after both candidates have moved, all regions will have their votes added. Each person will either vote for one candidate or be neutral, regardless of by how much (i.e., a score of +0.05 or +30 would be identical here). If the following conditons are met, an election will be held and the winner chosen:

• All regions are made up of less than half neutral voters
• The number of regions voting for each candidate are not tied

## I/O

All bots should be submitted in the form of Javascript functions. The following information will be provided as arguments to the function:

• An array of voting regions, represented as objects with the following properties:
• blocks: An array of voting blocks, represented as the coordinates [x, y] of the top-left person (such as [4, 0] or [12, 12])
• number_neutral: The number of people in the region who are neutral
• number_you: The number of people in the region voting for the bot
• number_opponent: The number of people in the region voting for the bot's opponent
• absolute_average: The average absolute value of people's support for a candidate
• Higher numbers indicate campaigning or bribing will typically be less effective
• Exactly 0 would mean every person in the region is neutral
• The amount of money the bot has
• An object containing the results of the last move (empty unless it was a poll)
• An array people will contain objects representing each person polled:
• position: The person's coordinates, formatted as [x, y]
• region: The numbered ID of the region the person is in (the region's index in the first argument)
• support: A number indicating whether the person is neutral (0), voting for the bot (positive), or voting for the bot's opponent (negative)
• An object amounts containing the following properties:
• number_neutral: The number of people in the region who are neutral
• number_you: The number of people in the region voting for the bot
• number_opponent: The number of people in the region voting for the bot's opponent
• absolute_average: The average absolute value of people's support for a candidate
• An object that can be used for storage between turns (but not between rounds/games)

To move, the result one of the functions above should be returned. For example:

{
"Example": (regions, money, result, storage) => {
storage.block = ((storage.block || 0) + 1) % 16;

return campaign(
[(storage.block / 4 | 0) * 4, (storage.block % 4) * 4],
[(storage.block / 4 | 0) * 4 + 4, (storage.block % 4) * 4 + 4]
);
}
}


## Rules

• Bots should take a reasonable amount of time to run
• Bots should play fairly, no manipulating the controller or other submissions in ways not allowed here
• Every bot will be run against every other bot once, with the winner being the bot which wins most often
• In the event of a tie, the earlier bot wins
• Invalid return values or bots that error will assume no move for the turn
• Bots must be deterministic

## Sandbox

• Is this game balanced? Is there room for strategy?
• Is there anything unclear? Is it difficult to read ("wall of text" or similar)?
• Is there anything repetitive or unnecesary? Underspecified?

# Can I print my picture on {A,B,C}{0-10} paper?

The task is to find the smallest paper size on which it is possible to print a picture of the dimensions given in milimetres. The image will be printed without margins.

# Input:

Two numbers, bigger than zero, and a letter a, b, or c, for example:

290

200

A

# Output:

Paper size, for example:

A4

• Upper- and lowercase variants of letters "A", "B" and "C" are allowed on input and on output.
• The values can be passed as a parameter or entered by the user.
• You need to handle paper sizes A0 - A10, B0 - B10 and C0 - C10. If the image is too large, you can throw an exception, print an error or whatever you want, as long as it is clearly different from valid result and the application will not hung up.

This is - fewest bytes wins.

New contributor
TeslaX93 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Perhaps you should inline what sizes the An, Bn and Cn papers are. Also, some more test cases (~5-10) would be nice for the final version. – Sisyphus 2 days ago

# Almost Illegal Strings

Welcome to a cops and robbers version of Find an Illegal String.

An illegal string is "a string of characters that cannot appear in any legal program in your programming language of choice" (from the linked post).

For this challenge, we will define an almost illegal string, which is a string of characters that is very hard, but not impossible, to include in a valid program.

## The Cops' Challenge

• Choose a programming language, and choose an 'almost illegal string' - this is a sequence of characters that is very hard to include in a valid program without causing it to error.
• Write a program that prints Well done! to standard output, with exact capitalization and optionally with a trailing newline, that contains the 'almost illegal string' you chose.

That's it! You will reveal the programming language and the almost illegal string, and challenge robbers to write a program that contains the illegal string you chose and prints Well done!.

## The Robbers' Challenge

Find an uncracked answer. Write a program in the language specified that contains as a contiguous substring the almost illegal string specified and prints Well done! exactly to standard output, optionally with a trailing newline. Your program does not need to be exactly what the cop had in mind. Post an answer to the robber's thread and leave a comment on the cops' answer to crack it.

## Clarifications

• Solutions may print anything to standard error, and may terminate with a non zero exit code, as long as the only output to standard output is the Well done! string specified.
• The cop's almost illegal string that they reveal is to be interpreted with respect to the standard encoding for the language's interpreter. For most programs, this will be UTF8.
• Solutions should not take any input (via standard input, argv, or any other source) and may assume no such input is given.
• Solutions must terminate in a finite amount of time. This means entering an infinite loop and getting killed by TIO's 60 second timeout is not a valid solution.
• Cops should make sure if their almost illegal string contains leading or trailing newlines that it is very clear it does so. Robbers should carefully note any leading or trailing newlines in a cop's post.

## Formatting hint

The clearest way to inlcude leading or trailing newlines is to use the backtick syntax for your post:



foo




Renders as:


foo



To remove any ambiguity, explicitly mention the leading/trailing newlines in your post.

## Scoring

After 10 days without a crack, a cop can mark their answer as safe and reveal their solution. Once the cop has revealed their solution, it is no longer able to be cracked.

Cops are scored based on the length (in bytes) of their almost illegal string in their safe answer(s), with lower being better.

Robbers are scored by the number of answers they crack, with higher being better.

## Example

### Python 3, 5 bytes

Illegal string:

"'1/0


### Python 3, cracks example's answer

Program:

print("Well done!")#"'1/0


The idea is that we can just comment out the string.

# Count Syllables

The goal of this challenge is to write a program that can count the syllables in a word as accurately as possible.

## Input

On STDIN, your program will receive a number X followed by X lines, each containing a single word. Simple enough. (Should there be a limit on the size of X?) The words will come from this list.

4
challenge
to
count
syllables


## Output

Your output should be to STDOUT and have X lines. On each line should be the number of syllables counted in that word.

2
1
1
3


# Scoring

To score you program, it will receive a long secret list of words to test. All programs will receive the same list of words. For each word, the number of syllables that your program got wrong will be added to the score of the program. If it output a 4 or a 2 when the word had 3 syllables, then one point will be added. If it said a 15 instead of a 3, then 12 points will be added to the score. The lower the score, the better.

For example, if for the above input your program output 3 2 2 2 (which would be produced by a program that counts strings of vowels), then the program would receive a score of 2.

# Rules

Your program should not access any external files (such as the word list). Also, your program should be no more than 5,000 bytes long (is this a reasonable limit?).

The winner will be the person whose program has the lowest score, therefor the most accurate syllable counter. The deadline for submissions is [some time at least a month away].

# Suggestions

I am open to all constructive criticism. Is 5,000 bytes a reasonable limit for the program size? How long should the official scoring test be? How long should the deadline be?

• This has one major flaw: the output is subjective. How many syllables do these words have? Every; victory; hierarchy; desire; oil; hour; poem. The only real way I see to work around this is for you to produce a marked-up version of the word list. – Peter Taylor May 29 '12 at 20:40
• I was really worried about that, and I don't see a way around it. – PhiNotPi May 29 '12 at 20:42
• I personally would love to see more language processing challenges. I agree with @PeterTaylor on the difficulty of some words. Perhaps taking a specific text(s) and identifying explicitly in the challenge which words will have how many syllables? – Gaffi Jun 8 '12 at 3:34
• @PeterTaylor ...Or maybe you could filter ambiguous words out of the reference list? – user16991 Feb 8 '15 at 1:19
• What's the point of the first line of input? – msh210 Apr 27 '16 at 20:05
• If you provide a reference list, A hyphenated reference list, and hide a secret list which may or may not include members of the reference list, this would be a reasonable challenge – Rohan Jhunjhunwala Sep 17 '16 at 0:05
• Do you plan to post this? If not, I'd be happy to adopt it. (If you don't respond within two weeks, by community standards, I'm allowed to do so.) – MD XF Aug 18 '17 at 3:20
• The example of inaccurate program that would score 2 - did you mean to output 3 1 1 2 rather than 3 2 2 2? – Heimdall Nov 9 '17 at 18:31
• A reference list could be dynamic: potential contestants can ask for words of their choice to be added to the list. They won't know what's on the secret list but will try to make their programs as accurate as possible (according to your syllable count) so they should always be able to ask for specific words they are not sure about. Of course, you could make it in different language. In my language, Slovene, it's much clearer how many syllables words have. How about Solresol, haha! – Heimdall Nov 9 '17 at 18:38
• I am going to adopt this if you don''t respond – Christopher Dec 20 '17 at 16:48

## Play Simple 2-Dimensional Minecraft

Recently I found this video of "HansLemurson" showing a computer that was built in minecraft, which runs minecraft. He is playing minecraft on a computer that was built in minecraft that is running on his computer. To be specific, it is a two dimensional version with an 8x8 grid of cells. There is gravity, block placement, and even jumping. It is worth noting that the computer is single purpose. The same person has built programmable computers, but making them single purpose allows the computer to be much smaller.

## Details

The minecraft world is an 8x8 grid (one horizontal and one vertical dimension). The grid is comprised of either Xs (representing blocks) or empty spaces. The player is an X that is blinking on and off about once every second.

There are two modes in the game, controlled by a toggle switch. The first mode is movement. This is controlled by a WASD-like button arrangement. If the player chooses to move left/right/down, the computer checks to see if the space immediately in that direction is empty. If so, then the player moves into that space.

If the player chooses to move up, then the computer checks that the block underneath the player is solid. If so, then the player moves upward two units. Notice that this can propel the player into a solid block. If this happens, the player is obscured by the solid block, but can still move to an empty block next to him. When the player is inside on a solid block, the game continues as if the block isn't there, although the block is still there once the player leaves it.

After each move, the player falls down one unit if there is empty space there. This simulates gravity. This is also why moving up moves up two units, so that the gravity makes a net movement of up one unit. Gravity does not cause the player to fall all of the way to the ground, just one unit.

The second mode is block placement. In this mode, the same exact WASD buttons are used. Instead of moving the player, they toggle the state of the block in that direction. If the player presses "left" and there is a block there, then the block is destroyed. If there is not a block there, then a block is placed. Again after this move, the player is again subject to gravity. The blocks are not subject to falling.

Toggling the toggle switch does not count as a move, and does not invoke gravity.

The game board is a torus, so all actions (movement, block creation) can wrap around the board. The board does not scroll with the player. The player moves, and the blocks stay in the same place.

## The challenge

You challenge is to write the shortest program that simulates this game. Your program should display and update the map correctly (with Xs as blocks, and with the blinking player). It should accept input from a button that toggles the state and four buttons for movement and actions. This is code golf.

There are imaginary bonus points for adding more features (block types, game size, etc) to your game.

## Suggestions?

• With more complicated challenges I find that it helps to do a reference implementation so that you have a very concrete idea of how much work is involved. Aside from that, I like it. – dmckee --- ex-moderator kitten Jun 3 '12 at 20:11
• Is the blink rate selected to fit with the ANSI escape sequence? Either way I would explicitly allow that, because it's the obvious way to do it on compatible terminals. – Peter Taylor Jun 5 '12 at 7:14
• The blink rate wasn't selected to be anything specific. I think that I will broaden the restriction. Maybe any blink rate between 3 blinks per second to 1 blink every 2 seconds. – PhiNotPi Jun 5 '12 at 20:21
• @programmer5000 No, for two main reasons: First, challenges can go extended periods of time in the sandbox before they are posted and/or adopted. In the past I've posted challenges after not touching them for 4 years. Second, deleting this answer will not reduce lag, as deleted answers are still present, simply not visible. Users with sufficient rep will see all 4040 answers in the sandbox, and you will too once you earn the "view deleted answers" privilege. – PhiNotPi Apr 13 '17 at 18:15