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 ...
42
votes
When will the DVD logo hit the corner?
Wolfram Language (Mathematica), 27 bytes
ChineseRemainder[-#,#2-#3]&
Try it online!
This is the least \$t\ge0\$ such that \$i+t\equiv0\pmod{g-d}\$.
36
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
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
Accepted
Display the Hacker Logo
Mathematica, 62 bytes
Grid[{{,a=██,},{,,a},{a,a,a}},Frame->All,FrameStyle->Gray]
Mathematica, 71 bytes
...
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 ...
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
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. ...
24
votes
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
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
...
22
votes
When will the DVD logo hit the corner?
Python, 59 bytes
-1 thanks to @xnor
f=lambda i,I,g,G,d,D:i%(g-d)+I%(G-D)and-~f(i+1,I+1,g,G,d,D)
Attempt This Online!
Based on the observation that we can "...
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
Accepted
There's an ant on my Rubik's Cube
Perl, 156 143 134 128 127 125 120 119 117 113 109 bytes
Includes +1 for -p
Run with the control string on STDIN, e.g.
...
20
votes
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.
...
20
votes
Partitioning the grid into triangles
Haskell, 60 55 54 52 bytes
After a drawing and programming a lot of examples, it occured to me that this is the same as the problem of the rooks:
On a \$(n+1) \times (n+1)\$ chessboard, how many ...
20
votes
20
votes
19
votes
Accepted
"Fill the Grid" Problem
CJam, 119 91 bytes
q~:M;),>:R;(:L{{R{ML)d/-Y#)mr}$L/L<2{{M1$:+-+}%z}*:U:+__O|=R*-}gU{:s_:,:e>f{Se[}}%zSf*N*}M?
This is a provably correct, non-...
19
votes
Stuffing primes in a box
Smalltalk, 1098 primes
First off, nice hard question - as evidenced by the lack of non-trivial responses thus far.
I had a solution cooking at work, but had to wait for the long weekend to have time ...
19
votes
19
votes
N-movers: How much of the infinite board can I reach?
JavaScript (Node.js), 144 138 125 74 73 70 bytes
f=(x,n=2,c=0)=>x%n?x-!c?f(x,n+1)/(n%4>2?n/=~c&1:n%4)**c:1:f(x/n,n,c+1)
Try it online!
-4 byte thanks @...
18
votes
Determine winner of Connect 4
Perl, 119 118 117 bytes
Includes +4 for -0p
Give rotated board padded with spaces on STDIN (gravity pulls stones to the right)
...
18
votes
Accepted
Follow incomplete directions
Perl, 150 149 146 145 141 140 138 136 135 133 130 126 125 124
Added +7 for -F -Xn0i
An initial attempt.
Run with the map on STDIN and the directions after the -i option, e.g.
...
18
votes
A Numpad's Knight Numbers
Python 2, 52 bytes
f=lambda n:n<6or`n%100`in'18349276167294381'*f(n/10)
Checks that any two consecutive digits are in the string ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
grid × 379code-golf × 344
ascii-art × 48
decision-problem × 46
string × 45
path-finding × 41
geometry × 40
game × 28
combinatorics × 27
graph-theory × 22
math × 19
puzzle-solver × 19
array × 19
sequence × 16
number × 15
code-challenge × 14
chess × 13
tiling × 13
matrix × 12
counting × 12
random × 11
binary-matrix × 11
king-of-the-hill × 10
maze × 10
arithmetic × 9