Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

143

Bash, 39 For those who just can't wait: sudo date 12250000 echo It\'s Christmas This follows all of the rules, especially the first one.


92

Excel, 6 Bytes =B1-A1 Assuming A is in cell A1 and B is in cell B1


56

Minecraft 1.8.7, 7 + 8 = 15 blytes (bytes + blocks) Only one command block involved: xp 1 @p Output goes to the client console like so: As part of the normal output. This is the system: xp gives a specified amount of experience to a specified player with the syntax xp <amount> <player>. I'm pretty sure this is the smallest command that has ...


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.


43

Bash + linux utilities, 19 seq 40 2 72|pv -qlL2 seq generates the numerical output. pv ratelimits it to 2 lines/sec.


42

Minecraft 1.9.0+, 204 162 bytes + 58 36 28 24 20 blocks = 262 240 232 186 182 blytes This solution is golfed down, and it can't be seen whole in one, or even two screenshots. Uses two glitches and abuses another two features of the game This solution uses the same principles as the one below, just a 4 blocks more compact design. Abuses the fact that ...


42

Excel, 10 =NOW()+100 Demonstration


41

Jelly, 19 bytes 11ị“bMAanlseovc”iµÞ This is a monadic link that takes a list as argument and sorts it. Try it online! Background Jelly uses modular, 1-based indexing. If we repeat the months names often enough to obtain 11 characters, we get the following array. J a n u a r y J a n u F e b r u a r y F e b M a r c h M a r c h M A p r i l A p r i l A M a ...


40

TI-BASIC, 15 bytes * 0.75 = 11.25 Tested on my TI-84+ calculator 1129-dayOfWk(Ans+ᴇ4,9,1 Thankgiving is November 29, minus the day of the week of September 1st, where 1 is Sunday and 7 is Saturday. This outputs in the format MMDD. Test cases: 2015 -> 1126, 1917 -> 1122, -480 -> 1125 have been verified. TI-BASIC seems to use the Gregorian calendar for all ...


40

HTML (JavaScript (ES6)), 129 126 117 bytes <input id=i onfocus=l=0,n=Date.now onkeypress=event.which-97-l?i.outerHTML='Fail':24<l?i.outerHTML=n()-t:t=l++?t:n()> Click in the input and start typing! Also, my typing sucks; I take about 5 seconds even with practice. Edit: Saved 2 bytes thanks to @HermanLauenstein by switching language. Saved ...


39

HTML on Google Chrome 67 in Chinese (Simplified), 39 bytes <input type=time value=00:00 autofocus> Chrome show different UI component in different language. Even a simple time input: AM/PM will be shown if you are using English (US). If you want test this by changing your Chrome's language. Do not mass up how to change it back.


36

x86_64 machine code, 10 bytes Hexdump of the code: 48 69 c9 ca fc 59 38 e2 fe c3 Source code (can be assembled by ml64 of Visual Studio): TITLE heh PUBLIC mywait _TEXT SEGMENT mywait PROC imul rcx, 945421514 myloop: loop myloop ret mywait ENDP _TEXT ENDS END Performs an empty loop, starting from the specified value down to 0. I ...


35

R, 78 75 bytes Built-ins, you say? Well... message(paste(as.Date(.leap.seconds)-1,"23:59:60\n"),"2015-06-30 23:59:60") R has an automatic variable .leap.seconds which contains the date and time of each leap second insertion, given in the system's local time. As of R version 3.2.0, this does not include today, so I've added that manually. Ungolfed + ...


34

2 2.2 I love arbitrary precision arithmetic. 0x4126030156610>>(n<<2) Or, if you don't like hex, 1146104239711760>>(n<<2) Test: print([(0x4126030156610>>(n<<2))%7 for n in range(1,13)]) [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]


33

6502 machine code (C64 PAL), 189 165 bytes 00 C0 A9 17 8D 18 D0 A9 40 85 FE E6 FE 20 E4 FF F0 FB 20 D2 FF C5 FE 38 D0 38 C9 5A 18 F0 33 C9 41 D0 E8 A9 00 85 FC 85 FD A9 18 85 FB A9 7F 8D 0D DD A9 7F 8D 18 03 A9 C0 8D 19 03 A9 D8 8D 04 DD A9 03 8D 05 DD A9 01 8D 0E DD A9 81 8D 0D DD D0 B9 A9 7F 8D 0D DD A9 47 8D 18 03 A9 FE AD 19 03 CE 0E DD B0 14 A9 0D 20 ...


32

2.0 (127004 >> i) ^ 60233 or (score 2.2) : (i * 3246) ^ 130159 All found with brute force :-)


32

JavaScript (ES6),  48 47 44 43  42 bytes m=>31^'311'[parseInt(m[1]+m[2],34)*3%49%8] Demo let f = m=>31^'311'[parseInt(m[1]+m[2],34)*3%49%8] ;( 'JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,' + 'JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER' ).split`,` .forEach(m => console.log(...


31

Mathematica, 45 37 27 24 bytes #+5[6,6,11][[#~Mod~4]]& Improvements thanks to @MartinBüttner (10 bytes), and @ChipHurst (a further 3 bytes).


29

Unix, 39 bytes echo{,} "It\'s christmas"|at -t12252359 With help from Dennis, thanks for that.


29

Operation Flashpoint scripting language,  174  171 bytes s="" #l t=_time t=t-t%1 a=t%60 c=(t-a)/60 b=c%60 c=(c-b)/60 d="" e=d f=d ?a<10:d=0 ?b<10:e=0 ?c<10:f=0 s=s+format["%1%2:%3%4:%5%6\n",f,c,e,b,d,a] hint s @t+1<_time goto"l" In action: 158 bytes, if the previous time is overwritten by the next time: #l t=_time t=t-t%1 a=t%60 c=(t-a)/60 b=...


27

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


26

MUMPS - 30 characters, circa 1966 (ANSI standard first in 1977) My first attempt at code golf, here we go! f w "4 8 15 16 23 42" h 6420 MUMPS is still a popular language for EHR software, created by Massachusetts General Hospital in Boston. Most known implementation is Epic Systems in Verona, WI.


26

JavaScript (ES6), 74 bytes You may want to change your system clock before testing, congratulations if you landed here at 59 minutes past. setTimeout(a=alert,36e5-new Date%36e5,"dary!");a`Legen... wait for it... `


25

CJam, 72 70 69 64 bytes 26,"~g¼K&Béx¸¦­Ø"240bFbf{<1b2md\1972+'-@6X$4*-'-Z3$" 23:59:60"N} Try it online in the CJam interpreter. Idea We start by encoding each leap second as 2 * (Y - 1972) + D, where D is 1 if it occurs in December and 0 otherwise. The array of all encoded leap seconds is: [0 1 3 5 7 9 11 13 15 18 20 22 26 31 35 37 40 42 44 47 ...


24

HTML, 594 bytes 1972-06-30 23:59:60<br>1972-12-31 23:59:60<br>1973-12-31 23:59:60<br>1974-12-31 23:59:60<br>1975-12-31 23:59:60<br>1976-12-31 23:59:60<br>1977-12-31 23:59:60<br>1978-12-31 23:59:60<br>1979-12-31 23:59:60<br>1981-06-30 23:59:60<br>1982-06-30 23:59:60<br>1983-06-30 23:59:60<...


24

C (Windows), 361 bytes #import<time.h> #import<windows.h> C(x){SetConsoleTextAttribute(GetStdHandle(-11),x);}F(I,N,l,a,n,d)time_t n;struct tm*d;{system("mode 90,65");time(&n);d=gmtime(&n);n=d->tm_year<<24|d->tm_mon<<16|d->tm_mday<<8|d->tm_hour;for(a=l=I=15;I++<70;a=l=I<35|I>49?15:9)for(N=n>...


24

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


23

PHP, 65 48 42 41 36 (+2 for -F) = 38 bytes <?date(Md,strtotime("4thuXI$argn")); Takes input as the first command line argument. Runs with warnings, which are acceptable by our rules. Prints NovDD, where DD is the day of Thanksgiving. No online link because ideone doesn't support command line args and I don't know of an online interpreter that does. ...


22

APL, 16 14 12 characters Returns 0 for a leap year, 1 for a non-leap year. ≥/⌽×4 25 4⊤⎕ Try this solution on tryapl.org. Note that I have changed the solution to the dfn {≥/⌽×4 25 4⊤⍵} as tryapl.com does not support ⎕ (take user input). Note that ⎕ is an empty box, not a missing character. The same solution in J: 4 25 4>:/@|.@:*@#:] Explanation ...


22

Pyth, 21 20 bytes -1 byte by Dennis c/J-*3.d3C\ᙹ4T+33J These have the same byte count but are ASCII-only: c/J%*3.d3 523 4T+33J c/-J%*3.d3*44T33 4TJ I don't know Pyth, so still probably possibly golfable. Using the same algorithm: TI-BASIC, 23 bytes max(3getDate-5753 {.1int(Ans/4),Ans+33 getDate returns a list of three floats {YYYY,MM,DD} in some ...


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