92
votes
Accepted
Rearranging Words
CJam, 58,598 58,494 57,898 57,772 57,704 57,680 moves
This approach takes the family of all unordered sets of horizontal moves of minimum cardinality (with some false positives) and adds the minimum ...
55
votes
Accepted
Is my prison secure?
Snails, 13 bytes
!(t\P(o\ ),o~
Try it online!
Prints 0 for insecure prisons and the size of the input's bounding box for ...
52
votes
Accepted
49
votes
40
votes
Accepted
Shortest universal maze exit string
C++, 97 95 93 91 86 83 82 81 79 characters
My strategy is fairly simple - an evolution algorithm that can grow, shrink, swap elements of and mutate valid sequences. My evolution logic is now nearly ...
35
votes
Display the Hacker Logo
CSS+HTML, 56+84=140 bytes 52+84=136 bytes
Saved 4 bytes by incorporating suggestions from the comments.
td{border:1px solid#888;line-height:.4;font-size:3em
<...
34
votes
Print all colorings of a 3x3 grid
Mathematica, 25 bytes
Image/@{0,1}~Tuples~{3,3}
Gives an array with all the grids as images, which is also directly displayed on screen:
(Cropped so as not to ...
34
votes
Solve Grid-Tangram
BBC BASIC, 570 514 490 bytes ASCII
Download interpreter at http://www.bbcbasic.co.uk/bbcwin/download.html
435 bytes tokenised
Full program displays an input from ...
32
votes
Language Design: 2-D Pattern Matching
SnakeEx
Solves 15/16 problems so far!
Online Interpreter! - Full Language Spec - Javascript Source
The idea behind this language is to define 'snakes' that move around the text checking characters ...
31
votes
Accepted
Display the Hacker Logo
Mathematica, 62 bytes
Grid[{{,a=██,},{,,a},{a,a,a}},Frame->All,FrameStyle->Gray]
Mathematica, 71 bytes
...
29
votes
40 Numbers in 9 Bytes
Deadfish, 18
This was actually the first language I tried before I considered infix operators. I'm posting it now for the sheer hilarity of the idea that Deadfish could be useful for something.
<...
28
votes
Accepted
Will I make it out in time?
Snails, 15 bytes
\Oo!{.,fee7.,\F
Try it online!
1 means survival while 0 means death.
Since ...
27
votes
Accepted
40 Numbers in 9 Bytes
PARI/GP - 24
1%1
8
2+3
PARI/GP ignores spaces between digits, so that 1 8 2, for example is treated as ...
26
votes
Recognize a vine
Snails, 25 19 17 bytes
&
\0z),(\1dlr)+d~
Try it online!
Explanation
Snails is a 2D pattern-matching language inspired by regex, which was originally ...
26
votes
25
votes
40 Numbers in 9 Bytes
Python REPL and many more, 22 23
6+7
*5%
6%4
Key observation: If you colour the grid like a checkerboard, the path alternates grid colours as it goes and starts ...
24
votes
24
votes
Maximum number of squares touched by a line segment
Python 2, 27 bytes
lambda L:(2*L*L-2)**.5//1+3
Try it online!
A direct formula:
$$ f(L) = \lfloor \sqrt{2 L^2-2}\rfloor + 3 $$
Derivation
As noted by @Kirill L. ...
23
votes
Invert a Minesweeper Board
CJam, 58 57 bytes
0WX]2m*qN/{'*f+z}2*f{\~@m<fm<W<}:..+{W<{_'*#'*@'*-,?}/N}/
Input should not end with a linefeed. Output contains ...
22
votes
How many towers can you see?
APL 19
≢¨∪/⌈\(⍉⍪⌽⍪⊖∘⌽∘⍉⍪⊖)
(golfed a bit more after ngn's suggestion, thanks)
Explanation:
...
22
votes
Language Design: 2-D Pattern Matching
Slip, Python 3.4 (Github wiki, online interpreter)
Like feersum's submission this is also based on traversing the grid, but like CarpetPython's submission this is based on regex. Somehow it looks ...
22
votes
Accepted
Dennis, Doorknob, Martin Büttner, Chris Jester-Young - Pizzeria!
CJam, 20 bytes
q~1$*4/"CEDM"e*/:$N*
I think this should work :)
Try it online
Explanation:
This first makes a pizza labeled CC…EE…DD…MM… from left to right ...
22
votes
Fill the rows, columns, and diagonals of an NxN grid with 1 through N
Funciton, non-competitive
UPDATE! Massive performance improvement! n = 7 now completes in under 10 minutes! See explanation at bottom!
This was good fun to write. This is a brute-force solver for ...
22
votes
A square of text
Vim, 59, 57, 48 bytes/keystrokes
$:let @q=float2nr(sqrt(col('.')))."|li<C-v><cr><C-v><esc>@q"<cr>@q
Since V is backwards ...
22
votes
Fill in the Minesweeper clues
MATL, 18 17 bytes
Thanks to @mbomb007 for a correction in the input of test case 6
32>t3Y6Z+-6b(48+c
Input is a 2D char array, in the format
...
21
votes
Infinite Labyrinths
C# - 423 375 bytes
Complete C# program, accepts input via STDIN, outputs "True" or "False" to STDOUT as appropriate.
I could not bare to leave that Linq in there... thankfully its removal paid off! ...
21
votes
21
votes
Can I Slide Apart The Puzzle?
CJam, 33 32 20 19 17 bytes
Revised version, with massive support from @Sp3000 and @MartinBüttner:
qN/_z]{:e`z,3<}/|
Try it online
Contributions
@Sp3000 ...
20
votes
Formic Functions - Ant Queen of the Hill Contest
Forensic Ants
All my answers are sharing the same set of low-level helper functions.
Search for "High-level logic begins here" to see the code specific to this answer.
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
grid × 355code-golf × 323
ascii-art × 48
string × 44
decision-problem × 44
geometry × 38
path-finding × 38
game × 27
combinatorics × 25
graph-theory × 20
math × 18
puzzle-solver × 18
array × 18
sequence × 15
code-challenge × 13
tiling × 13
number × 12
counting × 12
matrix × 11
random × 10
king-of-the-hill × 10
maze × 10
arithmetic × 9
binary-matrix × 9
javascript × 8