New answers tagged

1

Reg, 14 bytes 1¿:%[4|]%[;] Try it online! How it works (because it contains unprintable characters)


0

PHP, 29 bytes <?=floor((date(G)+$argn)/24); Try it online! Full program, with current hour being the current hour on the platform host, and delta of hours input via STDIN. Or PHP, 30 bytes <?=floor(array_sum($argv)/24); Try it online! Input of current hour and delta of hours via command line.


0

Forth (gforth), 12 bytes : f + 24 / ; Try it online! Code Explanation : f \ start a new word definition + \ add current hour and delta 24 / \ (integer) divide result by 24, round towards negative infinity ; \ end word definition


0

Whitespace, 49 bytes [S S S N _Push_0][S N S _Duplicate_0][T N T T _Read_STDIN_as_integer][T T T _Retrieve_input][S S S N _Push_0][S N S _Duplicate_0][T N T T _Read_STDIN_as_integer][T T T _Retrieve_input][T S S S _Add][S S S T T S S S N _Push_24][T S T S _integer_division][T N S T _Print_as_integer] Letters S (space), T (tab), ...


0

Perl 5 (-MPOSIX=floor -MList::Util=sum -alp), 19 bytes $_=floor+(sum@F)/24 TIO


1

Perl 6, 11 bytes (*+*)div 24 Try it online! Anonymous Whatever lambda that takes two arguments and returns the sum of the two integer divided by 24


1

Lua, 32 26 bytes print((arg[1]+arg[2])//24) Try it online! Rather boring solution. Take input as arguments, print to stdout. Require Lua 5.3 or greater. Old solution: Lua, 32 bytes function(a,b)return(a+b)//24 end Try it online! Same idea, but implemented as function instead of full program.


0

Python 2, 18 bytes lambda*a:sum(a)/24 Try it online!


0

Retina 0.8.2, 41 bytes \d+,? $* (1+)-\1 - ^((-)1|1{24})*.* $2$#1 Try it online! Link includes test suite. Explanation: \d+,? $* Convert both inputs to unary and take the sum if the second input is positive. (1+)-\1 - But if the second input is negative then take the difference. ^((-)1|1{24})*.* $2$#1 Floor divide the input by 24 and convert to ...


3

R, 28 16 bytes Just a port of most of the other answers... -12 bytes thanks Giuseppe sum(scan())%/%24 Try it online!


3

Haskell, 18 16 bytes ((`div`24).).(+) Try it online! If taking input as a list is allowed, this can be done in 13 bytes (thanks cole): (`div`24).sum Try it online! I've seen people leave off the function declaration in the byte count for pointfree style, so I'm doing the same here. Explanation: (`div`24) div is the shorter integer division operator. ...


0

I, 6 bytes Anonymous tacit infix function, taking current and delta as arguments. +/24.m Try it online! Beginning with:  + the sum of the arguments / divide by:  24 twentyfour . apply:  m floor (minimum)


1

C# (Visual C# Interactive Compiler), 26 bytes a=>b=>Math.Floor((a+b)/24) Try it online!


4

Python 3, 20 19 bytes Simple lambda: lambda*a:sum(a)//24 -1 byte thanx to Jonathan Allan Try it online! Full program for 38 bytes: print((int(input())+int(input()))//24)


1

Lua, 70 50 bytes c,d=io.read():match("(%S+) (%S+)")print((c+d)//24) -20 bytes thanks to val Try it online!


2

Ohm v2, 4 bytes +24v Try it online!


6

Jelly, 4 bytes +:24 Try it online! + add the arguments :24 integer divide by 24


4

APL (Dyalog Unicode), 6 bytesSBCS Anonymous tacit infix function, taking current and delta as arguments. ⌊24÷⍨+ Try it online! + add the arguments 24÷⍨ divide that by 24 ⌊ floor


4

05AB1E (legacy), 4 bytes +24÷ Try it online or verify all test cases. 05AB1E, 11 5 bytes +24/ï -6 bytes by porting @Adam's approach in his APL answer. Try it online or verify all test cases. Explanation: + # Sum the two (implicit) input-integers together 24÷ # Integer-divide this sum by 24 # (after which the result is output implicitly)...


7

JavaScript (ES6),  26  25 bytes Takes input as (current)(delta). a=>b=>(a+b-(a<-b)*2)/3>>3 Try it online! Commented a => // a = current hour b => // b = delta of hours ( // a + b // 1) we compute the sum - (a < -b) * 2 // and we subtract 2 if this sum ...


Top 50 recent answers are included