# What is the Sandbox?

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

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

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

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

## Background

As you may or may not be aware, Pokemon Go's servers have not fared well under the stress of the game's extreme popularity. As an amateur programmer, I'm in the sweet spot where I know just enough to think I can solve all of their problems, but not enough to be able to understand how complex their problems actually are. Thus, I find myself constantly thinking "Why didn't they just do <insert naive suggestion here>? It would fix everything!" This challenge is focused on one of those probably-useless ideas I've thought up.

First, some very quick background, in case you haven't played the game (you can skip this paragraph if you have): In the course of gameplay, Pokemon can randomly appear at certain real-life locations. Every player in the same location sees the same Pokemon, and multiple players can catch one Pokemon.

One potential difficulty I see with this is storing all of that data. With millions of concurrent players, the game servers have to keep track of millions of Pokemon. That's a lot of IO for their database. Fortunately, I, a graduate of not one, but two introductory CS courses, have a solution! Because player interactions have nothing to do with where and when Pokemon spawn, it is essentially deterministic. This means that it should be possible to drop the database entirely (at least for this one specific task), and replace it with a function! This function could take the player's location, the current system time, and a random seed as input, and return a list of all Pokemon within a certain radius. Because no database lookup is needed, this function would be lightning fast and easily scalable to millions of players.

## The Challenge

Your challenge is to write this function. Obviously, the actual game of Pokemon has way too many details to make a feasible code challenge for PPCG, so here's the simplified guidelines:

• Create a function that takes the following inputs, in any format you like:
• Player location, as 2D coordinates
• System time
• Random seed
• The function should return a list of nearby Pokemon, with the following requirements:
• "Nearby" means "within one unit of distance of the player", where distance is 2d euclidean distance. (Just ignore the edge case where the location is on a round planet)
• Each Pokemon should have a species and an exact location
• This list can be in any format you want
• The results are deterministic (i.e., for the same location, time, and random seed, the same Pokemon are always returned)
• The Pokemon should persist for some pseudorandom amount of time
• Thus, if the function is called twice with the same location and random seed, and two times that are very close, then each Pokemon returned the first time should have a large possibility of being returned the second time
• If the function is called twice with the same time and random seed, and two nearby locations, then any Pokemon that are near both locations should be returned both times
• The Pokemon should be somewhat evenly distributed across the "world" (the coordinate plane).
• The Pokemon should be distributed such that at any location and time, the probability of finding exactly n nearby Pokemon of any type is (0.5)^(n+1)
• Thus, there is a 50% chance of finding no Pokemon at all, a 25% chance of finding exactly 1, a 12.5% chance of finding exactly two, etc.
• Your algorithm should be capable of returning up to 10 nearby Pokemon, but is allowed to return more, as long as it follows the right probability distribution
• Sandbox question: I want a requirement to be that the algorithm can't simply generate all of the Pokemon in the world and then just return the nearby ones, but I don't know how to formally state this. I had some fleeting thoughts about O(1) memory usage, but that method could strictly speaking have O(1) memory usage if the world is a constant size (which I'm pretty sure it is).

Might this make a good challenge? That would fit in with the premise, and might produce some interesting algorithms.

For the sake of making this challenge somewhat reasonable, the list of possible Pokemon and their probabilities of appearing will be small:

• Weedle: 60%
• Charmander: 30%
• Blastoise: 10%

## Scoring

This is part of what I need help with in the sandbox. How should I distinguish two entries that both meet all of the requirements?

Thanks for reading this far! I know this question isn't nearly ready to be a real challenge. At the very least, it need more specific requirements. But I figured I'd post what I currently have in the sandbox to see if it's worth continuing with. I've never posted or participated in a PPCG challenge before, and I'm sure that's obvious, but hopefully with your help, I can refine this to the point of being a legitimate challenge.

• Welcome to PPCG, and thanks for using the sandbox! :) Currently I'm afraid your question is rather underspecified. You need to define "nearby" as well as describe how Pokemon should be distributed, as otherwise I could just put 6 weedles, 3 charmanders and a blastoise on the north pole for some time, then swap them to the south pole, etc. You could put a time constraint on the code to try to limit the whole world generation problem, but to do that you'd probably need a reference implementation. Personally, I think code-golf is likely the best scoring method. – FryAmTheEggman Jul 22 '16 at 15:25
• I was imagining this challenge would be very difficult and require a somewhat complex answer, which is why I didn't initially tag it as code golf. But after thinking about it for a little while, I came up with a rather simple solution that isn't as interesting as I thought it would be. So maybe code golf is a better tag. As for you other remarks, I'll get to work editing the answer to make it less ambiguous. – ItsTimmy Jul 22 '16 at 15:39
• 1. Does "the usual euclidean distance" mean in the 3D embedding of the globe whose surface is parameterised by the input coordinates? Or have you decided to simplify by ignoring the fact that real Pokémon Go takes place on a round planet? 2. What does "as long as it follows the right probability distribution" mean if you curtail the probability distribution? What happens to the probability from the tail? – Peter Taylor Jul 22 '16 at 21:43
• @PeterTaylor: I have answered both of your questions by editing my post. Thanks for the feedback! – ItsTimmy Jul 22 '16 at 21:53

# Punch Buggy Probabilities

A popular game among children in the USA is "punch buggy", and as with every such game, there are many variations. The one we'll consider for this challenge goes like this:

• The moment anyone sees a Volkswagon Beetle (the "buggy"), participants may punch each other (usually in the shoulder or upper arm).
• A punch must be accompanied by "punch buggy <color>!", where <color> is the color of the VW Beetle (red, green, black, gray, yellow, etc.).
• Whoever makes contact first gets priority (and for this challenge, there are no ties).
• Once person A punches person B, B cannot punch A back (usually accomplished by saying "no punch back!").
• Punches may occur between any pair of participants (for this challenge, every pair of participants).

## The challenge

Assuming all possible punching configurations among n people are equally likely to happen, what is the probability of any particular punching configuration? To put it another way, for each distinct punching configuration, how many ways can it occur?

## Rules

• Input is a single positive integer greater than 1.
• Output must be one of the following: A) a list of decimals, B) a list of fractions (simplified or not), or C) a list of counts. META: Should I allow these lists to be unordered, or should I require that they be associated with punching configurations somehow? I'm leaning towards the former since it seems like it'd be a headache to figure out how to specify the latter and it would likely be an extra task that doesn't really have anything to do with the core problem.
• Standard rules apply, and standard loopholes are banned.

## Test cases

Input
Output A
Output B
Output C

2
1.0
2/2
2

3
0.75 0.25
3/4 1/4
3 1


Explanation of input 2: With only two people, there are exactly two possible ways: either A punches B or B punches A. These are equivalent, so the probability is 1.0, the fraction is 2/2, and the count is 2.

Explanation of input 3: There are two distinct punching configurations: A -> B -> C, A -> C; A -> B -> C -> A. The latter has only two varieties (the other is A -> C -> B -> A) and the former has six, since there are three choices for the person who punches two others and then two choices for the remaining pair. Thus, the probabilities are 0.75 and 0.25, the fractions are 3/4 and 1/4, and the counts are 3 and 1.

## META

• I want to add 4 to the test cases, and I think I'm gonna need help on it since I'm having a hard time counting all 2^6 = 64 possibilities correctly.
• Any clarifications/corrections?

# Teh Scrolling Codez

In many movies, computer often appear to be scrolling through some code. We should automate this process to make it easier. Your job is to write code that displays to a graphical console a scrolling view of its own source code. You have two options...

## Sandbox Questions

Should this be a code golf or pop-con. Pop-con's could result in more visually pleasing solutions. or [tag:popularity contest]

• I'm wondering how you vertically scroll source code that's one line. – feersum Jul 28 '16 at 1:17
• SIngle line source code is permitted. That is why it may make more sense to scroll it horizontally @feersum – Rohan Jhunjhunwala Jul 28 '16 at 2:13
• A quine in a loop and rely on the console having finite height? – Peter Taylor Jul 28 '16 at 8:07
• Yeah that could work – Rohan Jhunjhunwala Jul 28 '16 at 12:18
• @PeterTaylor ^^ – Rohan Jhunjhunwala Jul 28 '16 at 12:18
• @PeterTaylor do you have an opinion on what tag should be used? – Rohan Jhunjhunwala Jul 28 '16 at 12:21
• I suspect that this applies and that it's not an interesting question, although I personally don't find quines interesting so I'm not the best person to comment on that. – Peter Taylor Jul 28 '16 at 13:32
• but F() in and of itself is an interesting challenge. @PeterTaylor – Rohan Jhunjhunwala Jul 28 '16 at 15:37
• F(P) is while(true) print P. That's not an interesting challenge in any language I know. – Peter Taylor Jul 28 '16 at 16:10
• @PeterTaylor than I think I should ban console output, and require graphical output – Rohan Jhunjhunwala Jul 28 '16 at 16:12
• thus F(P) becomes while(true){print(sectionOf(p))move(p)}; – Rohan Jhunjhunwala Jul 28 '16 at 16:13

# Autonomous Vehicle

I need a brain for my self-driving car. Something that will take still frames from the front-facing camera and give the navigation system commands. Obviously, if my car is driving me somewhere, I don't want to stop. However, I also don't want to:

1. Kill someone
2. Die

Knowing myself, we can assume that:

• At the speed I drive, hitting the curb or otherwise leaving the road will kill me and thus violate Don't #2
• With my luck, running a stop light, will violate Don't #1 or #2 or both

• Also hitting a pedestrian (or another car) violates Don't #1 (and possibly #2)

## Input

The program/function should take an image as input. How it does this is flexible.

## Output

The program/function should output one of these commands; ideally, one of the commands that doesn't result in one of the Don'ts being violated.

╔═════════╤═══════════════════════════════════════════════╗
║ Command │ Navigational Outcome                          ║
╠═════════╪═══════════════════════════════════════════════╣
║ Forward │ No course correction, continue straight ahead ║
╟─────────┼───────────────────────────────────────────────╢
║ Left    │ Veer left                                     ║
╟─────────┼───────────────────────────────────────────────╢
║ Right   │ Veer right                                    ║
╟─────────┼───────────────────────────────────────────────╢
║ Stop    │ Screech to a grinding halt                    ║
╚═════════╧═══════════════════════════════════════════════╝


## Specifications

• Take an image as input in someway
• Output a command [ Forward, Left, Right, Stop ]
• Commands can be aliased as [ 0, 1, 2, 3 ] respectively
• Returning one valid command and no invalid commands is sufficient to pass a test
• Stop is only valid iff every other command would violate one of the Don'ts
• Rules for valid commands:
• No running stop lights
• No running over people
• No running into vehicles
• No running off the road
• If a command does not violate any of the above, then it is valid
• Program/Function must be deterministic

# Scoring

Lowest score wins! The scoring function is:

• ( # of Bytes ) / ( Number of Passed Tests )

For example, a 450 byte Python solution that passes 2 test cases earns a score of 450 / 2 or 225.

## Test Cases

1. Valid Commands: Forward

2. Valid Commands: Left, Right

• Straight ahead there are pedestrians crossing

1. Valid Commands: Forward, Right

2. Valid Commands: Forward

3. Valid Commands: Left, Right

4. Valid Commands: Stop

• I like this challenge. However, I don't see any test cases for lights. I also think that the test case for pedestrians is pretty bad. Also, realize that people might be using the text on the images (the road labels) to determine orientation, so make sure you're ok with that. I'd also recommend more test cases. Your current set is a good example set, but not comprehensive enough for testing IMO. – Nathan Merrill Jul 30 '16 at 1:19
• will all testcases be available? if so i would determine the output by the value of the pixel in the top-left corner. – KarlKastor Jul 30 '16 at 19:47

## Embed a graph into the Rado graph

The Rado graph is an infinite undirected graph whose vertices are labelled with natural numbers {0, 1, 2, ...}.

The edge (i,j) with i<j is in the graph whenever the binary expansion of j has a 1 in its ith place. Here, place values are counted from the end, with the 0'th place being the least significant bit. In terms of bitshifts, this means (j>>i)&1==1.

The Rado graph is universal in that any finite graph is a subgraph of it. This means that any finite graph can be embedded in the Rado graph: to each vertex of the finite graph, assign a distinct vertex of the Rado graph so that any two vertices of the original graph have an edge if and only if the corresponding vertices of the Rado graph have an edge.

Your task is to output such an embedding for a finite graph given as input.

TODO: Lots of stuff

• Lovely challenge :). Is there a known algorithm to find the embedding? If so, might it be worth linking to it with a spoiler warning? – Martin Ender Jul 31 '16 at 10:05
• 1. It would be more accurate to say that this is one of several constructions of the Rado graph, and to state that answers are required to work with this construction in particular. 2. The statement of universality is incorrect. It should say induced subgraph rather than subgraph. 3. I assume that by "an embedding" you mean a mapping from vertices of the input graph to vertices of this construction of the Rado graph, but it would be good to make that explicit. 4. @MartinEnder, there's a greedy algorithm described in Wikipedia. – Peter Taylor Jul 31 '16 at 20:02

# Draw Concentric Squarephabets

## Challenge

Write a program or function that, given an input integer n, outputs a concentric squarephabet of size n×n.

A concentric squarephabet is an ASCII-art square of concentric rings, where the outside ring of characters are As, the second Bs, the third Cs, etc. For example, a 25×25 squarephabet looks like this:

AAAAAAAAAAAAAAAAAAAAAAAAA
ABBBBBBBBBBBBBBBBBBBBBBBA
ABCCCCCCCCCCCCCCCCCCCCCBA
ABCDDDDDDDDDDDDDDDDDDDCBA
ABCDEEEEEEEEEEEEEEEEEDCBA
ABCDEFFFFFFFFFFFFFFFEDCBA
ABCDEFGGGGGGGGGGGGGFEDCBA
ABCDEFGHHHHHHHHHHHGFEDCBA
ABCDEFGHIIIIIIIIIHGFEDCBA
ABCDEFGHIJJJJJJJIHGFEDCBA
ABCDEFGHIJKKKKKJIHGFEDCBA
ABCDEFGHIJKLLLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLLLKJIHGFEDCBA
ABCDEFGHIJKKKKKJIHGFEDCBA
ABCDEFGHIJJJJJJJIHGFEDCBA
ABCDEFGHIIIIIIIIIHGFEDCBA
ABCDEFGHHHHHHHHHHHGFEDCBA
ABCDEFGGGGGGGGGGGGGFEDCBA
ABCDEFFFFFFFFFFFFFFFEDCBA
ABCDEEEEEEEEEEEEEEEEEDCBA
ABCDDDDDDDDDDDDDDDDDDDCBA
ABCCCCCCCCCCCCCCCCCCCCCBA
ABBBBBBBBBBBBBBBBBBBBBBBA
AAAAAAAAAAAAAAAAAAAAAAAAA


(and yes I typed that by hand ☺)

If the input is an even number, the centre of the squarephabet will be a 2×2 square instead of a single letter. For example, for input 8:

AAAAAAAA
ABBBBBBA
ABCCCCBA
ABCDDCBA
ABCDDCBA
ABCCCCBA
ABBBBBBA
AAAAAAAA


## Specification

• Standard loopholes are forbidden.
• The input to your program or function will never be less than 1 or greater than 52 (26×2). This means you do not have to deal with letters after Z.
• You may output uppercase or lowercase letters, but you must be consistent in your choice.

## Test Cases

Format:

Input
Output


Test cases:

1
A

2
AA
AA

3
AAA
ABA
AAA

10
AAAAAAAAAA
ABBBBBBBBA
ABCCCCCCBA
ABCDDDDCBA
ABCDEEDCBA
ABCDEEDCBA
ABCDDDDCBA
ABCCCCCCBA
ABBBBBBBBA
AAAAAAAAAA

25
AAAAAAAAAAAAAAAAAAAAAAAAA
ABBBBBBBBBBBBBBBBBBBBBBBA
ABCCCCCCCCCCCCCCCCCCCCCBA
ABCDDDDDDDDDDDDDDDDDDDCBA
ABCDEEEEEEEEEEEEEEEEEDCBA
ABCDEFFFFFFFFFFFFFFFEDCBA
ABCDEFGGGGGGGGGGGGGFEDCBA
ABCDEFGHHHHHHHHHHHGFEDCBA
ABCDEFGHIIIIIIIIIHGFEDCBA
ABCDEFGHIJJJJJJJIHGFEDCBA
ABCDEFGHIJKKKKKJIHGFEDCBA
ABCDEFGHIJKLLLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLLLKJIHGFEDCBA
ABCDEFGHIJKKKKKJIHGFEDCBA
ABCDEFGHIJJJJJJJIHGFEDCBA
ABCDEFGHIIIIIIIIIHGFEDCBA
ABCDEFGHHHHHHHHHHHGFEDCBA
ABCDEFGGGGGGGGGGGGGFEDCBA
ABCDEFFFFFFFFFFFFFFFEDCBA
ABCDEEEEEEEEEEEEEEEEEDCBA
ABCDDDDDDDDDDDDDDDDDDDCBA
ABCCCCCCCCCCCCCCCCCCCCCBA
ABBBBBBBBBBBBBBBBBBBBBBBA
AAAAAAAAAAAAAAAAAAAAAAAAA

52
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA
ABCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBA
ABCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDCBA
ABCDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEDCBA
ABCDEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEDCBA
ABCDEFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGFEDCBA
ABCDEFGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGFEDCBA
ABCDEFGHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIHGFEDCBA
ABCDEFGHIJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJIHGFEDCBA
ABCDEFGHIJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKJIHGFEDCBA
ABCDEFGHIJKLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLKJIHGFEDCBA
ABCDEFGHIJKLMMMMMMMMMMMMMMMMMMMMMMMMMMMMLKJIHGFEDCBA
ABCDEFGHIJKLMNNNNNNNNNNNNNNNNNNNNNNNNNNMLKJIHGFEDCBA
ABCDEFGHIJKLMNOOOOOOOOOOOOOOOOOOOOOOOONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPPPPPPPPPPPPPPPPPPPPPPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQQQQQQQQQQQQQQQQQQQQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRRRRRRRRRRRRRRRRRRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTTTTTTTTTTTTTTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUUUUUUUUUUUUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVVVVVVVVVVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWWWWWWWWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXXXXXXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYYYYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZZYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYYYYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXXXXXXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWWWWWWWWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVVVVVVVVVVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUUUUUUUUUUUUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTTTTTTTTTTTTTTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRRRRRRRRRRRRRRRRRRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQQQQQQQQQQQQQQQQQQQQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPPPPPPPPPPPPPPPPPPPPPPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOOOOOOOOOOOOOOOOOOOOOOOONMLKJIHGFEDCBA
ABCDEFGHIJKLMNNNNNNNNNNNNNNNNNNNNNNNNNNMLKJIHGFEDCBA
ABCDEFGHIJKLMMMMMMMMMMMMMMMMMMMMMMMMMMMMLKJIHGFEDCBA
ABCDEFGHIJKLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLKJIHGFEDCBA
ABCDEFGHIJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKJIHGFEDCBA
ABCDEFGHIJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJIHGFEDCBA
ABCDEFGHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIHGFEDCBA
ABCDEFGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGFEDCBA
ABCDEFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGFEDCBA
ABCDEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEDCBA
ABCDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEDCBA
ABCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDCBA
ABCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBA
ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA


## Scoring

This is , so shortest answer wins. Good luck!

• We're getting slightly into idea-milking territory here. While this isn't a bad idea, a lot of similar challenges in short succession tend to lose interest and popularity fast so you might want to think twice whether you want to post this any time soon. That said, the construction seems simple enough that I'm pretty sure it's been done before. For instance this challenge requires the exact same computation at the core: codegolf.stackexchange.com/q/57845/8478 (although yours probably allows for other approaches, too). – Martin Ender Aug 1 '16 at 16:31

A meander is a self-avoiding closed curve which intersects a line a number of times.

Your task is, given a self-avoiding walk on a lattice/grid, produce a meander a la the following:

Input

{{{3, 4}}, {1, 2}, {2, 6}, {6, 7}, {7, 3}, {3, 4}, {4, 8}, {8, 12}, {12, 11}, {11, 10}, {10, 9}, {9, 5}, {5, 1}}


Output

or similar.

# Test cases:

Inputs

a={{{3, 5}}, {{1, 2}, {2, 3}, {3, 8}, {8, 9}, {9, 4}, {4, 5}, {5, 10}, {10, 15}, {15, 14}, {14, 13}, {13, 8}, {8, 7}, {7, 12}, {12, 11}, {11, 6}, {6, 1}}}
b={{{3, 6}}, {{1, 2}, {2, 8}, {8, 9}, {9, 3}, {3, 4}, {4, 10}, {10, 11}, {11, 5}, {5, 6}, {6, 12}, {12, 18}, {18, 17}, {17, 16}, {16, 10}, {10, 9}, {9, 15}, {15, 14}, {14, 13}, {13, 7}, {7, 1}}


Output

In the above examples, the numbers correspond to a grid, bottom to top, left to right, so 1 is bottom-left, and 18 on a 3*6 grid is top-right. The orientation of your grid doesn't have to follow this order: it can have any desired orientation.

You can assume dimensions of the grid are given at the begining of the input, as per the obove examples.

Feel free to use either pre-existing images - eg

or generate your own. This is Code Golf, so the shortest answer in bytes wins.

• I'm still not clear how the points relate the the final image. For the pre-existing images, can we use them at no bytes cost? Is the code for loading them free? – xnor Aug 4 '16 at 10:44
• @xnor I think you are right - it is not clear as it stands - think I will leave it on the back-burner for the moment. – martin Aug 4 '16 at 12:31

## ASCII Art converter

see ASCII Art on Esolangs

Your task is to take input of a brainf*** program and output its equivalent ASCII art program. Your challenge: You may not use the following symbols in your program: \ / - | _ # Standard loopholes not allowed...

This is a so shortest answer in bytes wins

## ACII Art Interpreter

Your task is to create an interpreter for the ASCII art language. ASCII Art is a variant of brainf*** where characters are instead ASCII art figures 5 lines tall.

< looks like

 /
/
\
\


> looks like

\
\
/
/


+ looks like

  |
|
-----
|
|


- looks like

-----


[ looks like

____
|
|
|
|___


] looks like

____
|
|
|
___|


. looks like

##
##


, looks like

##
##
_|


Characters that are less than 5 characters tall may be placed anywhere within the top line and bottom line of input.

____________________ top line
\
\
/
/
<--- gap because this char is only 5 characters tall
_____________________bottom line


There may be any amount of white space between characters. Also characters can be "nested" in each other, as long as they do not touch. EG

____ |  ##
|    |  ##
|  -----_|
|    |
|___ |


is perfectly valid

Your code should not allow improperly formatted ASCII art, and should print to Standard error. For example, the following code should not work

\
\
|
|
|____


This is a , so the shortest answer in bytes wins!

• What is the winning criterion (is it codegolf, popularty contest, anything else...), and what is the font to use? – TuxCrafting Aug 3 '16 at 17:06
• @TùxCräftîñg By font, what do you mean - the ASCII art page on esolangs depicts what each and every symbol should look like – vikarjramun Aug 3 '16 at 17:31
• Nevermind, I haven't seen this part – TuxCrafting Aug 3 '16 at 17:39
• Welcome to PPCG and thanks for using the sandbox! Unfortunately, this is basically a dupe of this challenge with a do X without Y bit tacked on, so I don't think this will be received well. I'm not really sure if there is a way to salvage your intent, here, but I recommend trying something different. Best of luck! – FryAmTheEggman Aug 3 '16 at 17:45
• 1. If at all possible, posts should be self-contained. The Esolangs page you link to might change or disappear. 2. You should specify how the commands should be chained (horizontally, vertically or something else), how they should be aligned, and how much whitespace has to separate them. 3. In my opinion, forbidding those characters doesn't make the challenge more interesting. – Dennis Aug 3 '16 at 17:49
• @FryAmTheEggman Except my challenge is meant to convert only brainf*** code – vikarjramun Aug 3 '16 at 17:49
• I'm afraid that isn't nearly enough to make it not a duplicate, in my opinion. However, Dennis brings up a potentially interesting point, you may be able to salvage this by also requiring that the code be "formatted" a certain way. I also agree with the rest of the advice Dennis gave you, and I think you should address them before deciding on what else to do. – FryAmTheEggman Aug 3 '16 at 17:52
• What if I change it to a ASCII art interpreter – vikarjramun Aug 3 '16 at 17:57

# Find the Watermark

At the moment, I don't have time to outline this properly. The idea is simple: Find the watermark in an image. The implementation, however, is obviously not simple. Since watermarks can have a variety of characteristics, I'd like to admit a variety of answer styles and make it a . Some ideas for the output format:

• Return coordinates of the (centre|corner(s)?) of the watermark
• Return a line in some form (e.g., endpoints or equation) that runs through the watermark
• Return an image that contains only a mask matching the watermark

Input, obviously, would be an image containing a watermark. Images without watermarks are not valid input; as such, submissions do not need to handle them in any special way.

• I fear that this is far too vague, and probably too difficult. – Joe Aug 21 '16 at 2:10
• Maybe a test-battery tag? – Rohan Jhunjhunwala Aug 21 '16 at 2:19
• Yes, seeing the proposed test cases would give a much better idea of whether this is realistic. – trichoplax Aug 21 '16 at 7:40
• I hereby encourage any member of the community to take over this challenge. I have no experience with graphical I/O, and I don't foresee myself gaining any in the near future. I doubt that I can write a reasonable spec; also, I'm just not that interested in it anymore. – Joe Sep 5 '16 at 20:37

# whispering and SHOUTING

Typing in all caps on the internet is often called "shouting". For the sake of this challenge, I'll call typing in all-lowercase "whispering".

## The challenge

Write a complete program that can be run in two different ways: whispering and shouting. The "whispering" version of the program must be written in all-lowercase characters, and it should print whisper to STDOUT. The "shouting" version of the program will print SHOUT. The shouting version must be the exact same program as the whispering version, but with all lowercase letters replaced by the uppercase version of the letter. Everything else must be identical.

## Rules

• No standard loopholes
• This is , so shortest program in bytes wins!
• Is shortest program in bytes? – Buffer Over Read Aug 21 '16 at 2:46
• Yes, I'll clarify that – Daniel M. Aug 21 '16 at 2:46
• Though I'm not too sure if I want to keep the restriction of not containing the words because it feels kind of arbitrary and that isn't the point of the challenge – Daniel M. Aug 21 '16 at 3:52
• It may be a "Do X without Y" question, which could be bad if not done carefully. – Buffer Over Read Aug 21 '16 at 3:53
• @ColdGolf The difference between this and a do X without Y is that this challenge focuses on actually doing the X (a non-trivial task) instead of focusing on not using Y. Still, I think I'll get rid of the restriction because a) I'd like to focus more on the X and b) the restriction is trivial to circumvent (simply use concatenation) – Daniel M. Aug 21 '16 at 3:59
• What about characters that don't have a case? Or characters that have more than two cases? Is the program restricted to ASCII? – FryAmTheEggman Aug 21 '16 at 4:13
• @FryAmTheEggman characters without a case don't have to change. What character has more than 2 cases? And it's whatever encoding the program uses. – Daniel M. Aug 21 '16 at 11:54
• Sigma has three total variants. Not restricting this to ASCII makes it seem rather odd. Couldn't a language totally avoid the problem by writing the program in caseless characters and then checking like A > 65? Additionally, some characters (i.e. small caps) look like they should have lower case variants, but don't AFAIK. What standard of considering things lower case should we follow? Without restricting or clarifying this, I think this is too unclear. – FryAmTheEggman Aug 21 '16 at 13:31

# Switching lines

Let's say you have a string of text:

Hello, World! Today is a
most glorious day. In fact,
it's another day. Woohoo!


This string has three lines. We can call them lines 1, 2, and 3. (Or, if you prefer zero-indexing, lines 0, 1, and 2. I'll be using one-indexing to describe this challenge.)

Let's also say we have a mapping of line numbers to line numbers, such as 1 => 2, 3 => 1, 2 => 3. We will interpret this mapping as a method of "switching" lines with each other; the first rule switches line 1 with line 2, then line 3 with line 1, then line 2 with line 3. This would make the string look like, with intermediate steps:

Rule: (initial)
1. Hello, World! Today is a
2. most glorious day. In fact,
3. it's another day. Woohoo!

Rule: 1 => 2
2. most glorious day. In fact,
1. Hello, World! Today is a
3. it's another day. Woohoo!

Rule: 3 => 1
2. most glorious day. In fact,
3. it's another day. Woohoo!
1. Hello, World! Today is a

Rule: 2 => 3
3. it's another day. Woohoo!
2. most glorious day. In fact,
1. Hello, World! Today is a


Notice how the rule describes lines to be switched, not merely lines in that index. So each line has a permanent, associated line number.

Any rule such as 1 => 1 is effectively a no-operation.

Objective Given a list of numbers in any convenient format (e.g. an array of pairs of integers, a list like A B\nC D, a list of numbers, etc.) and a non-empty string of text, perform the action described above.

## Meta

is it a good idea to do line identity instead of line locations?

• So the requirements are 1) number the lines; 2) apply the permutation which results from composing a series of simple swap permutations, each of which must be interpreted in the light of the previous ones? The lines really seem to be superfluous: the core of the question is the permutations, surely? – Peter Taylor Aug 27 '16 at 19:13
• @PeterTaylor I suppose that's true. It would certainly simplify the questions. – Conor O'Brien Aug 27 '16 at 19:26

# Tweetable Video

This challenge is inspired by the Encode Images into Tweets challenge, extending the idea to now attempt to compress video into a series of "tweet" sized messages where the number of tweets == number frames of the video.

The competition is to compress 450 frames of video into 450 (or less) tweets of 140 charactes ( 114.97 bytes per tweet, total max 51737 bytes).

Original frames as Video, as PNG images [Sandbox note: Higher quality version will be uploaded soon]

Reference solution frames as Video [Sandbox note: Reference solution will be expanded once challenge changes stabilized]

### Rules:

These rules are the based from rules in Encode Images into Tweets modified to accommodate multiple frames that will yield the resultant video.

1. You must write a program that will communicate via std in/out based on the communication protocol defined below, ultimately producing a series of tweets that will, when fed back to your program, produce image frames of the video.
2. The text created for each 'Tweet' by the program must be at most 140 characters long and must only contain characters whose code points are in the range of 32-126, inclusive.
3. The source video will be 450 frames of Big Buck Bunny. Frames can be downloaded here
4. Frames will be width 320 pixels and height 240 pixels @ 24 bit RGB, each channel having 8 bit precision.
5. Your program should be able to compress other video sources at same resolution.
6. Your program can use external libraries and files, but cannot require an internet connection or a connection to other computers.
7. The decoding process cannot access or contain the original images in any way. (Clarification use of corpus images is allowed as long as these images do not contain direct or manipulated original image frames)
8. Use of video codecs or existing libraries that perform video compression are not allowed. This is to encourage experimentation and originality rather than simply calling libraries. Note that use of static image compressors/ libraries are allowed.
9. Standard Loopholes are forbidden.

### Communication Protocol

1. All communication is via std in/out.
2. The controller program will launch your program with no command line arguments.
3. The controller will either initiate a one of the following sequences commanding to your program and expecting results.

Note the sequences are described below in the following format:

<Comms direction from controller perspective>, <seq number>: <Transmitted Data> - <Information>


For Encoding of the frames:

Output, 1: ENCODE\n - Indicating that the controller will be sending frames for your program to compress.
Output, 2: <number of frames>\n - String indicating number of frames. i.e. 450
Output, 3: <number of bytes for image data>\n - String indicating number of bytes of the current image data. e.g. 32145
Output, 4: <image data> - sequence of bytes of length defined in output line 3. The is the image data. The image data is a 24 bit image in PNG format
Repeat from output seq number 3 for the number of frames in output seq number 2.
Input, 1: <Tweet>\n - encoded image data. upto 140 characters, whose code points are in the range of 32-126, inclusive. A zero sized tweet will indicate end of all tweets.
Repeat from input line 1 for 1 to up to the number of frames in output seq number 2. Note a zero sized tweet will indicate end of all tweets.
Output, 5: END\n - Indicating that all processing has finished and your program should quit gracefully.


For Decoding of the frames:

Output, 1: DECODE\n - Indicating that the controller will be sending tweets for your program to decompress.
Output, 2: <number of tweets>\n - String indicating number of tweets. i.e. 450
Output, 3: <Tweet>\n - encoded image data. upto 140 characters, whose code points are in the range of 32-126
Input, 1: <number image frames decoded>\n - String indicating number of image frames that have been decoded as a result of the provided tweet. If 0 then no images have been decoded for this tweet.
Input, 2: <number of bytes for image data>\n - String indicating number of bytes of the current image data. e.g. 32145.
Input, 3: <image data> - sequence of bytes of length defined in input line 2. The is the image data. The image data is a 24 bit image in PNG format.
Repeat from input seq number 2 for the number of frames in input seq number 1.
Repeat from output seq number 3 for the number of tweets in output seq number 2.
Output, 4: END\n - Indicating that all processing has finished and your program should quit gracefully.

1. Your program will be restart between the encoding and decoding phases.

### Scoring

As an attempt to model the human visual system in a simplistic manner, JPEG quality levels are used as an analogue. Each frame will be compressed to a JPEG using quality levels 0.01 to 1.0 in 0.01 increments. The PSNR of these JPEG compressed versions are calculated and added into a data structure. Additionally, each frame will be resized by half and the JPEG encoding and PSNR calculations performed and added to the data structure. The resizing and calculating will repeat until a single pixel is left.

The result of which will be a scoring continuum of visual 'quality' from low (single color frame) to High (near-identical to original).

Thus, scoring will be objective by means of the following formula:

JPEG_QUALITY_LEVEL_PSNR = a pre-computed data multi dimensional structure consisting of the
PSNR for incremental JPEG quality levels for each image frame of
the video. The entries into this structure for each frame is such
that higher indecies are deemed to be of more similar to the
original.

Score = SUM of (index of closest matching entry in JPEG_QUALITY_LEVEL_PSNR for given
original frame and given PSNR of decoded frame)


### Controller

[Sandbox note: Controller is to be created]

### Refrence Solution

[Sandbox note: Reference is to be created once question stabilizes]

## Sandbox Questions

Ok, so this is my first question ever posed to codegolf and I am very keen to get feedback on how to better present the challenge.

Some areas where I would like specific feed back is the objective scoring mechanism... i purposely avoided direct PSNR as the score as it is very limited for scoring video quality, being biased toward blurry images, however other algorithms are too complex or not defined. So as a compromise I am using JPEG compression as an analogue for the Human Visual System. Effectively matching a given solutions output frame to original frame PSNR to a JPEG compressed, at a given quality level) version's PSNR and using that match's index in sorted JPEG quality order as input for the score.

Is the protocol clear enough? if not what would be a better way to present it?

• "I introduced it so that solutions that take all the frames then perform processing over all the frames would be at a clear advantage over those solutions than work over a much shorter frame period." I'm not seeing it. If I process all of the frames then the first frame will probably use a lot of tweets and the subsequent ones fewer, so I'll be penalised for the first frame. – Peter Taylor Sep 21 '16 at 9:25
• @PeterTaylor Indeed, that is the point i am ?trying? to make, In the fantasy world where video by tweets is a feature desired by users, having to wait until all the tweets are received before playing the video would be very annoying. So this part of the scoring is to give those solutions that return frames quicker in response to provided tweet(s) an advantage. I am thinking that it may be not that "interesting" or "fun" to have this modifier. I think i shall remove it unless some people think it has some worth. – Moogie Sep 21 '16 at 11:23
• The point I was trying to make is that the feature of the scoring system seems to me to penalise the approach which you say it's trying to promote. – Peter Taylor Sep 21 '16 at 11:28
• oh i apologize, i think i misunderstood. Yes, in the example you have given it will penalize that solution, however it would be less penalized than a solution that waited for all tweets, but more penalized than a solution that immediately gives an image frame after each tweet. i.e. the fantasy user would have to wait longer than if the solution produced images after each tweet. Hmm, given the confusion i will remove the modifer as it will be difficult to tune the "negative" effect as to not completely favour immediate frames vs better quality frames. – Moogie Sep 21 '16 at 11:42

# Interpret MSF-!

Because there aren't enough "Interpret X" challenges.

MiniStringFuck (or MSF-) is a brainfuck derivate made by @ErikTheGolfer, with two commands, operating on one cell:

InstructionAction
+               Increment the memory cell. If it reaches 256, wrap to 0.
.                Output the character in the cell.

Instruction, Action
+, Increment the memory cell. If it reaches 256, wrap to 0.
., Output the character in the cell.


Your task is to, given a string of MSF- code, containing only printable ASCII characters, output what it would print.

The string may have other characters than + and .. Treat them as NOPs

## Example

++++++++++++++++++++++++++++++++++++++++++++++++.+.+.+.+.+.+.+.+.+.
++++++++++++++++++++++++++++++++++++++++++++++++.                    Set cell to 48 (0) and output
+.+.+.+.+.+.+.+.+.  Keep adding and outputting until 57 (9)


## Test Cases

+++++++++++++++++++++++++++++++++.+.+. -> !"#
++++++++++++++++++++++++++++++++++++++++++++++++.+.+.+.+.+.+.+.+.+. -> 0123456789
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+. -> ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ -> (no output)

• Will the input string ever contain other characters? If so, should they be treated as NOP/comments? – Geobits Sep 22 '16 at 14:16
• @Geobits Yes and yes. – acrolith Sep 22 '16 at 15:39
• This is basically "Parse unary numbers", and as such I think it's a duplicate of codegolf.stackexchange.com/q/76756/194 – Peter Taylor Sep 22 '16 at 16:20

# Interleave your code with the input

Given an input string, interleave this string with the source code of your solution.

For example, if your code is abcd and the input is 1234, then your program must output 1a2b3c4d.

If your code is shorter than the input, then it must loop back to the beginning of your code. For example, if your code is abcd and the input is 123456, then your program must output 1a2b3c4d5a6b.

If your code is longer than the input, then only part of your code will be interleaved with the input. For example, if your code is abcd and the input is 12, then your program must output 1a2b.

### Inputs and outputs

• The input string will only contain characters which are valid string characters in your language.

• The input may be taken through STDIN, as a function argument, or anything similar.

• The output may be printed to STDOUT, returned from a function, or anything similar.

### Scoring

This is , so the shortest answer in bytes wins.

• I'm not even sure that this is possible. – Fatalize Sep 28 '16 at 12:01
• Why would it not be possible? The only potential problem I see is being closed as a dupe for being a straightforward generalised quine. – Peter Taylor Sep 28 '16 at 12:05
• @PeterTaylor I don't understand how being a "straightforward generalised quine" makes it a dupe (of what?). I don't see how this is more straightforward than say this challenge nor do I think it is a dupe simply because source code is involved. – Fatalize Sep 28 '16 at 12:09
• meta.codegolf.stackexchange.com/a/8595/194 – Peter Taylor Sep 28 '16 at 13:28

## Priority to the right

The input is a string representing the upcoming traffic on each road. For example, NNNWS indicates there is a total of 5 cars: three at the north, one at the west and one at the south. The order has no importance here, NNNWS is equivalent to WNNSN.

You must output the order in which the cars should go, using the priority to the right rule: cars coming from the south must let cars coming from east go first, east gives way to north, north gives way to west and west gives way to south.

For example, with the input NNNWS, the south car should go first, then the west car, then the 3 north cars. The output should then be SWNNN.

There are some indecidable cases, for example NS or NNWSE : you should then output the string stuck.

Test cases

N => N
NW => WN
NWS => SWN
SNW => SWN
SSSSS => SSSSS
ENNNNES => NNNNEES
NS => stuck
NNWSE => stuck


## golf.ko - Kernel module golf

A Linux-specific challenge.

Implement a Linux kernel module which printks Hello world upon loading, in some compiled language.

Source file, linker scripts and command lines, Makefile content (if any) are all counted towards the byte score.

You may expect kernel version to be 4.1 or 4.4.

The kernel is assumed to be running. It's built, not cleaned source code is assumed to reside in /usr/src/linux. In addition you may expect the system to be Debian and to have working DKMS.

• Maybe can be a catalog. – Vi. Sep 30 '16 at 13:18
• What does it mean for a kernel module to "print"? – Peter Taylor Sep 30 '16 at 18:00
• Issue behaviour similar to printk kernel API function in C. Output message to logs, to console, to /proc/kmsg. Shall definition what exactly is a printk be included? Obviously user is expected to call the function inside kernel, not re-implement printk. – Vi. Oct 2 '16 at 18:29
• I see: "printks" just looks like a typo, it isn't really one. That could be clearer if you wrote "printks", and clearer still if you link to a man page or other documentation. But if you're requiring use of that library, you can pretty much rule out answers in languages other than C and maybe Rust (since what other languages will have bindings for it?), and I wouldn't be surprised if there's nothing interesting left to golf and you just get one answer. – Peter Taylor Oct 3 '16 at 11:49
• @PeterTaylor, Maybe just exclude printk requirement and require just some code derived from posted source code to be executed? Or just the endless loop (it should be doable in almost any language, is API-agnostic and is observable)? – Vi. Oct 3 '16 at 23:32

# Random Quine

(something related to languages?)

You are to write N programs in N langauges (at least 2) that satify the following properties:

1. For each program P, the program P must produce an output O that is equal to a random program Q that you wrote, including P.
2. No two programs P and Q may be equal.

Let's say you have two programs, ABCD in language Bar and 1234 in language Baz. Then, ABCD must produce each of ABCD and 1234 with nonzero (but not necessarily equal) probability. Similarly, 1234 must output ABCD or 1234 with nonzero chance. Note that the chances do not have to be same for each program.

• Higher N being winning doesn't seem to be viable on it's own as I think this could be done essentially forever. Will it be something like total length of all Ps divided by N? – FryAmTheEggman Oct 5 '16 at 22:35
• 1. On clarity: it's not clear what the requirements are for which programs each P must produce with non-zero probability. All of them? At least two different ones? ("At least one" would satisfy the stated properties, but not the explanation in the example). 2. On boringness: the programs can just be identical apart from an integer or string literal which they ignore when executing and replace at random when outputting. So a generalised quine of half of the random challenges would meet spec. – Peter Taylor Oct 6 '16 at 7:28

# Introduction

The challenge is to determine if two complex lines intersect.

# Challenge

Given two lines made up of multiple straight line segments determine if the lines cross at any point.

Input can be in the format of you choice that takes a series of [x,y] coordinates. All coordinates will be integers (positive or negative)

Output will be truthy if the lines cross and falsey if they don't cross.

There will be no coincidental points and no segment of one line will terminate at a point touching the other line (there will be a clean cross of line segments if the case is truthy).

This is code golf so shortest answer wins

# Example Input and Output

For the examples formats are given as

Line 1: [[X1,Y1],[X2,Y2]...,[Xn,Yn]] Line 2: [[X1,Y1],[X2,Y2]...,[Xn,Yn]]

Examples

Line 1: [[0,0],[1,1]] Line 2: [[0,1],[1,0]] = TRUE

Line 1: [[2,2],[1,0],[0,2]] Line 2: [[0,1],[1,1]] = TRUE

Line 1: [[1,3],[2,9],[3,6],[4,7],[5,4],[6,1]] Line 2: [[2,6],[3,5],[5,2]] = FALSE

Line 1: [[0,6],[3,8],[5,5],[8,5]] Line 2: [[0,4],[3,7],[5,4],[7,6]] = TRUE

Line 1: [[2,2],[3,2]] Line 2: [[1,1],[10,4]] = FALSE

• What about the case where one of the line segments "touches" another. That is: one of the end points of a line is on the other line. Would that be considered "crossing" or not? – DarthRubik Oct 6 '16 at 23:49
• @DarthRubik tried to clarify, don't need to handle that case. – gtwebb Oct 6 '16 at 23:55
• All of the test cases have x increasing strictly monotonically. Is this guaranteed, or could line segments be vertical or even loop back? If you don't guarantee that input will avoid those situations, please add test cases to cover them. – Peter Taylor Oct 9 '16 at 16:11

# Raytracing/Raycasting

Here is a 256*256 heightmap. Your challenge is to render it, in minecraft-style blocks, using some form of raytracing.

### Fundamental Definitions And Clarifications

These are all straightforward and fairly obvious but I'm being explicit so that what follows is (ideally) unambiguous.

• Let each pixel represent 1x1 metre, for ease of thought.
• This image is a top-down view. The bottom-left pixel of the image in screen space is at [0,0,0] in world space. The bottom-right pixel of the image in screen space is at [255,0,0] (i.e. the next full tile to the right would be anchored at [256,0,0]). The Z-axis increases away from us in world space so the top-left pixel is at [0,0,255] and the top-right-pixel is at [255,0,255].
• As you are looking down to the floor at the moment, you have positive height and the vector from your eye to the image points in the direction of [0,-1,0], so the camera which corresponds to the above image has a world-space coordinate of something like [128,300,128].
• It shouldn't really matter, but let's take the red channel as holding the height. A red channel value of foo puts that pixel at y=foo. The tallest possible pixel would have world coordinate [x,255,z] with 0<=x,z<256.

### Aesthetic Definitions

• Each pixel effectively represents a tower some number of 1x1x1 solid cubes. The edges of these blocks should be rendered sharply at 90-degree angles. If you were to convert this scene to triangles, each normal would be along one of the major axes. You can think of blocks having end-caps on their top (which is the floor, to us), and walls are extruded between neighbouring blocks as required. There are no holes in the rendered surface. You can assume all renderings will be from above (extra implied geometry below the floor doesn't matter).
• As well as the heightmap, the world contains one camera and one light source. The light casts hard shadows, so every rendered pixel will require two ray casts. Light falloff is inverse-square. You may optionally gamma-correct the result.
• Pixels on a surface which receive no light should be black. Pixels of rays which do not hit any surface should be magenta: rgb=(255,0,255).

### Input Parameters

• The camera is defined by position P=[px,py,pz], a T=[tx,ty,tz] target point, and a field of view FOV. It renders WIDTH x HEIGHT images such that the target point appears in the centre.
• The camera is orientated such that it yaws, then pitches, but does not roll.
• The light is at position L=[lx,ly,lz] and casts light uniformly in all directions.
• You solution must be posted with reference image rendered with P=[80,256,0], T=[128,50,200], L=[256,300,128], WIDTH=400, HEIGHT=300 and FOV=45 degrees.
• (As reference images emerge I might tweak these parameters.)

### Free Parameters

• The light can be any colour and brightness you like but the colour and brightness must be inputs to the program.
• Likewise, the colour/material of the surface may be anything you like (except magenta, which is for revealing holes) but these colour/material parameters must be an adjustable input to the program.
• Use any lighting/shader model you like.
• Use fog or other effects if you like. Different submissions are likely to vary considerably in size, so there's room to play a bit.

### Criteria

• You must post code which can be run as-is, with the specified reference parameters and all your free parameters included.
• You can take the heightmap image as hardcoded in a representation of your choice and this does not count towards your golf score. You must post the code which converts an image to your preferred format. This script should either run using common Linux command-line tools, or over an online service. This script should not assume that heightmaps are square.
• The output of raw pixel data can be in any format you like (e.g. [[r,g,b],...] BUT you must provide a second script, not counted towards your golf score, which turns your program's raw output into some standard image format such as PNG. This script should either run using common Linux command-line tools, or over an online service.
• You must post the final image produced by this method, as well as the code which produces the output which produces the image.

In a nutshell, the above specifies that your output is reproducible, with different parameters and heightmap images as desired.

The winner will be chosen a few weeks from now, as the shortest code which conforms to the above aesthetic specifications (e.g. shadows, no holes, etc) and which gives end-to-end reproducible results.

• Maybe include a sample output? – Steven H. Oct 7 '16 at 18:10
• My own attempt at this is part of a larger, more complex project, it'll be a while :-) In the meantime I was curious if others would find a simplified version of the problem a bit more fun. – spraff Oct 7 '16 at 19:42
• Must run, so will expand on this later, if not within 48 hours then ping me. There are some subtleties with respect to offsets (are blocks centred?) The stuff about fog etc is wasted space, because in code-golf no-one will spend bytes on it, so remove it to KISS. I strongly advise before posting to get a test output which two independent programs agree on. – Peter Taylor Oct 8 '16 at 8:07
• 1. The subtlety I promised to expand on: does "The bottom-left pixel of the image in screen space is at [0,0,0] in world space" mean that the pixel corresponds to the voxel whose coordinates range from (0,0,0) to (1,1,1) or the voxel whose coordinates range from (-0.5, -0.5, -0.5) to (0.5, 0.5, 0.5)? 2. Also, what does "The camera is orientated such that it yaws, then pitches, but does not roll" mean? Perhaps it could be better expressed by giving the initial up, forward, right vectors and then saying around which axes it rotates. – Peter Taylor Oct 9 '16 at 16:09

# First 100 prime numbers in Wentelx87 code-golf

Wentel consists of, at the basic level, a memory pointer and an instruction pointer. Instructions are stored loaded into memory. The execution pointer moves to the right after executing the instruction at that memory pointer.

The program is loaded into rightmost slot of memory. For example, if your program is 0010 0000 0101 0100, then the virtual machine will look like this when started:

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0010 0000 0101 0100 (memory)
^                   (execution pointer)
^                                                                               (memory pointer)


Wentel documentation examples, thorough and clear explanation here.

Wentel is language that is very hard to program in. Unlike brain**k, functions and GOTOs can be implemented. It emulates real machine code/assembly much better than brainf**k.

Wentel is a simple language.

1. instructions are held in the rightmost cells, one cell = one instruction
2. execution pointer starts out on first instruction
3. execution pointer moves right
4. the same cells that hold memory hold instructions.
5. these are the opcodes:

0000 - no-op

0001 - if the current address's value is equal to the value stored by the adress defined by the next word, move the execution pointer to the address pointed to the next word after the word after the current address.

0010 - move memory pointer to address specified by next word.

0011 - deposit the current address of the execution pointer into the current memory address

0100 - increment current memory address

0101 - decrement current memory address

0110 - move memory pointer left

0111 - move memory pointer right

1. and here are the specialized opcodes for output.

1000 - output 0

1001 - output 1

That was a boiling down of Wentel. Please read the full docs. Now for the actual challenge. Output the first 100 prime numbers, separated by spaces, in Wentel.

This is , so the shortest answer in bits wins.

• If you want to encourage an answer to an existing question in a new language, the way to do it is with a bounty on the existing question. If you're worried about losing your rep because no answers will be posted, see meta.codegolf.stackexchange.com/q/5243/194 – Peter Taylor Oct 10 '16 at 8:33

A simple but fun code golf challenge!

Given positive integer n

create a 2 dimensional matrix where each location is filled with it's xy index (starting from the top left).

For example:

Your grid should look like: input: 2

00 10
01 11


input: 3

00 10 20
01 11 21
02 12 22


Once the grid is created, randomly fill each index. This can be with an 'x' or any other way to denote a spot has been filled

A complete simulation looks like:

input: 3

x x x
x x x
x x x

O O O
O O O
O O O


You can use whatever character you want to fill in each location.

Extra points if you use a GUI and use black squares to fill it in

You should only fill a spot in once so the number of times you fill should be n^2. (So no randomly filling spots until they are all filled you have to check!)

You can refresh the grid however you want. i.e print the grid, make a new line, print again... You can use a timer. However you want to do it to illustrate each step. You only need to refresh when you are filling not when you are populating the grid.

An example simulation looks like this:

input: 2

00 10
01 11


randomed 01

00 10
XX 11


randomed 11

00 10
XX XX


randomed 11
re-roll
randomed 01
re-roll
randomed 00

XX 10
XX XX


randomed 10

XX XX
XX XX


Complete

Do not display your randomed numbers, the output should tell me which were randomed.

Have fun!

# Just like magic

Nowadays, the word "abracadabra" is used mostly in connection with magic tricks. The original purpose of the word had more to do with superstition, and some doctors used it to make lethal diseases go away by writing it in a triangle1, like so:

A B R A C A D A B R A
A B R A C A D A B R
A B R A C A D A B
A B R A C A D A
A B R A C A D
A B R A C A
A B R A C
A B R A
A B R
A B
A


Your task is to write a program or function that outputs/returns the exact text shown above in as few bytes as possible. The output may contain trailing spaces on each line and/or trailing newlines. This is , so the shortest code in bytes wins.

# Sandbox questions

• Is it too simple?
• Is it a duplicate?
• Any better name ideas?
• "It's magic, you know! Never believe it's not so!" – Addison Crump Oct 11 '16 at 20:32
• @VTCAKAVSMoACE Haha :) though I'm not sure how many people would get the reference. I had to google the lyrics, but the song sounds very familiar. I wonder where I've heard it before... – ETHproductions Oct 11 '16 at 20:39
• Well, it's the same formatting than Number Triangles, but the task is clearly different. I suppose you could also call it "A Kind of Magic", although the Queen/Highlander reference might be a bit far-fetched. – Arnauld Oct 11 '16 at 23:04
• The closest I can think of as a dupe is codegolf.stackexchange.com/q/65300/8478, but it seems likely that it's shorter to generate each line from the previous instead of generating a string of all prefixes first and the laying it out in a triangle. – Martin Ender Oct 12 '16 at 12:38

## Ungolf batch

This question wants you to golf batch programms. In Batch you can use

set x=averylongbatchcommand
%x% arg1


which expands to

set x=averylongbatchcommand
averylongbatchcommand arg1


As you can also use set for arithmetic purposes like this:

set x = 0
set /a x= %x%+1


you should ignore the statements where the pattern with set /a is applied.
There will never be something like

set s=SET
%s% s=%s% a


where the variable is assigned using itself as command. But you have to handle things like

b:
set a =echo
%a% Hello World!
set a=goto
%a% b


## Scoring

This is so the answer with the fewest bytes wins.

## Testcases

set s=set
%s% e=echo
%e% I will have to use this exact thing very often because
%e% it absolutely wouldn't be shorter if i just left out these set statements


Expands to:

set s=set
set e=echo
echo I will have to use this exact thing very often because
echo it absolutely wouldn't be shorter if i just left out these set statements


set s=set
%s% i=0
set g=goto
:a
if %i%==15 (
%g% e
)
%s% /a i=%i%+1
%g% a
:e


Expands to:

set s=set
set i=0
:a
if %i%==15(
set e
)
set /a i=%i%+1
goto a
e:


set s=set
%s% s=%s% a=


Mustn't be supported.

• Too bad the question mentioned has no answers... – Conor O'Brien Oct 18 '16 at 0:44
• I will probably post It tomorrow, if there isn't any critic. – Roman Gräf Oct 18 '16 at 12:46

## Introduction

Birkana is a not-very-well-known notation for hexadecimal using rune-like symbols. The general structure of a Birkana rune is like this:

|\     <-- 0x1
|/     <-- 0x2
|\     <-- 0x4
|/     <-- 0x8


The slash or backslash is present if its base number (0x1, 0x2, 0x4, or 0x8) is present in the number, or not otherwise. The pipe is always at the left-hand side.

For example, here's the Birkana rune for 0xD (= 0x1 + 0x4 + 0x8):

|\
|
|\
|/


## Challenge

Given a Birkana rune as input, write a program or function to output the corresponding hexadecimal digit.

You may choose to output either lowercase (a-f) or uppercase (A-F) hex digits, but they cannot be mixed.

You only need to support the 16 hexadecimal digits and their corresponding Birkana runes.

## Test cases

Input
Output

|
|
|
|
0

|\
|
|
|
1

|
|/
|
|
2

|\
|/
|
|
3

|
|
|\
|
4

|\
|
|\
|
5

|
|/
|\
|
6

|\
|/
|\
|
7

|
|
|
|/
8

|\
|
|
|/
9

|
|/
|
|/
A

|\
|/
|
|/
B

|
|
|\
|/
C

|\
|
|\
|/
D

|
|/
|\
|/
E

|\
|/
|\
|/
F


## Scoring

This is , so the shortest answer (in bytes) wins.

• Is this just binary displayed vertically using space/nothing for zero and a slash for a one? I guess the fact that the slashes alternate could just be ignored, treating each position as either empty or full, which would still give the correct output? If so, is it acceptable to output a hex digit for invalid inputs? This is likely to make a difference to the approaches used. – trichoplax Oct 18 '16 at 12:03

## Background

I'm taking AP stats now, so I figured I'd bring the joy to you all here.

The form of an LSRL (least squares regression line) is ŷ = a + bx.

## Input

Your job is to find the least squares regression line for two data sets (lists), X and Y. X and Y will be the same size with at least 2 elements. They will contain positive or negative floats. Input can be taken in any reasonable format.

## Output

The values a and b in the least squares regression line (LSRL) for the data in X and Y, where a is the y-intercept and b is the slope of the LSRL. This page describes a way to calculate this line.

This is , so shortest code in bytes wins!

Also, built-ins are allowed!

Examples

[1.0, 2.0, 3.0, 4.0] [12.0, 15.0, 16.0, 17.0] -> A: 11.0 B: 1.6
[1.5, 1.5, 51.0, -15.0] [2.0, 1109.0, 0.003, 2.0] -> A: 314.92 B: -3.7609
[1.0, 2.0] [1.0, 2.0] -> A: 0.0 B: 1.0
[-15.0, -13.0, -163.0, -12.25, -14.41, 100000.0, -630.0, -135.0] [-142531.0, -12.0, 153.0, -135.0, 135.0, 16.0, 21.0, 0.0] -> A: -20285.0 B: 0.20121
[3.0, 5.0, 7.0, 9.0, 11.0, 13.0] [2.0, 4.0, 6.0, 8.0, 10.0, 12.0] -> A: -1.0 B: 1.0

• 1. Use the full name in the title, because the title will be shown in contexts where the body isn't. 2. What kind of numbers will X and Y contain? The test cases use signed integers, but can answers assume that all inputs will be integers, or that all inputs will be floating point numbers? 3. In some contexts, a quadratic can validly be described as a least squares regression line. It would be better to move the definition which makes it clear that it's a linear polynomial to the introduction, before the section on input, rather than having it in the section on output. – Peter Taylor Oct 22 '16 at 20:55
• 4. There's more than one way to calculate the gradient, and the method described is not the best one. I would suggest removing that section entirely and having a link to en.wikipedia.org/wiki/Simple_linear_regression in the introduction. – Peter Taylor Oct 22 '16 at 20:56
• @PeterTaylor, I have edited the question. Is it better now? – Daniel Oct 22 '16 at 21:26
• Every math language has a builtin for this so it's just solve(x,y). Even without the built-in linear solver, this is just the pseudoinverse of (1,x) multiplied with y. – Angs Oct 23 '16 at 6:04
• I disagree with Peter - for the sake of self-containedness, you should include at least one method of computing the LSRL (and keep the link in case people want to see more methods). – user45941 Oct 24 '16 at 6:50

# 2D Poor Man's Plotting!

## Introduction

Surely you've also come across the problem where you have a multi-dimensional function at hand and want to visualize it (it's just such an everyday problem!). So we need a (programmatic) solution to this. A memorable solution, thus obviously the shortest solution is best!

## Specification

### Input

Your (primary) input will be a function that maps two floats onto another float.

Additionally there are six other parameters (floats), which you may take explicitely or hard-code:

• StartingValueX: 0
• StartingValueY: 0
• EndingValueX: 10
• EndingValueY: 10
• StepSizeX: 1
• StepSizeY: 1

You may take these parameters using your preferred method of input, but please document it (especially how the function should be passed).

### Output

The output is a formatted string or a printed output (whatever pleases you).

### What to do?

Given a function that takes two floats as inputs, iterate it two-dimensionally and print the resulting values. So the top left entry is the result of the evaluation at (StartValueX,StartValueY) and the bottom right entry is the evaluation of (EndValueX,EndValueY) and then you form basically a table from this by incrementing the StartValue by the respective StepSize for each iteration.

Formatting guidelines:
Between each line may be one (or more) empty lines (eg end your lines with \n\n in C).
There must be at least one white space between every output number.
All numbers with the same x-coordinate must be aligned respectively to their start.

### Potential Corner Cases

You may always assume a certain function prototype is used.
If EndValue-StartValue is not an exact multiple of StepSize (which may happen because we're dealing with floats here) then you shall compute for all StartValue + k * StepSize smaller than EndValue as well as for EndValue.
You may always assume the computation results (of the function) are actually representable in your language.
You may not assume that the function is a simple mathematical function (e.g. any valid function adhering to the above conditions in your language must work).
Trailing newlines and white spaces are allowed.

### Who wins?

This is code-golf so the shortest answer in bytes wins!
Standard rules apply of course.

## Test-cases

Default parameters, f(x,y)=x+y
Output:

0  1  2  3  4  5  6  7  8  9  10
1  2  3  4  5  6  7  8  9  10 11
2  3  4  5  6  7  8  9  10 11 12
3  4  5  6  7  8  9  10 11 12 13
4  5  6  7  8  9  10 11 12 13 14
5  6  7  8  9  10 11 12 13 14 15
6  7  8  9  10 11 12 13 14 15 16
7  8  9  10 11 12 13 14 15 16 17
8  9  10 11 12 13 14 15 16 17 18
9  10 11 12 13 14 15 16 17 18 19
10 11 12 13 14 15 16 17 18 19 20


# [Lang1] vs [Lang2] ... vs [LangN]: Battle of the golfers!

and other tags for the challenge questions, which may be a lot.

Note: I haven't figured out all the kinks out yet, all I have is a general idea that, with your help, can be put properly into an awesome challenge (I hope). The parts where my ideas are not solid yet have Notes attached to them that must be read.

# Team

In the midst of the nation of SE, there lies a golf field for the community of golfers. These golfers play day and night using specialised clubs (languages) to complete difficult and challenging holes (challenges). Now it is time to see the best of these golf clubs in the game!

Note 1: First of all, this challenge is going to be language-specific. I haven't decided the languages yet, but right now I'm thinking around the lines of Java, C, C++, C# since these languages are very well known, unlike the other esoteric languages.

You, the golfer, are to choose one golf club out from these [Lang1], [Lang2], ..., [LangN]. You will team up with other players using the same golf club as you.

Note 2: Now there is supposed to be a table where the players can edit into this challenge (once I post it) to join a team. After ~1 week from the beginning of the sign-up, people will start competing in the challenge.

This will be a sort of golf relay, where every player must only complete 1 hole, no more, no less. But of course, each player may help teammates to complete the holes using the minimum number of shots (bytes) as possible. All golfers, of every team, will be playing using the same playing field, in this case UTF-8.

# The Challenge

There will be a list of challenges [see Note 3] to be completed by the team. Each team member must complete 1 challenge only. After a fixed amount of time (see Note 3), all team members must have complete their assigned challenges (see Note 4). I will sum of all the bytes used by each team to figure out the winning team (see Note 5)!

Note 3: Either I will provide all the challenges, or each team member may give 1 challenge to the challenge pool. Challenges can range from anything like quines and "Hello, World" challenges, to more complicated ones, like solving advanced mathematical (pardon me) mumbo jumbo and outputting complex sequences. Every team completes all of these challenges (see Note 4).
The time that I have decided, so far, is to give the entire team 3 weeks (subject to change) to complete their challenges.

Note 4: Each team member complete 1 challenge. However, if the team sizes are different, the team with the greatest number of members will have to complete all of the challenges. The other teams only have to complete as many challenges as members, so that there will be one for every member.

Note 5: The scoring will be the number of bytes used by each team, summed up, and then divided by the number of challenges completed.

Here is the format to each answer:

#Language, challenge-number, byte-count in UTF-8


for example:

#Java, #34, <s>463</s> <s>444</s>  <s>442</s> bytes


## Summary

To sum it up, here is the process that this challenge goes through:

1. People who want to play must choose one team to be on, if they want to play.
2. After registration is over, the games begin: each player is to choose only one challenge and give a golfed answer. (Other players of the same team are allowed to help teammates)
3. After some time, when all the challenges are attempted (one for every person, if people haven't answered in this time, they won't be counted towards the challenge), I will calculate the score of each team (using the total bytes used).
4. Leaderboard is announced and the winning team walks away with all the glory!

Comment any ways this challenge can be improved. My general idea is to implement a team game, instead of the standard free-for-all.

# King of the Hill: Moon Rockets

This is a challenge where you code bots to compete in an arena. In this case, you code a rocket flying over the Moon. Your goal is to shoot down enemy rockets, while not running out of fuel and crashing into the Moon.

### Environment

Unlike many KOTH challenges the playing field is continuous, rather than discrete. You are provided with variables for your position, velocity, and the direction you are facing. Each turn, you are given a list of all the rockets you can "see" (all rockets less than 10 units away). You return a turning speed, thrust and whether you want to fire missiles.

### Arena

The arena wraps left-right. There is a floor; if you crash into it going faster than 4 m/s, you will explode. There is no ceiling, but you do have a limit of 10 fuel units. This can be refueled by landing on the floor going less than 4 m/s.

### Missiles

Every turn, you have the option to fire missiles. Missiles go in the direction you are pointing, at a constant velocity 5 m/s faster than you were when you fired. If they come within a 1m radius of another rocket, they explode and destroy it.

### Gravity

Gravity is a constant force of 1 downward. With a max thrust of 2, you can accelerate at an equal rate in the opposite direction.

Pastebin for current controller code: http://pastebin.com/FNyjrJfr
No tournament code is in place yet.

• Possibly relevant: Spacewar KotH – trichoplax Oct 25 '16 at 20:11
• The controller seems to set the step size at 0.5s. Does that give enough time to take evasive action at all, given the missile speed and sight range? (Even discounting step size, with max thrust of 2, it seems like it's going to be hard to outmaneuver something going possibly several times faster) – Geobits Oct 25 '16 at 20:11
• Additionally related to step size, how are collisions handled? If I'm a meter away from you and fire a missile that goes 7m/s, can it miss by overshooting in that half second? – Geobits Oct 25 '16 at 20:14
• Can spaceships collide with each other, or only the surface? – Geobits Oct 25 '16 at 20:15
• 1. Continuous presumably means floats, which means possible disagreements over the results (because e.g. Java doesn't strictly apply the IEEE-754 spec unless you tell it to). 2. The spec should say at the very least what information is available to the bots. Does the "list of all the rockets you can "see"" include velocity, angular velocity, etc. or just position? – Peter Taylor Oct 25 '16 at 20:24
• I assume one win condition is "last rocket flying", but what about stalemates? Is there a "last turn", since it seems like a couple pacifists could land/refuel forever? – Geobits Oct 25 '16 at 20:27
• @Geobits - the collisions are handled point-by-point, so yes, you could miss someone right in front of you if you have a high closing speed. I think evasion is possible as long as you have at least 1 step of warning. – Skyler Oct 26 '16 at 13:10
• @Geobits Spaceships can't collide in the current code. If they could, what should define a "collision"? Currently they are modeled as point objects. – Skyler Oct 26 '16 at 13:11
• @PeterTaylor they can access velocity etc. as well as position. I think this might be required as if a rocket is moving fast you need to lead it with the missile. – Skyler Oct 26 '16 at 13:12
• @Geobits I could add a condition that limits the total turns. Does 50 turns seem reasonable? – Skyler Oct 26 '16 at 13:13

# 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 s = i + j;
i = 0;
j = 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[i][j];
}
return s;
}


• What does need to be implemented? A question should ideally be self-contained, but if there's too much information to fit in the post then it should contain links to the relevant specifications. – Peter Taylor Oct 26 '16 at 10:08

# HamSort a list of strings

Given a list of strings, sort them in a manner such that the Hamming distance between each is minimal.

The Hamming distance between two strings of equal length is the number of positions where the corresponding characters do not match. For example, the Hamming distance between apple and ample is 1 since only the second characters of each do not match.

apple
ample
*


# Rules

• This is so the shortest code wins.
• Each string in the input list will have the same length and will consist of only the letters in the English alphabet. You may assume all to be either uppercase or lowercase.
• If there are multiple possible solutions, you may output any number of them.

## Test Cases

<to be created>

• The Hamming between consecutive pairs? If so, what is to be minimized? The sum of the Hamming distances? Their maximum? – xnor Oct 26 '16 at 7:32
• What is (for this challenge) the hamming distance of strings without equal length? Or will the list contain only strings of the same length? – Laikoni Oct 26 '16 at 8:06
• @xnor It's still a work-in-progress. I'd like to have the problem be minimizing the Hamming distance between the consecutive pairs, but that problem might be hard enough that the only golfy solution would be generating all permutations and testing each pair. Then a length n input would have a length n-1 Hamming distance array where each value is minimal. If you have better ideas that could still capture the spirit of this, feel free to suggest them. – miles Oct 26 '16 at 8:33
• @Laikoni Yes, Hamming distance is only defined between strings with equal length and one of the rules was that the input array would only contain strings with equal length. – miles Oct 26 '16 at 8:34
• I think it's NP hard to find the path that minimizes total Hamming distance by reduction to Ham-Path. So, I wouldn't expect anything better than brute force there. – xnor Oct 26 '16 at 9:00