40
\$\begingroup\$

Display the 12 numbers on a clock face exactly like this:

           12            
     11           1      

 10                   2  


9                       3


  8                   4  

      7           5      
            6            

To better see the grid, here's one with dots:

...........12............
.....11...........1......
.........................
.10...................2..
.........................
.........................
9.......................3
.........................
.........................
..8...................4..
.........................
......7...........5......
............6............

Note that the grid is stretched in width by a factor of two to make it look more square.

Also note that two-digit numbers are aligned with their ones digit in place. The 9 digit should be flush against the left.

Return or print the result as a multiline string (not a list of lines). Any trailing spaces are optional. The final newline also optional.

\$\endgroup\$

37 Answers 37

1
2
1
\$\begingroup\$

Perl 6, 116 bytes

my@a=["  "xx 13]xx 13;($_=pi/6*++$;@a[0+|6*(1.1-.cos);0+|6*(1.1+.sin)]=fmt ++$: "%2s")xx 12;@a>>.join>>.&{say S/.//}

Try it online!

(Ta @JoKing for saving 26 bytes)

Perl 6, 142 bytes

my@a=[[[32,32]xx 13]xx 13];for 1..12 {$_=$^b*pi/6;@a[round 6*(1-.cos);round 6*(1+.sin)]=[" $b".ords.tail(2)]}
{say S/^.//}(.[*;*].chrs) for @a

Try it online!

I wanted to do something... different. So this one calculates the positions of all the digits, via pairs of characters, strips off the initial space and prints the lines.

Easily modifiable for different parameters, e.g. a 45 character wide version with 17 digits.

\$\endgroup\$
2
  • \$\begingroup\$ 116 bytes \$\endgroup\$ – Jo King Aug 31 '18 at 5:53
  • \$\begingroup\$ @JoKing: Ta, I've pasted that in & made it a wiki. \$\endgroup\$ – Phil H Aug 31 '18 at 7:50
1
\$\begingroup\$

Deadfish~, 290 bytes

{iii}ii{c}c{ii}dddcic{dddd}c{ii}iiccccc{ii}dddcc{dd}iii{c}c{ii}dddc{dddd}icc{ii}iic{ii}dddcdc{d}dddddd{c}ccccccccc{ii}ddc{dddd}ccc{iiiii}dddc{dd}ddddd{cc}ccc{ii}dc{dddd}dccc{ii}iicc{ii}iiiic{dd}dddd{c}ccccccccc{ii}c{dddd}ddcc{ii}iicccccc{ii}iiic{dd}ddd{c}c{ii}ic{dddd}dddc{ii}ii{c}cc{ii}iic

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Canvas, 49 bytes

12∙11∙17«1╋¶10∙2‾⁶2╋¶¶9∙3‾⁹3╋¶¶8∙4‾⁵3╋¶7∙5‾¹2╋6)r

Try it here!

\$\endgroup\$
0
\$\begingroup\$

Perl 5, 73 bytes

Port of Arnauld's answer.

say"K12
E11K1

A10S2


9W3


B8S4

F7K5
L6"=~s,[A-Z]," "x(ord($&)-64),erg

Try it online!

As a one-liner:

perl -E'say"K12\nE11K1\n\nA10S2\n\n\n9W3\n\n\nB8S4\n\nF7K5\nL6"=~s,[A-Z]," "x(ord($&)-64),erg'

Another approach, but longer:

map$s.=$_%26?{12,12,32,11,44,1,80,10,100,2,157,9,181,3,237,8,257,4,293,7,
305,5,325,6}->{$_}||" ":"\n",1..338;
say$s
\$\endgroup\$
0
\$\begingroup\$

Python, 99, 91

print"%13d\n%7d%12d\n\n%3d%20d\n\n\n9%24d\n\n\n%3d%20d\n\n%7d%12d\n%13d"%(12,11,1,10,2,3,8,4,7,5,6)

print"""%13d
%7d%12d

%3d%20d


9%24d


%3d%20d

%7d%12d
%13d"""%(12,11,1,10,2,3,8,4,7,5,6)

Thanks to Jo King

Spaces hardcoded in -- I'm sure its possible to golf the \ns down, by repeating but I don't know how...

\$\endgroup\$
1
0
\$\begingroup\$

Javascript, 93 bytes

console.log((

_=>`F 12
A11F 1

 10FE2


9FCB3


  8FE4

B7F 5
AC6`.replace(/[A-F]/g,c=>''.padEnd('0x'+c-5))

)())

Port of Arnauld's answer to general JS

\$\endgroup\$
0
\$\begingroup\$

05AB1E, 47 42 bytes

•1)âÝÈ݉ʒ%и&ñjÓU‰÷JêĆ+•₆B'X¶:AuðAuÇ31&ׇ.c

Try it online!

•...•₆B'X¶:AuðAuÇ31&ׇ.c  # trimmed program
•...•                     # push 1902039976984631753317213270923121051329258518010...
      B                   # in base...
     ₆                    # 36...
          :               # with all...
       'X                 # literal...
          :               # s replaced by...
         ¶                # newline...
          :               # s...
                     ‡    # with each...
           Au             # letter...
                     ‡    # replaced by the corresponding...
              Au          # letter...
                Ç         # 's codepoint...
                   &      # bitwise and...
                 31       # literal...
             ð            # " "...
                    ×     # s...
                      .c  # with each line centered more to the left
                          # implicit output
\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.