Auf den meisten neuen Jahren Herausforderungen , wenn es zur Zeit nicht das entsprechende Jahr der Herausforderung ist, es sagt , das in der Front.
Es ist schon [aktuelles Jahr], Leute, geht nach Hause.
Sie müssen diesen Text mit dem ersetzten aktuellen Jahr ausgeben.
I / O
Eingabe: Keine.
Ausgabe : It's [year] already, folks, go home.
mit [Jahr] auf das aktuelle Jahr geändert.
String goHome(Object foo){return "It's "+currentYear()+" already, folks, go home.";}
(aber natürlich viel kürzer))?It's the current year already, folks, go home.
Antworten:
bash + date, 40 bytes
Try it online!
quelle
C (gcc), 58 bytes
quelle
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).__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
).05AB1E,
2120 bytesSaved a byte thanks to Erik the Outgolfer
Try it online!
quelle
“...»
syntax for compressed strings and the»
can't be suppressed in any case.It's
is readable. For the rest do this.TeX (44 bytes)
quelle
PHP, 42 bytes
quelle
Y
.Bash, 45 characters
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:
quelle
Batch, 45 bytes
Batch is actually reasonably competitive for once.
quelle
Mathematica, 53 bytes
quelle
x86 machine code on DOS - 62 bytes
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.
quelle
Ruby, 52 bytes
quelle
Python 2, 67 bytes
Try it online!
quelle
CJam, 38 bytes
Try it online!
quelle
Mathematica, 58 bytes
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.
quelle
Perl 6,
5351 bytesTry it
Try it
quelle
TI-Basic (TI-84 Plus CE with OS 5.2+), 64 bytes
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:
TI-Basic (TI-84 Plus CE with OS 5.1), 108 bytes
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:
quelle
LinReg(ax+b)
uses L_1 and L_2, so I have to set them both.max(getDate)
instead because the largest number in getDate is always the year.JavaScript ES6, 56 bytes
Try it online!
quelle
substr(11,4)
orslice(11,15)
instead of thesplit
.Japt, 31 bytes
Try it online!
quelle
PowerShell 3.0, 44 bytes
PowerShell is competing quite well today!
quelle
C#, 58 bytes
Anonymous function which returns the required string.
Full program:
quelle
()=>$"It's {DateTime.Now.Year} already, folks, go home.";
57Pyth, 38 bytes
Online interpreter.
quelle
s["It's ".d3d." y\n9?}7Tè+1°Õh6%Ñ<
(If you replace\n
by an actual newline) link+++\.N++hSzeSzCi-RChSzCMz-hCeSzChSzN
Haskell, 113 bytes
Try it online! Replace
f
withmain
for a full program.The function
getCurrentTime
returns aUTCTime
object which looks something like"2017-04-02 10:22:29.8550527 UTC"
when converted to a string byshow
.fst.span(>'-')
takes the leading characters while they are larger than'-'
, that is the current year. For the next 7972 yearstake 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.quelle
JavaScript,
77716763 bytesThanks to @programmer5000 for the spaces!
JavaScript ES6
6660 bytesquelle
+
s!)console.log("It's",new Date().getFullYear(),"already, folks, go home.")
for 71 bytesR,
62 5962 bytesquelle
substr(date(),21,24)
instead offormat(Sys.time(),"%Y")
saves three bytes20017
?Befunge-98,
5755 bytesTry 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 where4k,
prints the first word.y
is the sysinfo instruction. When passed 20 (the unprintable in the string), it returns256*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.quelle
GolfScript, 48 bytes
Try it online!
Yes, this is string interpolation.
quelle
MATL, 42 bytes
Try it online!
quelle
Python 3,
7368 bytesVery basic answer. The "%Y" gets the current year.
Thanks to @ovs for removing 5 bytes
quelle
print(f"It's {time.gmtime()[0]} already, go home")
IBM/Lotus Notes Formula, 54 bytes
Not exactly challenging but here we go anyway...
quelle
Java 8,
8178 bytesquelle
T-SQL, 66 bytes
quelle