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

• How are tags added to questions? – guest271314 Jan 9 at 7:51
• @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] – DJMcMayhem Aug 29 at 15:19
• Why no featured anymore? Can't we have it auto-added or something? – JL2210 Sep 26 at 15:57
• @JL2210 We now have a permanent info box that links to the Sandbox, so the featured tag isn't necessary – caird coinheringaahing Sep 29 at 13:43
• I think the sentence 'replace the post here with a link to the challenge and delete it' may specify that the deletion should be done immediately . – AZTECCO Oct 5 at 19:39

# Matrix Decomposition

## Meta

• Duplicate?
• What rules should I add?
• Are my explanations sufficient?
• Any room for improvement?

It's possible to "factor" any invertible (a.k.a. non-singular) square matrix A into a combination of a permutation matrix1 (P), a unit3 lower triangular matrix2 (L), a diagonal matrix4 (D), and a unit upper triangular matrix2 (U).

That is, A = PLDU

For instance, the matrix [[4, 5], [2, 3]] can be expressed as the multiplication of the following matrices:

P = [[0, 1],
[1, 0]]
L = [[1, 0],
[2, 1]]
D = [[2, 0 ],
[0, -1]]
U = [[1, 3/2],
[0, 1  ]]


Given an invertible square matrix A, output P, L, D, and U.

# Test Cases

TBD


# Rules

• Any reasonable output format is acceptable, but P, L, D, and U must be separate outputs.

1. A permutation matrix is a permutation of the identity matrix.

2. An upper triangular matrix is a square matrix whose nonzero values occur only on or above the main diagonal, and a lower triangular matrix is a matrix whose nonzero values occur only on or below the main diagonal.

3. A unit triangular matrix is a triangular matrix whose main diagonal is all 1s.

4. A diagonal matrix is a matrix whose nonzero values occur only on the main diagonal.

# Become a Word-Pontif

The french used to define the word pontif as one who builds bridges stemming from the conjunction of pons, facere which literally translates to a bridge, to create one. Your task will be, given a list of 1 or more lower-case words l (String Array), output the MAXIMUM length of a bridge that can be built from these words.

# Bridge Rules

• Bridges can be made by connecting two or more words together:
• Words must be connected prefix-to-suffix or suffix-to-prefix.
• To join two words into one:
• The suffix of the first must match the prefix of the second (abc+cba=abcba).
• The prefix of the first must match the suffix of the second (earl+toe=toearl).
• If a word's prefix/suffix contains more than one common character:
• You can only connect them with the maximal common substring.
• In other words,abc and bcdefg can be connected using a[bc]defg.
• The length of a bridge is simply the length of the conjoined words in characters.

# Building Material Rules

• The list will contain at fewest 1 word.
• The list may hold 0 links between words, in this case the maximal size is the longest word in the list.
• The list will not contain the empty string and will only use the lowercase alphabet (a-z).
• The list MAY NOT contain duplicates.

# Examples

Example 1:

[abcdefgh,holographic,graphical,quine,loitering]

abcdefholo[graphic]al = 19

19


Example 2:

[noon,moon,loon,noon,groom]

groo[m]oon

8


Example 3:

[spoon,whatifgodwereoneofus,oneofusisatraitor,aaaaaaaaaaaaaa,aaaaaaaaaa]

whatifgodwere[oneofus]isatraitor (because the two aaaaa's overlap too much).

30


Example 4:

[abc,def,ghi,jkl,mnop,qrst,uvwxyz]

uvwxyz (No matches)

6


Example 5:

[xox,xxox,lol,lolol,lololol,xoxx]

xo[xx]o[x]ox    < 8  (Maximal of the xox path)
[lol]o[l]ololol < 10 (Maximal of the lol path)

10


Example 6 (Base):

[hi]

hi

2


Example 7:

# Note, when a link has been used it cannot be used twice.
# In other words, the brackets used cannot overlap in these examples.
[aa,aaa,aaaa]

aa[aa][a]a (Chose to use aaaa,aaa,aa)

7


# General Rules

• 1. This is extremely close to codegolf.stackexchange.com/q/132561/194 . 2. Examples 5 and 7 look wrong. – Peter Taylor Sep 12 '17 at 8:52
• In example 1, isn't it abcdefgholographicaloitering = 28? – KSmarts Sep 18 '17 at 14:22

# Validating Words in Word Grids

A follow on from Generating Word Grids

Given a grid of letters and a set of co-ordinates, validate that the co-ordinates follow only cardinal direction changes, at least one of the co-ordinates touch an empty space in the centre of the grid, the resulting word is valid given the dictionary (taking into consideration any blank tiles) and return either the grid, with the letters at the co-ordinate removed along with the score of the word, or, if one of the conditions fails, the original grid and a score of -1.

## Details

Please use the dictionary provided which is a /usr/bin/dict clone with all words converted to lowercase, non-alphabetic characters removed, and then de-duplicated.

0,0 will be the uppermost, leftmost character on the grid, working right and down.

## Scoring

Letters are worth their values as per Scrabble:

0 points: blank tiles
1 point: E, A, I, O, N, R, T, L, S, U
2 points: D, G
3 points: B, C, M, P
4 points: F, H, V, W, Y
5 points: K
8 points: J, X
10 points: Q, Z


Bonus tiles (indicated by a lowercase letter, or ! for a blank tile) provide a *2 multiplier and stack (eg. if my co-ordinates spell gOLf I would earn (((2+1+1+4)*2)*2), 32 points).

### Examples:

Input:

6,4 6,5 5,5 4,5 3,5 3,6 2,6 1,6
UWDESTKP?
TERMDYTSR
ROANJLEFT
EkCI OOsT
IPAJPGMNY
MZLORITVI
GwEGgPUeI
MNROYOEER


Output:

9
UWDESTKP?
TERMDY SR
ROANJ  FT
EkCI  OsT
IPAJP MNY
MZLO  TVI
GwEGgPUeI
MNROYOEER


(spells RIGOLETE, (1+1+2+1+1+1+1))

Input:

0,3 0,4 0,5 0,6
UWDESTKP?
TERMDY SR
ROANJ  FT
EkCI  OsT
IP  P MNY
MZL   TVI
GwE gPUeI
MNROYOEER


Output:

-1
UWDESTKP?
TERMDY SR
ROANJ  FT
EkCI  OsT
IP  P MNY
MZL   TVI
GwE gPUeI
MNROYOEER


(spells DEST which doesn't appear in the dictionary)

Input:

5,6 4,6 4,7 4,8
UWDESTKP?
TERMDY SR
ROANJ  FT
EkCI  OsT
IP  P MNY
MZL   TVI
GwE gPUeI
MNROYOEER


Output:

12
UWDESTKP?
TERMDY SR
ROANJ  FT
EkCI
IP  P  NY
MZL   TVI
GwE gPUeI
MNROYOEER


(spells MOsT, (3+1+1+1)*2)

## Rules

This is so the shortest code in bytes wins.

• The order is not important, it can be score then grid, or vice versa.
• Any reasonable format can be used for I/O assuming it is consistent.
• All standard loopholes are forbidden.
• This looks pretty good to me. – Rɪᴋᴇʀ Sep 15 '17 at 18:20
• Thanks @Pavel, I'll bear that in mind, i'm not sure how much interest there is based off of part 1, but I might still post this in the next week or so :) – Dom Hastings Sep 16 '17 at 9:21

# Word Grid Pathfinding

A follow up to Generating Word Grids and Validating Words in Word Grids.

## Meta

My original idea for this was to have entries compete, but I'd like to have different winning conditions. Given grid x, pit all scripts against each other for the following win criteria:

• Highest Score
• Shortest Path
• Fewest remaining tiles
• Longest Words

but I think perhaps just making it code golf and offering a bounty to each of the criteria above after some time. I'd like some feedback on this. I like @LegionMammal978's idea, but feel like perhaps that could be a separate challenge (again, only if these are interesting to anyone!)

Given a grid of letters, complete a path of words that reaches from the centre of the board, to the edges. You must return lists of your moves as co-ordinates and your score will be tallied. As soon as there is a clear path from the centre to the edge, the game is over, and no further words will be scored.

## Details

Grids will always have an equal, odd, number of rows and columns, such that no direction contains fewer tiles.

## Restrictions

In the event that the grid is unsolvable (or becomes unasolvable because of your chosen path, you may return something falsy instead of a list of co-ordinates.

Your script must be able to handle grids of varying sizes and solve them in a reasonable time, such that a service like TIO can be used, without causing problems in most cases, for extremely large inputs (> 500). You are free to take input in any reasonable format, but please include a link to your script with a wrapper such that it can take input in via STDIN/script arguments via an online service.

#TODO: copy details of the adjacency rules from above.

For example, in the grid provided below, the J, I, P or O letters (north, east, south and west of the blank square) must be included, once this word has been removed, you have more available words.

There are bonus letters that provide a double point score, denoted by a lowercase letter or ! (instead of ? for a blank tile). Blank tiles are used exactly as they are in Scrabble and can count as any letter, the validating program will search for words replacing the ? (or !) with a wildcard. Letters are scored as per Scrabble:

0 points: blank tiles
1 point: E, A, I, O, N, R, T, L, S, U
2 points: D, G
3 points: B, C, M, P
4 points: F, H, V, W, Y
5 points: K
8 points: J, X
10 points: Q, Z


Your score will be calculated by the validator.

## Examples

Input:

UWDESTKP?
TERMDYTSR
ROANJLEFT
EkCI OOsT
IPAJPGMNY
MZLORITVI
GwEGgPUeI
MNROYOEER


Output:

6,4 6,5 5,5 4,5 3,5 3,6 2,6 1,6
5,6 4,6 4,7 4,8


Total moves: 2
Points: 21

#TODO: more examples.

# Proper Kerning

Kerning is the adjustment of spacing between pairs of letters in order to obtain an aesthetic result. When kerning is applied automatically by a program (typically whatever editor you're using), it is said to be automatic. There are two types of automatic kerning. The one used in this challenge is metric kerning. With metric kerning, the amount of space between pairs of letters is dictated by the kerning tables found in the font file.

Given a TrueType font file, output the kerning values for each mapping in the kerning table for ASCII characters 48 - 122 inclusive.

## Example

calibri.ttf

l="A" r="C" v="-15"
l="A" r="G" v="-15"
l="A" r="J" v="23"
l="A" r="O" v="-23"
l="A" r="Q" v="-23"
l="A" r="T" v="-160"
l="A" r="U" v="-32"
l="A" r="V" v="-89"
l="A" r="W" v="-80"
l="A" r="Y" v="-150"
l="A" r="t" v="-52"
l="A" r="v" v="-38"
l="A" r="y" v="-41"
l="A" r="?" v="-68"
l="B" r="A" v="-20"
l="B" r="T" v="-48"
l="B" r="V" v="-25"
l="B" r="W" v="-24"
l="B" r="X" v="-44"
l="B" r="Y" v="-57"
l="B" r="Z" v="-20"
l="B" r="f" v="-20"
l="B" r="t" v="-20"
l="B" r="v" v="-20"
l="B" r="x" v="-15"
l="B" r="y" v="-20"
l="C" r="G" v="-18"
l="C" r="J" v="12"
l="C" r="O" v="-18"
l="C" r="Q" v="-18"
l="C" r="T" v="10"
l="D" r="A" v="-30"
l="D" r="J" v="-22"
l="D" r="T" v="-23"
l="D" r="V" v="-24"
l="D" r="W" v="-14"
l="D" r="X" v="-31"
l="D" r="Y" v="-39"
l="D" r="Z" v="-22"
l="E" r="A" v="-22"
l="E" r="C" v="-24"
l="E" r="G" v="-24"
l="E" r="O" v="-32"
l="E" r="Q" v="-32"
l="E" r="S" v="-20"
l="E" r="Z" v="-10"
l="E" r="a" v="-34"
l="E" r="c" v="-28"
l="E" r="d" v="-30"
l="E" r="e" v="-37"
l="E" r="f" v="-64"
l="E" r="o" v="-37"
l="E" r="q" v="-30"
l="E" r="t" v="-24"
l="E" r="v" v="-48"
l="E" r="w" v="-34"
l="E" r="y" v="-48"
l="F" r="A" v="-115"
l="F" r="C" v="-18"
l="F" r="G" v="-18"
l="F" r="J" v="-109"
l="F" r="O" v="-18"
l="F" r="Q" v="-18"
l="F" r="S" v="-29"
l="F" r="X" v="-22"
l="F" r="Z" v="-11"
l="F" r="a" v="-55"
l="F" r="c" v="-28"
l="F" r="d" v="-20"
l="F" r="e" v="-30"
l="F" r="o" v="-28"
l="F" r="q" v="-20"
l="F" r="s" v="-35"
l="G" r="T" v="-10"
l="G" r="V" v="-10"
l="G" r="W" v="-9"
l="G" r="Y" v="-30"
l="G" r="v" v="-29"
l="G" r="w" v="-22"
l="G" r="x" v="-14"
l="G" r="y" v="-30"
l="J" r="A" v="-35"
l="J" r="X" v="-20"
l="K" r="C" v="-78"
l="K" r="G" v="-80"
l="K" r="O" v="-97"
l="K" r="Q" v="-97"
l="K" r="S" v="-18"
l="K" r="U" v="-29"
l="K" r="W" v="-34"
l="K" r="a" v="-34"
l="K" r="c" v="-40"
l="K" r="d" v="-33"
l="K" r="e" v="-37"
l="K" r="f" v="-25"
l="K" r="m" v="-32"
l="K" r="n" v="-32"
l="K" r="o" v="-37"
l="K" r="p" v="-32"
l="K" r="q" v="-33"
l="K" r="r" v="-32"
l="K" r="s" v="-18"
l="K" r="t" v="-38"
l="K" r="u" v="-32"
l="K" r="v" v="-101"
l="K" r="w" v="-95"
l="K" r="y" v="-85"
l="L" r="C" v="-22"
l="L" r="G" v="-47"
l="L" r="J" v="25"
l="L" r="O" v="-45"
l="L" r="Q" v="-45"
l="L" r="T" v="-150"
l="L" r="U" v="-44"
l="L" r="V" v="-147"
l="L" r="W" v="-118"
l="L" r="Y" v="-167"
l="L" r="f" v="-23"
l="L" r="t" v="-38"
l="L" r="v" v="-78"
l="L" r="w" v="-72"
l="L" r="y" v="-79"
l="O" r="A" v="-23"
l="O" r="J" v="-27"
l="O" r="T" v="-55"
l="O" r="V" v="-25"
l="O" r="W" v="-22"
l="O" r="X" v="-64"
l="O" r="Y" v="-55"
l="O" r="Z" v="-38"
l="O" r="x" v="-12"
l="O" r="z" v="-10"
l="P" r="A" v="-151"
l="P" r="J" v="-140"
l="P" r="T" v="-9"
l="P" r="V" v="-10"
l="P" r="X" v="-35"
l="P" r="Y" v="-11"
l="P" r="Z" v="-29"
l="P" r="a" v="-44"
l="P" r="c" v="-43"
l="P" r="d" v="-34"
l="P" r="e" v="-41"
l="P" r="f" v="12"
l="P" r="o" v="-41"
l="P" r="q" v="-34"
l="P" r="s" v="-32"
l="P" r="t" v="12"
l="P" r="y" v="12"
l="Q" r="J" v="41"
l="Q" r="T" v="-47"
l="Q" r="V" v="-25"
l="Q" r="W" v="-12"
l="Q" r="X" v="12"
l="Q" r="Y" v="-46"
l="Q" r="g" v="59"
l="Q" r="j" v="79"
l="Q" r="x" v="31"
l="Q" r=";" v="60"
l="Q" r="]" v="32"
l="R" r="C" v="-18"
l="R" r="G" v="-19"
l="R" r="O" v="-20"
l="R" r="Q" v="-20"
l="R" r="S" v="-27"
l="R" r="T" v="-20"
l="R" r="V" v="-28"
l="R" r="W" v="-18"
l="R" r="Y" v="-30"
l="R" r="e" v="-36"
l="R" r="o" v="-42"
l="R" r="v" v="-26"
l="R" r="w" v="-33"
l="R" r="y" v="-33"
l="S" r="A" v="-15"
l="S" r="J" v="-9"
l="S" r="T" v="-14"
l="S" r="V" v="-14"
l="S" r="W" v="-15"
l="S" r="X" v="-13"
l="S" r="Y" v="-20"
l="S" r="v" v="-23"
l="S" r="w" v="-17"
l="S" r="y" v="-25"
l="T" r="A" v="-160"
l="T" r="C" v="-42"
l="T" r="G" v="-59"
l="T" r="J" v="-65"
l="T" r="O" v="-58"
l="T" r="Q" v="-58"
l="T" r="S" v="-10"
l="T" r="T" v="28"
l="T" r="a" v="-160"
l="T" r="c" v="-177"
l="T" r="d" v="-147"
l="T" r="e" v="-182"
l="T" r="g" v="-151"
l="T" r="m" v="-127"
l="T" r="n" v="-127"
l="T" r="o" v="-182"
l="T" r="p" v="-127"
l="T" r="q" v="-147"
l="T" r="r" v="-127"
l="T" r="s" v="-153"
l="T" r="u" v="-127"
l="T" r="v" v="-92"
l="T" r="w" v="-86"
l="T" r="x" v="-90"
l="T" r="y" v="-93"
l="T" r="z" v="-142"
l="T" r=";" v="-114"
l="T" r=":" v="-134"
l="U" r="A" v="-45"
l="U" r="J" v="-40"
l="V" r="A" v="-96"
l="V" r="C" v="-18"
l="V" r="G" v="-25"
l="V" r="J" v="-80"
l="V" r="O" v="-27"
l="V" r="Q" v="-27"
l="V" r="S" v="-12"
l="V" r="V" v="9"
l="V" r="a" v="-114"
l="V" r="c" v="-103"
l="V" r="d" v="-87"
l="V" r="e" v="-102"
l="V" r="g" v="-100"
l="V" r="m" v="-50"
l="V" r="n" v="-50"
l="V" r="o" v="-86"
l="V" r="p" v="-50"
l="V" r="q" v="-87"
l="V" r="r" v="-50"
l="V" r="s" v="-90"
l="V" r="u" v="-50"
l="V" r="y" v="-35"
l="V" r="z" v="-82"
l="V" r=";" v="-108"
l="V" r=":" v="-73"
l="W" r="A" v="-93"
l="W" r="C" v="-22"
l="W" r="G" v="-22"
l="W" r="J" v="-88"
l="W" r="O" v="-22"
l="W" r="Q" v="-22"
l="W" r="S" v="-10"
l="W" r="X" v="-13"
l="W" r="a" v="-71"
l="W" r="c" v="-78"
l="W" r="d" v="-72"
l="W" r="e" v="-75"
l="W" r="g" v="-54"
l="W" r="m" v="-60"
l="W" r="n" v="-60"
l="W" r="o" v="-86"
l="W" r="p" v="-60"
l="W" r="q" v="-72"
l="W" r="r" v="-60"
l="W" r="s" v="-73"
l="W" r="u" v="-60"
l="W" r="v" v="-34"
l="W" r="y" v="-53"
l="W" r=";" v="-156"
l="X" r="C" v="-57"
l="X" r="G" v="-65"
l="X" r="O" v="-57"
l="X" r="Q" v="-57"
l="X" r="S" v="-20"
l="X" r="d" v="-44"
l="X" r="e" v="-39"
l="X" r="g" v="-9"
l="X" r="o" v="-38"
l="X" r="q" v="-44"
l="X" r="t" v="-31"
l="X" r="u" v="-38"
l="X" r="v" v="-55"
l="X" r="w" v="-49"
l="X" r="y" v="-43"
l="Y" r="A" v="-152"
l="Y" r="C" v="-67"
l="Y" r="G" v="-67"
l="Y" r="J" v="-112"
l="Y" r="O" v="-66"
l="Y" r="Q" v="-66"
l="Y" r="S" v="-17"
l="Y" r="Z" v="-10"
l="Y" r="a" v="-134"
l="Y" r="c" v="-159"
l="Y" r="d" v="-131"
l="Y" r="e" v="-147"
l="Y" r="f" v="-62"
l="Y" r="g" v="-142"
l="Y" r="i" v="-32"
l="Y" r="j" v="-49"
l="Y" r="m" v="-94"
l="Y" r="n" v="-94"
l="Y" r="o" v="-153"
l="Y" r="p" v="-94"
l="Y" r="q" v="-131"
l="Y" r="r" v="-94"
l="Y" r="s" v="-115"
l="Y" r="t" v="-44"
l="Y" r="u" v="-94"
l="Y" r="v" v="-69"
l="Y" r="w" v="-62"
l="Y" r="x" v="-70"
l="Y" r="y" v="-65"
l="Y" r="z" v="-100"
l="Y" r=";" v="-138"
l="Y" r=":" v="-154"
l="Z" r="A" v="-11"
l="Z" r="C" v="-25"
l="Z" r="G" v="-24"
l="Z" r="O" v="-24"
l="Z" r="Q" v="-24"
l="Z" r="W" v="-7"
l="Z" r="Y" v="-7"
l="Z" r="a" v="-10"
l="Z" r="c" v="-12"
l="Z" r="d" v="-18"
l="Z" r="e" v="-31"
l="Z" r="o" v="-29"
l="Z" r="q" v="-18"
l="Z" r="v" v="-45"
l="Z" r="w" v="-38"
l="Z" r="y" v="-37"
l="a" r="f" v="-12"
l="a" r="t" v="-19"
l="a" r="v" v="-34"
l="a" r="w" v="-14"
l="a" r="x" v="-19"
l="a" r="y" v="-38"
l="b" r="f" v="-17"
l="b" r="s" v="-10"
l="b" r="t" v="-9"
l="b" r="v" v="-10"
l="b" r="w" v="-10"
l="b" r="x" v="-41"
l="b" r="y" v="-10"
l="b" r="z" v="-28"
l="c" r="a" v="-17"
l="c" r="o" v="-17"
l="e" r="f" v="-18"
l="e" r="t" v="-11"
l="e" r="v" v="-10"
l="e" r="w" v="-10"
l="e" r="x" v="-31"
l="e" r="y" v="-13"
l="e" r="z" v="-20"
l="f" r="a" v="-40"
l="f" r="c" v="-45"
l="f" r="d" v="-53"
l="f" r="e" v="-51"
l="f" r="f" v="-20"
l="f" r="g" v="-60"
l="f" r="o" v="-43"
l="f" r="q" v="-53"
l="f" r="s" v="-27"
l="f" r="v" v="13"
l="f" r="w" v="6"
l="f" r="y" v="10"
l="f" r="z" v="-20"
l="g" r="a" v="-38"
l="g" r="c" v="-12"
l="g" r="d" v="-19"
l="g" r="e" v="-17"
l="g" r="g" v="19"
l="g" r="o" v="-14"
l="g" r="q" v="-19"
l="g" r="t" v="-31"
l="h" r="f" v="-12"
l="h" r="t" v="-19"
l="h" r="v" v="-34"
l="h" r="w" v="-14"
l="h" r="x" v="-19"
l="h" r="y" v="-38"
l="k" r="a" v="-35"
l="k" r="c" v="-48"
l="k" r="d" v="-56"
l="k" r="e" v="-66"
l="k" r="o" v="-69"
l="k" r="q" v="-56"
l="k" r="s" v="-19"
l="k" r="t" v="-10"
l="k" r="u" v="-26"
l="m" r="f" v="-12"
l="m" r="t" v="-19"
l="m" r="v" v="-34"
l="m" r="w" v="-14"
l="m" r="x" v="-19"
l="m" r="y" v="-38"
l="n" r="f" v="-12"
l="n" r="t" v="-19"
l="n" r="v" v="-34"
l="n" r="w" v="-14"
l="n" r="x" v="-19"
l="n" r="y" v="-38"
l="o" r="v" v="-9"
l="o" r="w" v="-8"
l="o" r="x" v="-40"
l="o" r="y" v="-11"
l="o" r="z" v="-27"
l="p" r="f" v="-17"
l="p" r="s" v="-10"
l="p" r="t" v="-9"
l="p" r="v" v="-10"
l="p" r="w" v="-10"
l="p" r="x" v="-41"
l="p" r="y" v="-10"
l="p" r="z" v="-28"
l="q" r="g" v="10"
l="r" r="a" v="-42"
l="r" r="c" v="-30"
l="r" r="d" v="-28"
l="r" r="e" v="-27"
l="r" r="g" v="-28"
l="r" r="o" v="-33"
l="r" r="q" v="-28"
l="r" r="s" v="-35"
l="r" r="v" v="19"
l="r" r="w" v="11"
l="r" r="y" v="10"
l="s" r="f" v="-19"
l="s" r="t" v="-23"
l="s" r="v" v="-31"
l="s" r="w" v="-10"
l="s" r="x" v="-22"
l="s" r="y" v="-37"
l="s" r="z" v="-18"
l="t" r="a" v="-25"
l="t" r="c" v="-25"
l="t" r="d" v="-23"
l="t" r="e" v="-22"
l="t" r="o" v="-20"
l="t" r="q" v="-23"
l="t" r="t" v="-29"
l="v" r="a" v="-30"
l="v" r="c" v="-25"
l="v" r="d" v="-20"
l="v" r="e" v="-20"
l="v" r="f" v="11"
l="v" r="g" v="-28"
l="v" r="o" v="-19"
l="v" r="q" v="-20"
l="v" r="s" v="-9"
l="v" r="t" v="10"
l="v" r="v" v="12"
l="v" r="w" v="12"
l="v" r="y" v="12"
l="v" r="z" v="-26"
l="w" r="a" v="-23"
l="w" r="c" v="-20"
l="w" r="d" v="-18"
l="w" r="e" v="-18"
l="w" r="f" v="6"
l="w" r="g" v="-18"
l="w" r="o" v="-19"
l="w" r="q" v="-18"
l="w" r="s" v="-18"
l="w" r="t" v="4"
l="w" r="v" v="12"
l="w" r="w" v="8"
l="w" r="y" v="12"
l="w" r="z" v="-17"
l="x" r="a" v="-37"
l="x" r="c" v="-46"
l="x" r="d" v="-44"
l="x" r="e" v="-54"
l="x" r="o" v="-55"
l="x" r="q" v="-44"
l="x" r="s" v="-12"
l="x" r="t" v="6"
l="x" r="u" v="-20"
l="y" r="a" v="-31"
l="y" r="c" v="-26"
l="y" r="d" v="-24"
l="y" r="e" v="-25"
l="y" r="f" v="10"
l="y" r="g" v="-26"
l="y" r="o" v="-24"
l="y" r="q" v="-24"
l="y" r="s" v="-19"
l="y" r="t" v="10"
l="y" r="v" v="12"
l="y" r="w" v="8"
l="y" r="y" v="10"
l="y" r="z" v="-17"
l="z" r="a" v="-34"
l="z" r="c" v="-45"
l="z" r="d" v="-46"
l="z" r="e" v="-46"
l="z" r="f" v="-10"
l="z" r="g" v="-17"
l="z" r="o" v="-45"
l="z" r="q" v="-46"
l="z" r="s" v="-22"
l="z" r="u" v="-10"
l="z" r="v" v="-18"
l="z" r="w" v="-22"
l="z" r="y" v="-18"


## Scoring

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

### Meta

I know this challenge is going to need a lot of work before it's ready for main. Please hold criticisms for now. Helpful ideas and thoughts are welcome.

• I'm not sure that the problem is well defined. There's a reason it's called font hinting: the rendering application is free to take it into account or not, or even to apply more complex logic. E.g. some fonts have multiple sets of font hints for different contexts. There are other complex issues. A font can have Latin and Cyrillic letters and define hints for kerning between pairs of Latin and pairs of Cyrillic but not between Latin and Cyrillic; however, some letters may have identical glyphs, so a judgement on whether the kerning is "correct" might be ambiguous. Then there's antialiasing. – Peter Taylor May 24 '17 at 6:15
• @PeterTaylor Good notes. I will likely restrict the character set. I just wanted to start getting ideas down in the sandbox. – Poke May 24 '17 at 6:51
• Very ambiguous. – dkudriavtsev May 25 '17 at 17:48
• @Mendeleev It's not done yet. I'm aware it's ambiguous. – Poke May 26 '17 at 16:10
• Looking at developer.apple.com/fonts/TrueType-Reference-Manual/RM06/… I can see a number of issues to address. 16- vs 32-bit entries? Should multiple tables be combined or printed separately? All tables or only tables with certain coverage values? Which of the four defined formats need to be supported? Do you have a test case which covers glyph index differing from codepoint? – Peter Taylor Sep 16 '17 at 17:28
• @PeterTaylor I have a proof of concept that I wrote (it's the reason I have taken so long to update this) and I'm planning to address all of your questions. Thanks for doing a bit of research to help me out, though :] – Poke Sep 16 '17 at 18:57
• Downvoter, why? – Poke Oct 4 '17 at 21:03

# Shift-left golfer

Sometimes when doing code-golf, a person needs to understand which format is shorter:

• 2147483648
• 0x80000000
• 1<<31

You will receive a number in one of the three formats above: decimal, hexadecimal, or shift-left operation. If there is no advantage in converting it to another format, just leave the number the way it is; otherwise I want the shortest format. Of course there are numbers you can't convert to shift-left format!

# Notation:

• Hexadecimal0x#######.... where there are no leading zeros after the x. When accounting for evaluating the golfiness, the 0x part is also taken into consideration. For example 0x80000000 has a length of 10.

• Decimal#######.... where there are no leading zeros.

• Shift-left#...<<#.... no leading zeros both sides of <<. The << operator is also considered for length, e.g 1<<31 has a length of 5. You must also handle multiple digits before the << signal.

# represents a digit and ... represent possible repetition of digits

I don't care if you handle leading zeros at the input or not; but if you handle them, you must do the comparison operations without them and output also without them — You're a golfer, come on! You will understand!

There will be no accepted answer.

, so I want to know shortest answer by language.

# UPDATE 1:

In spite of @dzaima 's comment, now it also needs to handle multiple digits before << signal.

• How about just take an integer as input and return the shortest form as output? – HyperNeutrino Sep 15 '17 at 19:20
• 1<<31 has a length of 4 not 5? – Rɪᴋᴇʀ Sep 15 '17 at 22:38
• @Riker: Sorry, my mistake. Now fixed. – sergiol Sep 15 '17 at 22:59
• @dzaima: Updated. Yes, it will need to handle multiple digits before << – sergiol Sep 16 '17 at 11:07
• If you allow non-ones in front of the byte shift as input, but not as output, an input like 99<<99 would result in the output having more bytes than the input. – Jonathan Frech Sep 18 '17 at 5:23
• What about something like 0x45<<0x378? i.e., why not hex numbers in left-shifts? – wastl Jul 7 '18 at 20:38

# Translate Tetris moves to GoL!

Unless you've been living under a rock, you're probably aware of the fact that the highest voted unanswered, incredibly hard challenge to build a working game of Tetris in Conway's Game of Life just recently got answered. (Go check it out if you haven't already.)

Unfortunately, since this game is written in Conway's Game of Life, giving input to the code is a bit tricky. (Of course, if they can simulate Tetris in GoL, you can play it with tricky moves. :P) To quote the main answer:

Each move only requires editing a single bit of RAM, and this input register is automatically cleared after the input event has been read.

Each Tetris move corresponds to a single number by the following table:

value     motion

1         counterclockwise rotation
2         left
4         down (soft drop)
8         right
16        clockwise rotation


Now, of course, if there was only a way to automate this...

## Challenge

Write a program/function that takes a series of keypresses as input and outputs each keypress' respective number according to the table above.

The keypresses should map as the following:

value            motion

<                counterclockwise rotation
<left arrow>     left
<down arrow>     down (soft drop)
<right arrow>    right
>                clockwise rotation


### Specifications

• Standard I/O rules apply.
• Standard loopholes are forbidden.
• This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
• Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
• Built-in functions that perform this task are allowed but including a solution that doesn't rely on a built-in is encouraged. (Pshh, how likely is that?)
• Explanations, even for "practical" languages, are encouraged.

### Test cases

// incoming


# Sandbox

• Should I switch from keypresses to strings of ( < v > )?
• I'm really lacking on tags...
• Bump!
• Not all languages can support keypresses, so using a string would be better. – fireflame241 Sep 23 '17 at 18:20
• Also, if you go for keypresses: What happens if I hold a key for 10s? What happens if I hold a key and simultaneously press another one? – ბიმო Sep 25 '17 at 11:04

# Two-Symbol n-state Universal Turing Machine

A program is defined as a set of transition rules from one state to another based on the current state and symbol, optionally moving the tape head left or right.

The goal is to produce a program that satisfies all of the following criteria:

• It is a two-symbol Turing Machine program.
• It emulates a two-symbol Turing Machine program that is represented on the tape.
• where all tape that is not data is initialised to one symbol (designated 0 - the other is 1).

There are two scoring criteria:

1. The number of states. Smaller is better.
2. The compressibility of the program format (see below).

There is an individual scoring for each criterion and a combined position. The combined position is the sum of the ordinal positions in the leaderboard for each criterion (e.g. if your solution is 1st for number of states but 4th for compressibility it has a combined position of 5th). In the likely event of a tie, the compressibility of the program format is the tie-breaker.

## Compressibility of the Program Format

The compressibility of the program format is defined as the number of (additional) states required to write the program onto a blank (0) tape, move the head to the start position of the program and start running the emulator on the program (change state to a correct emulator state). Sandbox note: Hand-compressed test-cases? Average-case Big O?

• Todo: Work in a reference to this article and how a good solution to this challenge will reduce the upper bound for the maximum computable value of the Busy Beaver function. – wizzwizz4 Sep 22 '17 at 20:49
• Is there a way to tell the Kolmogorov complexity when compressed through a certain method? It seems like the compressibility of the input format is poorly defined and will vary between inputs. – wizzwizz4 Sep 22 '17 at 20:54
• I'm not quite seeing the busy beaver connection. Clearly it's not about emulating a single program, because in general the program itself would have fewer states than the program which puts it onto the tape and then runs the emulator; so it must be about some kind of loop over all programs, but then you run into undecidability of the termination of the emulator programs, meaning that the emulator certainly doesn't terminate. – Peter Taylor Sep 23 '17 at 20:25

Six Flags over HTTP

Let's say you need to transmit six boolean flags in a URL string. Obviously you could do it with six ones or zeroes, but you want better compression. With a little math you can pack them into two characters using 0-7 octal.

How about mapping all six to a single ASCII character? Here we have a problem: you are not allowed to use , / ? : @ & = + $# or space. Now the range of printable ASCII no longer has 64 valid characters in a row. In Javascript (or another language that can run from a web page, if any), what is the shortest code for a pair of functions to encode and decode this data, between an array of six booleans and a single character? • -1 language restriction, most languages have HTTP libraries so I think any language should be allowed – ASCII-only Sep 24 '17 at 13:11 • This challenge could be improved by rephrasing it to: "Write a bijective function between an array of six booleans and a single printable character excluding the characters ,/?:@&=+$# ". Mentioning that the encoder and decoder should be separate programs/functions would be helpful. Also, may the encoder and decoder share code? – fireflame241 Sep 24 '17 at 22:08

# It’s raining numbers! Better to get a good umbrella!

Your task is to take in one integer input and print a “raining” alternating pattern with that number, and an umbrella of appropriate size to protect yourself from such a rain!

# Examples

1 =>

1
_|_
/   \
-----
|
C

2 =>

2
2
___|___
/       \
---------
|
|
C

3 =>

3       3
3
3       3
_____|_____
/           \
-------------
|
|
|
C

4 =>

4       4
4       4
4       4
4       4
_______|_______
/               \
-----------------
|
|
|
|
C

10 =>

1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
1       1       1       1       1
0       0       0       0       0
___________________|___________________
/                                       \
-----------------------------------------
|
|
|
|
|
|
|
|
|
|
C


# Rules

• The output should use only the ascii characters _ | - / \ C, space, and the digits (no tabs are allowed).
• Numbers should have an alternating pattern, two digits on the same line are separated by 7 spaces.
• Number with more than one digit must be written vertically.
• The size of the first line of the top of the umbrella should be equal to 4n-1, for input n, centered below the “rain”; the size of the second line should be equal to 4n+1.
• The shank of the umbrella under the top is centered and should be of height n (the | characters), and terminated by a C handle.
• Lines can have trailing spaces.

This is a task, so the shortest solution is any language wins.

• shortest solution in any – Adám Sep 27 '17 at 7:36
• I think that you should explicitly state the input for each example output. – H.PWiz Sep 27 '17 at 9:21
• Allowed whitespace should be mentioned in the first rule. Regular spaces seem obvious, but using tab characters in place of 4 spaces could be used and it's a good idea to explicitly allow or forbid it. Also, that rule should start with "The output should..." to clarify that this is not restricted-source – Kamil Drakari Sep 27 '17 at 14:46

# Count letter frequency

Inspired by question Tweetable hash function challenge, you should take the English dictionary used there and produce a program or function that outputs the the absolute and relative frequency of each character. It is CASE SENSITIVE and the APOSTROPHE is also accountable as a real letter.

Example of a valid output format (but with stupid guessing values):

A      5566    20%
...
Z        60     0.2%
a     27000    30%
...
z       120     0.01%
'       450     3.5%


It is , but no answer will be accepted. Wanna know shortest script for each language.

• -1 (01) Don't rely on another challenge to define yours; include all the information we need in your write-up. (02) Make an effort to come up with some actual test cases - do you honestly expect us to verify our solutions against "stupid guessing values"? – Shaggy Sep 30 '17 at 0:55

# Sort a nested object by nested value

Your goal is to sort a nested object by a nested value. What does that mean? For example:

#1: Input

{
foo: {
category: "A",
hello: "world",
color: "blue"
},
bar: {
category: "B",
cu: "cumber",
color: "blue"
},
baz: {
category: "A",
let: "tuce",
color: "green",
}
}


#1a: Output sorted by category

{
A: {
foo: {
hello: "world",
color: "blue",
},
baz: {
let: "tuce",
color: "green"
}
},
B: {
bar: {
cu: "cumber",
color: "blue"
}
}
}


#1b: Output sorted by color

{
blue: {
foo: {
hello: "world",
category: "A"
},
bar: {
cu: "cumber",
category: "B"
}
},
green: {
baz: {
let: "tuce",
category: "A"
}
}
}


Note that the sorting key is always deleted from the objects (when sorting by color none of the items contain color).

Given an object, and a sorting key (a string), output the sorted object as shown.

## Rules

• You can always assume that the value of the sorting key is a string (as it also needs to be a key in the output)
• You can always assume that the given sorting key exists in all values
• Sorting will only occur on the first-level objects, but the sorting key can be nested (see test case #2)
• The object may be a JSON object, a python dict, a JS object, etc. but must always have string only keys.
• You may accept the object as a JSON string and/or return a JSON string.

## Test Cases

#2: Input

Sort by: rating.healthiness

{
icecream: {
sweet: true,
rating: {
tastiness: "8",
healthiness: "4"
}
},
pizza: {
sweet: false,
rating: {
tastiness: "9",
healthiness: "3"
}
},
chocolatecake: {
sweet: true,
rating: {
tastiness: "8",
healthiness: "3"
}
}
}


#2: Output (sorted by rating.healthiness)

{
"3": {
pizza: {
sweet: false,
rating: {
tastiness: "9"
}
},
chocolatecake: {
sweet: true,
rating: {
tastiness: "8"
}
}

},
"4": {
icecream: {
sweet: true,
rating: {
tastiness: "8"
}
}
},
}


## Sandbox Questions

1. I really need to make the question clearer. Any thoughts? How can I better describe the task?
2. Is this a duplicate?
3. I'm guessing I need a better title. Any ideas?
4. Should I make the input a JSON object or just a general object?
5. Are multi-level nested objects even possible? Would it be too easy without them?
6. Should I also allow booleans & numbers as the value for the sorting key (and then in a key form it would be stringified)?

# Output the Yggdrasil graph

In Norse mythology, Yggdrasil, or the world tree, is a giant tree that spans the entire universe and connects all nine worlds of the Norse mythology together. Here, we shall take a rather liberal reinterpretation of the term "world tree" - it's the tree that contains all other trees as subgraphs. Not only that, but each graph is present everywhere in Yggdrasil. Clearly, the only way to achieve that is if every node in the graph has infinitely many neighbors.

Yggdrasil is the unique (up to isomorphism) non-empty graph with the two properties that each vertex has ℵ₀ neighbors and that there is a unique simple path between any two vertices. In other words, Yggdrasil is the Cayley graph of the free group with countably infinitely many generators. Your goal is to output this graph.

Nodes can be given any printable label of your choice, as long as they are non-empty and unique within the graph. Edges shall be denoted as pairs of vertices in either order. It must be clear from the output which are the two nodes in a graph (a-b-c is not an acceptable representation of an edge from a-b to c, but ["a-b", "c"] is fine). In the output, each edge shall be output on a single line, and different edges shall go on different lines.

The output should be just the list of edges in the graph, one edge per line. Each edge in the graph must be output exactly once, and in a finite amount of time (barring memory limitations). Edges not in the graph must not be output. For example:

• Listing the edges in breath-first order is not sufficient, as any edge disjoint from the root would not get output.
• Listing the edges in depth-first order is not sufficient, as no more than two edges of any node would ever get output.
• It is sufficient (but not necessarily optimal) to generate the output by repeating (for each node in a copy of the list of known nodes, take the first unknown child, output the edge to it and add it to the list of known nodes).

The sufficient example above will output, if nodes are labeled 0, 0 1, 0 2, 0 1 1, ... :

0 => 0 1
0 => 0 2
0 1 => 0 1 1
0 => 0 3
0 1 => 0 1 2
0 2 => 0 2 1
0 1 1 => 0 1 1 1
...

• So basically we have a countably infinite set of vertices V, a countably infinite index set I, and an injection (V x I) -> V. Since any bijection is an injection, we can use minor variants of e.g. codegolf.stackexchange.com/q/8892/194 , codegolf.stackexchange.com/q/78606/194 , codegolf.stackexchange.com/q/48705/194 with a loop for(n=0;;n++) wrapped round to create a valid answer. So although quite well disguised this is actually a dupe. – Peter Taylor Oct 3 '17 at 8:34
• @PeterTaylor not sure how that would work. Are you trying to output the complete infinite graph rather than the infinite order regular tree? – John Dvorak Oct 3 '17 at 9:00
• Use the reverse direction of the bijection: N -> (N x N). Then for(n=0;;n++)print(unpair(n)[0],"=>",n). Every node has an infinite number of successors, but each node has only one predecessor, so it's a tree. For the previous questions which use a bijection N -> (Z x Z) it's ever so slightly more subtle: to enumerate the entire tree we need to add in a bijection N -> Z and write for(n=0;;n++)print(unpair(n)[0],"=>",z(n)), but there are some very simple bijections N -> Z. – Peter Taylor Oct 3 '17 at 9:28

# Is my Sukkah Kosher?

Do not rely on this text for questions of Jewish law!

You will be given a floor plan of a sukkah as follows:

• A rectangular 2D text (in any reasonable format).
• The first and last rows and columns will consist of printable ASCII (32-126).
• All interior characters will be spaces.

Determine if the sukkah is acceptible according to these simplified rules, using the scale of one character width/height representing the tefach unit.

• The inner area, as encompassed by the completion of the two longest solid walls into a square, must be at least 6 units by 6 units.

• If the two longest solid walls are across from each other, then the shorter one must be at least 6 units long, and the length with with they are diametrically across from each other must also be 6 units long.

• There must be an additional wall which is at least one unit long.

• The walls may be made of any material, i.e. any character except space.

• Walls with single unit gaps are still considered solid.

You may answer with any two distinct values, but please specify if different from true/1 and false/0. Explanations are appreciated.

### Acceptable

oOOOo.ooo...o--o
#              @
#              )
#              (
#
|
#
+++++++*******


oOOOo.ooo...o--o

@
@
@

+++++****


o O o o o . o

@

@
@

+++++****


### Not acceptable

oOOOo.ooo...o--o
#              @
#              )
(

|
#
++++      ****


       oOOOo.ooo..

@
@
@

+++++****


o O o o o . o

@

@
@
8
8


## A Conc-urn-ing Problem

You have a mysterious urn, which contains 0 <= n <= 10 sets of k balls. Each set of balls shares a numeric label, from zero to n-1. You perform a repeated experiment, wherein you remove a ball from the urn, and note its number. If the number of balls in the urn with the same label as the ball you removed has the highest or tied for highest frequency still in the urn, you put the ball back in.

Taking the recorded results of each of the trials yields an infinite sequence. For example, you might have for n=2, k=2 pulled: 1001000000...

Given n and k write a program or function that returns a regular expression which will match any valid real number generated by this process, and which fails to match any other real number.

### Sandbox

This is missing quite a bit (haven't written a program yet), but I'm not sure if it is too tedious the way that it currently is. It's somewhat boring if restricted to n=2 but rather quickly becomes tedious after that. Since most of the result would be symmetric, would it make sense to only require the "first" result? This also seems like it removes too much of the interest in the problem.

# Search Stack Overflow for Duplicates

The Stack Overflow search algorithm has been under fire recently. Several problems with the search algorithm being flawed exist, but one of the most important issues raised is with duplicates:

[...] The search engine is used while authoring a question to find potential duplicates. At that point there is no way for you to take advantage of its features through custom search operators, and it absolutely, positively must be as good as an external search engine in this scenario. Unfortunately, it isn't. – IInspectable (source)

A flawed duplicate search algorithm causes a lot more work for the comparatively few reviewers and duplicate closers than there should be, by not informing the question askers that the question that they are attempting to post is a duplicate. It is also bad for the question askers, preventing them from finding the answer to their question until somebody reviews the question.

This is where you come in. Given the title, body and tags of a question, output a list of 25 relevant questions in a reasonable format (e.g. question ids). Your program should run within 500ms on the Stack Exchange servers for each question. (Sandbox note: How fast are the Stack Exchange servers? What conversion factor should I use to test on my hardware?) You have access to all T-SQL database tables available from the Stack Exchange Data Explorer, but the current question that needs to be checked for duplicates will be absent from all tables (so it isn't found as a duplicate of itself). To test the algorithm, it would be tested on a random selection of or all of the existing duplicates on Stack Overflow - the algorithm with the lowest average position of the duplicate master(s) in the list would win, where "not in the list" is counted as 50. The set of existing duplicates tested would be the same for all algorithms to test - rationale includes scoring of questions with multiple duplicate masters. The search algorithm should be deterministic. It is allowed to prepare a cache table beforehand - none of the duplicates to test will be passed to this part of the algorithm. This cache table should be able to be updated with new questions without being completely rebuilt. (Sandbox note: How to score this?)

(Sandbox note: The final paragraph should be spread out and better laid out and reworded, but I think the wall of text contains enough information.)

# Constructively golf true primes!

## Introduction

A recurring pattern that I see in challenge involving primes is the (over-) use of prime-checking built-ins and of factorization built-ins. However, I kinda don't trust especially the latter, which is why today, we're gonna build primes and include a certificate that the result is actually a prime.

## Input

A positive integer n denoting the length of the resultung prime in a basis of your choice.

## Output

A list of primes in the base you picked above, one of these primes is of length n and one of these primes is smaller than 20.

## What to do?

Your challenge is to generate a prime of length n of which the primality can be reduced to the primality of one of the following primes: [2,3,5,7,11,13,17,19]. This can be achieved using Pocklington's criterion. Now the idea is to chain up from any of these primes using said criterion to a prime of appropriate size, while also outputting the intermediate steps so primality can be checked easily.

For your convenience, I shall reproduce the relevant theorem here:

Let N>1 be an integer and suppose there exist a,q such that

• q is prime
• q divides N-1
• q>sqrt(N)-1
• a^(N-1) mod N == 1
• gcd(a^((N-1)/q)-1,N)=1

Then N is prime.

And as you might see, your initial set of primes (as candidates for q) is limited to the above short list of primes smaller than 20.

## Who wins?

This is so the shortest solution in bytes wins!
However this is also so all solutions must run in (expected) polynomial time in n. Standard IO and Loophole rules apply.

## Got any help?

If you need algorithmic help, I suggest you consult the Handbook of Applied Cryptography, chapter 4 (PDF), algorithm 4.62 (on page 153 or 22 in the PDF) or you independently look for Maurer's prime generation algorithm (originally published here).

# I got them Mad Matrix Moves

Given a list of edges representing a simple directed graph and (optionally) the number of vertices n>1, output the adjacency matrix of that graph.

The vertices will always be numbered consecutively starting at 0 (or 1 -- your choice).

The adjacency matrix is defined as the n by n square matrix M such that M[i][j] is 1 if there is an edge from vertex i to vertex j and 0 otherwise.

# Example

For this example and the test cases, we will have the vertices numbered starting at 1.

Let's use the sample input [(1,2),(1,3),(3,2)]. Since there are vertices numbered 1-3, n=3 and our output is a 3 x 3 matrix.

The output should be

[[0, 1, 1],    <= (1,1) doesn't exist in the input list, (1,2) does, (1,3) does.
[0, 0, 0],    <= (2,1) doesn't exist, same with (2,2) and (2,3)
[0, 1, 0]]    <= (3,1) doesn't exist, (3,2) does, and (3,3) doesn't


(concisely represented as [[0,1,1],[0,0,0],[0,1,0]] in test cases).

# Notes

• Every vertex is the start and/or end of at least one edge.
• You may replace 1 and 0 in the output with any two consistent distinct values of your choosing.
• The input graph is simple, meaning that it has no loops nor multiple edges (e.g. no edge [1,1] or graph [[1,2],[1,2]])
• The graph is directed, meaning that each edge has a start and an edge (e.g. the edge [1,2] is distinct from [2,1])
• Every vertex is an endpoint of at least one edge
• This is , so shortest code in byes in each language wins.

# Test Cases

One test case per line. Each test case is in the format edges, n => output.

[(1,2)], 2 => [[0,1],[0,0]]
[(2,1)], 2 => [[0,0],[1,0]]
[(1,2),(2,1)], 2 => [[0,1],[1,0]]
[(1,2),(1,3),(3,2)], 3 => [[0,1,1],[0,0,0],[0,1,0]]
[(1,2),(2,3),(3,4),(4,5)], 5 => [[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,1],[0,0,0,0,0]]
[(1,2),(3,4),(4,3),(2,1),(2,4),(4,2)], 4 => [[0,1,0,0],[1,0,0,1],[0,0,0,1],[0,1,1,0]]
[(1,2),(2,3),(3,4),(4,5),(2,1),(3,2),(4,3),(5,4)], 5 => [[0,1,0,0,0],[1,0,1,0,0],[0,1,0,1,0],[0,0,1,0,1],[0,0,0,1,0]]
[(1,2),(3,1),(2,3),(1,1),(2,1)], 3 => [[1,1,0],[1,0,1],[1,0,0]]
[(1,2),(3,2),(1,3),(5,4),(5,6),(5,1),(2,3),(1,5),(5,2),(3,6),(4,5),(5,3),(2,1),(3,5),(4,6),(6,3),(6,5),(4,2),(3,4)], 6 => [[0,1,1,0,1,0],[1,0,1,0,0,0],[0,1,0,1,1,1],[0,1,0,0,1,1],[1,1,1,1,0,1],[0,0,1,0,1,0]]


# Get the Average Number of Bytes for an Answer

Have you ever wanted to know the average number of bytes all the answers to a given code golf question took? Probably not. But I did!

## Input

You'll have to take in a link to a codegolf exchange question by text or you can run this in a browser extension/user-script. If you have a clever way of identifying the webpage and producing the necessary output, just ask about it in the comments, and I'll update the question as long as it doesn't violate the rules. The input will be a link to a codegolf question. It will include http::// or https:://. The slashes will be facing this way: "/". The link may not be to a code-golf challenge specifically, but it could be something like a code-challenge.

## Output

If the user inputs something that isn't to a code golf website output something along the lines of "Hey! That's not a link to a code-golf challenge" If the user inputs a link that links to the codegolf exchange, but isn't a codegolf (maybe it's a code-challenge) the program should output anything that is not a natural number.

If there are strikethroughs through previous amounts of bytes a solution took, those should not be included in the average. If the person answering the question in one of the links did not conform to formatting standards, the program doesn't have to account for it. Minor differences will be allowed. Specifically, the number of bytes should be within 5 lines of the top of the answer and bolded.

All answers should be rounded to the nearest whole number with .5 rounding up.

## Examples

Input:

https://codegolf.stackexchange.com/questions/54038/average-out-two-lists

Output:

95

## Winning Criterion

The winner will be given by (1 / execution time (s) + bytes).

If you know of anything that I missed, comment below.

• What if I make the output message my entire program and then just exec it? – HyperNeutrino Oct 10 '17 at 23:30
• @HyperNeutrino I'm not really sure what that means. If it takes a link in and outputs the answer then you've completed the challenge. If it outputs the answer and 20 lines of unnecessary information that the user can see, I would say that that doesn't pass the program. – Byte11 Oct 10 '17 at 23:34
• My point is, what if I make a string containing my entire program, use string slicing to output a good falsy message, and then use exec to run the string? Would I be exempted from counting the bytes of my string? – HyperNeutrino Oct 11 '17 at 0:05
• @HyperNeutrino That's a smart way to get around the rules. No, you wouldn't be exempt from the rules, but from a literal interpretation, you could argue that that is allowed. How should most concisely update my rules to prevent this? – Byte11 Oct 11 '17 at 0:08
• I'd just guarantee that the input will follow a specific format, because making the input contain backslashes, missing components, etc. is just a pain and doesn't demonstrate the answerer's ability to actually do what you really want. Essentially, don't add too much fancy stuff – HyperNeutrino Oct 11 '17 at 0:22
• @HyperNeutrino Okay, I've updated the question. – Byte11 Oct 11 '17 at 0:47
• along the lines of  → unclear what you're asking. – user202729 Nov 3 '17 at 13:21
• Also what exactly is the winning criteria? Another point: A link to this site never have https:://, only https://. – user202729 Nov 3 '17 at 13:21

# Optimised Hashing

For a given set of input, output a program that can 'hash' the input with a minimum number of collisions.

## The Challenge

Write a method or function that receives an array of Strings (see input for more detail) and outputs a full program. This program must, for each String in the original input array, print to STDOUT (or equivalent) some positive integer i where i<100 and is unique for that input.

## The Input

Each program will be tested with 4 different input sets of 50 unique Strings;

• 50 English words of the same length.
• 50 English words of differing lengths.
• 50 randomly generated character strings of the same length
• 50 randomly generated character strings of differing lengths

All Strings in all inputs will only contain the character set [a-zA-z] (ASCII values 65-90 and 97-122) and will all be no more than 20 characters long.

## Special Rules

• Standard loopholes are forbidden.
• Inbuilt hashing functions are not allowed.
• You must provide a free and easily accessible environment to compile and run both programs with your answer.
• I reserve the right to discount any program which takes more than 10 minutes to complete any test.

## Scoring

You will be scored by combining the following;

• The byte count of your original program
• The byte count of each outputted program
• 5 penalty points for each 'collision'.

I will keep and update a leader board as programs are added and I can test them.

Please let me know if I've missed anything; this is my first question idea!

# Hunting The Wren

Write a program to produce the words to the folk song Hunting The Wren.

"We're hunting the wren." says Robin to Bobbin.
"We're hunting the wren." says Richard to Robin.
"We're hunting the wren." says Jack of the land.
"We're hunting the wren." says everyone.

"Where oh where?" says Robin to Bobbin.
"Where oh where?" says Richard to Robin.
"Where oh where?" says Jack of the land.
"Where oh where?" says everyone.


The song continues with the same structure.

"In yonder green bush."
"How get him down?"
"With sticks and stones."
"How get him home?"
"The brewer's big cart."
"How will we eat him?"
"With knives and forks."
"Who'll come to the dinner?"
"The King and the Queen."


The song concludes with three more verses, which because they have no repetition, we'll omit for the purposes of this challenge.

Rules

• The program must produce the full words of the song as 54 or 55 lines of text.
• Each verse of four lines must be separated by a blank line. A blank line on the end is optional.
• You must not use a text decompression library. (GZIP the whole song is 380 bytes.)
• Normal code golf rules apply. Shortest code wins.

C# Reference Implementation

public class Program
{
public static void Main()
{
string[] starts = new [] {
"We're hunting the wren.",
"Where oh where?",            "In yonder green bush.",
"How get him down?",          "With sticks and stones.",
"How get him home?",          "The brewer's big cart.",
"How will we eat him?",       "With knives and forks.",
"Who'll come to the dinner?", "The King and the Queen." };

string[] ends = new [] {
"says Robin to Bobbin.",      "says Richard to Robin.",
"says Jack of the land.",     "says everyone."            };

foreach (string start in starts)
{
foreach (string end in ends)
{
System.Console.WriteLine("\"" + start + "\" " + end);
}
System.Console.WriteLine();
}
}
}


# Pokémon Champion

This challenge is about writing the ultimate bot for battling Pokémon. Since knowledge of competitive Pokémon battling is necessary, I'll leave that to the experts at Smogon University.

### Rules

• Your bot must battle another bot in a Gen 7 Random Battle Format.
• Your bot will be judged based on its performance in a round-robin tournament orchestrated by the author of the challenge, against all other submitted bots before a specific deadline.
• In order to avoid reinventing the wheel, there are several frameworks already available to choose from. Unfortunately, a lot of these are written in Node.js, so you might still have some porting to do, unless this challenge decides to create its own framework for battling.
• Since your bot will be connecting to a Showdown server using the existing Web Socket API, any error in your program that causes the bot to become non-responsive or to disconnect will automatically forfeit that match.
• Standard loopholes apply, and do not exploit any possible bugs in the API. If you find a bug, please report it here.

### Further Considerations

While in theory, I think this would be a great idea, I believe this would require a lot of time-investment and groundwork, which frankly I don't have the availability for right now, so anyone is free to take this over, but please be courteous and get my consent in The Nineteenth Byte first. Just @PatrickRoberts and wait for a reply before modifying this proposal.

* Not sure if it's preferable to write an API specifically for this challenge to eliminate the need for Web Socket communication, since there are already available platforms. The idea is to host an official tournament at a certain date (yet undecided) on Pokémon Showdown.

• I could use a new bot on my side server (the one I've got doesn't know about Z-moves so even I can beat it at Ultimate Z...) – Neil Oct 18 '17 at 0:19

# Is it a perfect loop? test-batterydecision-problem

Your task is to take a GIF or an animated image in any reasonable format as input (including taking the file name of a GIF in the current directory), and output whether it is a "perfect loop" - that is, the frames transition seamlessly from the end to the start, and a human cannot notice where it starts and ends at first glance. Return or print a truthy value if it is a perfect loop, otherwise print or return a falsy value.

## Scoring

Winners will be determined from the percentage of test cases they get correct. In the event of a tie, highest votes wins. You can view test cases at https://ghostbin.com/paste/m3yaw. Show your score against the test cases when you post.

## Input

If you are not taking input in a GIF, please provide a program that will convert a GIF to your desired format.

Images corresponding to a truthy value have been taken from /r/perfectloops and for falsy test cases, /r/almostperfectloops and /r/gifs.

## Restrictions

• Hard coding is not allowed (violates standard loophole 1 and 2).
• You must provide consistent results for the same GIF (no randomness)
• Remember, this is not , so byte count is not needed in your solution. Just post the language name and add the percentage correct when I comment.
• I'm not sure it's as simple as comparing the first to the last frame, if it is we'd have duplicate frames. is this challenge allowing HTTP requests? – tuskiomi Oct 17 '17 at 21:15
• If hashing the inputs is not allowed, then you should clearly define what constitutes a “perfect loop”. It's not good to extrapolate from a handful of test cases where the pass/fail cases are very similar. – japh Oct 18 '17 at 14:31

# All the same digits

For any two coprime integers n, b > 1 there exist infinitely many integers k > 0 for which n * k's representation in base b only contains the digit b-1.
This challenge's task is to output the smallest such k for given integers n, b.

### Input

Two integers n, b with the above described properties in any reasonable format (integers, strings, ...). If your language does not support arbitrary precision integers, you can assume that n, b < 2**31.

### Ouput

An integer k with the above described properties in any reasonable format (integer, string, ...). If your language does not support arbitrary precision integers, you can assume that k < 2**31.

### Test cases

f(  n,     b) == k

f(  7,    10) == 142857
f(  13,    5) == 48
f(  14,   13) == 12
f(1728, 1729) == 1
f( 107,   99) == 54863250648363053681585635237627534906401818527472898624219397466199311510764517134614152141940101983414


To generate more test cases, take a look at my reference implementation written in Python 2.

Fraction periods can also be used to calculate k (example given for n, b = 13, 10).

1/13             =      0.076923(076923)* (period length 6)
1/13 *  10**6    = 076923.076923(076923)*
1/13 * (10**6-1) = 076923
999999   = 076923 * 13
k =  76923

• Not true. Consider n=b>1. You need a coprimality condition. – Peter Taylor Oct 17 '17 at 16:03
• @PeterTaylor Thanks for noting. – Jonathan Frech Oct 17 '17 at 17:38

I'm posting this on sandbox first, because this might not be a good challenge for this site, or just too complicated, because it's about constructing a meaningful sentence. Please, tell me, if it's appropriate task for this site.

Also a note: If you want, I can wait for Christmas with this.

# Back to the New Year!

You encounter a probably hard challenge.

Inspired by this answer by @dansalmo.

If we sum character codes in the string Happy new year to you!, we will get 2014. With later years, people started to modify the string, so it fits the current year:

• 2015: A Happy New Year to You!
• 2016: Happy New Year to you!!!

## The challenge

Given an integer year, output a string meaning "Happy new year!". Sum of character codes should be equal to the integer.

Rules:

• No default loop holes allowed
• Output rules:
• Meaning rules:
• You must use the word Happy - you cannot use any other adjective instead.
• You must wish a NEW year, no matter if it's 2010 or 2020!
• You can only wish a happy new year - You can't wish a happy new Easter...
• You can target the string to a person or group, or to everybody: Happy new year!, Happy new year, Soaku!, Happy new year, CodeGolfers!
• You can add new words, but the sentence can't lose the meaning!
• Output must have valid grammar, but you can mess up the punctuation. Just note that you can't use punctuation characters except trailing exclamation marks.
• Letter case rules:
• Letters that aren't first should be lowercase. The only exception is when all letters in the word are uppercase.
• Punctuation rules:
• You are not allowed to use any punctuation characters, except on the end of the string
• There must be exactly one or three exclamation marks ! at the end.
• Spacing rules:
• There must be exactly one space between words.
• No line breaks allowed
• Leading and trailing spaces/newlines are allowed, but they don't count in the character code sum. Word is the same as outputting Word.
• Character rules:
• You cannot use digits!
• You must only use ASCII letters (the only exception are the trailing exclamation marks)
• You can assume the input is an integer between 2000 and 3000

## Test cases

examples, don't need to be the same

2001 - Happy new YEAR to MYSELF!
2002 - A VERY HAPPY NEW YEAR TO PPCG!
2003 - Happy NEW Year TO MYSELF!!!
2004 - A happy new year to me!
2013 - A HAPPY NEW Year To The SE!!!
2014 - Happy new year to you!
2015 - A Happy New Year to You!
2016 - Happy New Year to you!!!
2030 - A Happy New Year To PPCG!!!


• I think meaning "Happy new year!" is too unclear. There is no way to objectively enforce this. – Sriotchilism O'Zaic Oct 23 '17 at 17:38

# Behavior Driven Golfing

### Context

From wikipedia (emphasis mine): Behavior Driven Development (BDD) is largely facilitated through the use of a simple domain-specific language (DSL) using natural language constructs (e.g., English-like sentences) that can express the behavior and the expected outcomes.

Example in normal BDD (also from Wikipedia):

Story: Returns go to stock

As a store owner In order to keep track of stock I want to add items back to stock when they're returned.

### The challenge:

Write a program that reads like a single English-like sentence that executes the meaning of that sentence.

### Other details

• The program must receive input of some kind (stdin, arguments are okay depending on your language's syntax).
• The input can be limited in scope, (e.g. all real numbers, all positive even integers), but there must be infinitely many possible inputs assuming that your language doesn't have a cap.
• For example, if the input is an integer, you don't actually have to handle integers beyond the language's cap, if your language happens to cap at 32 bit long, it just has to be infinitely many in theory but not necessarily in practice.
• The program must have at least log(n) distinct outputs over an input space of size n.
• For example, if there existed a language where convert to zero was a valid program, returning 0 on all inputs would not be okay, but printing a number of 0 equal to the base 10 number of digits of the input number would be okay.
• The program should not error out on legal input.
• Irregular case and unicode characters are allowed
• Unicode characters will be interpreted as the similar character in English (so most commands in 05AB1E are allowed).
• Words may be delimited by punctuation marks instead of spaces, but they must be delimited.
• Punctuation should not be present in the middle of a word unless it's legal in English (such as an apostrophe in a contraction or a possessive)

Example valid answer for all requirements except the "must take input" requirement:

### HQ9+

Print Hello, world.

Since only the H character is an instruction in this language, all the other characters are ignored, and the program prints hello, world. Since case is ignored, this program does what the english sentence says it will do.

• As it's currently written, the task is way too broad. The task that the program should do must be narrowed and clearly specified (e.g., "add the input with itself") in order for this to be well-received. – AdmBorkBork Oct 20 '17 at 20:00
• I like the challenge, but I think it should be popularity-contest rather than code-golf. I just feel like code-golf will attract too many answers similar to the example: pick a language that ignores most characters, then write a sentence that describes a built-in and includes that built-in as the only executed character. Popularity Contest seems like it would attract much more interesting answers. – Kamil Drakari Oct 20 '17 at 21:59
• @KamilDrakari popularity-content is typically not well received, most of those are closed. – durron597 Oct 20 '17 at 23:20
• I'm not exactly sure how we can measure "X is a similar character to Y" objectively.. Probably @Kamil is right and this should be a popularity contest. – ბიმო Oct 26 '17 at 19:02
• @BruceForte, pop-con is not a "solution" to the problem that the spec is not objective. A pop-con should have an objective validity criterion and not be amenable to an objective scoring criterion. – Peter Taylor Oct 27 '17 at 12:04

# Does the Riemann hypothesis hold?

I would like to earn a million dollars, and the hardest way to do it is apparently solving one of the Millenium problems, so let's focus on one: the Riemann hypothesis.

Now, how could I possibly ever solve it? By writing a computer program, of course! However, I am lazy, so I would rather have you do the work for me by making the program as short as possible (to minimize the number of key strokes required for me to verify your results)

## The challenge

Your goal is to write a program in a language of your choice which would decide the Riemann hypothesis. More precisely, you should write a program which terminates iff the Riemann hypothesis fails.

## Restrictions

• The program has to work when running with empty input [Sandbox note: perhaps allow input but add it to byte count?]
• Standard loopholes are forbidden.
• Your program must provably terminate iff RH is false. For example, submitting two programs, one trivially terminating, one trivially not terminating, and claiming one of them works, is not allowed, since neither of the programs provably works.
• You must give a proof of equivalence of your program's termination with RH failing, with references to other work allowed. I give myself the right to decide whether the work referenced is valid or not, to exclude the many proofs and disproofs of RH.
• If the Riemann hypothesis doesn't hold, your program can throw an error, or simply exit, as long as the program cannot continue beyond that.
• You may assume you have unlimited memory and time, and also that your number types can hold real numbers of arbitrary size to arbitrary precision.
• This is , so the shortest code in bytes wins!

## Sandbox comment

To address the comments below, let me clarify why this challenge is most definitely solvable. Note that the problem is not of the sort "give a counterexample to RH" (if it did, then it would fall under this discussion and I completely agree it would not be a good challenge). Instead, it asks for a program whose termination depends on RH, and then one can give valid solutions regardless of the fact that RH is not solved yet.

To give an analogy (following Deedlit's example), suppose we have replaced RH with Goldbach's conjecture. This conjecture surely is unresolved, but one can give a valid solution to the challenge, for example by following this pseudocode:

n = 4
while true:
found = false
for k from 1 to n-1:
if k is prime and n-k is prime:
found = true
break
if found == false:
break
else:
n = n+2
return 0


If Goldbach's conjecture is false, this program will eventually terminate by returning 0 (namely, when it finds the first counterexample). Otherwise, it will stay in the while loop forever. Hence it would be a valid solution.

My challenge as it stands can be solved in a similar manner, perhaps using

one of the many known equivalents of RH.

• codegolf.meta.stackexchange.com/q/11033/45941 – Mego Oct 27 '17 at 19:47
• @Mego My proposed challenge doesn't fall under that discussion. It is not an open problem whether a solution for that problem is possible. – Wojowu Oct 27 '17 at 19:51
• Relying on open problems for challenges is not a good idea. Either it will be impossible to answer because the problem isn't solved, or answers will be trivial copy jobs of the proof once the problem is solved. This challenge relies on both an open problem (Riemann hypothesis) and an unsolvable problem (halting problem). – Mego Oct 27 '17 at 20:42
• @Mego The way I have phrased my problem makes it possible, but not trivial, once the Riemann hypothesis is unsolved. True, the problem trivializes once we get a (dis)proof of RH, but until then I don't see an issue with this problem. Also, I don't see how halting problem is in any way relevant here. – Wojowu Oct 27 '17 at 20:58
• You don't see how the halting problem is relevant in a challenge for writing problems that halt iff some unsolved problem in mathematics is true? – Mego Oct 27 '17 at 20:59
• @Mego Let me rephrase - I don't see how its unsolvability impacts the challenge in any way. – Wojowu Oct 27 '17 at 21:01
• @Mego As an example, it is straightforward to write a program that halts if and only if the Goldbach conjecture is false. Simply test out even numbers one at a time until you find one that is not the sum of two prime numbers. The unsolvability of the halting problem doesn't have any bearing on this, since we aren't relying on an algorithm that determines the halting behavior of all programs. A program that halts precisely when the Riemann Hypothesis is true could be done similarly. – Deedlit Oct 27 '17 at 22:01
• @Deedlit Can one also show that it is possible to write a program that halts iff Goldbach's conjecture is true? – Jonathan Frech Oct 27 '17 at 22:31
• @JonathanFrech I believe that's an open problem. However, thanks to your comment I've realized I have mixed things up - my challenge should've been about RH being false, not true (so just like in Deedlit's example with Goldbach). Sorry if any confusion was caused. – Wojowu Oct 27 '17 at 22:43
• @Wojowu Well, that seems solvable then. Would one, however, not simply loop through all complex numbers (as one has a lot of computational power), implement the zeta function (again, infinite computational power) and halt if they find a counterexample to the hypothesis? – Jonathan Frech Oct 27 '17 at 22:49
• @JonathanFrech It needs to be quite a bit more than that, because there are uncountably many complex numbers, so you can't loop over them all even with unbounded computing power. I believe you can do it by evaluating a contour integral around rectangles in the complex plane and looping over these rectangles. And it gets annoying around the critical line. It's definitely more complicated than just implementing the zeta function, though. – Chris Oct 28 '17 at 1:58
• @Chris Could one not loop through all possible sums of all rationals to approximate the reals, argue that every real is computable by an infinite sum of rationals, do that twice to gain a program which theoretically looks at every complex number, implement the zeta function and check if the hypothesis holds? – Jonathan Frech Oct 28 '17 at 12:02
• @JonathanFrech It's not possible to look at all possible infinite sums of rational numbers. Some (in fact, most) are uncomputable, and either way there are just too many real/complex numbers. Try to implement your algorithm in a real language like C, you will see that this simply doesn't go through. – Wojowu Oct 28 '17 at 12:06
• @JonathanFrech It is not possible to cycle through all possible complex numbers, but there are other ways which would let one verify the Riemann hypothesis. – Wojowu Oct 28 '17 at 12:17
• @Chris err, yes, that's what I meant. – Wojowu Oct 28 '17 at 20:40

# Are these numbers perfect for each other?

A perfect number is a number that is the sum of its divisors. Examples of perfect numbers are:

     | Divisors                                  | Divisor sum
-----+-------------------------------------------+-------------
6    | 1, 2, 3                                   | 6
28   | 1, 2, 4, 7, 14                            | 28
496  | 1, 2, 4, 8, 16, 31, 62, 124, 248          | 496


Similarly, numbers that are perfect for each other are numbers where each is the sum of the other's divisors.

     | Divisors                                  | Divisor sum
-----+-------------------------------------------+-------------
220  | 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110   | 284
284  | 1, 2, 4, 71, 142                          | 220


## Challenge

Write a program/function that takes two positive integers and outputs a truthy/falsey value based on whether they are perfect for each other.

### Specifications

• Standard I/O rules apply.
• Standard loopholes are forbidden.
• The output must be consistent for both truthy and falsey values.
• This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
• Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
• Built-in functions that perform this task are allowed but including a solution that doesn't rely on a built-in is encouraged.
• Explanations, even for "practical" languages, are encouraged.

## Test cases

Input         Output

1, 1          truthy
3, 7          falsey
6, 6          truthy
13, 42        falsey
220, 284      truthy
563, 492      truthy
1184, 1210    truthy


In a few better formats:

1, 1
3, 7
6, 6
13, 42
220, 284
563, 492
1184, 1210

1 1
3 7
6 6
13 42
220 284
563 492
1184 1210


## Reference implementation

divisors :: Integer -> [Integer]
divisors 1 = [1]
divisors n = [i | i <- [1..n - 1], n mod i == 0]

perfectPair :: (Integer, Integer) -> Bool
perfectPair (a, b) = (sum $divisors a) == b && (sum$ divisors b) == a


Try it online!

This challenge was sandboxed.

• Although I wouldn't really VTC (seems fine to me), this is very likely to be closed as a dupe of Am I perfect (number)?. – Mr. Xcoder Oct 29 '17 at 19:46
• it's also kinda trivial... Try it online! - 3 bytes, 05AB1E – Magic Octopus Urn Oct 31 '17 at 20:24

# Self-language validator

Create a language validator, which takes a string/file that might or might not be syntactically in the language of your choice, and returns a value corresponding to whether or not it is a syntactically valid program in the implementing language.

• At a bare minimum, your submission must return a truthy value for code where a strict implementation compiles/interprets without any problems, and must return a falsey value for code that even lax implementations cannot recognise as valid in your language.
• Your submission must have cases where it returns a truthy value, and cases where it returns a falsey value.
• As long as a construct is syntactically valid and could possibly be of the correct scope/type/whatever, it can be called valid. No need to dig into a repository to fetch documentation for an import or anything like that.
• Constructs whose syntactic validity depends on the current runtime execution state do not need to be checked, as statically checking their validity would necessitate reasoning about program execution.
• Appealing to external programs/libraries or to the compiler/interpreter, runtime, or standard libraries to parse or execute the string as language instructions for you would circumvent the whole point of this challenge, and thus is forbidden.
• Standard loopholes apply.
• I don't think quine is correct. Also, you might want to be more explicit that there must be a false case, as languages like Seriously are always syntactically valid. – ATaco Oct 30 '17 at 22:31
• I wonder how many languages get trivial solutions to this. – Joshua Oct 30 '17 at 22:55

# Budget my lunch!

I'm a man of habit, but I also like to live quite frugally so every day I make myself the same lunch consisting of;

• 3 Falafel
• A serving of houmous
• Some lettuce

Now in order to make sure I always put aside enough money for my lunch I need a program that will calculate the total cost of these ingredients for x number of days, and that is where you come in!

# The Challenge

Write a method that, when given two integers representing the start day and the number of days to calculate for, will return/print out a the total cost of my food for that number of days. There are several rules that this calculation follows;

• Each pack of falafel contains 8 falafels and costs £1.50. However, every three days I get lucky and the pack has 9 falafel in it!
• Each pot of houmous contains 4 servings and costs £1.10.
• Each head of lettuce provides 7 servings and costs 46p (£0.46).
• Houmous and flatbread both go off over the weekend/I eat them so have to be bought fresh on Monday.

# The Input

You will recieve two integers as input. These can be read from STDIN, passed as individual arguments, or passed as an array. Up to you.

The first integer represents the starting day e.g. 1=Monday, 2=Tuesday etc. This will always be between 1 and 5 inclusive.

The second integer is the number of days to budget for not including weekends e.g. an input of 1 and 5 would be budgeting my lunch for each day of the standard working week.

# Sample program

Below is a throroughly ungolfed program to use as reference and clarification of the above rules.

public static double budgetMyLunch(int startDay, int days){
double totalCost = 0;

final double falafelCost = 1.5;
final int falafelsInPack = 8;
int falafels = 0;
int falafelPackCount = 0;

final double houmousCost = 1.1;
final int houmousServings = 4;
int houmous = 0;

final double lettuceCost = 0.46;
final int lettuceServings = 7;
int lettuce = 0;

int endDay = startDay + days;
int currentDay = startDay;

while(currentDay<endDay){

// If there are less than 3 falafels I have to buy some more
if(falafels<3){
falafelPackCount++;
falafels += falafelsInPack;
// Every third pack of falafel I get lucky and it has 9 instead of 8!
if(falafelPackCount%3==0) falafels++;
totalCost += falafelCost;
}

// If there are less than 2 flatbreads I have to buy some more
}

// If there are no servings of houmous left I have to buy some more
if(houmous == 0){
houmous += houmousServings;
totalCost += houmousCost;
}

// If there is no lettuce left I have to buy some more
if(lettuce == 0){
lettuce += lettuceServings;
totalCost += lettuceCost;
}

// Use up the ingredients for my lunch!
falafels -= 3;
houmous -= 1;
lettuce -= 1;

// If it's the end of the week, I eat the remaining
// houmous and flatbread over the weekend
if(currentDay%5==0){
houmous = 0;