# 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

To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

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
• Comments addressing specific points mentioned in the proposal
• 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!

The goal of this challenge is to fill a niche that is mostly lacking on this site. In my observations there most parsing verification challenges fall into two categories:

1. Super easy parsing. This parsing can usually be done with a regex, and regex based answers usually do well.

2. Super complex parsing. These are challenges with a lot of small parsing components that would on their own be type 1, but together make for long code with a lot of edge cases.

Neither of these categories are really bad, each can have fun challenges, but I want to shoot for something different. A challenge which is hard, hard enough that a regex will be unable to do the brunt of the work but with a easy to understand spec.

The goal of this challenge is to parse a lisp-like lambda function. Your code should accept a string as input and output of two possible consistent values. One which corresponds to an affirmative response (i.e. the input is a properly formatted lambda) and the other corresponds to a negative response (i.e. the input is not a properly formatted lambda).

I've put together 3 specifications of what constitutes a validly formatted lambda for this challenge. The first is a quick intuition base explanation. It explains the process and what things mean even if it is not perfectly rigorous. The second a formal grammar which expresses the idea succinctly and with no ambiguity. And the third is raw code, which is the hardest to read for humans but allows you to play around with the idea by trying different inputs. I recommend you read one of the first two and play around with the third.

## Formatting

The challenge uses a lisp like format. This consists of "lists" which are just parentheses enclosing lowercase words, and other lists separated each by a single space. So

(foo (bar baz) foobar)


Would be a lisp-like "list". For our challenge each list will be identified by it's first element (which should by highlighted by the syntax highlighter), which must be either app, abs, or var, representing applications, abstractions and variables, respectively.

An application is the application of one lambda function to another. It is represented by a three element list starting with of course app followed by two other valid lambda expressions. So if S and K were valid lambdas then:

(app S K)


would be a valid lambda too.

The other two abstractions and variables work together, an abstraction introduces new names for variables and variables use those names. An abstraction encloses some lambda which must be valid with the introduced variable name, and a variable can only use names which are given by abstractions that surround it. So

(abs x (abs y (var x)))


Is valid because the x name was introduced and used in a nested context. But

(app (abs x (var x)) (var x))


Is not because even though there is an abstraction for x the second (var x) is not surrounded by any abstraction at all, let alone one that introduces x.

Additionally abstractions can only introduce new variables, so

(abs x (abs x (var x)))


is not valid because the name x is ambiguous, it could refer to either abstraction. Variable names must be a string of lowercase ascii letters (a-z).

## Grammar

Now for the golfy definition. This parse cannot be defined in terms of a context free grammar, so this grammar uses context. The context is a set of strings of lowercase ascii letters as these are the valid variable names.

$$\ \begin{array}[rr] \ S\left(x\in C\right) &:= \color{green}{\texttt{(var }}x\color{green}{\texttt{)}} \\ S\left(x\notin C\right) &:= \color{green}{\texttt{(abs }} x\texttt{ }S(C\cup\{x\})\color{green}{\texttt{)}} \\ S\left(C\right) &:= \color{green}{\texttt{(app }} S(C)\texttt{ }S(C)\color{green}{\texttt{)}} \end{array} /extract_tex] Any string spanned by the grammar is valid and any string not is invalid. ## Code I've exhausted myself with the above. I will write to code in a bit when I've eaten and stuff. ## Scoring This is so answers will be scored in bytes with the goal being a smaller score. ## Test cases ### Reject (abs x (var x uuuuuuuuu )))(abs x (var x)) app (abs x (var x)) (abs x (var x)) (mmm hummus) (abs x (var y)) (abs x (abs x (var x))) (app (abs x (var x)) (var x)) (abs (var k) (var (vark k)))  ### Accept (abs x (var x)) (abs x (abs y (var x))) (abs xx (app (var xx) (var xx))) (app (abs ab (app (var ab) (var ab))) (abs ab (app (var ab) (var ab))))  ## In need of title. Note: In the final challenge $$\N\$$ will be a concrete number (I am thinking about 100), but while this is in the sandbox it is subject to change so I have left it as $$\N\$$. This challenge is based off of a list of $$\N\$$ Castilian Spanish words and the words they originate from. You are to write a program or function which takes the origin word as input and outputs as close as possible the Castilian derivative. Your program should be no longer than $$\N\$$ bytes. ## Scoring To calculate your score run your program on every origin word and calculate the distance between your output and the correct answer. Your score is the sum of all these distances. The distance here is a modified version of Levenshtein distance. It is the same as Levenshtein distance except replacement steps that add or remove a diacritic cost only 1/2 of a step as opposed to their normal 1. You can use this code to calculate the distance between two strings. The goal is to have as low a score as possible. ## About the list All of the origin words, spare 1, are Latin words (Late or Classical depending on the word). The one exception is ezkerra (the origin for izquierda) which is of Basque origin. It has been added as an extra curve-ball in case you can get all the others with a little space to spare. Verbs are always in the infinitive form and nouns in the nominative singular. The words are not chosen randomly but rather I have focused on choosing words that follow a number of simple rules. The list is also organized so that words that undergo similar transformations are grouped together. This is for your ease of use, nothing more. # The list faba, haba facienda, hacienda facere, hacer fundus, hondo profundus, profundo fungus, hongo fabulare, hablar furnus, horno ferrum, hierro filus, hijo filum, hilo folia, hoja fovea, hoyo fagea, haya fastidium, hastío fastidiare, hastiar afflare, hallar formica, hormiga fetere, heder ficcare, hincar factor, hechor factum, hecho octo, ocho octavus, ochavo noctu, noche lacte, leche iactare, echar coctus, cocho dictatum, dechado capere, caber sapere, saber lupus, lobo lacrima, lágrima lacuna, laguna eruca, oruga pater, padre mater, madre liber, libro thema, tema theatrum, teatro thesaurus, tesoro thesis, tesis thorax, tórax aether, éter anthropologia, antropología orthographia, ortografía sapphirus, zafiro philosophia, filosofía echo, eco chalare, callar chamaeleon, camaleón chaos, caos materia, materia resistentia, resistencia aurum, oro taurus, toro autumnus, otoño annus, año scribere, escribir scutum, escudo scutella, escudilla scriptor, escritor ezkerra, izquierda  • I think it's interesting in that it should be near impossible to get a perfect score without built-ins. As a suggestion I'd remove the non-ASCII words, or at least normalise them, and perhaps not let \N\ be too high. Also, I wonder what the default cat program would be. – Jo King Mar 3 '20 at 12:31 • @JoKing I am looking to somewhat twart perfect scores, I feel there should always be some room for improvement, It just is a little hard to balance this with golfing-languages ability for expressiveness. I am interested to hear what ranges for \N\ you think are too high. I started out by avoiding any non-ASCII characters, but it was really hard to build up a representative corpus of words. Plus the accents and eñe really are a feature of the language. I may adjust the scoring so that i and í for example are only half away from each other so that the penalty is small. – Wheat Wizard Mar 3 '20 at 13:05 • Suggested title: Hispanize these words. Also mention that words should be in lowercase. Finally I think it makes more sense to restrict programs to \N\ characters rather than \N\ bytes. – SunnyMoon Nov 20 '20 at 15:24 • I'm not a fan of "Your program should be no longer than N bytes". I think a scoring rule which incorporates both the Levenshtein distance and the byte count would be better, as in the Moby Dick challenge: it would allow more languages to compete, and would allow for more creativity. – Robin Ryder Nov 22 '20 at 23:43 • @RobinRyder I think that metrics that combine two non-obviously related factors such as in the Moby Dick challenge or as you are suggested rarely work. In fact I can't even think of an example I feel is good. They simply require fine tuning that can only really be done in retrospect. I also don't know how this would allow more languages to compete and I certainly don't know how it would "allow for more creativity". If you have a specific metric in mind and a compelling reason why that metric would not be broken I would be happy to try it out and see. – Wheat Wizard Nov 23 '20 at 1:38 • Sorry, I'll expand: with a low, hard limit on the number of characters, non-golfing languages don't stand a chance (hence the "more languages" part). If instead you set a high hard limit, it will be possible to reach a (near) perfect score, with no incentive to golf or search for trade-offs (hence the "creativity" part). There surely exists a sweet spot for the character limit where neither of these issues arise, but (a) it will be hard to find and (b) it will be highly language-dependent. – Robin Ryder Nov 23 '20 at 7:53 • @RobinRyder I think that 100 characters is plenty of characters for nearly any language to implement something a bit more complex than cat (e.g. replace ^f with ^h). I also think that it would require quite a few characters any language to acheive a perfect score. More than half of the words have seemly random vowel mutations that are not covered by any general rule. The only way I can see a perfect score is a compression decompression method. It seems to me to write the de-compressor and make up for the loss would require a deal of room. – Wheat Wizard Nov 24 '20 at 15:56 • What I'm saying is that I think that sweet spot is actually very large. And I think that adding more dimensions to the problem only increase the risk of missing the sweet spot. – Wheat Wizard Nov 24 '20 at 15:57 • I'm not sure the modified version of the Levenshtein distance really adds something to the challenge, but it certainly makes it harder to score an answer. Would you consider updating your script so that it accepts the whole list of translations? – Arnauld Dec 2 '20 at 22:36 • Some possible typos (I'm a native Castillian Spanish speaker and I'm familiar with Latin): afflare, hallar; factor, factor; chalare, callar – Luis Mendo Dec 20 '20 at 18:00 • @LuisMendo hallar and chalare are definitely typos. But hechor was intentional. I suspect your hang up is that factor and hechor are doublets but factor is more similar to the Latin. There are plenty of words here for which the Latin is not a direct translation or the Spanish or vice versa (even factor is not). I chose to include hechor because it is a good example of some of the changes that I want to highlight, (f -> h and ct -> ch). – Wheat Wizard Dec 21 '20 at 23:26 • The thing is, I never heard hechor. But I just checked in the dictionary and it is included, albeit as an old form, not in current use – Luis Mendo Dec 21 '20 at 23:46 # Strobogrammatic Numbers ### Definition A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better, (source: w3resource.com) # Task Given a number as the input, determine if it's strobogrammatic or not. # Examples • Truthy 1 8 0 69 96 69169 1001 666999 888888 101010101  • Falsey 2 3 4 5 7 666 969 1000 88881888 969696969  # Rules • The number is guaranteed to be less than a billion. • We are considering 1 in it's roman numeral format for the sake of the challenge. • Input can be taken as number, or an array of chars, or as string. • Output would be a truthy/falsey value. • This is a , so fewest bytes will win! # Meta • Although I've tried a search, but is this a duplicate? • Is the challenge's text clear enough? • Any tricky/interesting test case? # Explain a Code Golf Answer code-golfstring ## Background When writing Code Golf answers, it is often a good idea to add an explanation of the code so the reader understands what's going on. For example, this this answer by @Makonede (abridged):  θ # last element of Σ # the input, sorted in increasing order by 1¢ # the number of ones of % # modulo žJ # 4294967296 b # in binary  The full program is written on the first line, then a blank line, then on each successive line, a little snippet of the program, aligned using spaces with its position in the full program, and then some comments on the right-hand side explaining each part. I, for one, find writing and aligning these explanations tedious, so let's outsource it to a program. ## Task Given a program as a string, and a list of sets of pairs of start/end indices to form an inclusive range, output each sub-string defined by the indices on a new line, indented to its respective position in the whole string, with a # at the end of the line, padded so that there are two spaces before the # after the last sub-string, ready for the user to add their explanation. ## Rules • You may use 0-based or 1-based indexing • You are guaranteed to receive valid, non-overlapping ranges, which together cover the whole string • You may assume the program string contains no newlines, tabs or other unprintable characters, and no double-width characters • Standard I/O rules and loopholes apply • This is , so shortest code in bytes wins ## Examples (1-based indexing) Inputs: abcdwxyz, (1-8) Output: abcdwxyz #  Inputs: abcdwxyz, (5-7), (1-2),(8-8), (3-4) Output:  wxy # ab z # cd #  Inputs: <<<[grep -c wx 0-grep -c y\z 0];:<<'Q', (6-20), (22-37), (4-5),(38-38),(21-21), (1-3), (39-39), (40-40), (41-45)] Output:  grep -c wx 0 # grep -c y\z 0 # [ - ] # <<< # ; # : # <<'Q' #  # Meta • Is this a duplicate? • Is this clear enough? • Any other feedback? • Related – Razetime Dec 24 '20 at 10:32 • @Razetime I would say this is a dupe :-( – pxeger Dec 24 '20 at 13:35 • I'd say this is simpler and more suited for code golf because it functions without the need for a complex priority system. You may want to request more opinions on the nineteenth byte. – Razetime Dec 24 '20 at 17:51 # Interpret Interval Notation • @Adám yes to ∪ and -ish characters. I also broadened the scope to all meaningful intervals, so ranges may overlap and [5,5] (all integers x where 5<=x<=5)is [5] but not [5,5) (all integers x where 5<=x<5) and (5,5) (all integers x where5<x<5) are undefined. – Aiden4 Dec 22 '20 at 21:07 • All integers x where 5<=x<5 would be [], no? – Adám Dec 22 '20 at 22:25 • I'd put all the undefined cases separately, or at least at the end. – Adám Dec 23 '20 at 0:09 • Typo: the [9,13] test case should either be [9,13) or 13 is missing from the output. – Dingus Dec 23 '20 at 2:35 • undefined cases should be undefined behavior instead. Otherwise, one need to handle it separately which feels bad. Otherwise, it's a good challenge :) – vrintle Dec 23 '20 at 11:22 • If you allow other symbols for the brackets, make sure to prohibit other phrases as that can be abused. – Adám Dec 23 '20 at 15:16 • @Adám what do you mean by phrases? – pxeger Dec 23 '20 at 16:06 • @pxeger Multi-character constructs. It'd allow solutions to require an input format that contained the necessary code such that the solution becomes an eval. – Adám Dec 23 '20 at 16:46 • Related – Razetime Dec 24 '20 at 10:44 • Is parsing a string necessary? Could you also allow other constructs (tuples with a marker to show if they're open or closed)? – user Dec 25 '20 at 21:56 • Just asking frankly, did you forgot to post this, or is something yet missing? – vrintle Jan 4 at 2:59 • @user I am going to say no to other constructs otherwise, it is basically a duplicate of the related challenge. – Aiden4 Jan 4 at 15:03 • @vrintle Something like that. I haven't really been active since just before Christmas. I'll probably post it this afternoon. – Aiden4 Jan 4 at 15:04 # Implement a zipwith function • APL or J will win this with 2 bytes (that's the shortest possible score, right?) – Adám Jan 14 at 21:23 • Required tag: restricted-source – Adám Jan 14 at 21:24 • Why the builtin restriction? – Redwolf Programs Jan 14 at 21:45 • @RedwolfPrograms To avoid trivialising the challenge – caird coinheringaahing Jan 14 at 21:52 • @Adám 1) if those 2 bytes are a builtin, then no, otherwise, very possible. 2) Why [restricted-source]? – caird coinheringaahing Jan 14 at 21:52 • Any reason for banning that builtin in Haskell and Jelly? What's wrong with people submitting that as answer? They won't get upvoted much anyway. And it still lets people use builtins in other languages. – user Jan 14 at 22:14 • @cairdcoinheringaahing No, that'd be prohibited by your source restrictions rule on an exact built-in. Rather, it'd be a more general built-in (so not "exact") plus a parameter that makes the general built-in choose the required behaviour. – Adám Jan 15 at 3:21 • Allowing the built-in and seeing how many languages have it could be interesting in its own right. Or, generalize the problem to nzipwith, which takes an n-ary function and n sequences (and optionally the value n) and call the function for each n-tuple from the n sequences. – Bubbler Jan 15 at 6:10 • I've softened the builtin ban to simply encourage people to post a non-builtin answer as well. @Bubbler Possibly, but I think it'd be a good challenge to simply have the basic zipwith given that it's a fairly common functional programming construct – caird coinheringaahing Jan 15 at 14:39 • I think it's better to not ban them, and simply let builtin users wallow in their downvotes/shame so they don't do it again – pxeger Jan 16 at 19:45 • @pxeger I've removed the builtin ban, and changed it to encourage builtin-only answers to include a non-builtin version as well – caird coinheringaahing Jan 16 at 19:47 • Would taking input as two lazily evaluated iterators over the elements of the list or outputting an iterator over the results be acceptable – Aiden4 Jan 26 at 1:39 • @Aiden4 I think that taking lists as lazy iterators is an accepted I/O method, so yes – caird coinheringaahing Jan 26 at 9:11 • I find the former ban on Jelly's " interesting considering that there's no way to really pass it a function. – Unrelated String Jan 26 at 9:36 # KoTH: Hunter-Gatherer Society In this challenge, the goal is to write a bot (Javascript function) which survives for as long as possible with its tribe. The bots are placed on an island, with the ability to hunt, gather, farm, and build. Tribes can fight, and the last alive wins. This challenge is complicated, and it's designed to be that way. I'd recommend starting out with bots that specialize in a particular type of strategy, like gathering berries or fighting. To keep this post from being longer than it already is, technical details will be included in the links labeled More at the end of each section. (Meta: These links don't go anywhere yet) ## Overview Bots have hit points and hunger. In order to survive, bots need to eat. There are various foods, such as berries from berry bushes, bread from farming, and meat from hunting. Materials like sticks, rocks, logs, and ores can be found around the island, and used to make tools and buildings. The island has grasslands, forests, and rivers. Rabbits and elk can be hunted for meat and hide, with sticks, rocks, or spears. Meat can be cooked over a campfire. Tribes can build walls to protect their farms and bases, and fight to defend them with weapons and armor. Bots can talk to their tribe members, and trade for rare materials. ## Hit Points, Hunger, and Turns All bots have a number of hit points, and a number of hunger points. Bots start with 7.5 hit points, out of a maximum of 10. When they reach 0 or below, they die. Various actions take hunger. Bots start with 75, out of a maximum of 100, and when they drop below 0 hunger points they instead lose 10% of the hunger taken in hit points. Games consist of a number of turns. During each turn, all bots can perform actions including moving, eating, harvesting, and fighting. Each action takes a certain amount of hunger, and every action performed in the same turn after the first one doubles the hunger taken. More: Turns ## Terrain The world consists of a square grid, with a radius determined by floor(25 * sqrt(bot_count)) + 25. The center of the grid will always be [0, 0], with coordinated ranging from [-radius, -radius] to [radius, radius]. Positions will always be specified in absolute coordinates as an array [x, y], and most actions that take a position argument will require the bot to be adjacent to that position unless otherwise specified. This land is divided into four biomes: • Grassland • Forest • River • Ocean The outer ring of 25 grid squares will be ocean. This consists of a beach closer to the center, with water continuing to the boundary of the world. Rivers will generate similarly, usually with a width of 5-10, with a thin beach on each side. Each naturally generated terrain square can be one of the following: • Plain • Bush • Berry bush • Tree • Stone • Copper ore • Iron ore • Sand • Water Grasslands are mostly plain, with some stones and bushes. Forests are more interesting, with many trees and some stones, bushes, and berry bushes. More: Terrain ## Movement Bots can move in any of four directions: north(), east(), south(), or west(). Only some terrain can be walked into: • Plain • Sand • Farmland • Bush (+1) • Berry bush (+1) • Water (+2) It typically takes 1 hunger to move. However, moving into certain terrain (marked with +1 or +2) can take extra hunger. An addition hunger point is taken for every 10 items the bot is holding, rounded down. Multiple bots can occupy the same position. ## Food There are four foods, which restore different amounts of hunger: • Berries: 10 • Meat: 15 • Bread: 25 • Cooked meat: 40 Foods also restore 10% of their hunger restoration in hit points. Berries can be collected from berry bushes, by returning harvest() when adjacent to (or standing in) a berry bush. Meat is obtained by hunting, bread is crafted with grain, and cooked meat requires a campfire. Grain can be initially collected by returning harvest() when adjacent to (or standing in) plain land. It can also be collected from farming. Bread can be crafted by returning craft(Item.BREAD) while holding 1 grain and 1 rock. The rock will not be consumed. More: Food, Harvesting ## Resources Many types of terrain can be broken by returning break(position), turning into plain land and giving items: • Bush: Stick × 1 • Berry bush: Berries × 1 • Tree: Log × 2 • Stone: Stone × 1 • Copper ore: Copper ore × 1 • Iron ore: Iron ore × 1 Trees require an axe to break. All four will reappear after a number of turns if the land remains plain. A stone axe can be crafted from 1 stick and 1 stone by returning craft(Item.STONE_AXE), and will break after 10 uses. More: Breaking, Crafting ## Farming A stone shovel can be crafted from 1 stick and 1 stone by returning craft(Item.STONE_SHOVEL). A shovel can be used to turn plain land into farmland, and will break after 20 uses. This is done by returning shovel(position). Grain can be planted on farmland by returning plant(position). It will take around 100 to 200 turns to grow, although the amount of time is much shorter within 20 squares of water. Grain starts as Growth.NOT_GROWN, and cannot be harvested (only broken). It then becomes Growth.GROWING after about 70% of the total time, and will give one grain when broken or harvested. Finally, the last stage is Growth.GROWN, where two to four wheat are given from harvesting. More: Farming ## Hunting A stone spear can be crafted from 1 stick and 1 stone by returning craft(Item.STONE_SPEAR). A spear can be used to hunt, as well as a stick or stone. Bots can attack at a position by returning attack(position) (hunt(position) and fight(position) are aliases). Movement happens before attacking, so simply attacking an animal's current position may not work. If attacking would hit multiple targets, damage is distributed between them evenly. Sticks and stones have a range of 1, with sticks dealing 0.35 hit points, and stones dealing 0.75. Spears deal one hit point, with a maximum range of 2. A spear breaks after 10 successful hits. Attacking takes 10 hunger, whether or not any target is successfully hit. There are two types of animals: rabbits and elk. Rabbits have 1 hit point, and elk have 4. Rabbits will move every 1 to 2 turns, avoiding bots if they are very close. Elk will move every 2 to 4 turns, and will always move away from attackers for 2 to 4 turns after being attacked. Rabbits will give the last bot to hit them 1 meat, and have a 25% chance of giving 1 hide to the second to last player to hit them. Elk are similar, giving 1 meat and 1 hide to the last bot to hit them, and 1 meat to the bot that hit them the 2nd to last time. More: Hunting ## Tribes All bots will be part of a tribe. Tribes are determined by the creator of the bot, can contain any number of bots from any number of writers. Bots in the same tribe will be able to recognize each other, while bots outside their tribe will only have their tribe name known. Tribe members cannot attack each other. If a tribe member is next to another one, they can give an item with give(name, item), or transfer any JSON-serializable data with talk(name, data). Armor can be crafted from 2 hide with craft(Item.ARMOR). When a bot is holding armor, it can take up to 10 hit points before breaking. Bots fight with other bots in the same way they hunt animals. When a bot is killed, its items are distributed among the bots that attacked it recently according to the damage done. More: Tribes, Fighting ## Building Bots can build walls and campfires, by returning build(build, position), where build is one of Terrain.WOOD_WALL, Terrain.STONE_WALL, Terrain.CRATE, or Terrain.CAMPFIRE. Wood walls require 2 logs, and take 10 hits with an axe to break, giving the bot that breaks it one log. Stone walls require 4 stones, and take 75 hits with an axe to break, giving the bot that breaks it one stone. Crates require 1 log and 1 bronze, and can store items. If you're adjacent to a crate, you can store items in it with store(position, items), and take an item with take(position, items). Crates can store up to 40 items. The contents of crates are visible to any bot. Campfires require 1 stone, and 2 sticks, and can be used to cook meat. Campfires can be given fuel using fuel(position, item), accepting sticks, logs, and charcoal. Bots can cook meat or logs (which turn into cooked meat and charcoal, respectively) using cook(Item.MEAT) or cook(Item.LOG), if adjacent to a campfire. Cooking meat uses 3 fuel, and cooking logs uses 5. A stick provides 1 fuel, a log provides 5, and charcoal provides 15. A campfire can be broken with an axe, and will give the bot that breaks it all of the unused fuel it holds. Partially consumed logs or charcoal will not be given. More: Building, Cooking ## Upgrading Copper ore and iron ore can be cooked into bronze and iron in a campfire, requiring 10 and 15 fuel respectively. Bronze and iron can be used to craft stronger axes, shovels, and spears, by replacing the stone in the recipe with the corresponding item. For axes and shovels, the material affects the durability: • Stone axe: 10 • Bronze axe: 15 • Iron axe: 25 All shovels have twice the durability of a similarly strong axe. Spears are different, with all tiers having 10 durability. Instead, the number of hit points dealt is upgraded: • Stone spear: 1.0 • Bronze spear: 1.5 • Iron spear: 2.5 Because these items are so rare, trading might be a good way for a tribe to advance. By returning offer(sell, buy), any bot can offer a number of items they have (sell) for a number of items they want to have (buy). All bots will receive an array of offers made on the last turn, and can accept one with accept(offer), where offer is an offer ID. The sell array should contain IDs of items the bot is holding, while buy should be an array of objects. All objects should have an item property with the Item wanted, and an optional durability property can specify a minimum durability acceptable. If no minimum durability is included, only undamaged items will be accepted. More: Trading ## Bots Many arguments and functions involve enums including Terrain and Item. Here is a reference: • Terrain: PLAIN, BUSH, TREE, STONE, COPPER_ORE, IRON_ORE, FARMLAND, SAND, WATER, WOOD_WALL, STONE_WALL, CAMPFIRE • Item: STICK, BERRIES, LOG, STONE, COPPER_ORE, IRON_ORE, CHARCOAL, BRONZE, IRON, MEAT, COOKED_MEAT, GRAIN, BREAD, HIDE, ARMOR, STONE_AXE, BRONZE_AXE, IRON_AXE, STONE_SHOVEL, BRONZE_SHOVEL, IRON_SHOVEL, STONE_SPEAR, BRONZE_SPEAR, IRON_SPEAR • Growth: EMPTY, NOT_GROWN, GROWING, GROWN • Animal: RABBIT, ELK All bots should be Javascript functions, which take four arguments: • grid: A 15 by 15 grid centered around the bot, with all items being objects: • terrain: A type of Terrain • details: An object, with a has_berries property for Terrain.BUSH, a growth property for farmland (Growth.EMPTY if no grain is planted), a hit_points property for walls (starts as 10 for wood or 75 for stone), and a fuels property for campfires (array of Items.STICK, Items.LOG, and Items.CHARCOAL, does not include partially burned) • bots: An array of bots, with all being objects: • tribe: A string containing a tribe name • name: A string containing a bot name, if the bot is in the same tribe • animals: An array of animals, with all being one of Animal.RABBIT or Animal.ELK • bot: An object with information about the bot: • hit_points: Hit points • hunger: Hunger • position: Position as [x, y] • items: An array of items held, with all items being objects: • id: A unique ID for this item • item: A type of Item • durability: For armor, axes, shovels, or spears, the remaining uses (or hit points) until broken • offers: An array of offers from other bots on the last turn: • id: An ID unique to the offer • sell: An array of the items the seller is offering: • item: A type of Item • durability: For armor, axes, shovels, or spears, the remaining uses (or hit points) until broken • buy: An array of items the seller wants: • item: A type of Item • durability: For armor, axes, shovels, or spears, the minimum durability acceptable • talking: An array of data sent from other bots on the last turn: • name: The name of the sending bot • data: The data sent by the bot • storage: An object that can be used for storage between turns # Meta (Note that none of the links to More work yet) • Is this clear enough as it is, without the technical details? • Is there too much information, or is it too hard to read? • Do you think there will be strategy and clever bot design? • Would you compete in this challenge? Why not? ## New features Things I recently added: • Trading between tribes • Communication within tribes • Bronze and iron, and better tools • Crates to store items • When you say "Bots start with 75, out of a maximum of 100, and when they drop below 0 hunger points they instead lose 10% of the hunger taken in hit points." Did you mean: "Bots start with 75 hitpoints, out of a maximum of 100, and when they drop below 0 hit points they instead lose 10% of the hunger taken in hit points."? – DanielOnMSE Mar 9 at 4:58 • @DanielOnMSE The reverse, mostly. Bots start with 7.5/10 hit points, and 75/100 hunger. When a bot drops below 0 hunger, additional hunger is taken from the bot's hit points instead (but scaled by 10%) – Redwolf Programs Mar 9 at 5:19 • Ahh okay. I think this contradicts "Bots start with 7.5 hunger, out of a maximum of 10. When they reach 0 or below, they die" Unless hitpoints/hungers still mean something when dead? Nice idea btw. I've upvoted. I'll continue to trawl through it and see if I can find any errors. I think I get what you are trying to say with the hitpoints/hunger but I think you may have accidentally swapped the two in some places? – DanielOnMSE Mar 9 at 5:28 • @DanielOnMSE Ah, I see what you mean. I'll fix that. – Redwolf Programs Mar 9 at 5:44 • Just food for thought. Might make the challenge more approachable if you wrote a script that created the world state and takes input/gives output every turn to the bots? Or is part of this challenge making the "game" itself? Perhaps you've already considered this and made something. Whether or not this is implemented will determine the complexity of this, imo. Like if you could create something everyone involved could use to test their bot? Also give it fixed input and output formats? – DanielOnMSE Mar 9 at 5:53 • @DanielOnMSE Usually that's part of making a KoTH, yeah. There's a controller program (usually written by the author before posting) that manages all of the bots, sets up the games, determines the winner, etc. – Redwolf Programs Mar 9 at 13:21 • This challenge seems very interesting but even more complex to me... but I'd give it a try. However, it would need many participating bots to utilize all of its features and make it fun to play. Technical note: break won't work as a function name (it's reserved) unless it's an object property. – FZs May 18 at 15:38 • @FZs Part of my goal when designing this KotH was specifically for it to be very complex; I'm hoping bots will be sort of forced to specialize. Thanks for noticing the break thing, I guess I'll rename that to destroy or mine – Redwolf Programs May 18 at 15:40 # Calculate the 'geothmetic meandian' of a set of numbers Randall Munroe's March 10 xkcd comic "Geothmetic Meandian" defines the 'geothmetic meandian' of a set of positive real numbers as follows. Define a function F, such that F accepts a set of n positive real numbers and returns the set (a, b, c), where a is the arithmetic mean of the set (the sum of the numbers in the set divided by n), b is the geometric mean of the set (the product of the numbers in the set to the power of 1/n), and c is the median of the set (the average of the middle two numbers in the sorted set when n is even, and the middle number in the set when n is odd). The function F can therefore be applied again to its own output. Iterating F an infinite number of times should cause its three outputs to converge to one value g. This value g is defined as the geothmetic meandian of the original set of positive reals. (For the purposes of this challenge, you may assume this value exists and does not diverge.) Given a nonempty list of positive real numbers in any convenient and reasonable format and a positive integer q, compute its 'geothmetic meandian' to q significant figures. Standard rules apply, and the shortest code in bytes wins. ## Test cases [[1], 2] --> 1.0 [[2, 8], 4] --> 4.742 [[1, 1, 2, 3, 5], 6] --> 2.08906 [[1, 2, 4, 8], 6] --> 3.13227 [[1.1, 2.2, 4.4, 8.8], 9] --> 3.44550208  • This seems like a decent challenge, but I don't know if the rounding requirement adds anything. – rak1507 Mar 11 at 2:40 • @rak1507 I was accounting for if different languages have different levels of floating-point precision, and also because the calculation needs to stop at some defined point. – Cloudy7 Mar 11 at 3:24 • The problem with taking the number of significant figures q as input is that you're banning the use of float and double numbers entirely (doubles will break at q >= 16 or so), which is a big no-no. You could take the number of iterations i instead and require the solutions to output the result of i-th iteration. – Bubbler Mar 12 at 5:05 • @Bubbler I envisioned part of the challenge to be determining when to stop the iteration of F. Should I then restrict q to be a positive integer from 1 to 7 or something similar? – Cloudy7 Mar 12 at 17:28 • Alternatively, we can have have a fixed number of iterations i and output the geothmetic meandian to the highest precision possible given i iterations. However, thinking about it, I agree this part of the challenge may be unfeasible. – Cloudy7 Mar 12 at 17:39 • Oh dear. I just tried another test case and due to floating-point errors in calculation, my program slowly drifts by 2e-12 indefinitely as F is iterated... – Cloudy7 Mar 12 at 17:49 • How about this: Given a value q (a positive floating-point number), stop iteration when the difference between the maximum and the minimum is less than q, and output any of the three numbers (or all of them). Allow the solutions to fail if q is too small compared to the input (i.e. it is outside the precision capability of the floating-point type in use). I think this is clearer to specify the error margin this way. – Bubbler Mar 15 at 3:46 • Or just require that all programs use a fixed q, e.g. 100? – pxeger Mar 20 at 17:53 • I feel like adding anything to do with the precision will just complicate things, and most of the code will be for handling that, not for actually answering the challenge. IMO it's fine to say 'until it converges', and leave specifics up to the challenge answerers. – rak1507 Mar 22 at 12:19 # Complete the landscape Carcassonne is a tile-based game, where the objective is to construct Roads, Cities and Monasteries, in order to score points. The game works by players taking turns to draw and place tiles to construct a landscape, then claiming roads, cities and monasteries. An example landscape is: There are $$\19\$$ distinct tiles (ignoring rotations), each of which contains at least one feature (Road, City or Monastery): Also, notice that the landscape must be consistent. This means that roads must connect to other roads, city edges must connect to other city edges and fields must connect to fields. Therefore, these tiles are inconsistent: To avoid this challenge being about image processing, we can translate each tile into a list containing $$\5\$$ values, according to this legend: [North edge, East edge, South edge, West Edge, # of cities] 0: Field 1: Road 2: City  For instance, this tile can be described as [2, 0, 1, 1, 1]. Using this legend, we can describe each tile uniquely, and it's rotations are rotations of the first four elements. The entire grid can be described as a rectangular matrix, with a $$\20^\text{th}\$$ distinct value for an empty square. Translating the first landscape into this format, we get: [ [ [], [], [1, 1, 0, 0, 0], [1, 1, 2, 1, 1], [0, 1, 0, 1, 0], [], []], [[1, 0, 1, 0, 0], [], [0, 0, 0, 0, 0], [2, 0, 2, 0, 2], [], [0, 2, 2, 2, 1], [0, 0, 0, 2, 1]], [[1, 1, 0, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 0], [2, 2, 0, 0, 1], [2, 2, 0, 2, 1], [2, 0, 0, 2, 1], []] ]  using [] to represent an empty square. The complete list of tiles (ignoring rotations) in the same grid as the second image is [1, 0, 1, 0, 0] [0, 0, 1, 1, 0] [2, 1, 1, 1, 1] [0, 1, 1, 1, 0] [2, 0, 0, 0, 1] [2, 2, 0, 2, 1] [0, 0, 0, 0, 0] [2, 2, 2, 2, 1] [2, 2, 0, 0, 1] [2, 1, 1, 2, 1] [2, 2, 0, 0, 2] [0, 0, 1, 0, 0] [2, 0, 1, 1, 1] [2, 1, 1, 0, 1] [0, 2, 0, 2, 1] [1, 1, 1, 1, 0] [2, 1, 0, 1, 1] [2, 2, 1, 2, 1] [2, 0, 2, 0, 2]  Your task is to take in a rectangular matrix where every element save one is one of the 19 tiles given above or one of their rotations. Tiles can appear more than once, and not every tile will appear in every input. This landscape will be consistent, as defined above. You should take in this input and output the tile that could fill the empty space in the array, keeping the landscape consistent, as defined above. As the number of cities on a tile is redundant for this task, you may choose instead to only work with 17 tiles (as 2 tiles are duplicated when ignoring cities) and take input as lists in the form [N, E, S, W] instead. If there are multiple tiles that would work, you may output either all of them or just one. If no such tile exists, you may produce any output/result that could not be construed as a tile (i.e. it's not in the 19 tiles specified above, nor in any of their rotations). The representation of the "empty space" in the input may be your choice, so long as its consistent, and (although I'm not sure why you would) it isn't one of the 19 tiles above or their rotations, and there will only ever be a single empty space. This is , so the shortest code in bytes wins. ## Test cases test cases to be added # Meta • Is this clear enough? • More specifically, is the definition of a "consistent landscape" objective and understandable? • This is a somewhat related question, but I believe there are enough differences between the two for them to not be duplicates. Thoughts? • Tags are , , , . Any suggestions? • Any further feedback? • @Beefster Aside from involving tiling, I'm not quire sure how that challenge is related, let alone a possible duplicate – caird coinheringaahing Sep 28 '20 at 22:00 • Filling Carcassonne tiles in a grid can be thought of as a specific case of wang tiles with a different set of tiles, but upon closer inspection, seeing as your challenge is to complete the landscape, rather than fill a grid from nothing, this is actually a pretty different challenge. – Beefster Sep 28 '20 at 22:03 • Related – Beefster Sep 28 '20 at 22:04 • Does the 5th field, the # of citys, add anything? Makes it more cumbersome to store/rotate the tiles. Though it's understandable if you want to keep true to Carcassonne. – xash Mar 17 at 19:21 • @xash Yes, without the number of cities, some tiles (e.g. [2,2,0,0,1] and [2,2,0,0,2]) have the same representation as an array – caird coinheringaahing Mar 17 at 19:22 • @xash As "there will only ever be a single empty space.", "the empty space" makes more sense, as it refers to the only empty space in the input – caird coinheringaahing Mar 17 at 19:26 • Ah! I thought "The "empty space" in the input may be your choice" refers to which empty space to choose to fill, not the representation. Sorry, haven't slept well, makes perfect sense. :-) – xash Mar 17 at 19:29 • While I agree that to match Carcassonne, the number of cities field is useful for disambiguating two different tiles, it would never affect whether a tile fits into the space or not, so for this challenge it seems redundant. – Nick Kennedy Mar 20 at 7:42 • Will the 19 possible tiles be supplied as an input or do they need to be encoded into the answer? – Nick Kennedy Mar 20 at 7:46 • @NickKennedy Good point, I didn't realise that. I've added in a note about the redundancy of the city count. No, the tiles will not be provided as input, so the answer will need to implement some way of encoding them – caird coinheringaahing Mar 21 at 11:52 # Hide a message in ASCII art and an image (needs cooler title) # Cops # Robbers • How the heck?! I was just drafting a challenge about stenography and images yesterday and then I see this.. – Redwolf Programs Mar 26 at 16:28 • @RedwolfPrograms was your idea the exact same as mine? – Beefster Mar 26 at 16:35 • Not identical, there was no ASCII art included, but considering there are only 5 steganography questions on the whole site that's an insane coincidence – Redwolf Programs Mar 26 at 17:03 • If the robber doesn’t know any of the messages, it might be hard to verify any potential explanation. It might be more fun and easier to verify a correct solution if the cop posts N codes and the solutions to N-1 of them, and the robber has to use those to reverse engineer the method and decode the last one. Alternately, the cop could have to pick from a list of pre-selected messages so the robber has some idea what to look for. – water_ghosts Mar 26 at 17:33 • Do the ascii+png files have to contain all the information necessary for decoding? For example, could I use a book cipher where the PNG encodes word numbers, and you then have to look up the corresponding words from The Great Gatsby? – water_ghosts Mar 26 at 18:03 • @water_ghosts I think a book cipher should only be allowed if you provide a link to the book. All data needed to decode aside from the image and ascii art should be present in the post and be constant across all encodings. – Beefster Mar 29 at 18:43 • This is amazing! You, dear sir/ma'am, get an upvote – StackMeter Apr 3 at 17:05 # Determine Circles • Nice idea, but could you make it clearer what do you mean by cross? A test case would be good. – math Apr 6 at 7:04 • @math intersect or some concept like that. Can you give some better wording if you can understand what I mean? I can't find any word that suit line go over dot – okie Apr 6 at 7:09 • Maybe: 1, 2, 3 points will need 1 circle only to be sure that the points touch the circles boundary? Is that what you mean? – math Apr 6 at 7:17 • Some testcases are definitely needed, like five points on one circle and three points on another. Also, are the coordinates integers or real numbers? – Bubbler Apr 6 at 8:15 • @Bubbler Real number I think – okie Apr 6 at 8:17 • @okie Then you need to explicitly write it down, and add some testcases with non-integer coordinates. – Bubbler Apr 6 at 8:21 • In this problem, the answer does not change continuously with small perturbations of the input coordinates. Is it allowed to output the wrong answer due to floating point errors? For instance, if the input coordinates were (0,0),(0.3,0.3),(1,1) then the output should be 2. However, if the second point were instead (0.3,0.300...00001) then the answer should be 1. Given that floating point types are usually unable to tell these two cases apart, are we allowed to output either 1 or 2? – Delfad0r Apr 6 at 16:01 • @Delfad0r Thanks for your help. To solve such problem (float precision), I decided to add a limit to float so that precision are not extreme. – okie Apr 7 at 0:15 • Another possible approach (which I personally prefer, but the choice is entirely up to you) could be to only have integer coordinates as input, and then ask for an exact solution. If I am not mistaken, this problem should be solvable without resorting to square roots and similar, and therefore without any possibility of floating point errors. – Delfad0r Apr 7 at 12:30 • @Delfad0r But it's like a float *100 0.03*100 = 30 which just get every number bigger? – okie Apr 7 at 23:38 • @okie Yes, but the difference is that computations with integers are exact, while computations with floats are not. It shouldn't matter too much however, do whatever you prefer :) – Delfad0r Apr 7 at 23:43 • @Delfad0r I think I would take Integer, Thanks! – okie Apr 8 at 0:04 # posted lol • Another suggestion it can be kolmogorov complexity challe ge too, if someone downloads tags and compresses the text – Wasif Apr 12 at 5:31 • @Wasif it's better as an internet challenge because a new tag might be created after challenge posting making the list invalid. – lyxal Apr 12 at 5:31 • Should the list include the synonym tags, i.e. the tags that are listed as being on no questions in the tag listing? – caird coinheringaahing Apr 12 at 13:30 • @cairdcoinheringaahing if it is listed on the tags page, then it needs to be included – lyxal Apr 12 at 22:54 • What is the 43 for in example program? – tsh Apr 14 at 3:18 • @tsh 43 is the number of occurrences of tag when you try and access a page of tags that doesn't exist – lyxal Apr 14 at 3:19 • Rule is still too wide, everyone can upload code to codegolf.stackexchange.com – l4m2 Apr 15 at 4:19 • @l4m2 if people include all the tags in a post, then they will have to a) keep it constantly updated (which wouldn't be viewed favourably by the community) and b) withstand potential downvotes for loop holing on both the answer to this and the answer that has the tags – lyxal Apr 15 at 4:45 # Implement an Over function • Can we take \a\ and \b\ as [a,b]? In effect, this would make the challenge a \g\ reduction of \f\ mapped over that input list. – Adám Apr 19 at 21:12 • @Adám I think it would be unfair (and potentially unobservable) to ban languages from taking it as [a,b], and doing so would likely just create solutions in the form pair input; map f; reduce g – caird coinheringaahing Apr 19 at 21:41 # Rob the King: Hexagonal Mazes Consider the following hexagonal maze:  E . \ . . . . . . \ . \ . . . . . \ . \ . _ _ _ _ . \ . \ . . / . . . . . . | . . | . . _ _ _ _ / . . . \ . \ . . . / . . . \ . \ . . / . . . \ . \ . . . . . \ . \ / . . . \ . | . X  E represents the entrance, X the exit. |_/\ are walls and . are free spaces. In order to navigate from E to X, we can move to any free space in the up to 6 immediately surrounding spaces. The path from E to X, marked with P is:  E P \ P P P . . P \ P \ P . . . P \ P \ P _ _ _ _ P \ P \ P . / . . . P P P | P . | . . _ _ _ _ / . P . \ . \ . . . / . P . \ . \ . . / . P . \ . \ . . . P . \ . \ / . P . \ . | . X  This isn't the only path, but the others are trivial variations on it. # Cops You are to write a function in Python 3 which takes a positive integer $$\n \ge 2\$$ and returns a hexagonal maze of side-length $$\n\$$, as shown above. The maze will meet the following criteria: • The only characters in the output are EX.|_\/, space and newline • The hexagon is shown as a hexagon. That means: • The first $$\n\$$ lines will have one more non-space character than the previous line (the first has $$\n\$$ non-space characters), separated by a single space, and offset from adjacent lines • The first $$\n\$$ lines have one fewer leading space than the previous line (the first line has $$\n - 1\$$ leading spaces) • The next $$\n - 1\$$ lines have one more leading space than the previous line • The next $$\n - 1\$$ lines will have one fewer non-space character than the previous line, separated by a single space, and offset from adjacent lines • Lines may not have trailing whitespace • The E is the first non-space character on the first line, and the X is the last non-space character on the last line • There is at least 1 valid path that connects the E and the X, only moving from one free space to an adjacent free space. How your program generates these mazes is entirely up to you. It could randomly places walls in the grid, ensuring there is always at least one path left, or it could only block the center row except for one gap, or anything else. You may return either a multi-line string, or a list of lines. Lines should have appropriate space padding at the start, and may have a consistent amount of trailing spaces. "Consistent" here means either the same number on each line, or padding each line to the same length. The Robbers will be writing maze-solving programs that try to solve your mazes, so you should aim to generate mazes that are somewhat difficult to solve. This is not , you are under no obligation to golf your submission. Additionally, you may submit multiple submissions. You may not include anything in your submission that attempts to communicate with other submissions, attempts to interfere with other submissions or the controller or anything that could be malicious. If you do, your submission will be disqualified Empty mazes of sizes $$\n = 2, 3, 4, 5, 6\$$:  E . . . . . E . . . . . . . . . . . E . . . . . . . . . . . . . . . . . E . . . . . . . . . . . . . . . . . . . . . . . E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X . . . . . . . . . . . . . . . . . . . . . . . . X . . . . . . . . . . . . . . . . . . X . . . . . . . . . . . . X  # Robbers You are to write a Python 3 function that takes in the return value of a cop's answer. It may also take the number of sides, $$\n\$$, as an argument if you so wish. The input will only contain EX_|/\. and space, and newlines if inputting as a multiline string. It will either be a multiline string or a list of lines. Your function should handle both. Your function should then output the maze with any valid path connecting the E and X using only connected free spaces. You may show the path with any character aside from EX_|/\., space or newline. This is not , you are under no obligation to golf your submission. Additionally, you may submit multiple submissions. You may not include anything in your submission that attempts to communicate with other submissions, attempts to interfere with other submissions or the controller or anything that could be malicious. If you do, your submission will be disqualified ## Scoring The scoring will take the form of a round-robin, similar to challenges. Every cop will be paired up with every robber, and the following will happen with each pair: • The controller will call the cop's function 5 times with $$\n = 2\$$ as an argument, saving each of the 5 mazes. The cop will have 1 minute to produce each maze • It will then pass each maze to the robber to solve. The robber will have 1 minute per maze to produce a correct output. • If all 5 mazes are correctly solved by the robber within 1 minute each, the controller goes again, but with $$\n = 3\$$, and so on, increasing the $$\n\$$ by one, until either: • The robber fails to solve a maze within 1 minute • The robber produces an incorrect solution to an input maze • The cop fails to return a maze within 1 minute • The cop returns a maze with no path At this point, both the cop and the robber receive points equal to the highest $$\n\$$ that neither of them failed. If the cop failed, the robber receives an additional point, and if the robber failed, the cop receives an additional point instead. If both the cop and the robber reach $$\n = 50\$$ without failing, they both receive $$\50\$$ points. After all pairs have be run, the cop and robber with the most points are the respective winners # Meta • If you want to automate the scoring process, you might want to restrict the I/O further, e.g. only allow stdin/stdout as a hexagon-shaped multi-line string. (I'm suggesting stdio because I assume you want to allow different languages.) Looks interesting, though I have a slight feeling that a full Dijkstra impl in C will almost surely win as a robber. – Bubbler Apr 12 at 23:01 • @Bubbler Good point, I've updated the I/O to be stricter. – caird coinheringaahing Apr 12 at 23:22 • @Bubbler I've decided to limit it to Python 3 functions, as I was struggling to make a controller that would allow any language to compete – caird coinheringaahing Apr 23 at 15:49 • It's a minor thing, but maybe change E and X to A and B? It seems more logical that way – pxeger Apr 24 at 15:52 • @pxeger I chose E and X as "entrance" and "exit" respectively, but I doubt it'll affect any solutions as opposed to A/B – caird coinheringaahing Apr 24 at 16:06 ## Death-onacci sequence (WIP) The traditional Fibonacci sequence grows forever: 0 1 1 2 3 5 8 13 21 ... 1,346,269 ...  and is given by this formula: f(n) = f(n-1) + f(n-2)  where the initial numbers in the sequence are 0, 1. However, there's a set of as-yet unnamed sequences, where a previous number 'dies' and is removed from the total. For instance the sequence for the 5th death-onacci (m = 5) is given by f(n) = f(n-1) + f(n-2) + f(n-3) + f(n-4) - f(n-5)  And the first m-1 numbers is 0, followed by a single 1 (so for m=5 the sequence start 0 0 0 0 1) Test cases: Here are some test cases: n f(n), m=3 f(n), m=4 f(n), m=5 0 0 0 0 1 0 0 0 2 1 0 0 3 1 1 0 4 2 1 1 5 2 2 1 6 3 4 2 7 3 6 4 8 4 11 8 9 4 19 14 10 5 32 27 11 5 56 51 12 6 96 96 13 6 165 180 14 7 285 340 15 7 490 640 16 8 844 1205 17 8 1454 2269 18 9 2503 4274 19 9 4311 8048 20 10 7424 15156 21 10 12784 28542 22 11 22016 53751 23 11 37913 101223 24 12 65289 190624 25 12 112434 358984 26 13 193620 676040 27 13 333430 1273120 28 14 574195 2397545 29 14 988811 4515065 30 15 1702816 8502786 31 15 2932392 16012476 You must write a function or program that takes one number M, and prints out the first 31 M-Death-onacci numbers. M will be a whole number larger than 0 and less than 31. The output can be in any human readable format, and you can take input in any reasonable manner. (Command line arguments, function arguments, STDIN, etc.) As usual, this is Code-golf, so standard loopholes apply and the shortest answer in bytes wins! • Very similar. – Razetime Apr 24 at 9:57 • @Razetime definitely, but hopefully different enough? – Pureferret Apr 24 at 10:02 • Well, it's a WIP. You can go ahead and add more details which distinguish it. 'tis the sandbox, after all. – Razetime Apr 24 at 10:04 • @Razetime how's it looking now? – Pureferret Apr 24 at 10:23 • looks better, and the tests are more comprehensive. I suggest posting in TNB for other people's feedback. – Razetime Apr 24 at 11:11 • taking P as a fraction seems fine, but it seems more convenient separately since we're just supposed to increment N and P till the desired ratio is achieved. What is the allowance for floating point errors on this question? – Razetime Apr 24 at 10:07 • an additional "Streak bonus" for every x games might be an interesting addition. – Razetime Apr 24 at 10:08 • @Razetime Oh did I say fraction, I meant a decimal value between 0 and 1, eg: 0.53 for 53%. There wont be more than two decimal places in the input so I doubt if any language will run into floating point errors at all. – Manish Kundu Apr 24 at 10:11 • I updated the question to allow P as decimal. About the streak bonus, I think it might complicate things quite a bit so I am not going with that. – Manish Kundu Apr 24 at 10:21 • You should clarify in the text if the inputs W, N can be taken separately or only as one number corresponding to W/N. And if so, please address Razetime's comment on floating point errors – Luis Mendo Apr 24 at 15:17 • @LuisMendo Yes, taking them separately is fine. I updated the post again, please check if it is clear now. – Manish Kundu Apr 24 at 15:47 • I'd suggest also allowing languages to take P as a fraction. Other than that, this looks good to go – caird coinheringaahing Apr 24 at 16:09 • I think they have to be taken separately. In the first example, if you take W/N as 0.2 you cannot compute the output, because you don't know if W=1, N=5, or W=2,N=10, or... – Luis Mendo Apr 24 at 17:32 • Oh yes, you're right about that. You'd have to consider both the values to calculate the answer. – Manish Kundu Apr 24 at 19:01 • @LuisMendo But if it somehow benefits you to take it say as a string of the form "W/N" with the original values of W and N, then that's fine too. I think the rules clarify that point. – Manish Kundu Apr 24 at 19:16 # Gelatin integer metagolf # Drawing the Stack Overflow logo • I don't think restricting the language is a good idea. Move languages promotes diversity among submissions. However, I'm still new to the site so I'm not really sure. – EnderShadow8 Apr 30 at 4:32 • Like Ender said, language-specific challenges are strongly discouraged - here, it doesn't add anything, so removing the restriction would improve the challenge by allowing a wider variety of approaches and solutions. – hyper-neutrino Apr 30 at 4:34 • Also, seeing as to how this is a ascii-art challenge, you will need to either provide the exact text that needs to be outputted or a formal specification of what is considered valid output and what isn't - for example, could I just submit . and claim it's a very zoomed out logo? These will need to be clarified. Overall, I like the idea though. – hyper-neutrino Apr 30 at 4:35 • I think if you require the output to be the exact example you gave it would make it much easier to determine which answers are valid. – Redwolf Programs Apr 30 at 5:15 • @RedwolfPrograms It's the best I got, but I'll make it official. – Matt Sanchez Apr 30 at 5:20 • This challenge looks pretty good now, so I've upvoted, although I'd still recommend waiting a day or two just in case anyone else has feedback on the formatting or finds something unclear. – Redwolf Programs Apr 30 at 5:28 • A tip for future challenges: Anyone (not just you) reading the challenge and an answer should be able to decide (without disagreement) if the answer is valid or not. "Resembles a logo" is very subjective in this sense, and phrases like "as close as" should be avoided too. – Bubbler Apr 30 at 5:34 • @Bubbler Is this better? – Matt Sanchez Apr 30 at 6:10 • Yeah, it's better. A question: would you allow printing trailing spaces at the end of each line, or printing a trailing newline at the end? (These are commonly allowed because they don't impact the ascii art shown and they're hard to avoid in multiple languages) – Bubbler Apr 30 at 6:21 • @Bubbler I added a list of questions that are asked in the comments. Can I add the same if I posted this on main? – Matt Sanchez Apr 30 at 7:39 • I'd recommend to edit the challenge text directly to include any clarifications. – Bubbler Apr 30 at 7:45 • @Bubbler It will do and I'm hoping that when this gets published, I gain enough reputation just to talk in chat. – Matt Sanchez Apr 30 at 7:50 • Tags-wise: [kolmogorov-complexity]. I'd suggest just removing the 2 paragraphs beneath the output, as they just make it more confusing. A simple "output this exact text, with an optional trailing newline. Lines may have optional trailing spaces. Shortest code wins" is enough (plus the output itself) – caird coinheringaahing Apr 30 at 17:35 • I've edited this down to a stub now that it's been posted to save space – caird coinheringaahing May 1 at 13:46 # Time bomb KoTH • Enforcing determinism prevents luck based winning, which I personally like. Adds a sense of balance. – Razetime May 1 at 15:59 • Determinism also means anyone can run a simulation of the game on their own machine. The game then devolves into aggressive metagaming and iteratively updating one's bots to always beat the opponents'. If you decide to enforce determinism among the bots, you must have some outside source of randomness to prevent players from simply simulating the entire game and instead actually formulate a strategy that is robust enough to still work well in the face of unknowns. – EnderShadow8 May 2 at 9:57 • I personally like a bit of non determinism to spice things up but then this came along. So you have to be careful. – EnderShadow8 May 2 at 9:58 • @EnderShadow8 yeah I saw that answer. In the current design, the array for the numbers selected in the previous round will be initialized with random numbers on the first round, giving the initial seed of randomness – leo3065 May 2 at 15:36 • Another thing to consider: high numbers will have very small winning chances, and the entire game is biased towards low numbers (they come first, they don't subtract much, large numbers take many points on explosion vs large numbers give many points on success). So all "smart" bots will choose <= n / 2 numbers, but then the trigger will also be lower, so bots have to choose even lower numbers. That can lead to a case of positive feedback. It may or may not cause problems, but it may be good to keep that in mind. – FZs May 2 at 19:24 • And to the determinism topic: a viable compromise between determinism and randomness could be made: making the only allowed non-deterministic part a seeded PRNG function provided by the controller. The PRNG seeds used for the official ranking are kept secret, but it's still possible to replicate the given match by using the same seed. – FZs May 2 at 19:58 • @FZs That's true. I may need to buff the reward for larger numbers to encourage playing them. Also about the determinism topic, after some searching I found some method to provide a seeded random, and I think I'm going to try that. – leo3065 May 3 at 7:41 • More about the determinism: I decided to decide the secret seed before the challenge starts and provide the hash to prove that I won't change the key mid-challenge. – leo3065 May 3 at 9:14 • I've edited this down to a stub now that it's been posted to save space – caird coinheringaahing May 3 at 14:17 # Count up to 21 21 is a game my teachers had my classmates and I play in order to kill some time. The game works as follows: • All contestants stand in a circle. The aim is to count to 21, one by one. • At any time, any player may begin the counting by saying 1. • The plays then continue the counting by saying the next number. However, if multiple players say the number at the same time, the count resets, and someone has to say 1 again. • The first player who says 21 is "out", and the game begins again with the same contestants except for the "out" player(s) • The final player left is disqualified, and the entire game begins again. The last player not disqualified wins. We are going to run a challenge, where bots aim to play this game. You are to write a function in Python 3 that takes a list of lists $$\L\$$ as argument. Each list in $$\L\$$ represents a round in the game, with the last element being the most recent. The $$\i\$$th element of each list always corresponds to the same bot. Each list in $$\L\$$ will contain $$\n\$$ integers between $$\0\$$ and $$\21\$$, where $$\n\$$ is the number of contestants left in the game. The lists are either all $$\0\$$s, or are $$\n-1\$$ $$\0\$$s and a single non-zero value $$\v\$$. If a list is all $$\0\$$s, either it is the first round, or the counter was reset in the previous round. That function should then return either: • $$\0\$$, meaning that your bot stays quiet • $$\v+1\$$, meaning that your bot is attempting to guess this round And that's it! The competition will work exactly as described above. The controller will run 100 games. Each game will works as follows: • The first round begins with all $$\n\$$ contestants. They will count up to 21, eliminating each contestant as they count to 21, and resetting the count to 0. The final player left is then eliminated, and the next round with $$\n-1\$$ contestants is run. At the end, the final player left standing wins • The player with the most wins after 100 games wins overall You may not include anything in your submission that attempts to communicate with other submissions, attempts to interfere with other submissions or the controller or anything that could be malicious. If you do, your submission will be disqualified If any game has more than 10000 rounds, it'll be terminated and no player will win. ## Example bot This is Random: import random def bot(history): return random.choice([0, max(history[-1]) + 1])  • Infinite loops might happen quite often – Redwolf Programs Apr 28 at 1:51 • @RedwolfPrograms Put a limit of 10000 rounds per game – caird coinheringaahing Apr 28 at 20:32 • TNB Feedback link – caird coinheringaahing Apr 28 at 21:16 • So, if next number is 21: Is there any reason a bot will not to say 21 in that round? – tsh Apr 29 at 1:30 • I feel like someone's going to just add a bot to say every single number no matter what. – A username Apr 29 at 10:54 • @tsh If multiple bots say 21, none of them win and the count resets – caird coinheringaahing Apr 29 at 11:51 • Can you post the code to run the game so we can test our bots? – fasterthanlight Apr 29 at 21:05 • @fasterthanlight I haven't written the controller yet, so no – caird coinheringaahing Apr 29 at 22:57 • but if i will lost their turn if i dont say 21, and the worst case is a tie if I say 21? So any reason I try to be silent? – tsh Apr 30 at 5:10 • Because there's no reason to not say 21, infinite loops are probably going to occur no matter what. You might want to consider adding a rule regarding this to prevent infinite loops (or if everyone but 1 says a number the bot who said 0 can be eliminated) – fasterthanlight Apr 30 at 12:44 • Just wondering, is saving state between different turns allowed? Or between rounds? Or between games? You also don't seem to distinguish between rounds and turns (i.e times when the count resets vs. opportunities to guess), which may cause confusion. Also, a suggestion: Maybe let each game have only a small subset of the bots as contestants, so that if there's that one bot who always says 21 as soon as possible, it would just harm itself rather than ruining the challenge. (Sorry for this long block of text.) – Andrew Li May 4 at 3:42 • Interestingly, this is completely different from the game of 21 I know. – pxeger May 23 at 15:57 ## Challenge Statement The goal of this challenge is to build the 5 state Infinite Time Turing machine that takes the longest to halt. The rest of this challenge is some definitions and an example to help you. ## Turing Machines For clarity we will define the Turing machines as used for this problem. This is going to be rather formal. If you are familiar with Turing machines this is a single-tape, binary Turing machine, without an explicit halt state, and with the possibility of a no shift move. But for the sake of absolute clarity here is how we will define a classical Turing machine and its execution: A Turing machine consists of a $$\3\$$-Tuple containing the following: • $$\Q\$$: A finite non-empty set of states. • $$\q_s : Q\$$: The initial state. • $$\\delta : Q\times \{0,1\} \nrightarrow Q\times \{0,1\}\times\{1, 0, -1\}\$$: A partial transition function, which maps a state and a binary symbol, to a state, a binary symbol and a direction (left, right or no movement). During execution of a specific Turing machine the machine has a condition which is a $$\3\$$-Tuple of the following: • $$\\xi_\alpha : \mathbb{Z}\rightarrow \{0,1\}\$$: The tape represented by a function from an integer to a binary symbol. • $$\k_\alpha :\mathbb{Z}\$$: The location of the read head. • $$\q_\alpha : Q\$$: The current state. For a Turing machine the transition function takes the condition of a machine at step $$\\alpha\$$ and tells us the state of the machine at step $$\\alpha + 1\$$. This is done using the transition function $$\\delta\$$. We call the function $$\\delta\$$ with the current state and the symbol under the read head: $$\ \delta\left(q_\alpha, \xi_\alpha\left(k_\alpha\right)\right) \$$ If this does not yield a result, then we consider the machine to have halted at step $$\\alpha\$$, and the condition remains the same. If it does yield a result $$\\left(q_\delta, s_\delta, m_\delta\right)\$$ then the new state at $$\\alpha+1\$$ is as follows: • $$\\xi_{\alpha+1}(k) = \begin{cases}s_\delta & k = k_\alpha \\ \xi_\alpha(k) & k \neq k_\alpha\end{cases}\$$ (That is the tape replaces the symbol at the read head with the symbol given by $$\\delta\$$) • $$\k_{\alpha+1} = k_\alpha+m_\delta\$$ (That is the read head moves left right or not at all) • $$\q_{\alpha+1} = q_\delta\$$ (That is the new state is the state given by $$\\delta\$$) Additionally we define the condition of the machine at time $$\0\$$. • $$\\xi_0(k)=0\$$ (Tape is all zeros to start) • $$\k_0=0\$$ (Read head starts a zero) • $$\q_0=q_s\$$ (Start in the initial state) And thus by induction the state of a Turing machine is defined for all steps corresponding to a natural number. ## Infinite Ordinals In this section I will introduce the concept of transfinite ordinals in a somewhat informal context. If you would like to look up a more formal definition this explanation is based of of the Von Neumann definition of ordinals. In most contexts when talking about the order of events we use natural numbers. We can assign numbers to events such that events with smaller numbers happen earlier. However in this challenge we will care about events that happen after an infinite number of prior events, and for this natural numbers fail. So we will introduce infinite ordinals. To do this we will use a special function $$\g\$$. The $$\g\$$ function takes a set of numbers and gives us the smallest number greater than all the numbers in that set. For a finite set of natural numbers this is just the maximum plus 1. However this function is not defined on natural numbers alone. For example what is $$\g(\mathbb{N})\$$, or the smallest number greater than all naturals. To create our ordinals we say • $$\0\$$ exists and is an ordinal. • If $$\X\$$ is a set of ordinals then $$\g(X)\$$ exists and is an ordinal. This gives us the natural numbers (e.g. $$\1 = g(\{0\})\$$, $$\2 = g(\{1\})\$$ etc.) but also gives us numbers beyond that. For example $$\g(\mathbb{N})\$$, this is the smallest infinite ordinal, and we will call it $$\\omega\$$ for short. And there are ordinals after it, for example $$\g(\{\omega\})\$$ which we will call $$\\omega + 1\$$. We will in general use some math symbols $$\+\$$, $$\\times\$$ etc. in ways that are not defined explicitly. There are precise rules about these operators, but we will just use them as special notation without definition. Hopefully their use should be clear though. Here are a few specific ordinals to help you out: $$\ \begin{eqnarray} \omega\times 2 &=& \omega+\omega &=& g(\{\omega + x : x\in \mathbb{N}\})\\ \omega^2 &=& \omega\times\omega &=& g(\{\omega \times x + y : x\in \mathbb{N}, y\in \mathbb{N}\})\\ \omega^3 &=& \omega\times\omega\times\omega &=& g(\{\omega^2\times x+\omega\times y + z : x\in \mathbb{N}, y\in \mathbb{N}, z\in \mathbb{N}\})\\ \omega^\omega &=& & & g(\{\omega^x\times y + z : x\in \mathbb{N}, y\in \mathbb{N}, z < \omega^x\})\\ \end{eqnarray} \$$ If an ordinal is not the successor of another ordinal, meaning there is not a next smaller ordinal, we call that ordinal a limit ordinal. For example $$\\omega\$$, $$\\omega\times3\$$, and $$\\omega^{\omega\times 2}+\omega^6\times 4\$$ are all limit ordinals. $$\3\$$, $$\\omega\times 5 + 12\$$ and $$\\omega^{\omega^\omega}+1\$$ are not. Some authors will specify further that 0 is not a limit ordinal, we will be explicit about 0 when we talk about limit ordinals to avoid confusion. ## Infinite Time Turing Machines A classical Turing machine is equipped with a start status, and a way to get from one status to another. This allows you to determine the status of the machine at any finite step. Infinite time Turing machines extend classical Turing machines to have a defined status non-zero limit ordinals as well. That is ordinals as defined above which are not the successor of any previous ordinal. This addition makes the condition of the machine defined at transfinite time as well. ### Formal definition For this we add an additional object to the machine's definition • $$\q_l : Q\$$: The limit state And we define the condition of the machine at some limit ordinal $$\\lambda\$$ to be • $$\\xi_\lambda(k) = \limsup_{n\rightarrow \lambda} \xi_n(k)\$$ • $$\k_n = 0\$$ • $$\q_n = q_l\$$ $$\\$$ # Example Here we have a diagram of the current 2-state champion: If we want to calculate how long this takes to halt we can't just throw it into a computer and run it, rather we have to determine it by hand. To start we follow the machine through it's normal execution. It starts at $$\q_1\$$ and we can see that from there it always moves to $$\q_2\$$ flipping the cell under the read-write head. So here it turns the cell on. Then since the cell is on it will transition back to $$\q_1\$$, turning the cell off and moving to the right. This puts us in the exact same condition as the start, except the read-write head has advanced by 1. So it will continue in this loop of flipping on bit on and off and moving to the right endlessly. ANIMATION 1 HERE Now that we have determined the behavior of the machine for all finite steps we can figure out the state at step $$\\omega\$$. Each cell is on for at most 1 step, before being turned off, and then it is never on again. So the limit supremum of each cell is $$\0\$$, and at step $$\\omega\$$ the tape is entirely empty. So this means that after $$\\omega\$$ the machine just repeats its exact behavior, the condition at step $$\\omega+n\$$ is the same as the condition at step $$\n\$$. And this persists even after we hit another limit ordinal, $$\\omega+\omega\$$, the tape remains blank and just repeats the same behavior over and over. ANIMATION 2 HERE So we now have an accurate description of the machine for states of the form $$\\omega\times n + m\$$, and it doesn't halt for any of those steps. It just repeats the same infinite pattern an infinite number of times. So now we can look at the step after all the steps we have described. We take the next limit ordinal: $$\ g(\{\omega\times n + m : n\in \mathbb{N}, m \in \mathbb{N}\}) = \omega\times\omega = \omega^2 \$$ Your first instinct might be that the tape will be completely empty again, since it was empty at every step $$\\omega\times n\$$. However with infinities instincts can be misleading, so we should look at the definitions carefully instead. In order for a cell to be zero it must converge to zero. Since the only possibilities are zero and one, this means that for each cell there must be some step $$\x\$$ after which that cell is always zero. Previously since each cell was only turned on once that step was just the step after it was turned off. Now if such a step were to exist for a cell $$\k\$$ it would be of the form $$\\omega\times n + m\$$, however we know that the cell will be turned on again some time during the $$\\omega\times(n+1)\$$ iteration. In fact it will be turned on at exactly step $$\\omega\times(n+1) + 2k + 1\$$. So no cell (with a non-negative index) will converge to a stable value. Meaning that by the limit supremum all non-negative cells will be on at time $$\\omega^2\$$. ANIMATION 3 HERE So here we finally get some new behavior. With cell 0 on, the machine transitions to $$\q_2\$$ turning the cell off, and since $$\q_2\$$ doesn't have a transition for off cells the machine halts. This gives us a total of $$\\omega^2+1\$$ steps until halting. • It'd be nice to link the ITTM paper. Also, showing an example ITTM and explaining its halting time (like your ⍵×⍵ 2-state ITTM) would be helpful. – user41805 May 7 at 12:39 • @user41805 I'm currently working on an explanation for my 2-state ITTM champion. But the animations are a bit time consuming. I meant to link some ITTM papers, so I will add those links when I finish the edit I am working on. Thanks. – Wheat Wizard May 7 at 12:42 • Related: codegolf.stackexchange.com/q/36747/45613 and codegolf.stackexchange.com/questions/18028/… (This doesn't seem to be a duplicate) – Beefster May 18 at 16:25 # Reveal by Halves (in need of a better name) Inspired by this: http://nolandc.com/smalljs/mouse_reveal/ (source). A valid answer: • Takes a number $$\w\$$ and (assumed non-negative) integer $$\x\$$. • Outputs an integer list with a length of $$\2^w\$$, initially filled with zeroes. • For each number $$\n\$$ from $$\0\$$ to $$\w-1\$$ (inclusive), divide the list into sub-lists of size $$\2^n\$$, then increment all of the values in the sub-list that contains the index $$\x\$$. ## Examples (with coordinates from left, 0 indexed, but your answer may have change these) w=3, x=1 23110000 w=2, x=2 0021 w=3, x=5 00002311 w=4, x=4 1111432200000000 w=2, x=100 Do not need to handle (can do anything) because x is out of bounds  ## Meta questions • Are these tags fitting? • Would this be better in one dimension? (like $$\3, 2\$$ returns 11320000) Edit: I've changed it to one dimension but I can revert if it makes it less interesting. • Should $$\w\$$ or $$\2^w\$$ be the input? • Is this a duplicate? • My opinions on some meta questions. 1) I think one dimension would be better, the core of the challenge remains the same but the challenge itself becomes more "pure" which, in my opinion, is a good thing. 2) I'm a fan of flexible I/O, so if it were up to me I'd let people choose if they want \w\, \2^w\ or both as input. If you don't like this, both options are honestly fine. – Delfad0r May 10 at 22:24 # I'm Lazy*: Top-left align my text posted • Definitely not too trivial for code golf – qwr Jun 2 at 14:20 • I think squash up could be its own challenge which has room for simplification. My thoughts being using a transposed grid of strings, which I guess can work for this challenge too – qwr Jun 2 at 14:21 # Demonstrate some advanced abstract algebra • I think we should be able to define the types and values of S, rather than necessarily using integers. In that case, - and + would not (necessarily) be actual arithmetic negation and addition, so maybe they would have to be renamed to use other symbols (or just use function syntax f(a,b)?) – pxeger May 31 at 8:50 • And do all 9 functions have to operate on the same set S? I think it could be more interesting if they didn't have to, but it might result in cheating/loopholes. Also, what does "uniquely exhibits" mean exactly? Demonstrates exactly one of the 9 properties? – pxeger May 31 at 8:52 • In fact, I think people will just submit "addition, addition, multiplication, subtraction" for the first 4 at least, and I suspect they will almost always be the shortest option in most languages so it might not be very interesting as it is – pxeger May 31 at 9:04 • Writing one program is hard enough. Writing 9 seems like a lot to ask. I think you could make a stripped down challenge using just commutativity and associativity. I barely known any abstract algebra. I think these varieties are called magmas? – qwr Jun 2 at 14:54 • Is this even possible with the surjectivity condition? You should provide an example of each program. – qwr Jun 2 at 14:57 • @qwr I don't have examples for each program, and even if I did, I wouldn't include them as that would just lead to people porting them into their own languages. Yes, I believe magma is the correct term for \*\ here. I'm not sure if this is possible, but I'd be surprised if it isn't. I've allowed for an answer to be a proof of impossibility however, on that off-chance. – caird coinheringaahing Jun 2 at 15:04 • Well it's more than a magma since you added more two more operators right – qwr Jun 2 at 15:18 • @qwr No, I believe a magma is just a pair, the binary operator and the set its closed on, no matter the additional operators defined on that set – caird coinheringaahing Jun 2 at 15:31 • This is a really cool problem. It is hard so I wouldn't be again having a separate "easy" version with just the main three: commutative/associative/distributive. Uniquely exhibiting those is already a nontrivial and neat challenge. I don't know if others would vote a dupe, but I'd def be in favor of having both. As is, I don't think the harder version will have a lot activity. But I do think an easier one would! – AviFS Jun 13 at 1:18 • @AviFS I do actually have an easier version Sandboxed, where I think they're clearly separate enough to not be dupes. – caird coinheringaahing Jun 13 at 1:42 # Metagolf: Catlike Piet The goal of this is to write a catlike program, which would be executed (in a Unix environment, though you needn't stick to that) by the following: yourprogram < file > output piet output  where piet output writes the contents of file to stdout. That is, you're to generate a Piet program which prints the input to yourprogram. One-liners Straight line programs can be written in Piet... in straight lines. If you're willing to take a hit to your score, your output can take the form of a string of commands: = none (continue color block) | push ^ pop + add - subtract * multiply / divide % mod ~ not > greater . pointer \ switch : duplicate @ roll  input number ? input character # output number ! output character  which is trivial to convert to a Piet program with the following (partially golfed) Python code: def P(s): h=v=0;l=len(s)+1;R="P3 %i 2 255 192 0 0 "%(l+2) C=[1,3,2,6,4,5];V=[0,192,192,255,0,255] for x in map("=|^+-*/%~>.,:@?#!".find,s): C=C[x//3:]+C[:x//3];V=V[x%3*2:]+V[:x%3*2] for i in [1,2,4]:R+="%i "%V[(C[0]//i)%2] return R+"255 "*4+"0 0 "+"255 "*l*3+"255 0 0 "*2  The dimension of said program is (n+3) x 2 if there are n characters in the string. Scoring Your code will be judged on the maximum dimension of the images that it outputs. • Part 1: Take the maximum score taken over all ascii codes (that is, single-character inputs), discounting EOF. • Part 2: Take the score for the input "Hello. My name is Inigo Montoya. You killed my father. Prepare to die." Your score is the product of the scores in part 1 and part 2. Punishment: Double your score if you write one-liners as above (that is, if you don't output an image). Bonus: If your program is written in Piet, take the square root of your score above. • It took me a while to understand the task as "Write a program taking INPUT which produces as output a piet program that takes no input but produces INPUT." I think it is a interesting and challenging, but it's reception will depend entirely on how many people are willing to learn/futz-around-in/deal-with piet. And I have no feel for how many that is. – dmckee --- ex-moderator kitten Jul 7 '11 at 3:12 • @dmckee; would it be better if I just used a reduced instruction set, and only ask for the instruction stream? I think this is still challenging with {push 1,duplicate,add,subtract,multiply,output}. Come to think of it, if I restrict to {push 1,duplicate,add,output}, there's a reduction to some awesome algorithms. – boothby Jul 7 '11 at 4:48 • I did this in piet some time ago: craigoclock.blogspot.com/2011/05/metaprogramming-in-piet.html – captncraig May 21 '12 at 18:31 • Hello! This looks like a good but abandoned meta post, would you be willing to offer it for adoption? (If you want to, you can still post to main.) – user58826 Jun 9 '17 at 15:22 # 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 ### PETSCII banner In an other world... I was using a PET 2001 who used some particular PETSCII charset. The screen green on black, with 40 columns and 25 lines, was only able to display characters from this charset. No way to draw dots or lines... But in the chaset, there is some ▝ and ▚, which, ( by the use of reverse video in order to obtain 16 chars: ' ','▖','▗','▘','▝','▀','▄','▐','▌','▞','▚','▟','▛','▜','▙','█' ) make us able to draw graphics on a 80x50 dots plan. Using an internal clock triggering IRQ, I've done a animated prompter like this: The goal of this is to make a similar banner, with same charset, (but using UTF-8 characters: ' ','▖','▗','▘','▝','▀','▄','▐','▌','▞','▚','▟','▛','▜','▙','█'). Warn, this charset use inverted lower/upper cases. • This imply the use of PETSCII charset, I will post them there as a json string, before getting this out of the sandbox if some interest... • The tool have to change his position 20 time per second. • The tool must accept as argument, the string to display. • The tool must add date and time in the form - WDay MDay Mnth Year, HH:MM:SS - • Scrolling have to be done bit per bit: I.E.: by half character! • Shortest code... • -3 if size of console is not limited to 40 columns • -5 if cpu usage stay less than 90% (On my poor Core(TM)2 Duo CPU E8400 @ 3.00GHz, with 4G ram) • -5+ if cpu usage stay less than 50% • -5+ if cpu usage stay under 5% C.U. • as for the CPU bonuses - what is the target environment, what is the smoothing factor, and what processes count against this measure? – John Dvorak Dec 15 '13 at 6:19 • This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. – user58826 Jun 9 '17 at 15:32 ## Chess move The Challenge Write a program that gets a string containing a chessmove and a chessboard as input, and then outputs the chessboard. Requirements The chess move will have this format: <from square><to square>[<promoted to>]  Examples: d2d4 f8g7 a7a8R  The chessboard format is not fixed, but there must be a 1 to 1 relation between the board and the string to represent the board. Also the format of the input must bet the same as the format of the output. Two suggestions of what it could look like: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR rnbqkbnr pppppppp 00000000 00000000 00000000 00000000 PPPPPPPP RNBQKBNR  It is not required to store anything except the location of the pieces, and validity of moves can be assumed. Scoring Base score is character count (assuming your program can move pieces for all moves) Bonus multipliers: • If the program updates the promoted piece, divide by 2 • If the program also moves the rook when castling, divide by 2 • If the program also removes the pawn when capturing en passent, divide by 2 The moves, and castling & en passent in particular are explaned on Wikipedia. So basically writing a 100 character solution for the base problem gives the same score as an 800 character solution with all bonus multipliers. Examples If you would choose to use one of the board formats above, your input would look like one of these strings: e2e4 rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR e2e4 rnbqkbnr pppppppp 00000000 00000000 00000000 00000000 PPPPPPPP RNBQKBNR  Your corresponding output string would then be one of these: rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR rnbqkbnr pppppppp 00000000 00000000 0000P000 00000000 PPPP0PPP RNBQKBNR  • Before I get on to more specific criticisms: as presented, without the bonus this is too trivial to be interesting. I suggest removing some flexibility: require Fen notation for the board position and algebraic notation for the move, and making the current bonus options mandatory. On specifics: it's not clear why you talk about storage; and the board position notations you suggest don't include enough information to know whether en passant is possible. – Peter Taylor Dec 22 '13 at 23:56 • @PeterTaylor I agree that compared to chess programs this may be trivial, but I would like to make it a golf challenge. Compared to the hot code golf questions this is quite elaborate already in its basic form. (For a good solution the board design may need to be changed drastically). It is true that there is no attention to the legality of moves (whether it is possible to capture en passent) but for a mere viewer this is not required so I am not too worried about this. So far the chess questions seem to get very few answers as they tend to be complex and I hope to offer relatively easy entry. – Dennis Jaheruddin Dec 30 '13 at 11:02 • Your point about en passant is valid - you had said in the spec to not worry about legality. I'll try to convince you of my first point: without the bonus, this reduces to: a) parse first four characters into (col 1, row 1, col 2, row 2); b) take board as a 64-char string; c) board[8*row_2+col_2] := board[8*row_1+col_1]; board[8*row_1+col_1] := ' '; print board. This is trivial compared to any good golf question. (Note that the hot questions at the moment are neither golf questions nor good questions). – Peter Taylor Dec 30 '13 at 12:14 • This sandbox post has had little activity in a while. Please improve / edit it or delete it to help us clean up the sandbox. Due to community guidelines, if you don't respond to this comment in 7 days I have permission to vote to delete this. – user58826 Jun 9 '17 at 15:40 # Black Box Your task is to analyze a given situation for the game Black Box. Given a sequence of guesses and answers, your program is to either print the solution or suggest the next move. ## The game The board consists of 8×8 cells, with edges labeled like this: I'll probably create nice images here, particularly to make sure that the squares of the board are really square.  abcdefgh i I j J k K l L m M n N o O p P ABCDEFGH  The player shoots rays into the interior of the box, where they might get deflected, reflected or absorbed. He is told the position where the ray leaves the black box again, and from that has to deduce the positions of 4 atoms inside the black box. I'll have to include more of the game rules here, but for now see Wikipedia. # Input and output Input is a sequence of line, each consisting of two characters. The first denotes the point where the ray of light enters the black box, the second the place where it comes out again. In the case of a reflection, both characters will be equal. In the case of a hit, the second character will be -. If the input is enough to fully determine the locations of the atoms, then output should be four lines giving the coordinates of each atom. The lines should be two lower case characters each, the first giving the row and the second giving the column of the found solution. The atom positions must be printed in lexicographical order. If the input is consistent with more than one set of atom positions, then the output should consist of a single line containing a single character, which is the location where the next ray should be shot. That location has to be chosen in such a way that it can help find the solution. This is the case unless all of the atom positions consistent with the input so far would produce the same output for this next ray as well. Your output has to be terminated by a newline character. # Examples Let's take the atom configuration the Wikipedia article uses as an example as well:  abcdefgh i I j J k O O K l L m M n O N o O p O P ABCDEFGH  If the input were cf D- Em HH Co  then the output should be kb kg nd pg  but if the input were only Em HH  then the output might be for example K  ## Scoring This is code golf, so shortest answer wins. However, I'll only accept answers which are practical in so far as they compute their result in reasonable time. I'd say no more than five minutes on my system where I'll evaluate the answers, and I'll simply hope that correct solutions will be much faster and incorrect ones much slower, so that the speed of my system doesn't make a difference. A submission which gives a wrong answer for one of my test cases will be disqualified until it gets fixed. I will probably point out the problem in a comment to that post. # Create a program with "exact repetition" in its source code The task is to create a program, with the following restrictions placed on the printable ASCII characters in the source code: choose some k > 0. • Every non-alphabetic character has to appear exactly k times. • Every alphabetic character has to appear at most k times. • This rule differs from the former in order to avoid boring dummy identifiers while still making it a challenge to choose good library functions to call. Character set definitions used: • Non-alphabetic characters are !"#%&'()*+,-./0123456789:;<=>?@[^_{|}~ and '' (backtick).
• Alphabetic characters are ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.

Note that no restriction is placed on characters outside of the range of printable ASCII characters (including control codes, tabs, newlines, higher unicode codepoints, etc).

What the program does is up to you; be creative. Some general guidelines:

• Programs that do something interesting might have better chances, although more impressive code structure (i.e. fewer comments) is also beneficial.
• Stuffing excess characters in comments is boring, and should be avoided/is discouraged.
• Dead/no-op code isn't terribly interesting either, but is probably unavoidable and at least has to conform to the language's grammar.

This is : whatever has the most upvotes at Feb 1, 2014 gets accepted as the winner.

### Example answer (C)

#
#
/*@*/_[]={9.};main() {printf("He%clo \
world!%c\
",2^7&!8.&~1|~-1?4|5?0x6C:48:6<3>2>=3<++_[0],'@'^79-5);}


Prints "Hello world!" (adapted from an answer to another question). Probably wouldn't score a lot (since what it does isn't terribly interesting). Each of the non-alphabetic characters appear exactly twice, and no alphabetic character appears more than twice.

For meta: I want to post this, but I'm worrying that "do something interesting" might give too little guidance and the question won't receive many answers.. thoughts? Is it good as-is, or should I come up with some task that one should be required to implement (and possibly change the ruling to code-challenge, with length + 2^(characters-in-comments)` as the score)?