| Bytes | Lang | Time | Link |
|---|---|---|---|
| 069 | SAKO | 250325T184026Z | Acrimori |
| 045 | Tcl | 171230T014019Z | sergiol |
| 024 | Desmos | 250219T023356Z | DesmosEn |
| 045 | C gcc | 250218T011846Z | Weird Gl |
| 034 | AWK | 241105T191617Z | xrs |
| 009 | Japt | 171230T155109Z | Shaggy |
| nan | Piet + asciipiet | 220702T232925Z | naffetS |
| nan | Piet + asciipiet | 220705T020734Z | Bubbler |
| 009 | Nekomata | 230716T060440Z | alephalp |
| 008 | Thunno 2 | 230715T165119Z | The Thon |
| 012 | x8616 machine code | 220219T025332Z | 640KB |
| 008 | Vyxal | 220219T041309Z | a stone |
| 021 | Excel + Google Sheets Polyglot | 220219T032716Z | Taylor R |
| 008 | Stax | 220219T013259Z | recursiv |
| 024 | J | 220219T011242Z | sinvec |
| 008 | 05AB1E | 201128T183817Z | SunnyMoo |
| 008 | Husk | 201128T020444Z | Razetime |
| 020 | Wolfram Language Mathematica | 201127T184246Z | FarSeenN |
| 027 | Perl 5 a | 201127T204617Z | Xcali |
| 045 | Java 8 | 180104T121218Z | Kevin Cr |
| 039 | Forth gforth | 180124T181902Z | reffu |
| 012 | Pyth | 180105T185331Z | Dave |
| 029 | Ruby | 180104T125819Z | G B |
| 011 | Pyt | 171231T033252Z | mudkip20 |
| 023 | Octave | 180103T181129Z | Giuseppe |
| 084 | BrainFlak | 180103T172730Z | MegaTom |
| 030 | PowerShell | 180102T185646Z | AdmBorkB |
| 030 | Perl 5 | 180102T142421Z | mik |
| 094 | face | 180101T014338Z | Doorknob |
| 371 | PHP | 171231T222134Z | Titus |
| 023 | Perl 6 | 171231T202806Z | Sean |
| 046 | GolfScript | 171231T184033Z | QunSyBer |
| 068 | Windows Batch | 171231T120220Z | stevefes |
| 035 | Wolfram Language Mathematica | 171230T193410Z | DavidC |
| 012 | APL Dyalog | 171230T184636Z | Uriel |
| 011 | K oK | 171230T181800Z | mkst |
| 013 | APL+WIN | 171229T221717Z | Graham |
| 030 | Swift | 171230T115232Z | Endenite |
| 025 | Octave | 171230T113930Z | Tom Carp |
| 042 | C# .NET Core | 171230T104755Z | Ayb4btu |
| 018 | Befunge93 | 171230T020500Z | James Ho |
| 029 | Haskell | 171230T002919Z | totallyh |
| 029 | JavaScript ES6 | 171229T232659Z | Arnauld |
| 028 | R | 171229T213137Z | Steadybo |
| 009 | MATL | 171229T223552Z | Luis Men |
| 012 | Pushy | 171229T213555Z | FlipTack |
| 044 | Clean | 171229T213824Z | Οurous |
| 008 | Jelly | 171229T211457Z | Jonathan |
| 009 | SOGL V0.12 | 171229T212811Z | dzaima |
| 033 | Python 3 | 171229T211606Z | xnor |
| 035 | Python 2 | 171229T210949Z | notjagan |
| 048 | C gcc | 171229T210859Z | Steadybo |
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}}
Different approach using the command line arguments:
Tcl, 41 bytes
time {puts [expr [incr argv 3]%-12+12]} 3
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).
C (gcc), 45 bytes
f(n){for(;n<43;printf("%d ",n%12?:12))n+=15;}
Based on Steadybox's answer. Modular arithmetic is nice sometimes :)
AWK, 33 bytes
{for(;i++<3;print$1++%12+1)$1+=2}
Japt, 11 9 bytes
3Ʊ3 %CªC
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
Piet + ascii-piet, 45 bytes (5×18=90 codels)
tAaaqreeumccsqqqijlVa rbiqaaueljnvea?_ t?B tt
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¦
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%→
258¢D+12%→
258¢D Decimal digits of 258
+ Add
12% Modulo 12
→ Increment
Thunno 2, 8 bytes
ṇɗd+12%⁺
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
05AB1E, 8 bytes
ƵžS+12%>
At the time of writing this, this submission has the lowest score submitted. Technically I am winning!
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) 20 bytes
Mod[#+{3,6,9},12,1]&
The normal modulus operation, threaded over a list, offset by 1.
Java 8, 46 45 bytes
n->new int[]{1-~-~n%12,(5+n)%12+1,(8+n)%12+1}
-1 byte thanks to @ceilingcat.
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 ;
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
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)
Octave, 23 bytes
@(x)mod(x+[2 5 8],12)+1
Takes the same approach as most others; and it is golfier than Tom Carpenter's somewhat more unique solution.
Brain-Flak, 84 bytes
(()()()){({}<(()(){})(((()()()){}){}<>){(({})){({}[()])<>}{}}<>(([{}]{})<>)>[()])}<>
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}
Port of the other answers (e.g., xnor's Python 2 answer). Ho-hum.
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.)
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?
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}
K (oK), 11 bytes
Solution:
1+12!2 5 8+
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.
Octave, 25 bytes
@(x)[a=1:12 a](3+x:3:9+x)
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}
Essentially just a port of many of the other answers to C#.
Befunge-93, 20 19 18 bytes
852<_@#:.+1%+66+&p
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]]
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));
}
MATL, 9 bytes
I:I*+12X\
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_
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{:{;$...#
12R \ Push range(1, 12), inclusive
{: ; \ Input times do:
{ \ Rotate left
$ \ While there are items on stack:
... \ Pop the top three
# \ Print top item
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]
Python 3, 33 bytes
lambda n:{*range(n%3,13,3)}-{n,0}
Python 2, 35 bytes
lambda n:[(n+c)%12+1for c in 2,5,8]