# Tag Info

90

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 number (over all sets) of vertical moves required to avoid superpositions. If the resulting number of horizontal moves is suboptimal (a false positive), it ...

54

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 secure prisons. The idea is to ensure that we can't find a path from a P to an out of bounds cell (~) moving only orthogonally (o) through spaces. The t is a teleport so that regardless where we attempt the match it tries all possible ...

52

Blue Team - SphiNotPi3000 // Char 0: top or bottom ("T" or "B") // Char 1, 2: x/y coords // Char 3, move polarity // Char 4: offset (as codepoint - 128) var twin = 21487; var myself = 2867; var formpos = "T"; var tochar = String.fromCharCode; var movestat = (move % 2).toString(); var inbox = getMsg(twin); // Spoofing the message of a deceased partner if ...

47

Blue Team - SphiNotPi3000 // Char 0: top or bottom ("T" or "B") // Char 1, 2: x/y coords // Char 3, move polarity // Char 4: offset (as codepoint - 128) var myself = 21487; var twin = 2867; var formpos = "B"; var tochar = String.fromCharCode; var movestat = (move % 2).toString(); var inbox = getMsg(twin); // Spoofing the message of a deceased partner if ...

37

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 the same as @Sp3000's, as his was an improvement over mine. However, my implementation of the maze logic is rather nifty. This allows me to check if strings are ...

34

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 blow up the post unnecessarily.)

33

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 <table cellspacing=0><tr><td><td>•<td><tr><td><td><td>•<tr><td>•<td>•<td>• This uses the UTF-8 character • which ...

32

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 using a regex-like syntax. A program in SnakeEx consists of a list of definitions for snakes using different sequences of commands. Snakes can spawn other ...

31

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 L.bmp on the screen, then modifies it to find a solution. *DISPLAY L t=PI/8q=FNa(1) DEFFNa(n)IFn=7END LOCALz,j,p,i,c,s,x,y,m,u,v F.z=0TO99u=z MOD10*100v=z DIV10*100ORIGINu,v F.j=0TO12S.4p=0F.i=j+...

29

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. iii ios sii For those who don't know Deadfish, i is increment, s is square and o is output, with the accumulator starting at 0 (there's also a 4th instruction d ...

28

Snails, 15 bytes \Oo!{.,fee7.,\F Try it online! 1 means survival while 0 means death. Since it is impossible to outrun the fire, it is never useful to try to go around it. The best route is always a straight line. So there are only four possible choices of escape route. To determine if a direction is safe, we check for any F in the "fire cone" pointing ...

27

PARI/GP - 24 1%1 8 2+3 PARI/GP ignores spaces between digits, so that 1 8 2, for example is treated as 182. The same could work for perl by replacing the spaces with underscores. I haven't exhausted the entire search space, so there may be better candidates. A program can be fed to gp as gp -q -f program.gp, or interactively in the repl. Output 1%1 8 2+...

27

Mathematica, 62 bytes Grid[{{,a=██,},{,,a},{a,a,a}},Frame->All,FrameStyle->Gray] Mathematica, 71 bytes Grid[{{,l=Graphics@Disk[],},{,,l},{l,l,l}},Frame->All,FrameStyle->Gray]

26

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 developed for our 2D pattern matching language design challenge. The & makes Snails try the pattern from every possible starting position and prints 0 or 1 depending on whether the pattern fails in ...

25

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 and ends on the same colour. Still brute forcing for better. Trying with +*% (and even ** for languages where ^ is exponentiation) didn't turn up anything better, unfortunately. I also tried ...

25

GLSL (fragment shader), 278 235 256 bytes precision highp float;void main(){vec2 a=gl_FragCoord.xy/20.-.2;ivec2 b=ivec2(a);a-=vec2(b)+.5;if(b.x>2||b.y>2)discard;gl_FragColor=a.x<-.5||a.y<-.5||a.x>.3||a.y>.3?vec4(.5,.5,.5,1.):length(a+.1)<.4&&(b.x+b.y-3)*b.y==0?vec4(0.,0.,0.,1.):vec4(1.,1.,1.,1.);} See it in action: http://...

22

APL 19 ≢¨∪/⌈\(⍉⍪⌽⍪⊖∘⌽∘⍉⍪⊖) (golfed a bit more after ngn's suggestion, thanks) Explanation: (⍉⍪⌽⍪⊖∘⌽∘⍉⍪⊖) rotates matrix 4 times appending results ⌈\ gets maximums for each row up to current column (example: 4 2 3 5 1 gives 4 4 4 5 5) ≢¨∪/ counts unique elements for each row Try it on tryapl.org

22

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 0 for cells without nearby mines. Try it online in the CJam interpreter. Idea We start by padding the input matrix with one row and one column of asterisks. For input *4* **2 this results in *4** **2* **** ...

22

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 this problem written in Funciton. Some factoids: It accepts an integer on STDIN. Any extraneous whitespace breaks it, including a newline after the integer. It ...

22

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 compatible, you can Try it online! I randomly received an upvote on this answer, so I looked over it again. My vim-golfing skills have greatly increased over the last 7 months, so I saw that this answer was ... 21 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 like I managed to take the middle ground. There's a quite a lot of unimplemented features which I want to add, so where relevant I've noted what I intend to do ... 21 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! It now keeps track of seen and visited cells in an array (given it only ever looks at a finite number of them anyway). I also re-wrote the directional code, ... 21 Red Team - SeekerBot var myself = 38926; var messages = getMsg(myself).split(';'); var minimalDistanceToFriend = 2; var chosenMove = null; var newDistanceToFriend = null; var minimalVerticalDistanceToEnemy = null, minimalHorizontalDistanceToEnemy = null; var closestFriend = null; var closestEnemy = null; var possibleVictims = []; var possibleMoves = [ {... 21 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 and top to bottom, then sorts each row in alphabetical order. The only disconnections can happen between the C-E border and E-D border, or E-D border and D-M border (if they fall on adjacent rows). ... 21 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 suggested a critical simplification to my original algorithm. @MartinBüttner applied his mad golfing skills to the revised approach, which almost certainly resulted in shorter code than I would have ... 21 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 [' * '; '* * '; ' * '; ' *'] Try it online! Test cases: 1, 2, 3, 4, 5, 6. Explanation 32> % Input 2D char array implicitly. Transform it into a 2D logical % array with asterisk ... 21 Python 2, 169 140 bytes from turtle import* up() shape("square") color("gray",[1]*3) i=9 while i: i-=1;goto(20-i/3*20,20-i%3*20);stamp() if 302&2**i:dot(15,0,0,0) Actual size, 61 by 61, plotted within a much larger canvas of 300 by 400: Showing the pixel grid: The dots use 177 pixels within the range of 40%-80% whether considering the ... 20 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. // == Shared low-level helpers for all solutions == var QUEEN = 5; var WHITE = 1; var COL_MIN = WHITE; var COL_LIM = 9; var CENTRE = 4; var NOP = {cell: CENTRE}; var DIR_FORWARDS = ... 19 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-deterministic approach. On my desktop, the second test case generally finishes in less than 10 minutes. The first case finishes instantly. Try it online in the CJam interpreter. Sample run$ cjam grid....

Only top voted, non community-wiki answers of a minimum length are eligible