# Output the hours at 90 degrees

Today while playing with my kids I noticed that an apparently simple toy in the park hid a challenge.

The wheel has a triangle that points to a number, but also has three circles that point to the numbers every 90 degrees from the first one. So:

Challenge (really simple)

Given an integer between 1 and 12 (the one pointed by the triangle) in any acceptable form, output also in any acceptable form and order the three numbers pointed by the circles (the ones every 90 degrees).

Test cases

In       Out
1        4, 7, 10
2        5, 8, 11
3        6, 9, 12
4        7, 10, 1
5        8, 11, 2
6        9, 12, 3
7        10, 1, 4
8        11, 2, 5
9        12, 3, 6
10       1, 4, 7
11       2, 5, 8
12       3, 6, 9


This is , so may the shortest code for every language win!

• @Mr.Xcoder sorry, this time I'm going to say no. Dec 29, 2017 at 21:26
• Is this the fourth challenge now based on some activity involving your kids? :P Dec 29, 2017 at 21:58
• @FlipTack Perhaps we need an inspired-by-kids tag ;) Dec 29, 2017 at 22:13
• @FlipTack I've lost count. :-) But given that I spent most of my free time with my kids, guess where does my inspiration come from... Dec 29, 2017 at 22:17
• @Steadybox That would be a meta tag, which is BAD. But yes, we do. (Perhaps a meta question with links would suffice?) Jan 1, 2018 at 10:32

# PowerShell, 30 bytes

param($a)2,5,8|%{($_+$a)%12+1}  Try it online! Port of the other answers (e.g., xnor's Python 2 answer). Ho-hum. # Octave, 23 bytes @(x)mod(x+[2 5 8],12)+1  Try it online! Takes the same approach as most others; and it is golfier than Tom Carpenter's somewhat more unique solution. # Pyt, 12 11 bytes 258á←+26*%⁺  Explanation: 258 Pushes 2,5,8 onto the stack á Converts the stack to an array, and pushes the array onto the now-empty stack ←+ Adds input to [2,5,8] 26*%⁺ Mod 12 plus 1 (the 'plus 1' allows for '12' to be output)  Try it online! # Tcl, 45 bytes proc R i {lmap c {2 5 8} {expr ($i+$c)%12+1}}  Try it online! Different approach using the command line arguments: # Tcl, 39 bytes time {puts [expr [incr argv 3]%12+1]} 3  Try it online! # Forth (gforth), 39 bytes Input is taken from the stack and output is placed on the stack : a 2 + 12 mod 1+ ; : f a dup a dup a ;  Try it online! ### Explanation  : a 2 + 12 mod 1+ ; \ helper word to handle adding the hours 2 + \ Add 2 to the input 12 mod \ get the result modulo 12 1+ \ add 1 : f a dup a dup a ; \ word that calculates and outputs the result a dup \ add 3 hours to the input and then duplicate the result a dup \ add 3 hours to the duplicate then duplicate the result a \ add 3 hours to the duplicate  # Java 8, 46 45 bytes n->new int[]{1-~-~n%12,(5+n)%12+1,(8+n)%12+1}  -1 byte thanks to @ceilingcat. Try it online. # Perl 5-a, 27 bytes say+($_+"@F")%12+1for 2,5,8


Try it online!

# Husk, 8 bytes

tĊ3ṙḣ12←


Try it online!

# x86-16 machine code, 12 bytes

00000000: b903 0004 02d4 0c40 aae2 f8c3              ...........


Listing

B9 0003     MOV  CX, 3          ; loop counter CX = 3
CLOOP:
04 02       ADD  AL, 2          ; AL = AL + 2
D4 0C       AAM  12             ; AL = AL % 12
40          INC  AX             ; AL = AL + 1
AA          STOSB               ; [DI++] = AL
E2 F8       LOOP CLOOP          ; if --CX > 0 goto CLOOP


Callable function, input in AL, output to buffer at [DI].

# Piet + ascii-piet, 45 bytes (5×18=90 codels)

tAaaqreeumccsqqqijlVa rbiqaaueljnvea?_ t?B tt


Try Piet online!

My looping template is getting weirder and weirder... :P

inN 4    [n 4]; force toggle CC at the exit of 4 region
Loop:
dup CC+    [n flag] switch CC on 3rd iteration so it will exit after the loop
2 1 roll   [flag n]
2 +        [flag n+2]
3 dup dup * + %  [flag (n+2)%12]
1 + d outN [flag next_n] compute and print the next number
1 outC     [flag next_n] print the separator (ASCII 1)
2 1 roll   [next_n flag]
2 /        [next_n flag/2] divide flag by 2; flag becomes odd after two loops


# Wolfram Language (Mathematica) 35 bytes

Range@12~RotateLeft~#~Take~{3,9,3}&


The above asserts, in infix notation, what can be expressed more clearly as

Function[Take[RotateLeft[Range[12],Slot[1]],List[3,9,3]]]


RotateLeft rotates Range[12], the sequence 1,2,...12, leftward by the input number. Slot[1] or # holds the input number, n.

For example, with n = 4,

Function[RotateLeft[Range[12],4]]]


returns the list

{5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4}


Take...{3,9,3} returns every third element in that list from position 3 through position 9, namely

{7, 10, 1}

• 34 bytes Dec 31, 2017 at 2:20

# Windows Batch, 137 125 111 68 bytes

@set/ab=(%1+2)%%12+1,c=(%1+5)%%12+1,d=(%1+8)%%12+1
@echo %b% %c% %d%


Port of the add value to input and mod 12 + 1

# Ruby, 29 bytes

->n{3.times{p 12+(n+=3)%-12}}


# J, 24 bytes

{&((,])}.i.13)@+&(2 5 8)


Try it online!

# Stax, 8 bytes

äÆL6C╪Θ♪


Run and debug it

### Approach

3 times:

An anonymous worksheet function that takes input from cell A1 and returns a 1x3 spilled array beginning at the calling cell.
=MOD(A1+{2,5,8},12)+1