2048: Difference between revisions

3 bytes removed ,  7 years ago
→‎{{header|J}}: correct merging directions
(→‎{{header|J}}: name target)
(→‎{{header|J}}: correct merging directions)
Line 1,406:
 
newnum=: verb define
num=. ,/ 2 4 {~ 0.1 > ?0 NB. 10% chance of 4
idx=. 4 $. $. 0 = y NB. indicies of 0s
if. #idx do. NB. handle full grid
Line 1,420:
 
compress=: -.&0
toLeft=: 1 :'4&{.@(u@compress&.|.)"1'
toRight=: 1 : '_4&{.@(u@compress&.|.)"1'
toUp=: 1 : '(4&{.@(u@compress&.|.)"1)&.|:'
toDown=: 1 : '(_4&{.@(u@compress&.|.)"1)&.|:'
 
move=: conjunction define
892

edits