36

Retina, 74 bytes FKCIIBAVWMGN_PT_NC_CS_PP_SV_CS_PE_LS_BJCVCORIBCMG S_`(._.) _ 9$* \B 1 The third to last and last lines should contain a single space. Try it online! Explanation FKCIIBAVWMGN_PT_NC_CS_PP_SV_CS_PE_LS_BJCVCORIBCMG This replaces the (empty) input with the string on the second line. S_`(._.) This is split stage, which splits the string ...


25

Jelly, 44 bytes “£ċ9NɲT⁴MỵƇñdMỊḞ*µ7Sʂɓ¢Ż}ạ¥ċwÞ’ḃ23ṣ4ịØAz⁶ṙ1G Try it online! Idea If we remove every second column and transpose rows with columns, we get the following board. FNTCSPVSESJ K C C V I C I O B R A I V B W C M M GPNCPSCPLBG Now, we can rotate each column one unit to the ...


19

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 @Arnauld! Original approach, 125 bytes a=>(F=(x,n=2)=>n*n>x?[x,0]:x%n?F(x,n+1):[n,...F(x/n,n)])(a).map(y=>r-y?(z*=[,1,.5,p%2?0:1/r][r%4]**p,r=y,p=1):p++,z=r=p=1)&&z Try it ...


17

The shortest game of halma is 49 moves 49 move solution Proof there is no 48-move solution Code used for this solution The code now supports pass Notice that the 47 move solution in the paper is for the army transfer problem, not for the shortest game of halma I'll hopefully get to doing a proper writeup this weekend


16

JavaScript Work in progress. Unfortunately the maze is not always solvable - the limit on back-forward is the real hurdle. Edit 1 Cosmetic Edit 2 Better gameplay, but the big problem is still there var rows, columns, rowOfs, maze, plPos, points, playing $('#BNEW').on('click', function() { NewMaze(); }); $('#BREP').on('click', function() { ...


16

CJam, 61 59 43 40 38 36 bytes {{_N/eeSf.*:sW%zsS-\{_' >{;(}&+}/}*} This is an anonymous function that expects a string and an integer on the stack. Thanks to @jimmy23013 for golfing off 19 bytes. Try it online in the CJam interpreter. Idea We can assign an order to the printable characters of the checkerboards by reading them eastwards, then ...


16

Perl, 119 118 117 bytes Includes +4 for -0p Give rotated board padded with spaces on STDIN (gravity pulls stones to the right) connect4.pl OXXX XOO OX OOXX XXXO XXOOXO OOXXOO ^D connect4.pl: #!/usr/bin/perl -p0 y/XO/OX/if$^S|y/X//>y/O//;$_=$$_||=/Z@{[map"|O".".{$_}O"x3,0,5..7]}/sx||s% (?! )%$_="$`X$'";do$0%eg?/1/?3:1+/2/:2 Prints 3 if ...


16

MATL, 59 54 52 bytes 4t:g2I5vXdK8(3K23h32h(H14(t!XR+8: 7:Pht3$)'DtdTX.'w) Try it online! Explanation The code follows three main steps: Generate the 8x8 matrix 4 0 0 3 0 0 0 4 0 1 0 0 0 2 0 0 0 0 1 0 0 0 3 0 3 0 0 1 0 0 0 3 0 0 0 0 1 0 0 0 0 2 0 0 0 2 0 0 0 0 3 0 0 0 3 0 4 0 0 3 0 0 0 5 Extend it to the 15x15 matrix 4 0 0 3 0 0 0 4 0 0 0 3 0 0 4 0 1 ...


16

05AB1E, 48 47 bytes Thanks to Emigna for saving a byte! •(K·;“…¬È¦z"9äuŸé;TÞîÕs‡ÓÐV9XÒt\<•33B¾9ð×:S11ô» Explanation: First some compression. •(K·;“…¬È¦z"9äuŸé;TÞîÕs‡ÓÐV9XÒt\<• is a compressed version of the following number: 120860198958186421497710412212513392855208073968557051584380118734764403017 After that, this is converted to base 33, which ...


16

Haskell, 21 bytes all$scanr1 max>>=(==) Try it online! Takes a list of columns, with empty spaces as 0.


16

Python 2, 54 bytes lambda s:sum((s+"BLSW"*3).count(n)/4for n in"BLSWO")>3 Try it online! For each of our resources, we count the number of “freedoms” given by having n of that resource. A freedom represents an opportunity to fill one of the brick-log-wheat-sheep slots we need to fill in order to settle, accounting for the fact that we can convert our ...


16

sed 4.2.2, 81 s/[QZ]/JD/g s/[JX]/KB/g s/K/FE/g s/[FHVWY]/BE/g s/[BCMP]/DE/g s/[DG]/EE/g s/./1/g Output is in unary. Reduces each letter to a combination of lower-scoring letters until all letters are 1-scorers. Then replaces those with 1s to give a unary count. Try it online!


15

Perl 5 228 205 186 184 178 177 153 150 149 142 137 135 Run with perl -E. Golfed: $_=<>;@a=@b=map-ord,' 0 0@0 H ``'=~/./g;say s!.!($a[$q=64-ord$&]+=8)<8?$-+=1-29/$b[$q]:++$j!ge~~[2..15]&&$j<3?$-:Invalid This solution uses some non-printable characters, so a hexdump is provided below: 00000000: 245f 3d3c 3e3b 4061 ...


13

C, Rev 2, 151 145 138 Inspired by the 159-byte code in @bebe's comment, I squeezed another 8 14 21 characters out: 4 bytes saved by rearranging the length counter i. This is initialised to 1 (assuming the program takes no arguments) then multiplied by 4 every time a letter is read. It overflows to zero when the word length is greater than 15, so to check ...


12

Hexagony, 19 bytes ?({{&2'2':{):!/)'*/ Try it online. Explanation This is still the same computation as I've used in my CJam and Labyrinth answers, but due to Hexagony's... special... memory model, it's a bit trickier to squeeze the computation into 19 bytes (so that it fits inside a side-length 3 hexagon). Like my Labyrinth answer, this terminates ...


12

Python 2, 89 bytes l='%s '*11+'\n' print(l+'%s%20s\n'*9+l)%tuple("FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG") Creates the template ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ...


11

Python 2, 171 bytes def f(S,n): o="";E=enumerate;B=S.splitlines(1) for r,l in E(B): for c,q in E(l):z=r-8;y=6-(z+c)/2;x=-y-z;exec"x,y,z=-y,-z,-x;"*n;o+=q*(q<"!")or B[z+8][12-y+x] print o This is perhaps the only time I've ever found str.splitlines useful — for all other times, .split("\n") is shorter. Use like f(S,10). Explanation For each char ...


11

LabVIEW, 28 20 LabVIEW Primitives


11

MaxGayne This bot assigns a score to each position, based mainly on the length of connected parts. It looks 3 moves deep inspecting 3 best looking moves at each stage, and chooses the one with the maximum expected score. package connectn.players; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; ...


11

Wolfram Language (Mathematica), 45 bytes Because the other solution is incorrect (see Martin's comment below), so I decide to post my solution: 8~KnightTourGraph~8~AdjacencyList~#&~Nest~##& Try it online! Ultimate infix notation... Takes 2 input, the first one is a list of numbers in range [1,64] describe the starting positions of the knight, ...


11

JavaScript (ES6),  202 194 187  183 bytes Takes input as a matrix with \$2\$ for red, \$4\$ for yellow and \$0\$ for empty. Returns a string of 0-indexed moves (or an empty string if there's no solution). Reds start the game. m=>(p=[...'5555555'],g=(c,s=o='')=>/2|4/.test(m)?['',0,2,4].some(n=>m.join``.match(`(1|3)(.{1${n}}\\1){3}`))?o:p....


11

Clean, 189 185 172 171 bytes import StdEnv $n#r=[~n..n] #p=[[x,y]\\x<-r,y<-r|x^2+y^2==n] =sum[1.0\\_<-iter n(\q=removeDup[k\\[a,b]<-[[0,0]:p],[u,v]<-q,k<-[[a+u,b+v]]|all(\e=n>=e&&e>0)k])p]/toReal(n^2) Try it online! Finds every position reachable in the n-side-length square cornered on the origin in the first quadrant, then ...


11

Mathematica, 80 bytes d[n_]:=If[#=={},0,1/Det@LatticeReduce@#]&@Select[Tuples[Range[-n,n],2],#.#==n&]; This code is mostly reliant on a mathematical theorem. The basic idea is that the code asks for the density of a lattice given some generating set. More precisely, we are given some collection of vectors - namely, those whose length squared is ...


10

05AB1E, 4 bytes €{íQ Try it online! Same as my other two answers. I promise this is my last one until others have answered :)


10

Haskell, 86 84 bytes f s=length s+sum[n|x<-s,(n,y)<-zip(9:7:[1..])$words"QZ JX DG BCMP FHVWY K",x`elem`y] Try it online! Explanation Most letters give a score of 1 and thus we don't need to keep track of these, instead we just decrement each score (saves 1 byte on 10 as well) and then add the length of the string to the resulting score. Thanks @...


10

Octave, 50 bytes @(t)'       '/3*sum(65:90==t')' Try it online! Challenge accepted. Explanation: @(t) % Define anonymous function taking a single argument t. ' ... '/3 % Row vector with letter scores. Corresponds to char([1 3 3 2 ....


9

C, 234 286 256 chars Fixed to correctly solve the problem, by checking for opponent winning moves following every move attempted. This code is very sensitive to the input file format - each line must conatain 7 chars + newline. The board is treated as an 8x8 matrix, rather than 7x6. The 8th column contains the newlines, and the 2 extra rows contain zeros, ...


9

C, 617 592 bytes #define O(x)(x-'x'?'x':'o') q,f,t,k,i,x=4,o=4,*d;main(){char*A,Q[9],c='x',b[]="xxxx___oooo";printf(b);while(!q){scanf(" %8[^\n]%*[^\n]",Q);if(!strcmp(Q,"quit"))break;f=*Q>47&&*Q<58?atoi(Q):-1;A=f>9?Q+2:Q+1;t=*A==32&&A[1]>47&&A[1]<58?atoi(A+1):-1;i=t==f&&t<0&&f<0?1:0;for(k=f;k!=t;k+...


9

Python, 42 41 bytes m=lambda n,i=2:n*[1]and[n%i]+m(n-n%i,i+1)


9

PowerShell v2+, 131 123 114 110 99 bytes 'F K C I I B A V W M G N0P T0N C0C S0P P0S V0C S0P E0L S0B J C V C O R I B C M G'-replace0,(" "*19) This is just a literal string with newlines placed on the pipeline, with a little -replace at the end to turn the 0 into 19 spaces. The first and last lines are just verbatim. With only 10 spaces and little repetition ...


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