# 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!

• May we take the input as 0-indexed? Like, 0 -> 4, 7, 10? – Mr. Xcoder Dec 29 '17 at 21:20
• @Mr.Xcoder sorry, this time I'm going to say no. – Charlie Dec 29 '17 at 21:26
• Is this the fourth challenge now based on some activity involving your kids? :P – FlipTack Dec 29 '17 at 21:58
• @FlipTack Perhaps we need an inspired-by-kids tag ;) – Steadybox Dec 29 '17 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... – Charlie Dec 29 '17 at 22:17

# 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

: 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!

# Wolfram Language (Mathematica) 20 bytes

Mod[#+{3,6,9},12,1]&


The normal modulus operation, threaded over a list, offset by 1.

Try it online!

# Husk, 8 bytes

tĊ3ṙḣ12←


Try it online!

# 05AB1E, 8 bytes

ƵžS+12%>


At the time of writing this, this submission has the lowest score submitted. Technically I am winning!

Try it online!

# How?

ƵžS                   # Push the list [2, 5, 8]
+                  # Add the input to each number
12%               # Mod each result by 12
>              # Increment each
# And print the ending list implicitly!


See this tip of Kevin to know why Ƶž is 258!

# 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}


# 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}}