16
votes
Draw me a domino
Python 2, 101 97 92 68 64 bytes
lambda*a:[[[n>3,n>5,n>1],[n>7,n%2,n>7],[n>1,n>5,n>3]]for n in a]
Try it online!
Credits
Reduced from 101 ...
14
votes
Triangular domino tiling of an almost regular hexagon
APL (Dyalog Classic), 14 bytes
×/1+1÷1+∘,1⊥¨⍳
Try it online!
Uses 0 indexing with ⎕IO←0.
Explanation:
...
13
votes
Draw me a domino
C (gcc), 252 242 269 262 241 235 220 bytes
I was on stack overflow for sockets in python, when this popped up, said why not? first code golf, so i'm not entirely sure if I followed the rules 100% (...
13
votes
Topple some dominoes!
Retina, 32 bytes
+`(/.\\)|(/)\||\|(\\)
$1$2$2$3$3
Try it online!
Explanation
The + tells Retina to run the replacement in a ...
10
votes
Draw me a domino
Jelly, 20 bytes
“¤o.ƤẸʠṚ’B¬s5ŒBị@s€3
Try it online!
Alternate version, original output, 33 32 31 bytes
...
10
votes
9
votes
9
votes
Draw me a domino
Jelly, 13 bytes
⁽½ÑD<;ḂŒBs3µ€
Try it online!
Combining Dennis' idea of using ŒB (bounce) in this answer and Xcali's ...
8
votes
Triangular domino tiling of an almost regular hexagon
Perl 6, 38 30 bytes
{[*] map 1+1/(*+1),[X+] ^<<@_}
Try it online!
Based on the formula given in the question
Explanation:
...
8
votes
Maximal saturated domino covering of a rectangle
Sagemath, 60 bytes
lambda m,n:m*n-len(graphs.GridGraph([m,n]).dominating_set())
Try it online!
From Saturated Domino Coverings by Buchanan et al:
Corollary 6.3: ...
6
votes
6
votes
Draw me a domino
JavaScript (ES6), 79 78 bytes
Saved 1 byte thanks to @ETHproductions
Takes input in currying syntax (a)(b) and outputs a vertical ASCII domino.
...
6
votes
5
votes
Topple some dominoes!
Python 2, 115 114 111 108 98 95 bytes
-1 byte thanks to ovs
a=input()
for i in range(4)*len(a):a=a.replace('//|x||\ \\'[i::4],'/\/x|\/ \\'[3-i::4])
print a
Try ...
5
votes
Triangular domino tiling of an almost regular hexagon
Jelly, 9 8 bytes
Œp§_2İ‘P
Try it online!
Uses the altered form of the closed form expression. Takes input as a list [x,y,z].
...
5
votes
Triangular domino tiling of an almost regular hexagon
K (ngn/k), 17 15 bytes
%/*/'2 1+\:+/!:
Try it online!
last test fails because of an overflow
uses a 0-indexed version of the formula:
\$PL(x,y,z)=\prod_{i=0}^{x-1}\...
5
votes
Triangular domino tiling of an almost regular hexagon
Wolfram Language (Mathematica), 28 bytes
Array[1+1/(##-2)&,#,1,1##&]&
Try it online!
5
votes
Triangular domino tiling of an almost regular hexagon
Haskell, 44 bytes
foldr(\r k->k+k/(sum r-2))1.mapM(\n->[1..n])
Try it online!
Outputs floats. Thanks to @H.PWiz for 4 bytes using a fold.
5
votes
Triangular domino tiling of an almost regular hexagon
05AB1E, 13 11 bytes
L.«â€˜OÍz>P
Try it online or verify all test cases.
Explanation:
Uses the derived formula (inspired by @JoKing's answers):
$$PL(x,y,z) = \...
5
votes
Domino Recurrence Generator
APL (Dyalog Unicode), 72 bytes
{⍵=1:⍳2⋄(2*⌈⍵÷2)(⌷⌹⍉⍤↑)⍉L↑⍉↑,¨+.×\(L←2*⍵)⍴⊂∘.((0∊+)⍱1∊2|×≢¨⍤⊆⊣)⍨⍸1⍴⍨⍵⍴2}
Try it online! (uses a polyfill for ⍤ since TIO is not ...
5
votes
4
votes
4
votes
Longest domino chain
Brachylog, 29 bytes
v0|sp:{|r}aLcbk@b:{l:2%0}a,Ll
Try it online!
Pretty sure this is awfully long, but whatever. This is also awfully slow.
Explanation
...
4
votes
Draw me a domino
APL (Dyalog), 25 bytes
2∘|(3 3⍴⊢,,∘⌽)¨>∘3 5 1 7¨
Try it online!
-2 thanks to ngn.
The output format is a little bit weird: this function returns an array ...
4
votes
4
votes
Topple some dominoes!
V, 23 bytes
òÓ¯À<!|¨Ü©ü¨¯©|ÜÀ!/±±²²
Try it online!
Really, this is very similar to the retina answer, just that it looks uglier. Uses regex compression.
...
4
votes
4
votes
Maximal saturated domino covering of a rectangle
JavaScript (ES6), 120 bytes
A shorter (and slower) version, using the same algorithm with eval() and two for loops.
Expects <...
3
votes
Which dominoes are missing?
Julia 0.6, 47 bytes
A->setdiff([[i,j]for i=0:6 for j=i:6],sort.(A))
Try it online!
(Corrected range start thanks to JayCe.)
48 bytes
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
dominoes × 16code-golf × 15
combinatorics × 6
grid × 5
tiling × 5
ascii-art × 2
decision-problem × 2
string × 1
code-challenge × 1
game × 1
path-finding × 1
optimization × 1
restricted-time × 1
animation × 1
restricted-complexity × 1
binary-matrix × 1
logic-gates × 1
polyomino × 1