Draw me a domino

35

1

Challenge

Given two digits 0-9 as input, output a domino (from the double-nine domino set) with these number of pips (dots) on the two faces. The ten possible faces look like this (separated by pipes):

     |     |    o|    o|o   o|o   o|o o o|o o o|o o o|o o o
     |  o  |     |  o  |     |  o  |     |  o  |o   o|o o o
     |     |o    |o    |o   o|o   o|o o o|o o o|o o o|o o o

Or on separate lines:

     
     
     
-----
     
  o  
     
-----
    o
     
o    
-----
    o
  o  
o    
-----
o   o
     
o   o
-----
o   o
  o  
o   o
-----
o o o
     
o o o
-----
o o o
  o  
o o o
-----
o o o
o   o
o o o
-----
o o o
o o o
o o o

Input formats

You may take input in any reasonable format, including but not limited to:

  • Two separate integers, strings, or singleton arrays;
  • A single integer from 0-99;
  • An array of two integers;
  • A string of two digits.

Output formats

  • The two faces may be horizontally aligned, separated by pipes like so:
    o|o   o
     |  o  
o    |o   o
  • Or they may be vertically aligned, separated by hyphens like so:
    o
     
o    
-----
o   o
  o  
o   o
  • You may output a border around the domino if you wish.
  • You may also choose to output a list of lines, a list of the two faces, or a combination of these.
  • You may use any non-whitespace character for the pips (I used o).
  • If you really wish, you can use 0 for whitespace and 1 for the pips, or False/True (or your language's equivalent) if outputting an array.
  • You may remove the whitespace between columns; this is a valid output for 7, 7:
ooo|ooo
 o | o 
ooo|ooo
  • Any of the faces may be rotated by 90 degrees. This is also a valid output for 7, 7:
o   o|o o o
o o o|  o  
o   o|o o o
  • You may have as much/little leading/trailing whitespace as you like, as long as the main part of the output still fits the other constraints.
  • Each face must be 3 lines tall, even if the lines are empty. For 0, 1 you could not output this:
-----

  o

But you could output this:




-----

  o

Similarly, if you were outputting a list of two lists of lines, you could do [["", "", ""], ["", " o", ""]], but not [[""], [" o "]].

Scoring

This is , so the shortest code in bytes in each language wins.

ETHproductions

Posted 2017-12-23T01:15:26.700

Reputation: 47 880

So, for input [2, 1], I could output [[[0,0,1],[0,0,0],[1,0,0]],[[0,0,0],[0,1,0],[0,0,0]]]? – Dennis – 2017-12-23T02:42:25.887

@Dennis Correct. – ETHproductions – 2017-12-23T02:44:26.193

2Does the separator between the faces have to be dashes, or can it be some other consistent value? – Jo King – 2017-12-24T03:40:21.097

@JoKing I'll say you can use any consistent character other than the ones you're already using. – ETHproductions – 2017-12-24T16:22:50.113

[0,5,21,29,31] are all important numbers here my friends. – Magic Octopus Urn – 2018-01-24T21:28:29.457

Answers

14

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

Neil

Posted 2017-12-23T01:15:26.700

Reputation: 2 417

@Mr.Xcoder Updated again. – Neil – 2017-12-23T07:53:20.513

1The formatting is optional. Returning a pair of matrices saves at least 22 bytes. – Dennis – 2017-12-23T14:01:42.403

168 bytes with no formatting (note that 0 and False are equal in Python, so it should be OK). – Jonathan Allan – 2017-12-23T15:20:21.380

@JonathanAllan Very clever, updated. – Neil – 2017-12-23T18:05:52.437

64 bytes. If you have to make a lambda, a list comprehension's probably shorter. – totallyhuman – 2017-12-24T12:05:12.863

@totallyhuman Updated. – Neil – 2017-12-24T18:41:31.583

12

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% (and if not and someone wants to steal my proverbial cookie and fix it, so be it). With 'o' and ' ', 255 245 272 265 244 238 228 bytes. replace +48 with *79+32.

#define Q(P,R)(R>>P&1)+48
char a[11];i=0;f(char*c){char b=c[0];a[3]=a[7]='\n';a[5]=Q(0,b);a[1]=a[9]=Q(3,b);a[2]=a[8]=Q(2,b)|a[1];a[0]=a[10]=Q(1,b)|a[2];a[4]=a[6]=a[1]|Q(2,b)&Q(1,b);puts(a);if(i++<1){puts("---");f(c+1);}}

Try it online!

How it works:
I use a bit shift and bitwise and to find if a spot should be clear or a pip, then offset the 0 or 1 to the correct ASCII value. it messes up on 4 and 5, so they needed some fixing. actually added a few bytes. was able to remove several bytes by removing a mask and just using 1 (doh)

Special thanks to Mr. Xcoder for the 7 less bytes by removing an excess #define
Changes: removed memset -21 bytes. redid the bit logic for 6, 4, 2 to depend on 8|4&2, 8|4, 8|4|2, respectively. -6 bytes. removed extra newlines by using puts instead of printf, which is also shorter. shortened the array to 11, removing extra assignment. -15 bytes. NOW I think that's the best I can do.

Andrew Baumher

Posted 2017-12-23T01:15:26.700

Reputation: 351

7Welcome to PPCG! – Shaggy – 2017-12-23T09:50:08.430

Hi, welcome to PPCG! You can shorten your code a bit further, 245 bytes

– Mr. Xcoder – 2017-12-23T09:51:09.997

'\n' can be replaced by 10. (because in C, char data types are also integer data types) Some char can probably be replaced by int. (or omit entirely) – user202729 – 2017-12-23T11:44:23.527

Down to 184 bytes here but that's still more than the current c golf, so.

– Andrew Baumher – 2017-12-23T22:02:44.917

173 – Andrew Baumher – 2017-12-23T22:19:34.297

155 bytes – ceilingcat – 2019-08-22T22:26:07.747

10

Jelly, 20 bytes

“¤o.ƤẸʠṚ’B¬s5ŒBị@s€3

Try it online!

Alternate version, original output, 33 32 31 bytes

“¤o.ƤẸʠṚ’ṃ⁾ os5ŒBị@s€3K€€Zj€”|Y

Thanks to @user202729 for golfing off 1 byte!

Try it online!

How it works

First, “¤o.ƤẸʠṚ’ – an integer literal in bijective base 250 – sets the return value to 1086123479729183.

Then, converts the return value to binary and takes the logical NOT of each digit, yielding the array

00001001000010110100101011110011101111101111100000

Next, s5ŒB splits that array into chunks of length 5, then bounces each chunk, turning abcde into abcdedcba, yielding

000010000 001000100 001010100 101000101 101010101

111000111 111010111 111101111 111111111 000000000

Now, ị@ retrieves the jth and kth item of this array, where j, k is the program's first argument. Note that indexing is 1-based and modular, so the zeroth element is also the tenth.

Finally, s€3 splits each chunk of length nine into three chunks of length three.

Dennis

Posted 2017-12-23T01:15:26.700

Reputation: 196 637

1Still looks like magic to me, but I appreciate the attempt at an explanation. I will admit the fault is probably mine as I am just a lowly PHP web developer – ArtisticPhoenix – 2017-12-23T06:37:46.177

The 3 is using 0 for the pips, not 1 like all the others. – Jonathan Allan – 2017-12-23T13:28:05.787

“¤o.ƤẸʠṚ’ should work. – Jonathan Allan – 2017-12-23T13:41:37.550

@JonathanAllan Thanks! Not sure how that happened... – Dennis – 2017-12-23T13:48:44.540

8

Jelly, 13 bytes

⁽½ÑD<;ḂŒBs3µ€

Try it online!

Combining Dennis' idea of using ŒB (bounce) in this answer and Xcali's observation in this answer to get 13 bytes.


Jelly, 28 bytes

(with pretty printing)

Only now do I know that Jelly string literal is automatically terminated...

⁽½ÑD<;ḂŒBị⁾o Ks6Yµ€j“¶-----¶

Try it online!

user202729

Posted 2017-12-23T01:15:26.700

Reputation: 14 620

Apparently my approach ⁽½ÑD leads to less bytecount than EriktheOutgolfer's answer “¤¦¢¬‘ here

– user202729 – 2017-12-23T12:51:36.877

Wouldn't it be best to reorder the functions so the 13 bytes (outgolfing Dennis) is up top and can be seen more easily? – Zacharý – 2017-12-23T17:28:32.340

@Zacharý Temporary solution. Will fix it later. – user202729 – 2017-12-24T00:43:22.827

6

Perl 5, 107 76 70 + 1 (-a) = 70 bytes

Perl 5, 70 bytes

$,="
---
";say map{$_='351
7 7
153'=~s/\d/$_>$&||0/ger=~s/ /$_%2/er}<>

Try it online!

Uses 0 for whitespace and 1 for pips. Pretty simple method: observe that as the digit goes up, once a pip is "on", it never goes "off," except for the one in the middle. In the middle position, it is on for all odd numbers. Thus, for each position, it's a simple matter of checking if the digit is greater than the last digit for which it is off. The ||0 creates output when the condition is false. In Perl, false is undef which outputs as null.

Xcali

Posted 2017-12-23T01:15:26.700

Reputation: 7 671

6

PHP 155, 150 bytes

function d($a){foreach($a as$n){$o="---";for($i=0;$x=2**$i,$i<9;++$i)$o.=([0,16,68,84,325,341,365,381,495,511])[$n]&$x?0:' ';echo chunk_split($o,3);}}

It takes an array of integers as the input. For testing:

d([1,2]);

echo "=========\n";

d([0,1,2,3,4,5,6,7,8,9]);

Output Format:

---

 0 

---
  0

0  

Check it out live here

My Solution

For my solution I used a matrix consisting of bitwise numbers ( powers of 2 ). It can be visualized like this:

 1  |  2  |  4
 8  | 16  | 32
 64 | 128 | 256

And then a storage array consisting of the bit positions for the pips of each domino correlated by the numbered index:

[0,16,68,84,325,341,365,381,495,511]

So just to clarify:

  • example 0: index 0 or value 0 would be the blank domino, which is always false.
  • example 1: index 1 or value 16 would be the number one domino and in the matrix that is in the center 16.
  • example 2: index 2 or value 68 would be the number two domino and in the matrix that is top right 4 and bottom left 64 or 4|64
  • example 3: index 5 or value 341 would be the number five domino and in the matrix that is 1|4|16|64|256
  • example 4: index 9 or value 511 would be the number nine domino and in the matrix its the combination of all the bits.

Once that is established it's a fairly simple matter of looping for the 9 positions in the matrix, and setting $x to 2 to the power of $i

for($i=0;$x=2**$i,$i<9;++$i)

Then we do a bitwise And & as we iterate through those spots. So for examples sake will use example 2 from above and I will use x's instead spaces for sake of visual clarity:

  • iteration 1, 68 & 1 ? 0 : 'x' which results in 'x'
  • iteration 2, 68 & 2 ? 0 : 'x' which results in 'x'
  • iteration 3, 68 & 4 ? 0 : 'x' which results in 0
  • iteration 4, 68 & 8 ? 0 : 'x' which results in 'x'
  • iteration 5, 68 & 16 ? 0 : 'x' which results in 'x'
  • iteration 6, 68 & 32 ? 0 : 'x' which results in 'x'
  • iteration 7, 68 & 64 ? 0 : 'x' which results in 0
  • iteration 8, 68 & 128 ? 0 : 'x' which results in 'x'
  • iteration 9, 68 & 256 ? 0 : 'x' which results in 'x'

When the loop is complete we wind up with this string "xx0xxx0xx".

Then we add the border "---xx0xxx0xx" to it ( I actually start with the border, but whatever).

And finally we chunk_split() it on 3's for:

---
xx0
xxx
0xx

Feel free to let me know what you think.

ArtisticPhoenix

Posted 2017-12-23T01:15:26.700

Reputation: 329

You can shorten it even further by using the exponentiation operator ** introduced in PHP 5.6 instead of pow()

http://php.net/manual/en/language.operators.arithmetic.php

– Daniel – 2017-12-25T19:28:35.733

@Daniel - Thanks saved 5 bytes! I wasn't aware they added that, I always try to use the ^ but its the bitwise XOR ... lol – ArtisticPhoenix – 2017-12-25T19:50:44.217

I don't think you are allowed to print an extra border. – 12Me21 – 2018-01-29T16:13:46.707

show me where it even remotely hints at that in the OP. – ArtisticPhoenix – 2018-01-29T18:38:38.870

I guess this would be shorter operating on $argv. The function overhead in PHP is usually 13 bytes. – Titus – 2018-02-18T22:58:41.793

4

JavaScript (ES6), 79 78 bytes

Saved 1 byte thanks to @ETHproductions

Takes input in currying syntax (a)(b) and outputs a vertical ASCII domino.

a=>b=>(g=n=>`351
707
153`.replace(/./g,d=>' o'[(+d?n>d:n)&1]))(a)+`
---
`+g(b)

Demo

let f =

a=>b=>(g=n=>`351
707
153`.replace(/./g,d=>' o'[(+d?n>d:n)&1]))(a)+`
---
`+g(b)

console.log(f(4)(2))
console.log(f(3)(7))


Horizontal version, 80 79 bytes

Saved 1 byte thanks to @ETHproductions

Takes input as an array of 2 integers and outputs a horizontal ASCII domino.

a=>`240|351
686|797
042|153`.replace(/\d/g,d=>' o'[(d<8?(x=a[d&1])>(d|1):x)&1])

Demo

let f =

a=>`240|351
686|797
042|153`.replace(/\d/g,d=>' o'[(d<8?(x=a[d&1])>(d|1):x)&1])

console.log(f([4,2]))
console.log(f([3,7]))

Arnauld

Posted 2017-12-23T01:15:26.700

Reputation: 111 334

Nice, very similar to what I had. Save a byte with either n>d|0 or (+d?n>d:n)&1 – ETHproductions – 2017-12-23T15:52:14.477

4

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 containing two shape-3,3 arrays each containing 0s and 1s.

Erik the Outgolfer

Posted 2017-12-23T01:15:26.700

Reputation: 38 134

a rewrite for -2 bytes: 2∘|(3 3⍴⊢,,∘⌽)¨>∘3 5 1 7¨ – ngn – 2017-12-27T11:07:57.567

@ngn thanks, that's clever :p – Erik the Outgolfer – 2017-12-27T12:27:52.233

3

C (gcc), 115 bytes

i;g(x){for(i=0;++i<10;)printf("%c%c",32+(i^5?x>" CEAG@GAEC"[i]-64:x%2),i%3?32:10);}f(a,b){g(a),puts("-----"),g(b);}

Try it online!

gastropner

Posted 2017-12-23T01:15:26.700

Reputation: 3 264

113 bytes – ceilingcat – 2019-08-21T03:44:29.143

2

Javascript (ES6), 87 bytes

a=>b=>[(s=n=>[[n>3,n>5,n>1],[n>7,n%2,n>7],[n>1,n>5,n>3]].map(c=>c.map(b=>+b)))(a),s(b)]

f=a=>b=>[(s=n=>[[n>3,n>5,n>1],[n>7,n%2,n>7],[n>1,n>5,n>3]].map(c=>c.map(b=>+b)))(a),s(b)]
<div oninput="o.innerText=JSON.stringify(f(a.value)(b.value))"><input id=a type=number min=1 max=9 value=1><input id=b type=number min=1 max=9 value=1><pre id=o>

Herman L

Posted 2017-12-23T01:15:26.700

Reputation: 3 611

Nice DOMinoes... – Esolanging Fruit – 2018-01-24T19:48:34.667

2

Haskell - 88 characters

map$zipWith(zipWith($))[[(>4),(>5),(>1)],[(>7),odd,(>7)],[(>1),(>5),(>3)]].repeat.repeat

Takes a list of two numbers indicating the faces, returns a list of list of list of bool. Not that short but I find the solution interesting.

Geoff Reedy

Posted 2017-12-23T01:15:26.700

Reputation: 2 828

You can just use map instead of repeat and zipWith: map$(<$>[[(>4),(>5),(>1)],[(>7),odd,(>7)],[(>1),(>5),(>3)]]).map.flip($)Try it online!

– Laikoni – 2017-12-27T11:20:34.833

Non-pointfree saves two more bytes: Try it online!

– Laikoni – 2017-12-27T11:38:50.093

2

Pip, 32 27 24 21 bytes

-3 bytes thanks to @DLosc

FcgP[Yc>_M3517c%2RVy]

Try it online!

Explanation:

F                      For each
 c                       character $c
  g                      in the list of inputs:
   P                     Print
    [               ]      an array consisting of
                             an array of bits representing whether
      c>                       $c is greater than
        _M                       each of
          3517                     3, 5, 1, and 7
     Y                       (call this bit array $y),
              c%2            $c mod 2,
                 RV          and the reverse
                   y           of $y.

Esolanging Fruit

Posted 2017-12-23T01:15:26.700

Reputation: 13 542

1Congratulations on winning the Pip bounty! Now that the bounty period is over, I can tell you: save 3 bytes by mapping to a scalar 3517 instead of a list [3 5o7]. ;) – DLosc – 2018-01-29T19:35:28.760

1

Charcoal, 46 44 43 39 bytes

EE²℅§@APQTUVW^_NE⪪E⁹§ o÷ιX²↔⁻⁴λ³⪫λ M⁵↑⁵

Try it online! Link is to verbose version of code. Explanation:

EE²℅§@APQTUVW^_N

Read two integers and map them in the lookup table. Then map over the result. (This effectively captures the result in a temporary.)

  E⁹                Loop `l` (!) from 0 to 8
            ⁻⁴λ     Subtract from 4
           ↔        Absolute value
         X²         Power of 2
       ÷ι           Divide into the looked-up value `i`
    § o             Convert to space or o
 ⪪             ³    Split into (3) groups of 3
E                   Map over each group
                ⪫λ  Join the 3 characters with spaces

The results are then implicitly printed on separate lines, with an extra blank line between each face because the results are nested.

M⁵↑⁵

Move up and draw the dividing line in between the faces.

Previous 43-byte horizontal version:

↶P³M⁷←FE²℅§@APQTUVW^_NF⁹«F¬﹪κ³⸿⸿§ o÷ιX²↔⁻⁴κ

Try it online! Link is to verbose version of code. Explanation:

Work vertically.

P³

Print the dividing line.

M⁷←

Position to the start of the first face.

FE²℅§@APQTUVW^_N

Read two integers and map them in the lookup table.

F⁹«

Prepare to output up to 9 os.

F¬﹪κ³⸿⸿

But start a new column every three os.

§ o÷ιX²↔⁻⁴κ

Convert the lower 5 bits of the ASCII code to binary, and then mirror the output for the remaining 4 os.

Neil

Posted 2017-12-23T01:15:26.700

Reputation: 95 035

The output format is rather liberal, which should save a few bytes. – Dennis – 2017-12-23T02:38:05.333

1What is this witchcraft – ArtisticPhoenix – 2017-12-23T02:47:19.390

@Dennis Actually the original output format is the most helpful, as it automatically gives me room to draw the dividing line. – Neil – 2017-12-23T12:08:22.720

Oh god, there are two Neils. – Zacharý – 2017-12-23T17:19:51.683

2@Zacharý Actually according to the user page there are eight, or 40 if you include people whose names contain Neil... – Neil – 2017-12-23T19:37:44.903

You both answered the same question ... o_o – Zacharý – 2017-12-23T20:31:28.310

@Dennis OK you win, I found out a way to leave a gap when printing horizontally which lets me save a few bytes. – Neil – 2017-12-31T10:49:32.497

(I mean vertically don't I. Anyway, I found a slightly more idiomatic formulation.) – Neil – 2017-12-31T16:00:59.860

1

><>, 57+3 = 60 bytes

>{:3)$:5)$:1)$:7)$:2%$\ao \
\?%cl999)3$)5:$)1:$)7:/nnn<rp

Try It Online. Outputs as a vertical domino with 1s for dots, 0s for whitespace and 9s for separators like so:

001
000
100
999
111
111
111

Technically this can be extended to up to 12 inputted values.

Old Version:

><>, 76+3 = 79 bytes

>{:3)$:5)$:1)$a$:7)$:2%$:7)\&?o~?!n\
\?(*a3la"---"a)3$)5:$)1:$a$/$&:)9::<r~p

Try It Online. Outputs as a vertical domino with 1s for dots and 0s for whitespace like so:

001
000
100
---
111
111
111

Jo King

Posted 2017-12-23T01:15:26.700

Reputation: 38 234

1

Jelly, 16 bytes

>⁽¤xb8¤;ḂŒḄs3
Ç€

Try it online!

Used Neil's strategy and base decompression to generate the values; outputs as a binary array. Takes a list as input.

Explanation:

Ç€
 € for €ach input,
Ç  execute the previous line.

>⁽¤xb8¤;ḂŒḄs3
 ⁽¤xb8¤       the array [3, 5, 1, 7]
>             1 if the input is greater than each element, 0 otherwise
       ;Ḃ     append input % 2
         ŒḄ   bounce array
           s3 split into chunks of 3

ellie

Posted 2017-12-23T01:15:26.700

Reputation: 131

0

APL+WIN, 49 47 bytes

4⌽'|',⌽⍉6 3⍴,⍉(9⍴2)⊤(+\∊0 241 52 24 114,¨16)[⎕]

Edited as per Adam's comment, thanks, to run with index origin zero.

Prompts for screen input as a vector of integers one for each face.

The output is of the form:

1 1 1 | 0 0 1    0 0 0 | 1 0 1
0 1 0 | 0 1 0    0 0 0 | 0 1 0
1 1 1 | 1 0 0    0 0 0 | 1 0 1

for an inputs of 7 3 and 0 5

Explanation:

(+\∊0 241 52 24 114,¨16) create a vector of integers whose binaries
                         represent the dots on the domino faces

[1+⎕] take input integers as indices to select from above vector

⍉6 3⍴,⍉(9⍴2)⊤ convert selected integers to a 9x2 binary matrix and reshape
              to match the orientation of the domino faces

4⌽'|',⌽ rotate, concatenate centre line markers and rotate again to centre 

Graham

Posted 2017-12-23T01:15:26.700

Reputation: 3 184

Why not use ⎕IO←0 to save yourself the 1+? – Adám – 2017-12-24T11:07:24.820

@Adam Why not indeed - lazy ;) – Graham – 2017-12-24T11:29:52.547

0

C (gcc), 150 146 bytes

p(b){printf(" %c",33-b);}P(a){p(a<4),p(a<6),p(a<2),p(23),p(a<8),p(~a&1),p(a<8),p(23),p(a<2),p(a<6),p(a<4),p(23);}f(a,b){P(a),puts(" -----"),P(b);}

Try it online!

Jonathan Frech

Posted 2017-12-23T01:15:26.700

Reputation: 6 681

@ceilingcat Thank you. – Jonathan Frech – 2019-08-25T10:33:28.627

0

Python 2, 121 bytes

lambda x,y,d="001155777702020202570044557777":[("%03d"%int(bin(int(o))[2:]),"---")[o=="3"]for o in d[x::10]+"3"+d[y::10]]

Try it online!

Reduced to 121 using a lambda after going back and re-reading the rules. Now outputs a list of lines.

Previous version with nicely formatted output:

Python 2, 156 153 147 141 bytes

x,y=input()
d="001155777702020202570044557777"
a=["%03d"%int(bin(int(o))[2:])for o in d[x::10]+d[y::10]]
for x in a[:3]+["---"]+a[3:]:print x

Try it online!

-3 with thanks to @NieDzejkob

Takes input as 2 integers and outputs in vertical format with 0=space and 1=dot.

ElPedro

Posted 2017-12-23T01:15:26.700

Reputation: 5 301

153 bytes – NieDzejkob – 2017-12-24T08:17:57.200

0

Pyt, 220 154 bytes

Second attempt (154 bytes)

46281ᴇ8264áĐ9ř3%¬Đ¬2⁵*⇹1ᴇ*+03Ș←Đ3Ș≥Đ6²⁺3**⇹¬2⁵*+⇹9ř5=⇹2%*9²2-*+⇹9ř9<*Ž⇹ŕ⇹9ř3%¬Đ¬2⁵*⇹1ᴇ*+03Ș←Đ3Ș≥Đ6²⁺3**⇹¬2⁵*+⇹9ř5=⇹2%*9²2-*+⇹9ř9<*Ž⇹ŕ5⑴9△*Ƈǰ⇹Ƈǰ64ȘƇǰ6↔ŕ↔ŕ↔

Explanation:

46281ᴇ8264áĐ                                    Pattern matching for every cell but the middle
9ř3%¬Đ¬2⁵*⇹1ᴇ*+03Ș                              Non-pip characters
←Đ3Ș≥Đ6²⁺3**⇹¬2⁵*+⇹9ř5=⇹2%*9²2-*+⇹9ř9<*Ž⇹ŕ⇹     Make top cell
9ř3%¬Đ¬2⁵*⇹1ᴇ*+03Ș                              Non-pip characters
←Đ3Ș≥Đ6²⁺3**⇹¬2⁵*+⇹9ř5=⇹2%*9²2-*+⇹9ř9<*Ž⇹ŕ      Make bottom cell
5⑴9△*Ƈǰ⇹Ƈǰ64ȘƇǰ6↔ŕ↔ŕ↔                          Make boundary and combine



First attempt (220 bytes):

2`↔←Đ4≥Đ6²⁺3**⇹¬5«+2⁵⇹3ȘĐ6≥Đ6²⁺3**⇹¬5«+2⁵⇹3ȘĐ2≥Đ6²⁺3**⇹¬5«+1ᴇ⇹3ȘĐ8≥Đ6²⁺3**⇹¬5«+2⁵⇹3ȘĐ2%Đ6²⁺3**⇹¬5«+2⁵⇹3ȘĐ8≥Đ6²⁺3**⇹¬5«+1ᴇ⇹3ȘĐ2≥Đ6²⁺3**⇹¬5«+2⁵⇹3ȘĐ6≥Đ6²⁺3**⇹¬5«+2⁵⇹3Ș4≥Đ6²⁺3**⇹¬5«+1ᴇ9△ĐĐĐĐ1ᴇ↔⁻łŕ↔ŕŕŕŕŕŕáƇǰ

Explanation:

2                           Push 2 (this is how many 'cells' to make)
`     ... ł                 While the top of the stack is not zero, loop
↔                           Flip the stack (useless at the beginning, undoes the flip at the end of the loop)
←Đ4≥Đ6²⁺3**⇹¬5«+            Set top-left pip
2⁵⇹3Ș                       Space
Đ6≥Đ6²⁺3**⇹¬5«+             Set top-middle pip
2⁵⇹3Ș                       Space
Đ2≥Đ6²⁺3**⇹¬5«+             Set top-right pip
1ᴇ⇹3Ș                       New line
Đ8≥Đ6²⁺3**⇹¬5«+             Set middle-left pip
2⁵⇹3Ș                       Space
Đ2%Đ6²⁺3**⇹¬5«+             Set center pip
2⁵⇹3Ș                       Space
Đ8≥Đ6²⁺3**⇹¬5«+             Set middle-right pip
1ᴇ⇹3Ș                       New line
Đ2≥Đ6²⁺3**⇹¬5«+             Set bottom-left pip
2⁵⇹3Ș                       Space
Đ6≥Đ6²⁺3**⇹¬5«+             Set bottom-middle pip
2⁵⇹3Ș                       Space
4≥Đ6²⁺3**⇹¬5«+              Set bottom-right pip
1ᴇ                          New line
9△ĐĐĐĐ                      Add 5 dashes
1ᴇ                          New line
↔⁻ł                         Decrement counter (if >0, loop; otherwise, exit loop)
ŕ↔ŕŕŕŕŕŕ                    Remove all unnecessary items on the stack
áƇǰ                         Push stack to an array, get characters at unicode codepoints given by values in the array, join characters with empty string


Try it online!

mudkip201

Posted 2017-12-23T01:15:26.700

Reputation: 833

0

05AB1E, 34 bytes

•ΩõIº•R2ô¹2÷è¹È-bDg5s-ú.∞3ô»TR„ o‡

Try it online!


This was difficult because 05AB1E has bad padding.


Basic explanation:

  • There are 4 significant patterns here which are 2, 4, 6 and 8.
  • 3,5,7 and 9 are the other patterns plus 1.
  • 1 is not significant due to symmetry, if the input is even, subtract 1 to toggle the middle bit.
  • Toggling the LSB allows the middle bit to be flipped due to mirroring.

Magic Octopus Urn

Posted 2017-12-23T01:15:26.700

Reputation: 19 422

0

SmileBASIC, 92 69 bytes

INPUT N,M
DEF Q?N>3;N>5;N>1?N>7;1AND N;N>7?N>1;N>5;N>3
END
Q?777N=M
Q

Example:

? 7,2
111
010
111
777
001
000
100

This is what happens when your rules aren't strict enough.

12Me21

Posted 2017-12-23T01:15:26.700

Reputation: 6 110

0

FALSE, 116 80 78 70 69 66 63 61 59 58 bytes

[$3[>_$.\$]$p:!5p;!1p;!"
"7p;!%1&.."
"..."
"]$s:!"---
"s;!

still working on this...

12Me21

Posted 2017-12-23T01:15:26.700

Reputation: 6 110

0

Chip, 142 135 bytes

! CvDvB
>v-]-x.
|Z-]-]e
|Z]xe|
|ZR(-'
|Zx.AD
|Zxx]x.
|Zx^-]e
|Z<,(-.
|Zx]xe|
|Zx-]-]e
|Zx-]-x'
|Z<C^D^B
|>x~s
|Zx.
|Zx<
|Zxb
|Z+^~f
`zd

Try it online!

Input is a string of digits. Uses zeroes as the pips. Draws the pips for one number, reads next input byte. If no next byte, terminate, else draw the divider and go to start.

Each Z (or z) corresponds to one character of output, they are positioned to fire in order top to bottom. The capitalized A, B, C, and D correspond to the low four bits of the input (that's all we look at, so "34" == "CD" == "st" ...). The lowercase b, d, e, f correspond to various bits of the output.

Can make infinite-length dominoes too; try giving 0123456789 as input.

Phlarx

Posted 2017-12-23T01:15:26.700

Reputation: 1 366

0

PHP, 116 bytes

while($i<6)echo strtr(sprintf("%03b",[_011557777,_202020267,_044557777][$i/2][$argv[$i%2+1]]),10,"o "),"|
"[$i++%2];

requires PHP 5.5 or later. Run with -nr or try it online.

Titus

Posted 2017-12-23T01:15:26.700

Reputation: 13 814