We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

52

SmileBASIC, 73 71 67 bytes ?"Christmas"; @L?" Eve"*(D!=P); P=D DTREAD OUT,M,D IF M/D-.48GOTO@L The program prints "Christmas", then prints " Eve" every time a day passes, until it is December 25th. (12/25 = 0.48) May take up to a year to run.


27

PHP, 936 bytes for($a=explode('-',gzinflate(base64_decode('dVTRbtswDPwV/YANKXZq+zFJ1wRts3VZtgB7Y2Mm1ipLAO0089+PtNIuHbAnAzySd+RRNkVZ6XxSJUsMdES1g66x/tgHn5iiKnSms+Q+NF7Nami7xJTajLFtE1ro1D0eDkidZJe6itnQYqfWUNsYNsV1OHgKyNHJ9G/rryfr98M7wyT2mfma8KzuYf8SG2Wx0Rqot179AK/mJ0JB8qhpZ52z0KoVehrUCoguEhjP38i2g0OS2PRK1kOqnoJ7kXAk/wn7BrjJFgYXJH2qdaHLZM0UQLW6428bSCaZZmPFHYF/...


24

Excel formula, 59 bytes ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,25)-TODAY())


15

Bash, 1229 1124 bytes -103 bytes with @GammaFunction's excellent comments, removing a couple of unproductive substitutions (Adams), and refactoring the code to use the date offset from the previous date rather than the absolute date for each presidency. M=(. Ja F Mar Ap May Jun Jul Au S O N D) A=40000 B=80000 s=son a=James c=Andrew d=William e=Harri$s f=...


14

JavaScript (ES6),  41 40  39 bytes Takes inputs as (h)(m). h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90 Try it online! How? Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$: $$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$ $$x=\left|\frac{4h}{12}...


13

Excel, 3(+7?) =A1 with format yyy/m/d Pure port


12

Perl 6, 61 47 bytes say 'Christmas'~' Eve'x(Date.today...^{.month==12&&.day==25}) say 'Christmas'~' Eve'x(Date.today...^/12\-25/) Try it online! -14 bytes (!) thanks to Jo King Date.today ...^ /12\-25/ is the sequence of dates starting today and ending the day before Christmas. (The regular expression /12\-25/ is matched against the string ...


12

R, 77 72 bytes function(d,`~`=format)write(c(strtrim(d+-3:3~"%a",2),d+-17:17~"%e"),1,7) Try it online! Fixed output to use 2 letter day abbreviations. -1 byte using strtrim thanks to Aaron Hayman. Pads date numbers with leading 0s; takes input as a Date, which can be created by using as.Date("YYYY/MM/DD"). Weirdly short for an R ascii-art answer...


12

Excel, 1243 1206 1180 bytes -37 bytes by subtracting from all the dates -26 bytes by by fiddling with the subtraction values =CHOOSE(MATCH(A1-65^4,{39805,119679,159679,239679,319679,399679,439679,519679,559679,559779,599679,639679,650084,679679,719679,759679,799790,839679,919679,959679,960294,999679,1039679,1079679,1119679,1160289,1239679,1279679,1359679,...


12

T-SQL, 1169 981 979 977 bytes Holy cow, I figured out string compression in SQL (available in SQL 2016 and above): SELECT TOP 1 STUFF(value,1,8,'') FROM d,STRING_SPLIT( CAST(DECOMPRESS(CAST('H4sIAAAAAAAEAHVT23LaMBD9FX1AxiMZg+1HIAWGhDaltMz0bYMXrEaWOmsc6r/vrpw27kOHB8ZnL+fs2VWqTa6NKe+DB1epA3XNz7tU61LABRCcXtSnZ2hAQCPgGgNdUB0Tteja+s6U5STmWufU0ll/...


9

PHP, 38 40 30 28 bytes <?=date("jS F",86399*$argn); Try it online! Run with php -nF input is from STDIN. Example (above script named y.php): $ echo 1|php -nF y.php 1st January $ echo 2| php -nF y.php 2nd January $ echo 3| php -nF y.php 3rd January $ echo 11|php -nF y.php 11th January $ echo 21|php -nF y.php 21st January $ echo 60|php -nF y.php 1st ...


9

05AB1E, 587 584 568 bytes .•6}©ß þz∊‘Îнúj7a>º ·,$_+šüÑßu?PδIëàá©ā.ǝ/¬j«Ížr‹þVwô¨"¶&ˆ₃ǝαh^¼ì∞öîNÊÌ.ÚáýиÇ÷©Mèé…—¾…тŒ¹/ÈÂÓŒš/«ª³PÉÇJúΓÁ¦';X·₅ï»/„q<ƶÚÙÊtÔιuš2βƒ¼ï\~ö…3ihD·¢ðΘmζ8É9Ïγ=^$¨Ä₆ËÂÊPv5+}þ¯ÑX4hÖdÀÒuàнº₁›ǝΘ³P@¥ùnðT“É)ó_“:Èx³«äƒæ¤∞Wgþ¶š}ô|ićcÁ‘.·ƒp>Z¬Aéγê‰ù‰¥Ó₃#/›pÐT¹Â¹J3—ΛΓkÙ»(áÌ›₃z@ìqW›Â"™raÒ›₂%ïx{ _Ωb≠¹₁ľÊÌ›}çºô|ôëKÝǝÚï,‚£=A©áāY∊~"...


8

R, 112 106 72 bytes Via @digEmAll and @J.Doe x=Sys.Date()-1;cat('Christmas');while(!grepl('12-25',x<-x+1))cat(' Eve') Try it online! My original answer was prior to the clarification that the code was to take the date on which the code is run as input. It could be modified as above to save many bytes but I won't bother. function(x,z=as.Date(paste0(...


8

Windows PowerShell, 67 64 63 bytes for(;1225-'{0:Md}'-f(date|% *ys $i)){$i++}'Christmas'+' eve'*$i Try it online! Managed to shave off 3 bytes 4 bytes (thanks Cows quack) by using the -format operator instead of .ToString(), and then subtracting the date string from the numerical value 1225 instead of doing a comparison with -ne. The resulting integer ...


8

JavaScript (ES6), 65 bytes n=>'101010.1010'.replace(i=/\d/g,x=>new Date(n).toJSON()[i=x-~i]) Try it online! How? We initialize the pointer \$i\$ to a non-numeric value (coerced to \$0\$) and then add alternately \$2\$ and \$1\$ to it to pick the relevant characters from the ISO-8601 conversion of the input timestamp. yyyy-mm-ddThh:mm:ss.sssZ ^^ ^...


8

05AB1E, 175 174 172 171 160 bytes ¦WΘ1š-1šVтFY`2ô0Kθ4ÖUD2Qi\28X+ë<7%É31α}‹iY¬>0ëY1¾ǝDÅsD12‹i>1ë\1Dǝ¤>2}}ǝVY})DJIJk18+£35.£¬.•4ιõ÷‡o‹ƶ¸•2ôs`UÐ3‹12*+>13*5÷s3‹Xα©т%D4÷®т÷©4÷®·()DćsćsO7%._s€нT‰J«7ô» Input in the format [day, month, year]. Output with leading 0s for single-digit days, and lowercase mo through su (+1 byte can be added if titlecase ...


7

C# (Visual C# Interactive Compiler), 89 bytes Write("Christmas");for(var t=DateTime.Now;$"{t:Md}"!="1225";t=t.AddDays(1))Write(" Eve"); Try it online! -3 bytes thanks to @JeppeStigNielsen! My strategy is pretty straightforward: Initialize a loop variable t to the current date Print Eve if t is not Christmas Add a day to t and repeat I tried some ...


7

Bash + coreutils, 29 bytes date -d@${1::-3} +%y%m%d.%H%M Try it online!


7

PHP, 40 32 31 bytes -8 bytes thanks to Luis felipe -1 byte thanks to Jo King <?=date('ymd.hi',$argv[1]/1e3); Try it online! Simple naive answer. PHP's date function takes a format string and an integer timestamp. Input from cli arguments, which is a string by default, then /1e3 because date expects second-precise timestamps. This also coerces the ...


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 ...


7

Jelly,  431 428 427  426 bytes “¡Ẹị’ḃ4ż“ƓĠƒƝƊ!ɓa(‘ḅ⁹ “FQIȥ’ḃ8Ėẋ/€<8ż¢F1,303yo119 “f×Ð<Mk7LqƇ%_¡¤cċ⁴ẏ’Do13’⁽¤.;Äż¢ḅȷ4<VSị“¡ṀÑṅyȮÇæjRṂ~ɠƥ⁺'Ḃġ"Ƈ~Ị'9ƒȮṃ$ḶPȯṅṡḊl¥JƊ€ẊḥSṣọwɦṡ5ėṂU #Fɲẓ÷iḄþ%~%ñçŒfƒƙɼ=ɓ⁼¡⁻Q`⁵¡ḍ36)żȥÑR\ḋ⁾ḶƤ0ÞṘḳ÷¦IṂ\}ƊĊÐḳŻƈɦ!zɠ⁺ƈṖṭW⁸ƥṛU|ḄØ^ẓfḂḣƈCȦ8ɱḤH⁵AKṢzȯỵƭḊ:TʠƬ/~ƝÑȥgṖ(ṁȯDƲṫỴftlBOȧ6Ụiṃıẉ_ƈvh5ṄUɓạẓDẠẸıṣƥ"bçȥ¿çOġQẹİẊẸs*⁶ż,Ḍg®ƲW×ɗ,ẏ¡...


6

k (kdb+ 3.5), 55 54 51 50 bytes {$(`1900.01.00`1900.02.29,"d"$x-36526-x<60)0 60?x} to test, paste this line in the q console: k)-1@{$(`1900.01.00`1900.02.29,"d"$x-36526-x<60)0 60?x}'0 1 2 59 60 61 100 1000 10000 100000; the output should be 1900.01.00 1900.01.01 1900.01.02 1900.02.28 1900.02.29 1900.03.01 1900.04.09 1902.09.26 1927.05.18 2173.10....


6

T-SQL, 92 88 bytes PRINT'Christmas'+REPLICATE(' Eve',DATEDIFF(D,GETDATE(),STR(YEAR(GETDATE()+6))+'-12-25')) Edit: Saved 4 bytes thanks to @BradC.


6

C# (Visual C# Interactive Compiler), 115 113 109 98 bytes g=>$"{f=(g=p.AddDays(g-1)).Day}{"tsnr"[f=f%30%20<4?f%10:0]}{"htdd"[f]} {g:MMMM}";DateTime p;int f; Thanks to @someone for saving 9 bytes Try it online!


6

Jelly,  79 78  77 bytes -1 fixing a bug :) (shouldn't pre-transpose to find index, should post-reverse, but then we can tail rather than head) -1 using reflection (⁽©ṅB+30_2¦2 -> ⁽0ṗb4+28m0) ⁽0ṗb4+28m0SRṁRƲœiµṪȮ%30%20«4ị“nḄƲf⁷»s3¤Ṗ,ị“£ṢtẒ⁽ẹ½MḊxɲȧėAṅ ɓaṾ¥D¹ṀẏD8÷ṬØ»Ḳ¤$K A full program which prints the result Try it online! How? will update this ...


6

JavaScript (ES6),  141  126 bytes Saved 15 bytes by borrowing .toUTCString().slice(0,2) from Neil's answer Takes input as a Date object. f=(d,n=0)=>n<42?(D=new Date(d-864e5*(24-n)),n<7?D.toUTCString().slice(0,2):(i=D.getDate())>9?i:' '+i)+` `[++n%7&&1]+f(d,n):'' Try it online!


6

PowerShell, 74 70 67 bytes param($y,$m,$d)-join"$y 00$((date "$m/$d/$y"|% d*r)-1)"[2,3+-3..-1] Try it online! Exactly what it says on the tin (but formatted weirdly). Takes in $year, $month, $day, plucks out the last two digits of the $year, gets a .NET datetime object of the specified day, then gets the dayofyear (with |% d*r) thereof. Subtracts one to ...


6

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


5

APL (Dyalog Unicode), 76 63 bytesSBCS Full program. Assumes ⎕IO←0 (zero-indexing). ⎕CY'dfns' 'Christmas',' Eve'⍴⍨4×12 25⍳⍨⍉2↑1↓⍉date(⍳366)+days⎕TS Try it online! ⎕CY'dfns' copy in the dfns library ⎕TS current time stamp as [year,month,day,hour,min,sec,ms] days[c] find the number of days[n] since 1899-12-31 00:00:00.000 (⍳366) add the first 366 integers (...


5

Python 2, 111 103 bytes from datetime import* d=date.today() print"Christmas"+" Eve"*(date((d+timedelta(6)).year,12,25)-d).days Try it online! Update inspired by Richard Crossley's answer. Explanation: from datetime import* # get today as a date, so we don't have to worry about rounding errors due to time d=date.today() # ...


Only top voted, non community-wiki answers of a minimum length are eligible