# AKA: The Regifting of the White Elephants

Note - I'm not sure this is on-topic or not on meta, but it seems to be as good a place as any. Comment if you disagree.

I have a few challenges that I have posted to the sandbox and then more-or-less forgotten. Some of these challenges are OK; some not so much. I think all of them could do with at least some level of polishing before they are posted to main.

So this is my christmas gift to the community this year. I don't think I have the inclination to pick up any of these challenges right now, if ever, so if you are interested, you may claim ownership and run with it.

I will post the challenges I am donating as answers to this question. If you have similar challenges you wish to donate, then please feel free to post as answers too.

If you are interested in picking up any of these, go ahead and indicate this in the comments.

Up/down-vote answers to indicate your interest solving a challenge. This will give potential new owners a feel for whether its worth picking up that challenge.

### Seasons Greetings!

If you are taking one of these challenge ideas, you should either edit the existing sandbox entry with your ideas, or perhaps create a new sandbox entry.

• Why this is off-topic? – Xwtek Jan 1 '16 at 0:16
• @ChristianIrwan IMO its on-topic, and I think now its safe to say the community agrees - I just wasn't sure when I posted the question. – Digital Trauma Jan 2 '16 at 4:52
• If you take a challenge, you should edit the original sandbox post when you do, and make sure to do so when it's posted as well, so we don't end up with duplicates. – mbomb007 Sep 13 '16 at 13:56
• – Peter Taylor Jun 26 '17 at 16:37

You're welcome to take this over. I don't have time, sorry :-(

# Count the pips in a pair of dice

Here are two photographs of a pair of randomly thrown dice. (OK, they're 3D renderings, but never mind). In the photo on the left, the dice are showing one and five pips. In the photo on the right, they are showing three and four pips. Can you program your computer to count the pips automatically?

## The challenge:

Write a program that takes as its input the filename of a 240×180 JPEG image similar to the above examples, and outputs two numbers corresponding to the pips visible on the top faces of the dice (in ascending order). Your program must accomplish this in less than five seconds on an averagely specced desktop computer.

## Images:

For training and testing purposes, I have created a set of 1,000 JPEG images together with information about the number of pips visible in each image.

## Scoring:

For scoring purposes, it might be worth converting these to arrays of RGB values (or at least excluding the JPEG conversion code from the length of the submitted code). You might want to provide a randomly selected subset of these images for training, and reserve the other images for testing.

## Notes:

• There are no images with any die intersecting the edge of the image frame. However, there are many images where one die is partially obscuring the other.

• Both dice are standard right-handed dice, where each pair of opposite sides adds up to 7, and the numbers 1, 2 and 3 are arranged in anti-clockwise order around their shared vertex.

• I don't know who downvoted this, it's pretty solid – Conor O'Brien Jul 3 '18 at 4:12
• Is this possible? – S.S. Anne Jan 11 '20 at 21:28
• Sure. Finding the dice should be quite easy. Then with a bit of pattern matching, it shouldn't be too hard to count the pips on their upper surfaces with reasonable accuracy. – r3mainer Jan 12 '20 at 20:55

# Posted

Let's Play Mafia! pending removal of this post

• I will try this. – Christopher Dec 20 '17 at 16:51
• and after a few edits i am posting O_O – Christopher Dec 20 '17 at 16:56

### Frame ASCII art

I don't know what to do about the similarity to challenges about removing leading spaces, printing a border a border, and others I know exist but am not finding in a search.

### Stitch a Picture

I think this is an interesting idea, but the comments seemed to indicate that this is a lot harder to solve than I had anticipated. Perhaps it can be modified somewhat to make it reasonably solvable.

• I want to take this one. – Xwtek Dec 31 '15 at 23:59
• I actually am taking this one and posting again in sandbox – Christopher May 16 '17 at 15:11
• @Christopher Please post a link if you did. And if you did, you should comment on the original one so it gets deleted. We don't need duplicates. – mbomb007 Jun 5 '17 at 21:26
• codegolf.meta.stackexchange.com/questions/2140/… – Christopher Jun 5 '17 at 23:20

### Golf the numbers round a dartboard

In its current state, this one is fairly trivial, without a ton of creativity required for solutions. But the sequence is interesting. Perhaps there is some inspiration to had here.

• The plain 'print 20 1 18 4 13 6 10 15 2 17 3 19 7 16 8 11 14 9 12 5' will be hardcoded in non-golfing languages, and in golfing languages with permutations; indexed into permutations. For example, Pyth will just be @.pS20C"[an 8 char string]. To be interesting, we'll need to prevent both of the uninteresting solutions. – lirtosiast Dec 30 '15 at 22:00
• @ThomasKwa That pyth solution is pretty clever IMO. Once you've found the right 8-char string, I wonder how long pyth would actually take to output the right answer. – Digital Trauma Dec 30 '15 at 22:13
• It's just (19*19!+0*18!+16*17!+2*16!+...) converted to base 256, and more than a year if it doesn't run out of memory. – lirtosiast Dec 30 '15 at 22:18
• Just an idea, but maybe instead of only outputting the first 20 numbers, we output all possible dart-scores in that same clockwise rotation, going inward in terms of doubles, singles, triples, singles, and bull. So the output would be this instead. Still not too hard, but somewhat more interesting to golf. – Kevin Cruijssen Jun 27 '19 at 9:33
• PS: Your current challenge is 16 bytes in 05AB1E with two alternative approaches: compressed list or n'th permutation (second could be 1 byte shorter by changing A to 9 and removing < if digits were allowed). – Kevin Cruijssen Jun 27 '19 at 9:34

## Draughts KOTH

Definitely will be a fun KOTH, but I don't have the time or energy to write up the controller, so I'm giving it up to whoever wants to take it over.

anyone is more than welcome to polish and post this

# [something about slashes and doubling]

[ascii-art] [code-golf]

Given an integer N >= 0 output this doubling pattern of slash squares/rectangles.

Note how each new doubling is added on in a counterclockwise spiraling manner.

N=0:
/\
\/

N=1
/\
\/\
\/

N=2, etc...
/\
/\/\
\ \/
\/

/\
/\/\
\ \/\
\/  \
\  /
\/

/\
/  \
/\   \
/\/\   \
\ \/\  /
\/  \/
\  /
\/

/\
/  \
/    \
/      \
\      /\
\    /  \
\  /\   \
\/\/\   \
\ \/\  /
\/  \/
\  /
\/

/\
/  \
/    \
/      \
/\      /\
/  \    /  \
/    \  /\   \
/      \/\/\   \
\       \ \/\  /
\       \/  \/
\       \  /
\       \/
\      /
\    /
\  /
\/

/\
/  \
/    \
/      \
/\      /\
/  \    /  \
/    \  /\   \
/      \/\/\   \
\       \ \/\  /\
\       \/  \/  \
\       \  /    \
\       \/      \
\      /        \
\    /          \
\  /            \
\/              \
\              /
\            /
\          /
\        /
\      /
\    /
\  /
\/


### Do-nothing Polyglot

I think this one is pretty awful. But perhaps there is something to be salvaged.

• Why do you think it is awful? – TanMath Dec 25 '15 at 21:41
• @TanMath Perhaps "awful" is too strong of a word. My concern is that in its current state, it would probably be closed as unclear AND too broad. But perhaps with the right editing/sandboxing it can be fixed... – Digital Trauma Dec 26 '15 at 18:10
• I plan to take this one... would a scoring based on the versatile integer printer challenge be good? – TanMath Dec 28 '15 at 15:58
• @TanMath I assume this is the challenge you're referring to – Digital Trauma Dec 28 '15 at 18:57
• yes! that is the challenge I mean. – TanMath Dec 28 '15 at 20:33

This is a quick-and-dirty handmade ASCII art of our new logo.

Feel free to use it, either as-is or as a basis for something better. Maybe there's something interesting to do with it... or maybe we just have enough / challenges.

   .##   ###########   ##.
'#'   ## ####### ##   '#.
##   ###         ###   ##
##  #####       #####  ##
##   #####     #####   ##
##    #####   #####    ##
##     ##### #####     ##
.#'      ### #####      '#.
<#+        # #####        +#>
'#.        .===.        .#'
##      +" +++ "+      ##
##     # .#####. #     ##
##    # +#######+ #    ##
##    # +#######+ #    ##
##     # '#####' #     ##
.#.     +, +++ ,+     .#'
'##      '==='      ##'


## xnor's hoard

I have a bunch of old Sandbox posts that I don't feel like developing, some of which have a number of upvotes. Feel free to edit and post them. I just ask that you ping me before you post in case I have suggestions.

Crazy Librarian's Interesting Numbers Game

A card game between two bots. Interesting premise, got a couple of quick upvotes, and KOTHs are generally pretty well-received. I've just realized that I don't have the time to actually put a controller together and run a tourney, and that lack-of-time doesn't look to have changed in the past year. So ... donation time!

# Is the string ASCIIbetically ordered?

Seems interesting, but I am not sure if it's a dupe or not.

# Who is the winner?

I like the idea of this but I am finding it difficult to write a spec. So if anyone can come up with a better way to run this, please, go ahead!

# Tell me my vocabulary words!

I personally really like this challenge idea but no one has really understood what I want from it yet, so if you can write a better spec for it than I, go right ahead!

Hope you don't mind me posting this here instead of linking to the sandbox post - it's more of a rough idea than something I could even begin to make a formal writeup for.

I just came up with this idea recently, but don't have the patience to work out objective rules, or even the input format.

Essentially, I recently saw Tom Scott's video on the way the internet has taken over grammatical structures, such as punctuation and capitalisation, to give them a much more complex meaning that can almost convey all of the intonation and registers we use in normal, verbal conversation. So, I thought that some sort of challenge, that takes an input somehow describing the intentions of a post (e.g "this sentence is a rhetorical question", "I'm talking formally now", "put emphasis on this phrase"), can convert it into 'internet format', using just the few examples of rules that are used in the video.

Alternatively, you may want to reverse the challenge, and make an internet-speak decoder.

Some potential ideas for input format:

• A nested object, consisting of different parts, arranged in literal order (the order they appear in the sentence). This would be a good challenge. The parts are separated according to where new info needs to be introduced, so you may have something like:
...
{
type: "sentence",
contains: [
{
type: "phrase",
text: "And how are"
},
{
type: "phrase",
text: "you",
emphasis: true
},
{
type: "phrase",
text: "today?"
}
],
...
}
...

• Potentially, it could take audio input along with a transcript, so it needs to detect intonation too. This could potentially be used in a challenge, where the number of layers/weights, as well as the accuracy, all contribute to a final score.

In the case you decide to use the reverse (decoding) challenge idea instead, simply inputting Internet-speak and outputting normal English will do too.

# Tower Defense (Abandoned)

Anyone is free to take over this challenge and fork as necessary. Just give me credit ;)

# View it here | Chat

Tower Defense is a format for casual games that was popularized in the Flash era. The player places towers that shoot down invaders moving along a predefined path.

# Overview

Two submissions will compete against each other to invade the other player's village without being invaded themselves. They will have the ability to place towers, upgrade them, and spawn invaders to attack the enemy village. The game will be simulated deterministically in a turn based fashion, with each player being able to do one action each turn.

The game board is made up of two paths, each 100 spaces long. Each player begins with 500 gold, which is used for building towers and spawning invaders; and 100 life. Your objective is to bring your opponent's life down to 0. If neither player has been defeated after 100000 turns, the winner will be the player with the most life at that point, with ties being broken by who has the most gold at that point. If, somehow, there is still a tie, the match will be considered a tie.

# Income

Every 10 turns, players will receive gold. Initially, they receive 10 gold, but this amount increases by 3 every 100 turns.

# Towers

Each space on the path can house one tower. There are 3 types of towers, which have a range and a power. It takes 10 turns for a tower to be ready after it is built. Towers can be upgraded either with a wider range or an increased power, in increments of 1. There is no hard limit to how many times a tower can be upgraded.

Range refers to how many spaces away from the tower that can be reached by the tower's abilities. A range of 0 means that only the space that the tower is on is affected by the tower's attacks.

Power has a different meaning depending on the kind of tower.

## Turrets

Each turn, turrets fire at the invader within range that is farthest along the path to your village. They deal damage equal to the tower's power.

Turrets begin with a range of 1 and a power of 1.

## Stunners

Stunners fire at the invader within range that is farthest along the path to your village. However, instead of dealing damage, they stun the invader for a number of turns equal to the tower's power. After firing, stunners cannot fire again for their power + 1 turns. Stunners will not fire at invaders that are already stunned.

Stunners begin with a range of 0 and a power of 3

## Bombs

When an invader is on the same space as the bomb tower, it triggers and deals damage equal to its power to all invaders within its range. After being triggered, it cannot fire again for another 5 turns.

Bombs begin with a range of 2 and a power of 2

Each turn, you may spawn an invader. At minimum, it costs 10 gold and has a base HP of 10. You can spend additional gold to increase its power:

• (1G) +1 HP
• (10G) +1 Defense (reduce damage taken by 1, but not lower than 1)
• (10G) +1 Stun resistance (reduces stun time by 1 turn)

You are limited on the maximum stats. You start off unable to boost stats, but every 100 turns, the maximum increases by 5

There can only be one invader on each space of the board and invaders cannot pass through each other. You cannot spawn an invader if there is already an invader on the first space of the board. Therefore, a potential counterplay from defenders to prevent massive hordes of invaders is to put stunners on the first few spaces.

# Coding

The main game / AI driver is here (still a work in progress)

Submission logistics TBD

Both players will have complete knowledge about the state of the game and will be allowed to maintain state from the beginning of the game. They may not directly modify the game state. Any attempts to do so will be disqualified as will any attempt to obfuscate such an attempt.

(api description will go here)

Defenders should return an object with an action property that is either 'build', 'upgrade', or 'destroy'. Each requires some additional properties to be set: (will add later)

Invaders should return an object which contains any stat boosts desired: hp, defense, and stunRes.

Both defenders or invaders may also return undefined or null to indicate not taking an action.

AIs must return their desired action in less than 10 milliseconds, averaged over 100 turns. Invalid actions returned by the AI will be ignored.

# Scoring

All submissions will compete against all other submissions in a round-robin tournament. The bot that wins the most matches is declared the winner. In the event of a tie, the number of turns it took to win will be totaled for all winning matches with the smallest cumulative turn count to victory wins. In the unlikely event of a further tie, the turns to loss will be totaled for all losing matches and the bot with the highest cumulative turn count to loss wins.

Only one submission per user can be scored in the round-robin tournament.

# Rules

• No abusing standard loopholes
• No direct modification of the game state passed to you. It will not be defensively deep-copied. Don't obfuscate your code to try to hide state modification.
• Any uncaught exceptions will result in disqualification.
• Implementations must be totally deterministic, i.e. random number generators are only allowed if seeded consistently (either with a constant or with game state) and must use isolated random state which the other AI in play cannot access.
• Submissions shall include an explanation of the AI's strategy.

# C Compiler

Implement a basic C Compiler.

You do not need to implement the libraries. Compiler would output an object file containing a function, that would be linked with some libraries using GNU binutils ld and run.

No function calls, unions, structs, casts will be used in the test cases.

Test case:

int test(int i, int j) {
int x[10][20];
int i, j = 0, s = 0;
for(i = 0; i < 10; i++)
while (j < 20)
{
j += 1;
x[i][j] = i * j;
}
for(i = 0; i < 10; i++)
while (j < 20) {
s += x[1][j];
}
return s;
}