g | x | w | all
Bytes Lang Time Link
069SAKO250325T184026ZAcrimori
045Tcl171230T014019Zsergiol
024Desmos250219T023356ZDesmosEn
045C gcc250218T011846ZWeird Gl
034AWK241105T191617Zxrs
009Japt171230T155109ZShaggy
nanPiet + asciipiet220702T232925ZnaffetS
nanPiet + asciipiet220705T020734ZBubbler
009Nekomata230716T060440Zalephalp
008Thunno 2230715T165119ZThe Thon
012x8616 machine code220219T025332Z640KB
008Vyxal220219T041309Za stone
021Excel + Google Sheets Polyglot220219T032716ZTaylor R
008Stax220219T013259Zrecursiv
024J220219T011242Zsinvec
00805AB1E201128T183817ZSunnyMoo
008Husk201128T020444ZRazetime
020Wolfram Language Mathematica201127T184246ZFarSeenN
027Perl 5 a201127T204617ZXcali
045Java 8180104T121218ZKevin Cr
039Forth gforth180124T181902Zreffu
012Pyth180105T185331ZDave
029Ruby180104T125819ZG B
011Pyt171231T033252Zmudkip20
023Octave180103T181129ZGiuseppe
084BrainFlak180103T172730ZMegaTom
030PowerShell180102T185646ZAdmBorkB
030Perl 5180102T142421Zmik
094face180101T014338ZDoorknob
371PHP171231T222134ZTitus
023Perl 6171231T202806ZSean
046GolfScript171231T184033ZQunSyBer
068Windows Batch171231T120220Zstevefes
035Wolfram Language Mathematica171230T193410ZDavidC
012APL Dyalog171230T184636ZUriel
011K oK171230T181800Zmkst
013APL+WIN171229T221717ZGraham
030Swift171230T115232ZEndenite
025Octave171230T113930ZTom Carp
042C# .NET Core171230T104755ZAyb4btu
018Befunge93171230T020500ZJames Ho
029Haskell171230T002919Ztotallyh
029JavaScript ES6171229T232659ZArnauld
028R171229T213137ZSteadybo
009MATL171229T223552ZLuis Men
012Pushy171229T213555ZFlipTack
044Clean171229T213824ZΟurous
008Jelly171229T211457ZJonathan
009SOGL V0.12171229T212811Zdzaima
033Python 3171229T211606Zxnor
035Python 2171229T210949Znotjagan
048C gcc171229T210859ZSteadybo

SAKO, 69 bytes

PODPROGRAM:F(N)
*)DRUKUJ(0):MOD(ENT(I),12)+1
POWTORZ:I=N+2(3)N+8
WROC

Full programme version, 71 bytes

CZYTAJ:N
*1)DRUKUJ(0):MOD(ENT(I),12)+1
POWTORZ:I=N+2(3)N+8
STOP1
KONIEC

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, 41 bytes

time {puts [expr [incr argv 3]%-12+12]} 3

Try it online!

Desmos, 24 bytes

f(x)=mod(x+[2,5,8],12)+1

Adds 3,6,9 to the hour you give f(x), then takes that mod 12 (plus some transformations to make it 1 - indexed).

Try it on Desmos!

C (gcc), 45 bytes

f(n){for(;n<43;printf("%d ",n%12?:12))n+=15;}

Try it online!

Based on Steadybox's answer. Modular arithmetic is nice sometimes :)

AWK, 33 bytes

{for(;i++<3;print$1++%12+1)$1+=2}

Try it online!

Based on xrs' answer.

AWK, 34 bytes

{for(;i++<3;)print($1-1+i*3)%12+1}

Try it online!

Japt, 11 9 bytes

3Ʊ3 %CªC

Try it

3Ʊ3 %CªC     :Implicit input of integer U
3Æ            :Map the range [0,3)
  ±3          :  Increment U by 3
     %C       :  Modulo 12
       ªC     :  Logical OR with 12

Piet + ascii-piet, 62 bytes (46×2=92 codels)

TABdDTvVvVnNNFJAQUiIiIIAeEeEuUUMTJBCSBvVvVNMLnNnNfFFVBQIMEiCcc

Try Piet online!

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

Nekomata, 9 bytes

12Rᶠ{-Z3¦

Attempt This Online!

12Rᶠ{-Z3¦
12R         [1,2,...,12]
   ᶠ{       Filter by
     -          Subtract the input
      Z         Check if the result is non-zero
       3¦       Check if the result is divisible by 3

Nekomata, 10 bytes

258¢D+12%→

Attempt This Online!

258¢D+12%→
258¢D       Decimal digits of 258
     +      Add
      12%   Modulo 12
         →  Increment

Thunno 2, 8 bytes

ṇɗd+12%⁺

Try it online!

Explanation

ṇɗd+12%⁺  # Implicit input
ṇɗ        # Push compressed integer 258
  d+      # Add [2,5,8] to input
    12%   # Mod each by 12
       ⁺  # Increment each
          # Implicit output

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
C3          RET                 ; return to caller

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

Vyxal, 8 bytes

⁺ẇf+12%›

Try it online! (All test cases)

Port of SunnyMoon's 05AB1E solution

How it works:

⁺ẇf+12%›
⁺ẇ        The number 258
  f       ...as a list of digits ⟨ 2 | 5 | 8 ⟩
   +      Add the input to each
    12%   Mod-12 each
       ›  Increment each
          (implicit output)

Excel + Google Sheets Polyglot, 21 Bytes

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

Stax, 8 bytes

äÆL6C╪Θ♪

Run and debug it

Approach

3 times:
    add 2
    mod 12
    add 1
    print current value

J, 24 bytes

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

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!

Husk, 8 bytes

tĊ3ṙḣ12←

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!

Perl 5 -a, 27 bytes

say+($_+"@F")%12+1for 2,5,8

Try it online!

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.

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 

Pyth, 12 bytes

%R12+LQ*R3S3    

Try it online!

Ruby, 29 bytes

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

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!

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.

Brain-Flak, 84 bytes

(()()()){({}<(()(){})(((()()()){}){}<>){(({})){({}[()])<>}{}}<>(([{}]{})<>)>[()])}<>

Try it online!

At least I beat Doorknob's face solution...

Explanation:

LOOP 3 TIMES: (()()()){({}<

  n += 2:
   (()(){})
  push 12:
   (((()()()){}){}<>)
  n mod 12 + 1; pushing to both stacks:
   {(({})){({}[()])<>}{}}<>(([{}]{})<>)

END LOOP: >[()])}<>

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.

Perl 5, 30 bytes

sub{map{($_+$_[0])%12+1}2,5,8}

Try it online!

face, 96 94 bytes

(%d
@)\$*,c'$ooiim%*m1*6%+%%%11m!*mn*m~*3!m&!r!&!is!&$pn3!:L+nn1+nn1%nn%+nn1p~>$inw~>~o-!!1?!L

This simply adds two, mods by 12, adds one more, and prints. Then it does that two more times.

Commented version:

(%d
@)

\$*,c'$ooii     ( store format string in $, ip in *, get stdin/out )
m%*m1*6%+%%%11  ( initialize constants, %=12, 1=1 )
m!*mn*m~*       ( malloc space for a counter, input var, and length )
3!m&!r!&!i      ( read into & )
s!&$pn          ( scan into n )
3!:L            ( start of main loop, executed thrice )
  +nn1+nn1      ( add 2 to n )
  %nn%+nn1      ( mod by 12 and add 1 more )
  p~>$in        ( sprintf n into > )
  w~>~o         ( output to stdout )
  -!!1          ( decrement counter )
?!L             ( conditional jump back to loop start )

Try it online! (The trailing newline is required on TIO due to a bug that's been fixed in a newer version of face.)

PHP, 37+1 bytes

while($i++<3)echo(~-$argn+=3)%12+1,_;

Run as pipe with -nR or try it online.

Perl 6, 23 bytes

{map ($_+*)%12+1,2,5,8}

Try it online!

GolfScript, 46 bytes

~13,1>:x?:y;0:i;x y 3+12%=x y 6+12%=x y 9+12%=

This is the first time I'm doing code golf, so with my lack of experience I've probably not found the best solution, but I need to start somewhere, right?

Try it online or try all cases

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

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}

APL (Dyalog), 12 bytes

1+12|2 5 8∘+

Try it online!

K (oK), 11 bytes

Solution:

1+12!2 5 8+

Try it online!

Examples:

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

Explanation:

This was the first solution that came to mind. Might not be the best or shortest.

1+12!2 5 8+ / the solution
     2 5 8+ / add 2, 5 and 8 to the input
  12!       / apply modulo 12 to the results
1+          / add 1

APL+WIN, 13bytes

(⎕⌽⍳12)[3×⍳3]

Explanation:

⎕ Prompt for screen input of indicated time t

⍳12 Create a vector of integers from 1 to 12

⌽ Rotate the vector by t elements front to back

[3×⍳3] Select 3rd, 6th and 9th elements.

Swift, 30 bytes

{n in[2,5,8].map{($0+n)%12+1}}

Try it online!

Port of many other answers to Swift

Octave, 25 bytes

@(x)[a=1:12 a](3+x:3:9+x)

Try it online!

Fairly simple anonymous function.

We first create an array of [1:12 1:12] - so two copies of the full number set. Then we index in to select the values of x+3, x+6, x+9, where x is the number input.

Octave is 1-indexed, so we can simply select the array elements based on the input (although to be honest 0-indexed would use the same number of bytes here).

This seems to use a method that is unique to the other answers in that by having two copies of the array, we don't have to wrap the indices using modulo.

C# (.NET Core), 42 bytes

h=>new[]{(2+h)%12+1,(5+h)%12+1,(8+h)%12+1}

Try it online!

Essentially just a port of many of the other answers to C#.

Befunge-93, 20 19 18 bytes

852<_@#:.+1%+66+&p

Try it online!

Explanation

852                   Push 8, 5 and 2 onto the stack - the offsets we're going to add.
   <                  Reverse direction, and start the main loop.
852                   Push 2, 5, and 8 onto the stack, but we don't actually want these.
                 p    So we use a "put" operation to drop the top three values.
                &     Read the hour from stdin.
               +      Add it to the topmost offset.
         +1%+66       Mod 12 and add 1 to get it in the range 1 to 12.
        .             Then output the result to stdout.
    _@#:              Exit if the next offset is zero (i.e. nothing more on the stack).
   <                  Otherwise start the main loop again. 

This relies on behaviour specific to the reference interpreter: on end-of-file, the & operator returns the last value that was read. That's why we can safely re-read the hour from stdin on each iteration of the loop.

Haskell, 29 bytes

-2 bytes thanks to Laikoni.

f n=[mod(n+i)12+1|i<-[2,5,8]]

Try it online!

Not very original, no...

JavaScript (ES6), 29 bytes

Similar to xnor's answer.

n=>[2,5,8].map(k=>(n+k)%12+1)

Demo

let f =

n=>[2,5,8].map(k=>(n+k)%12+1)

for(n = 1; n <= 12; n++) {
  console.log(n + ' -> ' + f(n));
}

R,  29  28 bytes

Thanks to @Giuseppe for saving a byte!

function(n)(n+1:3*3-1)%%12+1

Try it online!

MATL, 9 bytes

I:I*+12X\

Try it online!

Explanation

Consider input 4 as an exmaple.

I:     % Push [1 2 3]
       % STACK: [1 2 3]
I      % Push 3
       % STACK: [1 2 3], 3
*      % Multiply, element-wise
       % STACK: [3 6 9]
+      % Add implicit input, element-wise
       % STACK: [7 10 13]
12     % Push 12
X\     % 1-based modulus. Implicit display
       % STACK: [7 10 1]

Pushy, 12 bytes

258s{K+12%h_

Try it online!

258            \ Push 258                            
   s           \ Split into digits, yielding [2, 5, 8]
    {K+        \ Add input to each
       12%     \ Modulo each by 12
          h    \ Increment each
           _   \ Print (space separated)

12 bytes

An alternative for the same byte count:

12R{:{;$...#

Try it online!

12R            \ Push range(1, 12), inclusive
   {: ;        \ Input times do:
     {         \   Rotate left
       $       \ While there are items on stack:
        ...    \   Pop the top three
           #   \   Print top item

Clean, 44 bytes

import StdEnv
@n=[(n+i)rem 12+1\\i<-[2,5,8]]

Try it online!

Jelly, 8 bytes

12Rṙ’m3Ḋ

A monadic link taking a number and returning a list of numbers.

Try it online! or see all cases.

How?

12Rṙ’m3Ḋ - Link: number, n   e.g. 5
12       - literal twelve         12
  R      - range                  [1,2,3,4,5,6,7,8,9,10,11,12]
    ’    - decrement n            4
   ṙ     - rotate left            [5,6,7,8,9,10,11,12,1,2,3,4]
      3  - literal three          3
     m   - modulo slice           [5,8,11,2]
       Ḋ - dequeue                [8,11,2]

SOGL V0.12, 9 bytes

3{3+:6«‰P

Try it Here!

Python 3, 33 bytes

lambda n:{*range(n%3,13,3)}-{n,0}

Try it online!


Python 2, 35 bytes

lambda n:[(n+c)%12+1for c in 2,5,8]

Try it online!

Python 2, 35 bytes

lambda n:(range(1,13)*2)[n+2:n+9:3]

Try it online!

C (gcc), 48 bytes

i;f(n){for(i=4;--i;printf("%d ",n%12?:12))n+=3;}

Try it online!