# Tag Info

1

TI-BASIC, 26 25 bytes ∑(X,X,1,1+int(7⁻¹(1+dbd(1.012,Ans Hooray for built-ins! Input is the compressed version of the end date in the form MM.DDYY or DDMM.YY where MM is the month (e.g. 01), DD is the day (e.g. 24) and YY is the year (in this case, 20). Input is in Ans. Output is the wanted result as specified in the challenge. Update: In my attempt to ...

1

JavaScript (V8), 35 26 bytes setTimeout(alert(''),3e13) Try it online!

1

TI-BASIC, 17 bytes For(I,0,2^32:rand(564:End TI-BASIC doesn't have any wait commands/functions, so I just used one of the slowest functions available: generating random lists! Generating a random list of 564 elements takes $\approx7.95$ seconds to make and the loop goes through $2^{32}$ iterations, so that results in $7.95*2^{32}=34144990003.2$ ...

0

PHP, 62 bytes <?php $t=microtime(1);for(;$i<N;$i++);echo microtime(1)-$t.'s'; Try it online! This is my first try in codeGolf, hope I get this right! Some explanations: microtime(true) gets timestamp in seconds as a float with the precision of microseconds taking advatange that errors are discarded, so $i is not initialized using automatic type ... 0 MathGolf, 10 9 (or 12?) bytes {t}]│Σûms With $n$ as STDIN input. Try it online. If this is not allowed, it would be 3 bytes longer instead: "#"i{t}]│Σûms Where the # is replaced with the integer $n$ (i.e. "100"i{t}]│Σûms). Try it online. Both answers output the execution time in milliseconds without space. Explanation: Uses a similar approach ... 0 Wolfram Language (Mathematica), 40 29 28 26 bytes First@Timing@Do[,N]~Print~s Try it online! Replace N with number of times to do the operation. Does null N times (doing nothing is an operation in this case, as you can observe by increasing N and time increases). 3 Python 2.7 - 32 20 bytes print t(number=N),'s' We can take advantage of the different scoring rules here. timeit.timeit has been in the standard library since 2.6, so we get to ignore the from timeit import timeit as t and hence 31 bytes that would have cost. timeit is designed to be able to take a statement for execution as a parameter, but has a ... 2 PHP, 67 59 57 bytes <?=(($d=(int)(date(z,strtotime($argv))/7+1))+$d*$d)/2; Try it online! 0 SAS, 37 bytes option stimer;data;do i=1to N;end;run; This increments a loop counter i and outputs the final value N to a SAS dataset. This is not optimised out, so the run time is linearly dependent on N. 1 Java 5/6, 99 98 78 bytes import static java.lang.System.*; enum A{A;{long s=nanoTime();for(int i=#;i-->0;);out.print(nanoTime()-s+"ns");}} Loops the given $n$ amount of times without doing anything in the loop body. Java 11, 128 122 121 101 bytes import static java.lang.System.*; interface M{static void main(String[]a){var s=nanoTime();"x".repeat(#);... 4 PowerShell, 38 bytes param($n)$a={1..$n};Measure-Command $a Try it online! 4 05AB1E, 12 10 bytes ƒžc})¥O's« -2 bytes thanks to @ExpiredData. Either add the $n$ as leading portion (i.e. 100ƒžc})¥O's«) or simply use $n$ as STDIN input. Outputs the execution time in whole seconds (without space). Try it online. Explanation: ƒ # Loop in the range [0, n]: žd # Push the current time in seconds }) # ... 2 C (gcc), 59 bytes main(c,a){a=clock();for(c=100;c--;);printf("%dus",clock()-a);} Try it online! 4 J, 16 14 19 bytes (20 - 1 for N) echo's',~":6!:2'i.N' Try it online! -2 bytes thanks to Adam -- after looking at his answer I realized I didn't need to sum the integers, just generate them +6 bytes thanks to Adam for pointing out I missed the unit Generates the integers 0..N-1, times it, and prints it to stdout. 's',~ prepends the unit s for seconds. 3 Raku (18 or 25) Depending on one's definition of a "standard" library for Raku... use Timer; # uncounted import line say timer {[+] ^N} or [+] ^N;say now -BEGIN now$/=now;[+] ^N;say now -$/ [+] ^N sums all numbers from 0 to N, so the bigger it gets, the more ops it does. The now - BEGIN now bit is a common idiom in Raku that virtually makes such ... 5 R, 29 28 bytes cat(system.time(!1:9e6),"s") Try it online! A full program printing the number of seconds elapsed complete with unit. The 9e6 is not counted per the rules and can be replaced with any other number. Thanks to @RobinRyder for saving a byte! An alternative would be paste(system.time(!1:9e6),"s"), but this also prints our four other times (... 7 Zsh, 14(?) bytes If N is substituted in place of$1 (as described in the prompt), then 14 bytes. If N is given as an argument, then 16 bytes. time (: {0..$1}) Try it online! Uses the builtin time (you can verify that this is a Zsh builtin: run type time). The time to expand the brace expansion increases with the input. You might think to use time sleep$...

6

APL (Dyalog Unicode), 12 bytesSBCS Full program. Returns elapsed time in seconds, followed an "s". Runtime on TIO is roughly linear with N, with a coefficient of about 6×10-10. Uses the dfns library, but per OP, import isn't counted. 's',⍨cmpx'⍳N' Try it online! '⍳N' expression generating the ɩntegers 1 through N cmpx time the execution of that ...

0

Java, 24 characters/bytes c->c.get(3)*-~c.get(3)/2 Try it online This is an instance of ToIntFunction as a Lambda function. c is a reference to a Calendar object. c.get(3) returns the week of year field (Calendar.WEEK_OF_YEAR == 3) x*-~x/2 is the triangle number calculation.

2

C (gcc), 34 32 38 34 32 bytes g(n){n=n/604800-2607;n=n*-~n/2;} Takes as input the number of seconds since January 1st, 1970 (the Unix epoch) at 0:00 AM UTC time. Explanation: n=n/604800-2607; Divide by number of seconds in a week and subtract the number of weeks from Jan 1 1970 to Jan 1 2020 minus one so we don't have to increment later. n=n*-~n/2; ...

6

JavaScript (ES6),  53  51 bytes Takes input as (month)(day). This is longer than my other answer but does not use any date built-in. m=>g=d=>--m?g(d+31+~m%9%2-(m==2)):~(d=~-d/7)*~-~d/2 Try it online! Commented version m => // m = month g = d => // g is a recursive function taking the day d --m ? ...

2

PowerShell, 48 bytes Thanks to @mazzy (1..(((Date|% DayOfYear)/7)+1)|measure -sum).sum Try it online! Originally 76 bytes [Linq.Enumerable]::Sum([Linq.Enumerable]::Range(1,(Get-Date).DayOfYear/7+1)) Try it online!

4

Red, 38 bytes func[d][(t: pick d - 2 14)*(t + 1)/ 2] Try it online! Takes input as a date in any reasonable format: dd-mm-yyyy, yyyy-mm-dd, dd-MMM-yyyy. Red's date datatype fourteenth field holds the week nember.

4

05AB1E, 20 19 bytes •Σ₁t•ºS₂+6šI£O+7÷LO -1 byte thanks to @Arnauld. Input in the order month, day, year (although the year is ignored). Try it online. Explanation: •Σ₁t• # Push compressed integer 5354545 º # Mirror it: 53545455454535 S # Convert it to a list of digits: [5,3,5,4,5,4,5,5,4,5,4,5,3,5] ...

1

C# (Visual C# Interactive Compiler), 44 bytes x=>Enumerable.Range(1,x.DayOfYear/7+1).Sum() Try it online!

2

Ruby, 42 bytes A function that takes the month and date. Time#yday returns the day of the year. ->m,d{k=1+~-Time.gm(4,m,d).yday/7;k*-~k/2} Try it online!

2

Perl 5 -ap -MTime::Local -MTime::Piece, 61 bytes $_=($w=(gmtime timegm 0,0,0,$F,$F-1,24)->week)*($w+1)/2 Try it online! 8 Perl 6, 33 bytes {[+] 1..Date.new(24,|@_).week} Try it online! Takes input as month,day. This initialises a date in the year 24 (since that year starts on Monday and is a leap year), and calculates the sum of the range of 1 to the current week number. 1 Jelly, 23 21 bytes “¢(Y’b3+29ÄŻ⁸ị++6:7RS Try it online! A full program taking the date as three arguments: month, day, year. Alternatively a dyadic link taking the month as its left and day as its right argument. (The year is ignored in any case.) Jelly has no date type, so this needs to generate the cumulative month lengths. 3 Python 3.8 (pre-release), 94 $\cdots$ 82 77 bytes lambda d:(n:=(date(*d)-date(2020,1,1)).days//7+1)*-~n/2 from datetime import* Try it online! Function takes date as a (year, month, day) tuple and returns the number of ACUs. Tests ported from Arnauld's answer. 9 R, 56 34 bytes function(d)sum(1:format(d-2,"%V")) Try it online! A function taking an R Date as its argument and returning a number. Works because 2019-12-30 was a Monday, strftime(,"%V") returns the ISO week number and then calculates the relevant triangular number. Thanks to @Giuseppe for saving 17 bytes, and @RobinRyder a further 3! 5 JavaScript (ES6), 61 50 49 47 bytes Assumes that the system is set up to UTC time (as the TIO servers are) Takes input as (month)(day). m=>d=>(n=new Date(68,m-1,d+738)/6048e5|0)*-~n/2 Try it online! How? Given the month $m$ and the day $d$, we generate the corresponding date in $1968$ (the closest leap year before Epoch) with an ... 10 APL (Dyalog Extended), 20 19 bytesSBCS Anonymous tacit prefix function taking [year,month,day] as argument. 2!∘⌊7÷⍨43816-⍨⌂days Try it online! ⌂days calculate the number of days since 1899-12-31 43816-⍨ subtract 43816; days since 2019 12 18, i.e 14 days weeks extra 7÷⍨ divide by 7; weeks since 2019 12 18, i.e two weeks extra ⌊ floor; whole weeks since ... 2 APL (Dyalog Unicode), 86 85 bytesSBCS Now that Arnauld has posted his C# solution, I can reveal my equivalent anonymous tacit prefix function. ⎕NEW{⎕USING←'System'⋄0::1221⋄⍺⍺DateTime((3761+⍵)3 24,⍺⍺Globalization.HebrewCalendar)} Can't try it online as this only works under Windows. (.NET Core support is planned for this year!) ⎕NEW{…} function derived ... 3 JavaScript (Node.js), 74 bytes d=>(i=5,g=(a,m=20-8%--i)=>i?g(a/m|0)+'.'+a%m:a)(new Date(d)/864e5+1856305) Try it online! Input as yyyy-MM-dd format string. Thanks Arnauld, save 4 bytes. 1 C (GCC) 239 200 -39 bytes ceilingcat #define S d/m;d%=m;m l(y){y=y%(y%25?4:16)<1;}b,k,t;D(y,m,d){for(d+=1137110+L" ?[z˜·ÕôēıŐŮ"[m-1]+(m>2?l(y):0);--y;d+=365+l(y));m=144e3;b=S=7200;k=S=360;t=S=20;y=S=1;printf("%d.%d.%d.%d.%d",b,k,t,y,d);} Try it online! 4 JavaScript (ES6), 96 bytes Assumes that the system is set up to UTC time (as the TIO servers are) Takes input as 3 distinct parameters (year, month, day). (y,m,d)=>[144e3,7200,360,20,1].map(k=>n/(n%=k,k)|0,n=new Date(y+4e3,m-1,d+395335)/864e5).join. Try it online! How? We can't safely pass a year $y<100$ to the Date constructor, as it gets ... 3 05AB1E, 54 52 bytes 365*Š3‹¹α4т‚DPª÷®β•ë˜¿•ºS₂+²£•HØ•OŽQív₂y-‰R})R'.ý Try it online! First step: compute the day number. 365 # literal 365 * # multiply # => 365*year is left on the stack for now Š # get the other two inputs # => day is left on the stack 3‹ ... 2 C# (Visual C# Interactive Compiler), 186 163 bytes string f(int[]t){int x,n=(int)(new DateTime(t,t,t)-new DateTime(1,1,1)).TotalDays+1137143;return string.Join(".",new[]{144000,7200,360,20,1}.Select(e=>{x=n/e;n%=e;return x;}));} Try it online! Edit: Use int[] as input instead of DateTime to meet the specification better. Thanks @keizerharm for ... 6 Python 3, 149 $\cdots$ 145 140 bytes from datetime import* def f(d): n,s=(date(*d)-date(1,1,1)).days+1137143,"" for i in[144000,7200,360,20,1]:s+=f".{n//i}";n%=i return s[1:] Try it online! Takes Gregorian date as [year, month, day] list and returns Mayan date as f"{B'ak'tun}.{K'atun}.{Tun}.{Winal}.{Day}"(loosely as a python f-string). 3 C# (Visual C# Interactive Compiler), 108 bytes An alternate version suggested by @Adám, with a distinct output format for the edge case 2239. using System.Globalization;string f(int y)=>y<2239?new DateTime(y+3761,3,24,new HebrewCalendar())+"":"1221"; Try it online! C# (Visual C# Interactive Compiler), 134 130 122 121 bytes Saved 8 ... 1 Python 3, all platforms, 91 bytes from datetime import *;z=datetime.now()+timedelta(days=365242) while z>datetime.now(): pass The rules say simple termination is fine, which happens after the while loop is done. I couldn't put it all on one line, because the while loop has to start on its own line for the interpreter to recognize it. I also didn't want ... 2 Perl 5, 313 278 bytes sub f{sub t{timegm_nocheck(0,0,0,pop,8,pop)}$Y=pop;eval'(R,N,Q)=map{X=12*(_%19+1)%19;N=1.554*X-2.9-_/314.4+_%4/4+_/100%99-_/400%9;I=intN;D=t(_,I)/86400%7;M=N-I;P=D=~//||D==4&&M>1?1:D==5&&M>=.63&&X>6?2:0;t(_,I+P),I+P}Y,Y+1;t(Y,N+82+((Q-R)/432e3)=~/1|7$/)'=~s/[A-Z_]/\$\$&/gr} Try it online! ...

8

JavaScript (ES6),  188 ... 168  160 bytes Assumes that the system is set up to UTC time (as the TIO servers are) Returns a Date instance. y=>(D=d=>new Date(y,8,n+=d))(((g=y=>D((n=80,d=D((3*-~(y/100)>>2)+1.554*(x=12*-~y%19)+y%4/4-y/314.6-.9).getDay())%2+2*(n%!d>.63&x>6))/864e5)(++y)-g(--y)+5)%30<1) Try it online! Or ...

1

W d, 10 8 bytes Ö♦Ç⌂╬§Γ Explanation: Uncompressed: 25m4&16|m! 25m % If the input is modulo-able by 25: 4& % Return 4 16| % Otherwise, return 16 m! % Modulo input by the value. Negate the value.

Top 50 recent answers are included