33
\$\begingroup\$

On most challenges when it is currently not the corresponding year of the challenge, It says this in the front.

It's [current year] already, folks, go home.

You have to output this text with the current year substituted.


I/O

Input: None.

Output: It's [year] already, folks, go home. with [year] changed to the current year.

\$\endgroup\$
11
  • 17
    \$\begingroup\$ First test run, got the time instead of the date: It's 8:58 already, folks, go home. \$\endgroup\$
    – steenbergh
    Apr 1, 2017 at 9:59
  • \$\begingroup\$ Can I take input and then ignore it (i.e do something along the lines of String goHome(Object foo){return "It's "+currentYear()+" already, folks, go home.";} (but much shorter, of course))? \$\endgroup\$
    – dorukayhan
    Apr 1, 2017 at 17:02
  • \$\begingroup\$ It's a shame I shouldn't compile the challenge to literally: ///, 46 bytes It's the current year already, folks, go home. \$\endgroup\$
    – sporklpony
    Apr 1, 2017 at 17:33
  • 3
    \$\begingroup\$ @steenbergh If only school was that way in the morning. xD :P \$\endgroup\$
    – hyper-neutrino
    Apr 1, 2017 at 21:33
  • \$\begingroup\$ I feel this challenge would be more appropriate if it were "if it's not the current year, output this, else output nothing", but still good challenge +1 \$\endgroup\$
    – Tas
    Apr 3, 2017 at 2:50

63 Answers 63

18
\$\begingroup\$

bash + date, 40 bytes

date +"It's %Y already, folks, go home."

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Also works with ZSH \$\endgroup\$
    – german_guy
    Apr 3, 2017 at 12:26
  • \$\begingroup\$ It works on nearly every shell, but I named it bash because TIO link is bash. \$\endgroup\$
    – fergusq
    Apr 3, 2017 at 12:39
17
\$\begingroup\$

C (gcc), 58 bytes

f(){printf("It's%s already, folks, go home.",__DATE__+6);}
\$\endgroup\$
12
  • 19
    \$\begingroup\$ Note you need to recompile this once a year to get the correct functionality. \$\endgroup\$ Apr 2, 2017 at 6:21
  • 3
    \$\begingroup\$ @RobertFraser To run any C (gcc) answer on this site you run it as gcc golf.c && ./a.out. That in this process a binary is formed is irrelevant for code golf. My source code is being judged, not the binary being generated (if that was the case my answer would be x86-64). \$\endgroup\$
    – orlp
    Apr 2, 2017 at 12:15
  • 1
    \$\begingroup\$ True, but this is not "A C program that will produce the desired output" but "A shell command that will produce the desired output" \$\endgroup\$
    – Elazar
    Apr 2, 2017 at 18:00
  • 2
    \$\begingroup\$ @12431234123412341234123 Functions are acceptable answers here on codegolf. \$\endgroup\$
    – orlp
    Apr 3, 2017 at 9:57
  • 1
    \$\begingroup\$ Nitpickers ... @orlp, since __DATE__[6] is a space, you can spare one byte: ..."It's%s already, folks, go home.",__DATE__+6);} (mind the missing space between It's and %s). \$\endgroup\$
    – YSC
    Apr 3, 2017 at 11:50
15
\$\begingroup\$

05AB1E, 21 20 bytes

Saved a byte thanks to Erik the Outgolfer

žg“It's ÿˆ§,¹Ò,‚œ€¨.

Try it online!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ I think you were confusing 05AB1E with Jelly, which has “...» syntax for compressed strings and the » can't be suppressed in any case. \$\endgroup\$ Apr 1, 2017 at 11:30
  • 3
    \$\begingroup\$ This is the only solution without readable text :( \$\endgroup\$
    – boboquack
    Apr 2, 2017 at 6:47
  • 1
    \$\begingroup\$ Explanation please? \$\endgroup\$
    – ckjbgames
    Apr 2, 2017 at 22:52
  • 2
    \$\begingroup\$ @ckjbgames built-in dictionary \$\endgroup\$
    – qwr
    Apr 2, 2017 at 23:18
  • \$\begingroup\$ @boboquack Yes, It's is readable. For the rest do this. \$\endgroup\$
    – DELETE_ME
    Apr 12, 2018 at 14:38
14
\$\begingroup\$

TeX (44 bytes)

It's \the\year\ already, folks, go home.\bye
\$\endgroup\$
0
11
\$\begingroup\$

PHP, 42 bytes

It's <?=date(Y)?> already, folks, go home.
\$\endgroup\$
3
  • \$\begingroup\$ Pretty sure you need quotes around the Y. \$\endgroup\$ Apr 3, 2017 at 7:57
  • 3
    \$\begingroup\$ @MichealJohnson PHP will convert unrecogized constants to strings with the same value, so this should work (but it'll throw a notice) \$\endgroup\$
    – Erik
    Apr 3, 2017 at 8:19
  • 7
    \$\begingroup\$ @MichealJohnson You're never sure with PHP \$\endgroup\$
    – Charlie
    Apr 3, 2017 at 14:36
8
\$\begingroup\$

Bash, 45 characters

printf "It's %(%Y)T already, folks, go home."

Bash's built-in printf in version 4.2 got the %(fmt)T format specifier and since version 4.3 it defaults to current timestamp in absence of argument.

Sample run:

bash-4.3$ printf "It's %(%Y)T already, folks, go home."
It's 2017 already, folks, go home.
\$\endgroup\$
6
\$\begingroup\$

Batch, 45 bytes

@echo It's %date:~6% already, folks, go home.

Batch is actually reasonably competitive for once.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I guess this solution result varies from different locale settings... \$\endgroup\$
    – stevefestl
    Apr 1, 2017 at 11:11
6
\$\begingroup\$

Mathematica, 53 bytes

Print["It's ",Now[[1,1]]," already, folks, go home."]
\$\endgroup\$
1
  • 3
    \$\begingroup\$ Reads like "It's Now already, folks, go home." \$\endgroup\$ Apr 4, 2017 at 10:25
5
\$\begingroup\$

Python 2, 67 bytes

import time
print"It's",time.gmtime()[0],"already, folks, go home."

Try it online!

\$\endgroup\$
5
\$\begingroup\$

x86 machine code on DOS - 62 bytes

00000000  b4 04 cd 1a bf 23 01 88  c8 24 0f 00 05 4f c1 e9  |.....#...$...O..|
00000010  04 75 f4 ba 1b 01 b4 09  cd 21 c3 49 74 27 73 20  |.u.......!.It's |
00000020  30 30 30 30 20 61 6c 72  65 61 64 79 2c 20 66 6f  |0000 already, fo|
00000030  6c 6b 73 2c 20 67 6f 20  68 6f 6d 65 2e 24        |lks, go home.$|
0000003e

Even though the input from the BIOS is in BCD (as opposed to the plain 16 bit value got from the equivalent DOS call), decoding it to ASCII turned out to be almost as long as base-10 printing a register. Oh well.

    org 100h

section .text

start:
    mov ah,4
    int 1ah             ; get the date from BIOS; cx now contains the year in packed BCD
    mov di,placeholder  ; put di on the last character of placeholder
lop:
    mov al,cl
    and al,0xf  ; get the low nibble of cx
    add [di],al ; add it to the digit
    dec di      ; previous character
    shr cx,4    ; next nibble
    jnz lop     ; loop as long as we have digits to unpack in cx
    mov dx,its
    mov ah,9
    int 21h     ; print the whole string
    ret

its:
    db "It's 000"
placeholder:
    db "0 already, folks, go home.$"
\$\endgroup\$
4
\$\begingroup\$

Ruby, 52 bytes

puts"It's #{Time.now.year} already, folks, go home."
\$\endgroup\$
4
\$\begingroup\$

CJam, 38 bytes

"It's "et0=" already, folks, go home."

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Mathematica, 58 bytes

"It's "<>ToString@#<>" already, folks, go home."&@@Date[]&

Anonymous function. Takes no input and returns a string as output. No, I'm not going to make a REPL submission, post it yourself if that one byte is so important.

\$\endgroup\$
3
\$\begingroup\$

Perl 6,  53  51 bytes

say "It's {Date.today.year} already, folks, go home."

Try it

say "It's {now.Date.year} already, folks, go home."

Try it

\$\endgroup\$
3
\$\begingroup\$

TI-Basic (TI-84 Plus CE with OS 5.2+), 64 bytes

getDate
"It's "+toString(Ans(1))+" already, folks, go home.

TI-Basic is a tokenized language. Some commands (getDate, toString(, etc.), and all lowercase letters are two-bytes and everything else used here is one byte each.

Explanation:

getDate                                             # 3, store {Y,M,D} in Ans
"It's "+toString(Ans(1))+" already, folks, go home. # 61, implicitly return required string with Y from getDate

TI-Basic (TI-84 Plus CE with OS 5.1), 108 bytes

{0,1→L1
getDate
Ans(1)L1→L2
LinReg(ax+b) Y1
Equ►String(Y1,Str0
sub(Str0,1,length(Str0)-3→Str0
"It's "+Str0+" already, folks, go home.

TI-Basic is a tokenized language. The more complicated user variables (Y1, L1, L2, Str0), some commands (LinReg(ax+b , getDate, sub(, Equ►String(, length(), and all lowercase letters are two-bytes and everything else used here is one byte each.

OS 5.2 added a toString( command, which obsolesces about half of this submission, which is based off of this algorithm.

Explanation:

{0,1→L1                                  # 8 bytes
getDate                                  # 3 bytes, store {Y,M,D} list in Ans
Ans(1)L1→L2                              # 10 bytes, multiply L1 by the year and store in L2
LinReg(ax+b) Y1                          # 5 bytes, take a linear regression of the points specified by each pair of corresponding coordinates in L1 and L2 and store it in Y1
Equ►String(Y1,Str0                       # 8 bytes, convert Y1 to a string
sub(Str0,1,length(Str0)-3→Str0           # 18 bytes, remove the "X+0" from LinReg
"It's "+Str0+" already, folks, go home.  # 56 bytes, implicitly return the required output
\$\endgroup\$
3
  • \$\begingroup\$ you can inline L_1 in the 5.1 programs. gets rid of a newline, two "L_1" tokens, and a →. 6 bytes saved? \$\endgroup\$
    – striking
    Apr 1, 2017 at 21:56
  • \$\begingroup\$ @striking LinReg(ax+b) uses L_1 and L_2, so I have to set them both. \$\endgroup\$ Apr 1, 2017 at 22:25
  • \$\begingroup\$ Save some bytes on the first: use max(getDate) instead because the largest number in getDate is always the year. \$\endgroup\$
    – lirtosiast
    Apr 6, 2017 at 18:43
3
\$\begingroup\$

JavaScript ES6, 56 bytes

_=>`It's ${Date().split` `[3]} already, folks, go home.`

Try it online!

const f = _=>`It's ${Date().split` `[3]} already, folks, go home.`

console.log(f())

\$\endgroup\$
9
  • \$\begingroup\$ +1 Exactly the solution I was about to post. You could also use substr(11,4) or slice(11,15) instead of the split. \$\endgroup\$
    – Shaggy
    Apr 2, 2017 at 9:57
  • \$\begingroup\$ Don't you require more than 56 bytes as part the challenge is to output it? \$\endgroup\$ Apr 2, 2017 at 10:30
  • 3
    \$\begingroup\$ @cnorthfield Generally speaking in code golf, a function that returns a value is an acceptable answer unless the question has more specific requirements. Check out this and this. \$\endgroup\$
    – powelles
    Apr 2, 2017 at 19:11
  • \$\begingroup\$ @powelles Thank you for explaining \$\endgroup\$ Apr 2, 2017 at 19:51
  • \$\begingroup\$ That is true @powelles, but your answer doesn't return anything unless more is added to your golf. \$\endgroup\$ Apr 3, 2017 at 12:54
3
\$\begingroup\$

Japt, 31 bytes

`It's {Ki} alÎ%y, folks, go Êà.

Try it online!

\$\endgroup\$
3
\$\begingroup\$

PowerShell 3.0, 44 bytes

"It's $(date|% y*) already, folks, go home."

PowerShell is competing quite well today!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This will not work in version 2 of PowerShell (the foreach syntax). So you should have a v3+ identifier on here. Cool other wise. \$\endgroup\$
    – Matt
    Apr 3, 2017 at 15:09
2
\$\begingroup\$

C#, 58 bytes

()=>"It's "+DateTime.Now.Year+" already, folks, go home.";

Anonymous function which returns the required string.

Full program:

using System;
                    
public class Program
{
    public static void Main()
    {
        Func<string> f=
        ()=>"It's "+DateTime.Now.Year+" already, folks, go home.";
        
        Console.WriteLine(f());
    }
}
\$\endgroup\$
2
  • 6
    \$\begingroup\$ I think you can save characters by using C# 6 strings: $"It's {DateTime.Now.Year} etc etc". \$\endgroup\$ Apr 1, 2017 at 16:14
  • \$\begingroup\$ ()=>$"It's {DateTime.Now.Year} already, folks, go home."; 57 \$\endgroup\$
    – wertzui
    Mar 9, 2018 at 12:49
2
\$\begingroup\$

Pyth, 38 bytes

s["It's ".d3" already, folks, go home.

Online interpreter.

\$\endgroup\$
4
  • \$\begingroup\$ Same length: s["It's ".d3d." y\n9?}7Tè+1°Õh6%Ñ< (If you replace \n by an actual newline) link \$\endgroup\$
    – KarlKastor
    Apr 1, 2017 at 17:36
  • \$\begingroup\$ @KarlKastor How did that work for you? \$\endgroup\$ Apr 1, 2017 at 18:04
  • \$\begingroup\$ Don't quite get the question. I used the online interpreter. The algorithm to create pyth's packed ."strings is: +++\.N++hSzeSzCi-RChSzCMz-hCeSzChSzN \$\endgroup\$
    – KarlKastor
    Apr 1, 2017 at 18:10
  • \$\begingroup\$ @KarlKastor I used that, but it must be something in Chrome, and I highly doubt it's the printable unprintable characters. \$\endgroup\$ Apr 1, 2017 at 18:14
2
\$\begingroup\$

Haskell, 113 bytes

import Data.Time.Clock
f=do t<-getCurrentTime;putStr$"It's "++(fst.span(>'-').show)t++" already, folks, go home."

Try it online! Replace f with main for a full program.

The function getCurrentTime returns a UTCTime object which looks something like "2017-04-02 10:22:29.8550527 UTC" when converted to a string by show. fst.span(>'-') takes the leading characters while they are larger than '-', that is the current year. For the next 7972 years take 4 would work for 8 bytes less, but we want our code to work correctly for ever and ever.

As far as I see build-in functions to get the current year require a import Data.Time.Calendar, so extracting the year from the string should be the shortest option.

\$\endgroup\$
2
\$\begingroup\$

JavaScript, 77 71 67 63 bytes

alert("It's "+Date().split(' ')[3]+" already, folks, go home.")

Thanks to @programmer5000 for the spaces!

JavaScript ES6 66 60 bytes

alert(`It's ${Date().split` `[3]} already, folks, go home.`)

\$\endgroup\$
3
  • \$\begingroup\$ Welcome to PPCG! Please golf your answer (remove the spaces around the +s!) \$\endgroup\$
    – user58826
    Apr 1, 2017 at 14:18
  • 1
    \$\begingroup\$ console.log("It's",new Date().getFullYear(),"already, folks, go home.") for 71 bytes \$\endgroup\$
    – ovs
    Apr 1, 2017 at 14:18
  • \$\begingroup\$ @fəˈnɛtɪk reverted back to console.log, added brackets to ES6 alert \$\endgroup\$ Apr 1, 2017 at 17:28
2
\$\begingroup\$

R, 62 59 62 bytes

cat("It's",format(Sys.time(),"%Y"),"already, folks, go home.")
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Using substr(date(),21,24) instead of format(Sys.time(),"%Y") saves three bytes \$\endgroup\$
    – bouncyball
    Apr 3, 2017 at 13:51
  • \$\begingroup\$ does this works in year 20017? \$\endgroup\$ Apr 4, 2017 at 10:19
  • \$\begingroup\$ Ahh. Correct. Reverting back. Tnx!! \$\endgroup\$
    – Zahiro Mor
    Apr 4, 2017 at 19:58
2
\$\begingroup\$

Befunge-98, 57 55 bytes

"emoh og ,sklof ,ydaerla@ s'tI"4k,y\4*:*/"&2"*+.f7+k,@

Try it online!

Thanks to James Holderness for pointing out my mistake with the sysinfo instruction.

"emoh og ,sklof ,ydaerla@ s'tI" pushes the sentence to the stack where 4k, prints the first word. y is the sysinfo instruction. When passed 20 (the unprintable in the string), it returns 256*256*(year-1900) + 256*month + day of month. \4*:*/"&2"*+. takes just the year from the value and prints it andf7+k, prints the rest of the sentence.

\$\endgroup\$
1
  • \$\begingroup\$ @JamesHolderness Arghhh, that explains why I've never been able to get sysinfo working. Thanks a bunch! \$\endgroup\$
    – Jo King
    Mar 6, 2018 at 23:31
1
\$\begingroup\$

GolfScript, 48 bytes

"It's #{Time.new.year} already, folks, go home."

Try it online!

Yes, this is string interpolation.

\$\endgroup\$
1
\$\begingroup\$

MATL, 42 bytes

'It''s '1&Z'V' already, folks, go home.'&h

Try it online!

'It''s '                      % Push this string
1&Z'                          % Push current year
V                             % Convert to string
' already, folks, go home.'   % Push this string
&h                            % Concatenate all stack contents horizontally
                              % Implicitly display
\$\endgroup\$
1
\$\begingroup\$

Python 3, 73 68 bytes

import time
print(time.strftime("It's %Y already, folks, go home."))

Very basic answer. The "%Y" gets the current year.

Thanks to @ovs for removing 5 bytes

\$\endgroup\$
2
  • \$\begingroup\$ Save 6 bytes with print(f"It's {time.gmtime()[0]} already, go home") \$\endgroup\$
    – L3viathan
    Jun 3, 2017 at 11:49
  • \$\begingroup\$ @L3viathan thats too similar to the other Python answer \$\endgroup\$ Jun 3, 2017 at 11:50
1
\$\begingroup\$

IBM/Lotus Notes Formula, 54 bytes

Not exactly challenging but here we go anyway...

"It's "+@Text(@Year(@Now))+" already, folks, go home."
\$\endgroup\$
1
\$\begingroup\$

VBScript, 53 bytes

msgbox"It's "&year(now())&" already, folks, go home."
\$\endgroup\$
1
  • \$\begingroup\$ You could save 4 bytes by assigning to a variable and 2 more by dropping the parentheses after now, giving you s="It's "&year(now)&" already, folks, go home." (49 bytes). In fact, you can shave 4 more bytes off by just using It's <%year(now)%> already, folks, go home. (45 bytes). \$\endgroup\$
    – Shaggy
    Apr 3, 2017 at 11:10
1
\$\begingroup\$

Java 8, 81 78 bytes

()->System.out.print("It's "+java.time.Year.now()+" already, folks, go home.")
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Don't need the semicolon at the end of a lambda, and either print or printf will be shorter than println. \$\endgroup\$
    – Pavel
    Apr 2, 2017 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.