이미 [현재 연도], 여러분, 집에 가십시오


31

대부분에 은 현재 도전의 해당 연도가 아닌 경우, 그것은 앞이 말한다 도전한다.

벌써 [현재의 해], 여러분, 집에 가십시오.

현재 연도를 대체하여이 텍스트를 출력해야합니다.


I / O

입력 : 없음

출력 : It's [year] already, folks, go home.[연도]가 현재 연도로 변경되었습니다.


17
첫 시운전, 날짜 대신 시간을 가졌습니다. 이미 8시 58 분입니다.
steenbergh

입력을 한 다음 무시할 수 있습니까 (즉 String goHome(Object foo){return "It's "+currentYear()+" already, folks, go home.";}, 물론 훨씬 더 짧은 줄을 따라 무언가를 할 수 있습니까)?
dorukayhan 님이 Monica 님을

문자 그대로 도전 과제를 컴파일해서는 안되는 것은 부끄러운 일입니다. ///, 46 bytesIt's the current year already, folks, go home.
SparklePony 동지 17

3
@steenbergh 아침에 학교 만 그랬다면. xD : P
HyperNeutrino

만약 "현재 연도가 아니라면 이것을 출력하고 다른 것을 출력하지 않는다면"이 도전이 더 적절할 것이라고 생각하지만 여전히 좋은 도전 +1
Tas

답변:



17

C (gcc), 58 바이트

f(){printf("It's%s already, folks, go home.",__DATE__+6);}

19
올바른 기능을 사용하려면 1 년에 한 번이 파일을 다시 컴파일해야합니다.
Robert Fraser

3
@RobertFraser이 사이트에서 C (gcc) 응답을 실행하려면 다음과 같이 실행합니다 gcc golf.c && ./a.out. 이 과정에서 바이너리가 형성되는 것은 코드 골프와 관련이 없습니다. 바이너리가 생성되는 것이 아니라 내 소스 코드가 판단되고 있습니다 (이 경우 내 대답은 x86-64입니다).
orlp

1
사실, 그러나 이것은 "원하는 출력을 생성하는 AC 프로그램"이 아니라 "원하는 출력을 생성하는 쉘 명령"
Elazar

2
@ 12431234123412341234123 codegolf에서 사용할 수있는 함수는 여기입니다.
orlp

1
Nitpickers ... 이후 @orlp, __DATE__[6]공간이며, 당신이 한 바이트를 절약 할 수 있습니다 ..."It's%s already, folks, go home.",__DATE__+6);}(사이에 누락 된 공간을 마음 그것은이다%s).
YSC

15

05AB1E , 21 20 바이트

Outgolfer Erik 덕분에 바이트 절약

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

온라인으로 사용해보십시오!


1
“...»압축 된 문자열에 대한 구문이 »있으며 어떤 경우에도 억제 할 수없는 Jelly와 05AB1E를 혼동하고 있다고 생각합니다 .
Outgolfer Erik

3
이것은 읽을 수있는 텍스트가없는 유일한 솔루션입니다 :(
boboquack

1
설명해주세요
ckjbgames

2
@ckjbgames 내장 사전
qwr

@boboquack 예, It's 읽을 수 있습니다. 나머지는 작업을 수행 하십시오 .
user202729


11

PHP, 42 바이트

It's <?=date(Y)?> already, folks, go home.

주위에 따옴표가 필요합니다 Y.
Micheal Johnson

3
@MichealJohnson PHP는 인식되지 않은 상수를 같은 값을 가진 문자열로 변환하므로 작동해야합니다 (그러나 통지가 나옵니다)
Erik

7
@MichealJohnson 당신은 PHP에 대해 확신하지 못합니다
Charlie

8

배쉬, 45 자

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

printf버전 4.2 에 내장 된 Bash 는 %(fmt)T형식 지정자를 가져 왔으며 버전 4.3 이후에는 인수가없는 경우 현재 시간 소인으로 기본 설정됩니다.

샘플 실행 :

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

6

배치, 45 바이트

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

배치는 실제로 한 번 합리적입니다.


1
이 솔루션의 결과는 로케일 설정에 따라 다릅니다 ...
stevefestl

6

수학, 53 바이트

Print["It's ",Now[[1,1]]," already, folks, go home."]

3
"이제 사람들은 이미 집에 가십시오"라고 읽습니다.
Roman Gräf

5

DOS의 x86 기계 코드-62 바이트

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

BIOS의 입력이 BCD에 있더라도 (동일한 DOS 호출에서 얻은 일반 16 비트 값과 달리) ASCII로 디코딩하는 것은 레지스터를 인쇄하는 10 진 정도의 길이 인 것으로 판명되었습니다. 오 잘

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




4

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.



3

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

you can inline L_1 in the 5.1 programs. gets rid of a newline, two "L_1" tokens, and a →. 6 bytes saved?
striking

@striking LinReg(ax+b) uses L_1 and L_2, so I have to set them both.
pizzapants184

Save some bytes on the first: use max(getDate) instead because the largest number in getDate is always the year.
lirtosiast

3

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())


+1 Exactly the solution I was about to post. You could also use substr(11,4) or slice(11,15) instead of the split.
Shaggy

Don't you require more than 56 bytes as part the challenge is to output it?
cnorthfield

3
@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.
powelles

@powelles Thank you for explaining
cnorthfield

That is true @powelles, but your answer doesn't return anything unless more is added to your golf.
Kyle Fairns


3

PowerShell 3.0, 44 bytes

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

PowerShell is competing quite well today!


1
This will not work in version 2 of PowerShell (the foreach syntax). So you should have a v3+ identifier on here. Cool other wise.
Matt

2

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());
    }
}

6
I think you can save characters by using C# 6 strings: $"It's {DateTime.Now.Year} etc etc".
Arturo Torres Sánchez

()=>$"It's {DateTime.Now.Year} already, folks, go home."; 57
wertzui

2

Pyth, 38 bytes

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

Online interpreter.


Same length: s["It's ".d3d." y\n9?}7Tè+1°Õh6%Ñ< (If you replace \n by an actual newline) link
KarlKastor

@KarlKastor How did that work for you?
Erik the Outgolfer

Don't quite get the question. I used the online interpreter. The algorithm to create pyth's packed ."strings is: +++\.N++hSzeSzCi-RChSzCMz-hCeSzChSzN
KarlKastor

@KarlKastor I used that, but it must be something in Chrome, and I highly doubt it's the printable unprintable characters.
Erik the Outgolfer

2

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.


2

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


Welcome to PPCG! Please golf your answer (remove the spaces around the +s!)
programmer5000

1
console.log("It's",new Date().getFullYear(),"already, folks, go home.") for 71 bytes
ovs

@fəˈnɛtɪk reverted back to console.log, added brackets to ES6 alert
cnorthfield

2

R, 62 59 62 bytes

cat("It's",format(Sys.time(),"%Y"),"already, folks, go home.")

1
Using substr(date(),21,24) instead of format(Sys.time(),"%Y") saves three bytes
bouncyball

does this works in year 20017?
Roman Gräf

Ahh. Correct. Reverting back. Tnx!!
Zahiro Mor

2

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.


@JamesHolderness Arghhh, that explains why I've never been able to get sysinfo working. Thanks a bunch!
Jo King


1

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

1

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


Save 6 bytes with print(f"It's {time.gmtime()[0]} already, go home")
L3viathan

@L3viathan thats too similar to the other Python answer
caird coinheringaahing

1

IBM/Lotus Notes Formula, 54 bytes

Not exactly challenging but here we go anyway...

"It's "+@Text(@Year(@Now))+" already, folks, go home."

1

Java 8, 81 78 bytes

()->System.out.print("It's "+java.time.Year.now()+" already, folks, go home.")

1
Don't need the semicolon at the end of a lambda, and either print or printf will be shorter than println.
Pavel

1

T-SQL, 66 bytes

print concat('It''s ',year(getdate()),' already, folks, go home.')
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.