New answers tagged

2

V (vim) -v calling bc, 105 bytes Thanks to caird coinheringaahing for filling in some V documentation gaps. One could reduce the byte count by using raw byte source code instead of -v. f:x"adt x"bdt:s <esc>"cddo<esc>"apA+1<esc>"cpA+0<esc>Vk:sort dd0dt+k"bPhxxJI(<esc>A)%24<esc>:.!bc "cpkJr:...


0

Vyxal, 49 bytes `⌊ẇ ₃¼ Roos≠∴ •∞ Ḣ⟩ ₀⌊ Ox ṗȦ ₈Ė ėɾ Ċṅ ½√`⌈kD⌊12%i Try it Online! `...` # Compressed string of names ⌈ # Split on spaces kD⌊ # Current year 12% # Modulo 12 i # Index into list of names


0

TI-Basic (TI-84), 32 bytes Output(1,1,sum(getDate{ᴇ6,ᴇ3,1 Output(1,5,"- Output(1,8,"- getDate is a list in the form {2021, 1, 20}. the date list is multiplied by {1e6, 1e3, 1} and then summed, giving a single number in the form yyyy0mm0dd, this deals automatically with leading zeros -s are then added at the right places, giving the output yyyy-mm-...


2

jq, 123 bytes .[2]|=[scan("\\d+")|tonumber]|.[0]+=((.[2][-1]>.[1]//1)?+0//0)+(.[2]|length-1|./.?//0)*.[2][0]|.[1]=.[2][-1]|.[0]%=24|.[:2] Try it online! Takes input as [hh,mm,string] and returns [hh,mm]. jq does not have a way to cast a boolean, so the try statements are used(thanks ovs). The modification ops are quite convenient, though. -5 ...


4

Perl 5 (-p), 56 bytes s/(.+):(.+) (.+\+)?xx:(.+)/(($1+$3+($4<=$2))%24).":$4"/e Try it online! We match the input regex and do some fun math. The minute hand of the result is always $4 (the fourth capture group). The hour hand is the initial hour hand ($1), plus the time offset ($3), plus one extra if we've already passed the minute in the ...


0

Python 2, 83 65 bytes a,b=input();print(eval(b[:-5]+a[:-3])+(a[-2:]>=b[-2:]))%24,b[-2:] Try it online! pretty simple Thanks @caird for changing language and saving 18 bytes! (That's a lot of bytes!)


0

Charcoal, 32 bytes ≔⪪S:θ≔⪪S:ηI﹪⁺¬›⊟θ§η¹Σ⁺§η⁰⊟θ²⁴:⊟η Try it online! Link is to verbose version of code. Could output in HH:mm format at a cost of 4 bytes. Explanation: ≔⪪S:θ Input the local time and split on :. ≔⪪S:η Input the party time and split on :. This means that the hours still contains the xx. I﹪⁺¬›⊟θ§η¹Σ⁺§η⁰⊟θ²⁴ Compare the two sets of minutes. ...


4

Haskell, 77 bytes (h,m)%s|[(b,_:c)]<-reads s=(h+b,m)%c|n<-read$drop 3s=(mod(h+sum[1|m>=n])24,n) Try it online!


0

Nim, 32 bytes import times echo ($now())[0..9] Try it online!


2

R, 111 108 105 102 bytes function(t,x,k=scan(t=el(regmatches(s<-paste0(0,x),gregexpr("\\d+",s)))))c(el(t+k+rev(t>=k))%%24,k[2]) Try it online! Slightly different solution with the same byte-count: R, 102 bytes function(t,x,k=scan(t=el(regmatches(s<-paste0(0,x),gregexpr("\\d+",s)))))c(k,(t+k+rev(t>=k))%%24)[3:2] Try it ...


2

TI-Basic, 72 bytes getDate→A toString(Ans(1→B toString(ʟA(2→C toString(ʟA(3→D If C<10 "0"+C→C If D<10 "0"+D→D B+"-"+C+"-"+D This only works on a TI-84+ CE OS 5.2 and if the user has already set the time and date correctly.


2

Vyxal, 19 bytes 0p\:€⌊Z÷÷:£≥J∑24%¥" Try it Online!


1

C (gcc), 144 143 bytes n;h;m;o;x,y;f(t,p)char*p,*t;{x=sscanf(p,"%d+xx:%d"+y*3,(y=*p>58)?&m:&o,&m);sscanf(t,"%d:%d",&h,&n);printf("%d:%02d",(h+(y?x:o+1)-(n<m))%24,m);} Try it online! Saved a byte thanks to ceilingcat!!!


5

Jelly, 22 20 bytes Ṗ+<¬Ṫɗ+%"24ɓṣ”:f€ØDV Try it online! Takes the time as [hh, mm] on the left and the xx string on the right. -2 bytes thanks to Lynn by a clever exploitation of Jelly's vectorising atoms! How it works This uses the ɓ chaining structure to group a series of links to act only on the string, then we run the main links on the result of ...


3

05AB1E, 19 18 bytes ':¡€þø``©@ªþO24%®‚ Try it online or verify all test cases. I/O of the times as pairs of [HH,mm]; input-order is the string followed by the pair. Explanation: ':¡ '# Split the first (implicit) input-string on ":" €þ # Only leave the digits of both parts (will be "" for "xx") ...


3

Python 3, 62 bytes lambda t,s:(str((eval(s[:-5]+t[0])+(t[1]>=s[-2:]))%24),s[-2:]) Try it online! Inputs and outputs a tuple of strings.


4

JavaScript (ES6), 52 bytes I/O format: tuple of integers ([h,m],s)=>[([H,M]=s.split(/\D+/),h-~H-(M>m))%24,+M] Try it online!


4

Retina 0.8.2, 81 76 bytes \d+ $* :(1*) (1*).*:((?!1\1))? $#3$*1$2: +`1{24}: : 1* $.& \B0\b \b\d\b 0$& Try it online! Link includes test cases. Edit: Saved 5 bytes thanks to @user41805. Explanation: \d+ $* Convert to unary. :(1*) (1*).*:((?!1\1))? $#3$*1$2: Add the extra hours, plus check whether the minutes are behind and if not add another hour. ...


2

Factor, 21 bytes [ now timestamp>ymd ] Try it online!


1

05AB1E, 17 bytes Çт÷`Ž4µ©*Iþ®%4°O¦ Input-format as HHmmx, where x is a/p; output format as HHmm. Try it online or verify all test cases. Explanation: Ç # Convert the (implicit) input-string to a list of unicode values т÷ # Integer-divide each by 100 (0 for "a" and every digit; 1 for "p") ` # Pop and dump ...


0

Julia -p 9, 48 bytes @time show(sum(pmap(_->@elapsed(sleep(7)),1:9))) Try it online! the -p 9 option launches julia with 9 workers and with the Distributed standard library pmap distributes the tasks over the available workers @elapsed returns the time taken so that they can be sumed @time prints the total time taken


Top 50 recent answers are included