Encode the date in Christmas Eve format
$begingroup$
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve
.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
$endgroup$
|
show 15 more comments
$begingroup$
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve
.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
$endgroup$
6
$begingroup$
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:36
24
$begingroup$
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:38
6
$begingroup$
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
$endgroup$
– PyRulez
Dec 24 '18 at 23:41
1
$begingroup$
Can the date be a parameter?
$endgroup$
– Olivier Grégoire
Dec 26 '18 at 11:23
1
$begingroup$
@OlivierGrégoire uhm, I'll permit it iff the language does not have the ability to get the current date in another way.
$endgroup$
– PyRulez
Dec 26 '18 at 14:53
|
show 15 more comments
$begingroup$
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve
.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
$endgroup$
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve
.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
code-golf string date
edited Dec 26 '18 at 16:31
PyRulez
asked Dec 24 '18 at 23:10
PyRulezPyRulez
3,58542357
3,58542357
6
$begingroup$
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:36
24
$begingroup$
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:38
6
$begingroup$
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
$endgroup$
– PyRulez
Dec 24 '18 at 23:41
1
$begingroup$
Can the date be a parameter?
$endgroup$
– Olivier Grégoire
Dec 26 '18 at 11:23
1
$begingroup$
@OlivierGrégoire uhm, I'll permit it iff the language does not have the ability to get the current date in another way.
$endgroup$
– PyRulez
Dec 26 '18 at 14:53
|
show 15 more comments
6
$begingroup$
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:36
24
$begingroup$
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:38
6
$begingroup$
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
$endgroup$
– PyRulez
Dec 24 '18 at 23:41
1
$begingroup$
Can the date be a parameter?
$endgroup$
– Olivier Grégoire
Dec 26 '18 at 11:23
1
$begingroup$
@OlivierGrégoire uhm, I'll permit it iff the language does not have the ability to get the current date in another way.
$endgroup$
– PyRulez
Dec 26 '18 at 14:53
6
6
$begingroup$
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:36
$begingroup$
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:36
24
24
$begingroup$
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:38
$begingroup$
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:38
6
6
$begingroup$
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
$endgroup$
– PyRulez
Dec 24 '18 at 23:41
$begingroup$
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
$endgroup$
– PyRulez
Dec 24 '18 at 23:41
1
1
$begingroup$
Can the date be a parameter?
$endgroup$
– Olivier Grégoire
Dec 26 '18 at 11:23
$begingroup$
Can the date be a parameter?
$endgroup$
– Olivier Grégoire
Dec 26 '18 at 11:23
1
1
$begingroup$
@OlivierGrégoire uhm, I'll permit it iff the language does not have the ability to get the current date in another way.
$endgroup$
– PyRulez
Dec 26 '18 at 14:53
$begingroup$
@OlivierGrégoire uhm, I'll permit it iff the language does not have the ability to get the current date in another way.
$endgroup$
– PyRulez
Dec 26 '18 at 14:53
|
show 15 more comments
29 Answers
29
active
oldest
votes
$begingroup$
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.
$endgroup$
7
$begingroup$
pure genius ...
$endgroup$
– FlipTack
Dec 25 '18 at 11:43
7
$begingroup$
This made me Smile...
$endgroup$
– Neil
Dec 25 '18 at 14:10
3
$begingroup$
Nice! One of my JavaScript solutions takes a similar approach. However, in JavaScript the wait time is just a best effort. How is SmileBASIC faring in this regard?
$endgroup$
– targumon
Dec 26 '18 at 0:16
4
$begingroup$
@12Me21 that would obviously fail due to leap seconds, this version looks much better.
$endgroup$
– Riker
Dec 26 '18 at 16:08
5
$begingroup$
+1 for thinking outside the box and making me laugh.
$endgroup$
– Tom
Dec 27 '18 at 10:29
|
show 3 more comments
$begingroup$
Excel formula, 59 bytes
="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,25)-TODAY())
$endgroup$
4
$begingroup$
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
$endgroup$
– Neil
Dec 25 '18 at 19:32
3
$begingroup$
I thinkYEAR(NOW()+6)works as well with 2 less bytes.
$endgroup$
– Engineer Toast
Dec 26 '18 at 20:01
2
$begingroup$
I think ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,26)-NOW()) is even shorter and I believe it should work.
$endgroup$
– JeroendeK
Dec 27 '18 at 14:02
1
$begingroup$
NOW()includes the time, so it won't be an integer and I'm not sureREPTwould allow that.
$endgroup$
– 12Me21
Dec 28 '18 at 4:57
2
$begingroup$
but this does not give "Christmas" on Christmas day. Check="Christmas"&REPT(" Eve",DATE(YEAR(DATE(2018,12,25)+6),12,26)-DATE(2018,12,25))
$endgroup$
– Anthony
Dec 29 '18 at 15:18
|
show 8 more comments
$begingroup$
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 representation of the dates.) The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
$endgroup$
$begingroup$
Could you do "month>11" to save a byte?
$endgroup$
– chrixbittinx
Dec 26 '18 at 19:35
2
$begingroup$
Would/12.25/work?
$endgroup$
– Cows quack
Dec 27 '18 at 7:49
2
$begingroup$
@Cowsquack no, because then it might match the year in dates like12025-12-24
$endgroup$
– Jo King
Dec 27 '18 at 12:05
$begingroup$
I think it's safe to assume that will never happen
$endgroup$
– 12Me21
Dec 28 '18 at 6:24
add a comment |
$begingroup$
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(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
$endgroup$
$begingroup$
You only useyonce so you can just use it directly for 108 bytes.
$endgroup$
– Giuseppe
Dec 25 '18 at 2:02
$begingroup$
Also wouldz[z>=0][1]work instead ofmin?
$endgroup$
– Giuseppe
Dec 25 '18 at 2:03
$begingroup$
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
$endgroup$
– digEmAll
Dec 25 '18 at 10:16
1
$begingroup$
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
$endgroup$
– J.Doe
Dec 25 '18 at 11:34
add a comment |
$begingroup$
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 will be interpreted as a boolean for the conditional where 0 (which will happen on Christmas) is interpreted as False (don't enter the loop), and any other value is interpreted as True (enter the loop).
Since the integer is on the left now, the date string will be converted to the integer and math will be done, as opposed to the previous version where the 1225 integer was converted to string for the comparison.
Original Version
Windows PowerShell, 67 bytes
for(;(date|% *ys $i|% tost* Md)-ne1225){$i++};'Christmas'+' eve'*$i
Try it online!
Using a for loop as a while loop basically, because it's shorter. In the loop condition we check the current date (date, a shortened form of Get-Date), piped to ForEach-Object's alias %, using the form that can invoke a method by wildcarded name; in this case the method is AddDays() on the DateTime object, and the value we give it is $i.
This gets piped to ForEach-Object again to invoke the ToString() method, with format string Md (month, then day, minimal digits since we don't care for what comes next). This string is then tested to see if it's not equal -ne to the number 1225, which will be converted to a string for the comparison, saving me the quotes.
This is why it doesn't matter that the months and days are single digits, it will never be ambiguous because there's no other day of the year that would stringify to 1225.
The loop continues until the string is 1225. At the beginning of the program, $i will be zero so it will be comparing today's date, and the loop will never execute, but for any other day $i gets incremented in the loop body, so that we will have a count of how many days until the next Christmas, automatically accounting for leap years and whether or not Christmas passed this year.
After the loop we just output the string Christmas concatenated with the result of multiplying the string eve times the value of $i (which, on Christmas day, will be 0, resulting in no eves).
$endgroup$
$begingroup$
Apparently the;after{$i++}is redundant? (also wow you took the lead over bash again)
$endgroup$
– Cows quack
Dec 27 '18 at 18:45
$begingroup$
@Cowsquack nice! how did I not notice that?!
$endgroup$
– briantist
Dec 27 '18 at 18:58
add a comment |
$begingroup$
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
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
$endgroup$
$begingroup$
...do you need to assign t to itself in the incrementor? I don't have the docs in front of me, but if not, you could save two bytes more.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:38
1
$begingroup$
oh, it's a struct. Of course it is. Nevermind.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:39
1
$begingroup$
You can substitutet.Month<12|t.Day!=25with the shorter$"{t:Md}"!="1225". It uses an interpolated string and a custom DateTime formatting string.
$endgroup$
– Jeppe Stig Nielsen
Dec 28 '18 at 23:34
add a comment |
$begingroup$
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.
$endgroup$
$begingroup$
Nice work. Save 2 withPRINT'Christmas'+...and 2 more by usingDATEDIFF(D,instead ofDATEDIFF(DAY,
$endgroup$
– BradC
Jan 7 at 16:19
$begingroup$
@BradC Nice, thanks!
$endgroup$
– Neil
Jan 7 at 16:54
add a comment |
$begingroup$
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 (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
$endgroup$
add a comment |
$begingroup$
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()
# get the year of the Christmas to compare to
# if the current date is after this year's Christmas, the 6 day offset will give the next year
# otherwise, returns this year
(d+timedelta(6)).year
# next Christmas minus the current date
date(.....................,12,25)-d
# Christmas, plus (number of days until next Christmas) " Eve"s
print"Christmas"+" Eve"*(...................................).days
$endgroup$
add a comment |
$begingroup$
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
$endgroup$
$begingroup$
77 bytes (i.e., save 3 bytes) by replacingputswithp: Try It Online link
$endgroup$
– Spencer Doak
Dec 30 '18 at 6:57
add a comment |
$begingroup$
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
$endgroup$
add a comment |
$begingroup$
JavaScript, 135 131 121 92 88 bytes
My first (naïve) solution (135b):
t=new Date();n=new Date();n.setMonth(11);n.setDate(25);'Christmas'+' Eve'.repeat((n>=t?n-t:(n.setFullYear(n.getFullYear()+1)-t))/864e5)
It sets 2 dates: now and Xmas of this year. If the latter hasn't passed yet, it just diffs them, if it has passed, diffs to next year's Xmas. Uses either diffs for the number of repeats.
(Trying to) Think Outside the Box (131b):
i=0;f=_=>{t=new Date();if(t.getMonth()!=11||t.getDate()!=25){i++;setTimeout(f,864e5)}else{alert('Christmas'+' Eve'.repeat(i))}};f()
The challange specifies WHICH output is required when running the program on a given day, but doesn't specify WHEN to return it...
This will just 'sleep' for a day, increment a counter by 1, and repeat till it's Xmas in order to give the output.
Since JavaScript doesn't guarantee the 'sleep' time, the actual result might be off.
It is also ugly for using the alert function, which means wer'e actually not dealing with pure JavaScript, but with browser APIs as well (we can use console.log at the cost of 6 extra bytes).
A better approach (121b):
t=new Date();i=0;while(t.getMonth()!=11||t.getDate()!=25){t=new Date(t.valueOf()+864e5);i++};'Christmas'+' Eve'.repeat(i)
Starting from today, increment the date by a day until it's Xmas, then use that loop's counter for the number of repeats required.
Improving (including going through a minifier and using 12Me21's trick to shave extra 5b) (92b):
for(s='Christmas',t=new Date;t.getMonth()/t.getDate()-.44;)t=new Date(t*1+864e5),s+=' Eve';s
Final touches (88b):
for(s='Christmas',t=new Date;t.getMonth()/(d=t.getDate())-.44;t.setDate(d+1))s+=' Eve';s
- For all of the above, REPL is assumed.
- See Vadim's submission - much better than mine!
$endgroup$
1
$begingroup$
I think you can uset.getMonth()/t.getDate-.48to check if date is not december 25th
$endgroup$
– 12Me21
Dec 26 '18 at 0:50
1
$begingroup$
Welcome to the site! You can use a 4 space indent to make your code blocks look better.
$endgroup$
– Wît Wisarhd
Dec 26 '18 at 3:51
1
$begingroup$
Welcome to PPCG!
$endgroup$
– Shaggy
Dec 26 '18 at 11:47
1
$begingroup$
98,printis needed since this is a program not a function, unless 1. you turn it into a lambda or 2. you state that you're using a REPL
$endgroup$
– ASCII-only
Dec 28 '18 at 1:28
1
$begingroup$
t=new Date(+t+864e5)is 1 byte shorter.
$endgroup$
– Andrew Svietlichnyy
Dec 29 '18 at 19:16
|
show 6 more comments
$begingroup$
Bash, 68 65 bytes
seq 0 366|sed 's/.*/date -d&day/e;1iChristmas
/c 25/Q;cEve'|xargs
Try it online!
BSD date should be able to save a byte with something like date -v+Ad (can't test it), however, BSD sed would add more bytes to i and c, requiring them to have a <newline>.
seq 0 366 create a stream of integers from 0 to 366
|sed perform the following sed code over each line of stream input
ssubstitute
.*the pattern space
date -d&daywith this string, with the match filling the place of&
ereplace the pattern space with itself evaluated as bash, which computes the date&days from today in the default format ofWed Dec 26 18:22:33 UTC 2018
1on the first line of input
iinsert
Christmasthis string above the line, so being on top of the output
/c 25/if the current line has ac 25in it, meaning it's Dec 25
Qquit the program without printing the pattern space, abruptly stopping any more lines from being read
c(otherwise) change the current line toEve
|xargs and convert newlines to spaces
$endgroup$
$begingroup$
There's nothing reallybash-specific about this solution. It requires GNUdate,sedandseqthough.
$endgroup$
– Kusalananda
Dec 27 '18 at 21:00
$begingroup$
-4 bytes
$endgroup$
– Nahuel Fouilleul
Dec 28 '18 at 9:12
add a comment |
$begingroup$
VBA (Excel), 108 bytes
Copy in a blank module. Prints to the Immediate window:
Sub X:s="Christmas":d=Now:For t=1 To (DateSerial(Year(d+6),12,25)-d):s=s &" Eve":Next:Debug.Print s:End Sub
Note: Using : instead of line breaks saves two bytes per line.
Notice that the VBA editor will insert additional spaces between keywords, operators, etc... and parenthesis after the Sub definition, but if you copy and paste this code it will work (I couldn't get rid of that space before the &).
Not bad for VBA (for once).
$endgroup$
1
$begingroup$
*Christmas:|
$endgroup$
– ASCII-only
Dec 26 '18 at 23:47
$begingroup$
@ASCII-only: removing the space before the&throws an error
$endgroup$
– Barranka
Dec 26 '18 at 23:49
$begingroup$
-1 bytes. Thanks to @ASCII-only for catching the typo
$endgroup$
– Barranka
Dec 27 '18 at 0:06
add a comment |
$begingroup$
Bash +GNU date, 72 73 bytes
for((d=0;1`date +%d%m -d$dday`-12512;d++));{ x+= Eve;};echo Christmas$x
- one byte saved replacing
!=with-
- another removing extra space
- fix -3 bytes
d=0, becausedate -ddayis date+1 and doesn't work on 25/12
Try it online
$endgroup$
$begingroup$
Hmmm, why does=~not work in the for-loop conditional?
$endgroup$
– Cows quack
Dec 26 '18 at 19:14
$begingroup$
because the for loop condition is an arithmetic expression, words are coerced to integer also number starting with 0 are assumed in octal, that's why 1 is prepended
$endgroup$
– Nahuel Fouilleul
Dec 27 '18 at 8:04
add a comment |
$begingroup$
Python 2, 128 bytes / Python 3, 130 bytes
of course, two less bytes with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
$endgroup$
1
$begingroup$
105 bytes
$endgroup$
– tsh
Dec 25 '18 at 13:00
$begingroup$
@tsh That's an amazing approach!
$endgroup$
– iBug
Dec 25 '18 at 13:18
1
$begingroup$
Python 2 doesn't need a space after print so it's 128 bytes
$endgroup$
– NieDzejkob
Dec 28 '18 at 12:48
3
$begingroup$
-2 bytes by implementingas Dby yourself
$endgroup$
– NieDzejkob
Dec 28 '18 at 13:05
add a comment |
$begingroup$
C (gcc), 157 bytes
I thought that I would be able to avoid including time.h but that just gave segment faults.
#include <time.h>
*t,u;f(){time(&u);t=localtime(&u);t[5]+=t[4]>10&t[3]>25;t[4]=11;t[3]=25;u-=mktime(t);printf("Christmas");for(u/=86400;u++;printf(" Eve"));}
Try it online!
$endgroup$
$begingroup$
IMO you should leave out the#include <stdlib.h>, not like it does anything at all here
$endgroup$
– ASCII-only
Dec 26 '18 at 9:02
$begingroup$
Suggest*t;f(u)instead of*t,u;f()and#import<time.h>instead of#include <time.h>and5[t=localtime(&u)]instead oft=localtime(&u);t[5]
$endgroup$
– ceilingcat
Dec 28 '18 at 20:40
add a comment |
$begingroup$
Groovy, 66 bytes
d=as Date
print'Christmas'+' Eve'*(new Date((d+6).year,11,25)-d)
Try it online!
Courtesy of @ASCII-only
$endgroup$
$begingroup$
You need to print it out since this is a full program not a function
$endgroup$
– ASCII-only
Dec 27 '18 at 23:25
$begingroup$
>Chistmas:/
$endgroup$
– ASCII-only
Dec 27 '18 at 23:32
$begingroup$
fixed, 149
$endgroup$
– ASCII-only
Dec 27 '18 at 23:36
$begingroup$
123
$endgroup$
– ASCII-only
Dec 27 '18 at 23:55
$begingroup$
taking your first one and using Groovy 2.5 slims it down to 115.
$endgroup$
– bdkosher
Dec 28 '18 at 0:01
|
show 7 more comments
$begingroup$
Python 3, 106 Bytes
from datetime import*
d=date.today()
print("Christmas"+" Eve"*(date((d+timedelta(6)).year,12,25)-d).days)
$endgroup$
add a comment |
$begingroup$
Scala, 116 113 bytes
var d=new java.util.Date
print("Christmas")
while(!(""+d).contains("c 25")){print(" Eve");d.setDate(d.getDate+1)}
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
1
$begingroup$
I think you can usecontains("c 25")instead ofmatches(".*c 25.*")
$endgroup$
– 12Me21
Dec 29 '18 at 15:49
$begingroup$
Thanks, three bytes less! 😁
$endgroup$
– Kjetil S.
Dec 29 '18 at 15:55
$begingroup$
wow, nicely done, toString of date was nice
$endgroup$
– V. Courtois
Jan 2 at 8:09
add a comment |
$begingroup$
JavaScript, 86 77 bytes
Using REPL it would be
for(c='Christmas',d=new Date;!/c 25/.test(d);d=new Date(+d+864e5))c+=' Eve';c
Kudos to ASCII-only for -9 bytes
$endgroup$
$begingroup$
77
$endgroup$
– ASCII-only
Dec 30 '18 at 8:33
$begingroup$
Bravo! You did much better than me. May I offer to shave an extra byte?for(c='Christmas',d=new Date;!/c 25/.test(d=new Date(+d+864e5));)c+=' Eve';cor this variant:for(s='Christmas',t=Date.now();!/c 25/.test(new Date(t+=864e5));)s+=' Eve';sboth are 76 bytes.
$endgroup$
– targumon
Dec 31 '18 at 23:42
add a comment |
$begingroup$
Lua, 137 118 bytes.
118 bytes
t,d,month,day=os.time,os.date,1,-6year=d"%Y"+(d"%D">"12/25"and 2or 1)print("Christmas",d" Eve":rep(d("%j",t(_G)-t())))
137 bytes (previous)
t,d=os.time,os.date a=d"*t"a.year,a.month,a.day=a.year+(d"%m%d">"1225"and 1 or 0),12,25 print("Christmas",("Eve "):rep((t(a)-t())/86400))
It's worth noting that it doesn't work in LuaJIT (syntax error)
$endgroup$
$begingroup$
Welcome to PPCG! Nice first post!
$endgroup$
– Riker
Dec 31 '18 at 4:14
add a comment |
$begingroup$
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
$endgroup$
add a comment |
$begingroup$
MATLAB, 91 bytes
n=datetime
x=datetime(year(n+6),12,25)
s='Christmas'
while days(x-n)>=1 n=n+1 s=[s,' Eve'] end
MATLAB Non-looper, 100 bytes
x=datenum(datetime(floor((now+5)/365.2425),12,25))
d=x-now
['Christmas' repmat(' Eve',1,min(d(d>=0)))]
$endgroup$
add a comment |
$begingroup$
Scala, 123 bytes
Thanks to ASCII-only's work.
print("Christmas")
var d=new java.util.Date
while(d.getMonth()<11||d.getDate()!=25){print(" Eve");d.setDate(d.getDate()+1)}
Try it online!
Scala + Joda-Time, 140 bytes
import org.joda.time._
var s="Christmas"
var d=DateTime.now
while(d!=d.withDate(d.year().get(),12,25)){d=d.plusDays(1);s+=" Eve"};println(s)
Does not run in TIO since it requires Joda-Time library.
$endgroup$
$begingroup$
no joda, 154. sadly can't getjava.util.Dateto work here :/
$endgroup$
– ASCII-only
Dec 28 '18 at 0:12
$begingroup$
148
$endgroup$
– ASCII-only
Dec 28 '18 at 0:19
$begingroup$
Ah @ASCII-only I did not countobject Main extends App{}chars in my counting (cause I didn't in my other Scala answers either). If we take that out you beat me ^^
$endgroup$
– V. Courtois
Dec 28 '18 at 6:40
$begingroup$
ThewithDate()call is so expensive...
$endgroup$
– V. Courtois
Dec 28 '18 at 6:41
$begingroup$
1. remember you need to specify language as "Scala + Joda-Time" since you use an external library and 2. not going to use my changes? it's shorter plus doesn't need a library :P
$endgroup$
– ASCII-only
Dec 31 '18 at 6:17
|
show 7 more comments
$begingroup$
05AB1E, 93 89 bytes
žežfžg)V'ŒÎ[Y¨JŽ9ÚQ#Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝVð'»ˆ}J™
Try it online or Try it online with an emulated self-specified date of 'today'.
Explanation:
05AB1E doesn't have any builtins for dates, except for receiving the current year/month/day/hours/minutes/seconds/microseconds, so most bytes are used for manual calculations.
žežfžg)V # Get the current date and save it in variable `Y`
'ŒÎ '# Push compressed string "christmas"
[ # Start an infinite loop
Y¨JŽ9ÚQ # If the current date is December 25th:
# # Stop the infinite loop
Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝV
# Go to the next day, and set `Y` to it
ð # Push a space " "
'»ˆ '# Push compressed string "eve"
} # After the infinite loop:
J # Join everything on the stack together
™ # And make every word title-case (and output the result implicitly)
See this answer of mine to understand how we go to the next day. (PS: 1¾ǝ has been replaced with T`ǝ, since we use the counter_variable somewhere else as well.)
See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why '»ˆ is "eve"; 'ŒÎ is "christmas"; and Ž9Ú is 1225.
$endgroup$
$begingroup$
Clever golfing!
$endgroup$
– MilkyWay90
Jan 5 at 18:35
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
$endgroup$
1
$begingroup$
I don't think this works for the 30th of November...
$endgroup$
– Neil
Dec 25 '18 at 9:56
$begingroup$
Fixed now, I forgot to add a check to if it was December or not
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 17:58
$begingroup$
Are you sure about Month > 25?
$endgroup$
– Neil
Dec 25 '18 at 19:12
$begingroup$
Fixed it now...
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 20:20
$begingroup$
Is the ?1:0 nessesary? doesn't & return an integer?
$endgroup$
– 12Me21
Dec 25 '18 at 23:33
add a comment |
$begingroup$
Red, 89 86 84 78 76 bytes
-10 bytes thanks to ASCII-only!
does[a: now prin"Christmas"while[a/3 * 31 + a/4 <> 397][prin" Eve"a: a + 1]]
Try it online!
$endgroup$
$begingroup$
84
$endgroup$
– ASCII-only
Dec 26 '18 at 9:04
$begingroup$
@ASCII-only Hmm, of course! Thank you!
$endgroup$
– Galen Ivanov
Dec 26 '18 at 10:01
$begingroup$
78
$endgroup$
– ASCII-only
Dec 26 '18 at 23:45
$begingroup$
76
$endgroup$
– ASCII-only
Dec 27 '18 at 0:12
$begingroup$
@ASCII-only Your 76-byte version does not give correct result when run on Christmas: Date as an argument I feel stupid for not using onlynowand notnow/date. Thank you for your improvements!
$endgroup$
– Galen Ivanov
Dec 27 '18 at 7:20
|
show 3 more comments
$begingroup$
Perl 5, 68 bytes
print"Christmas";print" Eve"while localtime($i++*86400+time)!~/c 25/
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
$begingroup$
Replacelocaltimewithgmtimeto save 3 bytes. After all, the question didn't state in which timezone Christmas is to be considered.
$endgroup$
– Abigail
Dec 29 '18 at 19:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178003%2fencode-the-date-in-christmas-eve-format%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
29 Answers
29
active
oldest
votes
29 Answers
29
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
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.
$endgroup$
7
$begingroup$
pure genius ...
$endgroup$
– FlipTack
Dec 25 '18 at 11:43
7
$begingroup$
This made me Smile...
$endgroup$
– Neil
Dec 25 '18 at 14:10
3
$begingroup$
Nice! One of my JavaScript solutions takes a similar approach. However, in JavaScript the wait time is just a best effort. How is SmileBASIC faring in this regard?
$endgroup$
– targumon
Dec 26 '18 at 0:16
4
$begingroup$
@12Me21 that would obviously fail due to leap seconds, this version looks much better.
$endgroup$
– Riker
Dec 26 '18 at 16:08
5
$begingroup$
+1 for thinking outside the box and making me laugh.
$endgroup$
– Tom
Dec 27 '18 at 10:29
|
show 3 more comments
$begingroup$
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.
$endgroup$
7
$begingroup$
pure genius ...
$endgroup$
– FlipTack
Dec 25 '18 at 11:43
7
$begingroup$
This made me Smile...
$endgroup$
– Neil
Dec 25 '18 at 14:10
3
$begingroup$
Nice! One of my JavaScript solutions takes a similar approach. However, in JavaScript the wait time is just a best effort. How is SmileBASIC faring in this regard?
$endgroup$
– targumon
Dec 26 '18 at 0:16
4
$begingroup$
@12Me21 that would obviously fail due to leap seconds, this version looks much better.
$endgroup$
– Riker
Dec 26 '18 at 16:08
5
$begingroup$
+1 for thinking outside the box and making me laugh.
$endgroup$
– Tom
Dec 27 '18 at 10:29
|
show 3 more comments
$begingroup$
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.
$endgroup$
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.
edited Dec 28 '18 at 0:48
answered Dec 25 '18 at 11:37
12Me2112Me21
5,50711336
5,50711336
7
$begingroup$
pure genius ...
$endgroup$
– FlipTack
Dec 25 '18 at 11:43
7
$begingroup$
This made me Smile...
$endgroup$
– Neil
Dec 25 '18 at 14:10
3
$begingroup$
Nice! One of my JavaScript solutions takes a similar approach. However, in JavaScript the wait time is just a best effort. How is SmileBASIC faring in this regard?
$endgroup$
– targumon
Dec 26 '18 at 0:16
4
$begingroup$
@12Me21 that would obviously fail due to leap seconds, this version looks much better.
$endgroup$
– Riker
Dec 26 '18 at 16:08
5
$begingroup$
+1 for thinking outside the box and making me laugh.
$endgroup$
– Tom
Dec 27 '18 at 10:29
|
show 3 more comments
7
$begingroup$
pure genius ...
$endgroup$
– FlipTack
Dec 25 '18 at 11:43
7
$begingroup$
This made me Smile...
$endgroup$
– Neil
Dec 25 '18 at 14:10
3
$begingroup$
Nice! One of my JavaScript solutions takes a similar approach. However, in JavaScript the wait time is just a best effort. How is SmileBASIC faring in this regard?
$endgroup$
– targumon
Dec 26 '18 at 0:16
4
$begingroup$
@12Me21 that would obviously fail due to leap seconds, this version looks much better.
$endgroup$
– Riker
Dec 26 '18 at 16:08
5
$begingroup$
+1 for thinking outside the box and making me laugh.
$endgroup$
– Tom
Dec 27 '18 at 10:29
7
7
$begingroup$
pure genius ...
$endgroup$
– FlipTack
Dec 25 '18 at 11:43
$begingroup$
pure genius ...
$endgroup$
– FlipTack
Dec 25 '18 at 11:43
7
7
$begingroup$
This made me Smile...
$endgroup$
– Neil
Dec 25 '18 at 14:10
$begingroup$
This made me Smile...
$endgroup$
– Neil
Dec 25 '18 at 14:10
3
3
$begingroup$
Nice! One of my JavaScript solutions takes a similar approach. However, in JavaScript the wait time is just a best effort. How is SmileBASIC faring in this regard?
$endgroup$
– targumon
Dec 26 '18 at 0:16
$begingroup$
Nice! One of my JavaScript solutions takes a similar approach. However, in JavaScript the wait time is just a best effort. How is SmileBASIC faring in this regard?
$endgroup$
– targumon
Dec 26 '18 at 0:16
4
4
$begingroup$
@12Me21 that would obviously fail due to leap seconds, this version looks much better.
$endgroup$
– Riker
Dec 26 '18 at 16:08
$begingroup$
@12Me21 that would obviously fail due to leap seconds, this version looks much better.
$endgroup$
– Riker
Dec 26 '18 at 16:08
5
5
$begingroup$
+1 for thinking outside the box and making me laugh.
$endgroup$
– Tom
Dec 27 '18 at 10:29
$begingroup$
+1 for thinking outside the box and making me laugh.
$endgroup$
– Tom
Dec 27 '18 at 10:29
|
show 3 more comments
$begingroup$
Excel formula, 59 bytes
="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,25)-TODAY())
$endgroup$
4
$begingroup$
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
$endgroup$
– Neil
Dec 25 '18 at 19:32
3
$begingroup$
I thinkYEAR(NOW()+6)works as well with 2 less bytes.
$endgroup$
– Engineer Toast
Dec 26 '18 at 20:01
2
$begingroup$
I think ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,26)-NOW()) is even shorter and I believe it should work.
$endgroup$
– JeroendeK
Dec 27 '18 at 14:02
1
$begingroup$
NOW()includes the time, so it won't be an integer and I'm not sureREPTwould allow that.
$endgroup$
– 12Me21
Dec 28 '18 at 4:57
2
$begingroup$
but this does not give "Christmas" on Christmas day. Check="Christmas"&REPT(" Eve",DATE(YEAR(DATE(2018,12,25)+6),12,26)-DATE(2018,12,25))
$endgroup$
– Anthony
Dec 29 '18 at 15:18
|
show 8 more comments
$begingroup$
Excel formula, 59 bytes
="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,25)-TODAY())
$endgroup$
4
$begingroup$
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
$endgroup$
– Neil
Dec 25 '18 at 19:32
3
$begingroup$
I thinkYEAR(NOW()+6)works as well with 2 less bytes.
$endgroup$
– Engineer Toast
Dec 26 '18 at 20:01
2
$begingroup$
I think ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,26)-NOW()) is even shorter and I believe it should work.
$endgroup$
– JeroendeK
Dec 27 '18 at 14:02
1
$begingroup$
NOW()includes the time, so it won't be an integer and I'm not sureREPTwould allow that.
$endgroup$
– 12Me21
Dec 28 '18 at 4:57
2
$begingroup$
but this does not give "Christmas" on Christmas day. Check="Christmas"&REPT(" Eve",DATE(YEAR(DATE(2018,12,25)+6),12,26)-DATE(2018,12,25))
$endgroup$
– Anthony
Dec 29 '18 at 15:18
|
show 8 more comments
$begingroup$
Excel formula, 59 bytes
="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,25)-TODAY())
$endgroup$
Excel formula, 59 bytes
="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,25)-TODAY())
edited Dec 31 '18 at 5:03
answered Dec 25 '18 at 13:33
Richard CrossleyRichard Crossley
3315
3315
4
$begingroup$
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
$endgroup$
– Neil
Dec 25 '18 at 19:32
3
$begingroup$
I thinkYEAR(NOW()+6)works as well with 2 less bytes.
$endgroup$
– Engineer Toast
Dec 26 '18 at 20:01
2
$begingroup$
I think ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,26)-NOW()) is even shorter and I believe it should work.
$endgroup$
– JeroendeK
Dec 27 '18 at 14:02
1
$begingroup$
NOW()includes the time, so it won't be an integer and I'm not sureREPTwould allow that.
$endgroup$
– 12Me21
Dec 28 '18 at 4:57
2
$begingroup$
but this does not give "Christmas" on Christmas day. Check="Christmas"&REPT(" Eve",DATE(YEAR(DATE(2018,12,25)+6),12,26)-DATE(2018,12,25))
$endgroup$
– Anthony
Dec 29 '18 at 15:18
|
show 8 more comments
4
$begingroup$
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
$endgroup$
– Neil
Dec 25 '18 at 19:32
3
$begingroup$
I thinkYEAR(NOW()+6)works as well with 2 less bytes.
$endgroup$
– Engineer Toast
Dec 26 '18 at 20:01
2
$begingroup$
I think ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,26)-NOW()) is even shorter and I believe it should work.
$endgroup$
– JeroendeK
Dec 27 '18 at 14:02
1
$begingroup$
NOW()includes the time, so it won't be an integer and I'm not sureREPTwould allow that.
$endgroup$
– 12Me21
Dec 28 '18 at 4:57
2
$begingroup$
but this does not give "Christmas" on Christmas day. Check="Christmas"&REPT(" Eve",DATE(YEAR(DATE(2018,12,25)+6),12,26)-DATE(2018,12,25))
$endgroup$
– Anthony
Dec 29 '18 at 15:18
4
4
$begingroup$
I think
YEAR(TODAY()+6) always returns the correct year, thus avoiding the condition.$endgroup$
– Neil
Dec 25 '18 at 19:32
$begingroup$
I think
YEAR(TODAY()+6) always returns the correct year, thus avoiding the condition.$endgroup$
– Neil
Dec 25 '18 at 19:32
3
3
$begingroup$
I think
YEAR(NOW()+6) works as well with 2 less bytes.$endgroup$
– Engineer Toast
Dec 26 '18 at 20:01
$begingroup$
I think
YEAR(NOW()+6) works as well with 2 less bytes.$endgroup$
– Engineer Toast
Dec 26 '18 at 20:01
2
2
$begingroup$
I think ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,26)-NOW()) is even shorter and I believe it should work.
$endgroup$
– JeroendeK
Dec 27 '18 at 14:02
$begingroup$
I think ="Christmas"&REPT(" Eve",DATE(YEAR(NOW()+6),12,26)-NOW()) is even shorter and I believe it should work.
$endgroup$
– JeroendeK
Dec 27 '18 at 14:02
1
1
$begingroup$
NOW() includes the time, so it won't be an integer and I'm not sure REPT would allow that.$endgroup$
– 12Me21
Dec 28 '18 at 4:57
$begingroup$
NOW() includes the time, so it won't be an integer and I'm not sure REPT would allow that.$endgroup$
– 12Me21
Dec 28 '18 at 4:57
2
2
$begingroup$
but this does not give "Christmas" on Christmas day. Check
="Christmas"&REPT(" Eve",DATE(YEAR(DATE(2018,12,25)+6),12,26)-DATE(2018,12,25))$endgroup$
– Anthony
Dec 29 '18 at 15:18
$begingroup$
but this does not give "Christmas" on Christmas day. Check
="Christmas"&REPT(" Eve",DATE(YEAR(DATE(2018,12,25)+6),12,26)-DATE(2018,12,25))$endgroup$
– Anthony
Dec 29 '18 at 15:18
|
show 8 more comments
$begingroup$
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 representation of the dates.) The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
$endgroup$
$begingroup$
Could you do "month>11" to save a byte?
$endgroup$
– chrixbittinx
Dec 26 '18 at 19:35
2
$begingroup$
Would/12.25/work?
$endgroup$
– Cows quack
Dec 27 '18 at 7:49
2
$begingroup$
@Cowsquack no, because then it might match the year in dates like12025-12-24
$endgroup$
– Jo King
Dec 27 '18 at 12:05
$begingroup$
I think it's safe to assume that will never happen
$endgroup$
– 12Me21
Dec 28 '18 at 6:24
add a comment |
$begingroup$
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 representation of the dates.) The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
$endgroup$
$begingroup$
Could you do "month>11" to save a byte?
$endgroup$
– chrixbittinx
Dec 26 '18 at 19:35
2
$begingroup$
Would/12.25/work?
$endgroup$
– Cows quack
Dec 27 '18 at 7:49
2
$begingroup$
@Cowsquack no, because then it might match the year in dates like12025-12-24
$endgroup$
– Jo King
Dec 27 '18 at 12:05
$begingroup$
I think it's safe to assume that will never happen
$endgroup$
– 12Me21
Dec 28 '18 at 6:24
add a comment |
$begingroup$
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 representation of the dates.) The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
$endgroup$
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 representation of the dates.) The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
edited Dec 27 '18 at 3:16
answered Dec 25 '18 at 3:20
SeanSean
3,46637
3,46637
$begingroup$
Could you do "month>11" to save a byte?
$endgroup$
– chrixbittinx
Dec 26 '18 at 19:35
2
$begingroup$
Would/12.25/work?
$endgroup$
– Cows quack
Dec 27 '18 at 7:49
2
$begingroup$
@Cowsquack no, because then it might match the year in dates like12025-12-24
$endgroup$
– Jo King
Dec 27 '18 at 12:05
$begingroup$
I think it's safe to assume that will never happen
$endgroup$
– 12Me21
Dec 28 '18 at 6:24
add a comment |
$begingroup$
Could you do "month>11" to save a byte?
$endgroup$
– chrixbittinx
Dec 26 '18 at 19:35
2
$begingroup$
Would/12.25/work?
$endgroup$
– Cows quack
Dec 27 '18 at 7:49
2
$begingroup$
@Cowsquack no, because then it might match the year in dates like12025-12-24
$endgroup$
– Jo King
Dec 27 '18 at 12:05
$begingroup$
I think it's safe to assume that will never happen
$endgroup$
– 12Me21
Dec 28 '18 at 6:24
$begingroup$
Could you do "month>11" to save a byte?
$endgroup$
– chrixbittinx
Dec 26 '18 at 19:35
$begingroup$
Could you do "month>11" to save a byte?
$endgroup$
– chrixbittinx
Dec 26 '18 at 19:35
2
2
$begingroup$
Would
/12.25/ work?$endgroup$
– Cows quack
Dec 27 '18 at 7:49
$begingroup$
Would
/12.25/ work?$endgroup$
– Cows quack
Dec 27 '18 at 7:49
2
2
$begingroup$
@Cowsquack no, because then it might match the year in dates like
12025-12-24$endgroup$
– Jo King
Dec 27 '18 at 12:05
$begingroup$
@Cowsquack no, because then it might match the year in dates like
12025-12-24$endgroup$
– Jo King
Dec 27 '18 at 12:05
$begingroup$
I think it's safe to assume that will never happen
$endgroup$
– 12Me21
Dec 28 '18 at 6:24
$begingroup$
I think it's safe to assume that will never happen
$endgroup$
– 12Me21
Dec 28 '18 at 6:24
add a comment |
$begingroup$
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(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
$endgroup$
$begingroup$
You only useyonce so you can just use it directly for 108 bytes.
$endgroup$
– Giuseppe
Dec 25 '18 at 2:02
$begingroup$
Also wouldz[z>=0][1]work instead ofmin?
$endgroup$
– Giuseppe
Dec 25 '18 at 2:03
$begingroup$
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
$endgroup$
– digEmAll
Dec 25 '18 at 10:16
1
$begingroup$
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
$endgroup$
– J.Doe
Dec 25 '18 at 11:34
add a comment |
$begingroup$
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(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
$endgroup$
$begingroup$
You only useyonce so you can just use it directly for 108 bytes.
$endgroup$
– Giuseppe
Dec 25 '18 at 2:02
$begingroup$
Also wouldz[z>=0][1]work instead ofmin?
$endgroup$
– Giuseppe
Dec 25 '18 at 2:03
$begingroup$
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
$endgroup$
– digEmAll
Dec 25 '18 at 10:16
1
$begingroup$
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
$endgroup$
– J.Doe
Dec 25 '18 at 11:34
add a comment |
$begingroup$
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(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
$endgroup$
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(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
edited Dec 26 '18 at 16:35
answered Dec 25 '18 at 1:56
ngmngm
3,34924
3,34924
$begingroup$
You only useyonce so you can just use it directly for 108 bytes.
$endgroup$
– Giuseppe
Dec 25 '18 at 2:02
$begingroup$
Also wouldz[z>=0][1]work instead ofmin?
$endgroup$
– Giuseppe
Dec 25 '18 at 2:03
$begingroup$
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
$endgroup$
– digEmAll
Dec 25 '18 at 10:16
1
$begingroup$
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
$endgroup$
– J.Doe
Dec 25 '18 at 11:34
add a comment |
$begingroup$
You only useyonce so you can just use it directly for 108 bytes.
$endgroup$
– Giuseppe
Dec 25 '18 at 2:02
$begingroup$
Also wouldz[z>=0][1]work instead ofmin?
$endgroup$
– Giuseppe
Dec 25 '18 at 2:03
$begingroup$
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
$endgroup$
– digEmAll
Dec 25 '18 at 10:16
1
$begingroup$
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
$endgroup$
– J.Doe
Dec 25 '18 at 11:34
$begingroup$
You only use
y once so you can just use it directly for 108 bytes.$endgroup$
– Giuseppe
Dec 25 '18 at 2:02
$begingroup$
You only use
y once so you can just use it directly for 108 bytes.$endgroup$
– Giuseppe
Dec 25 '18 at 2:02
$begingroup$
Also would
z[z>=0][1] work instead of min?$endgroup$
– Giuseppe
Dec 25 '18 at 2:03
$begingroup$
Also would
z[z>=0][1] work instead of min?$endgroup$
– Giuseppe
Dec 25 '18 at 2:03
$begingroup$
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
$endgroup$
– digEmAll
Dec 25 '18 at 10:16
$begingroup$
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
$endgroup$
– digEmAll
Dec 25 '18 at 10:16
1
1
$begingroup$
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
$endgroup$
– J.Doe
Dec 25 '18 at 11:34
$begingroup$
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
$endgroup$
– J.Doe
Dec 25 '18 at 11:34
add a comment |
$begingroup$
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 will be interpreted as a boolean for the conditional where 0 (which will happen on Christmas) is interpreted as False (don't enter the loop), and any other value is interpreted as True (enter the loop).
Since the integer is on the left now, the date string will be converted to the integer and math will be done, as opposed to the previous version where the 1225 integer was converted to string for the comparison.
Original Version
Windows PowerShell, 67 bytes
for(;(date|% *ys $i|% tost* Md)-ne1225){$i++};'Christmas'+' eve'*$i
Try it online!
Using a for loop as a while loop basically, because it's shorter. In the loop condition we check the current date (date, a shortened form of Get-Date), piped to ForEach-Object's alias %, using the form that can invoke a method by wildcarded name; in this case the method is AddDays() on the DateTime object, and the value we give it is $i.
This gets piped to ForEach-Object again to invoke the ToString() method, with format string Md (month, then day, minimal digits since we don't care for what comes next). This string is then tested to see if it's not equal -ne to the number 1225, which will be converted to a string for the comparison, saving me the quotes.
This is why it doesn't matter that the months and days are single digits, it will never be ambiguous because there's no other day of the year that would stringify to 1225.
The loop continues until the string is 1225. At the beginning of the program, $i will be zero so it will be comparing today's date, and the loop will never execute, but for any other day $i gets incremented in the loop body, so that we will have a count of how many days until the next Christmas, automatically accounting for leap years and whether or not Christmas passed this year.
After the loop we just output the string Christmas concatenated with the result of multiplying the string eve times the value of $i (which, on Christmas day, will be 0, resulting in no eves).
$endgroup$
$begingroup$
Apparently the;after{$i++}is redundant? (also wow you took the lead over bash again)
$endgroup$
– Cows quack
Dec 27 '18 at 18:45
$begingroup$
@Cowsquack nice! how did I not notice that?!
$endgroup$
– briantist
Dec 27 '18 at 18:58
add a comment |
$begingroup$
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 will be interpreted as a boolean for the conditional where 0 (which will happen on Christmas) is interpreted as False (don't enter the loop), and any other value is interpreted as True (enter the loop).
Since the integer is on the left now, the date string will be converted to the integer and math will be done, as opposed to the previous version where the 1225 integer was converted to string for the comparison.
Original Version
Windows PowerShell, 67 bytes
for(;(date|% *ys $i|% tost* Md)-ne1225){$i++};'Christmas'+' eve'*$i
Try it online!
Using a for loop as a while loop basically, because it's shorter. In the loop condition we check the current date (date, a shortened form of Get-Date), piped to ForEach-Object's alias %, using the form that can invoke a method by wildcarded name; in this case the method is AddDays() on the DateTime object, and the value we give it is $i.
This gets piped to ForEach-Object again to invoke the ToString() method, with format string Md (month, then day, minimal digits since we don't care for what comes next). This string is then tested to see if it's not equal -ne to the number 1225, which will be converted to a string for the comparison, saving me the quotes.
This is why it doesn't matter that the months and days are single digits, it will never be ambiguous because there's no other day of the year that would stringify to 1225.
The loop continues until the string is 1225. At the beginning of the program, $i will be zero so it will be comparing today's date, and the loop will never execute, but for any other day $i gets incremented in the loop body, so that we will have a count of how many days until the next Christmas, automatically accounting for leap years and whether or not Christmas passed this year.
After the loop we just output the string Christmas concatenated with the result of multiplying the string eve times the value of $i (which, on Christmas day, will be 0, resulting in no eves).
$endgroup$
$begingroup$
Apparently the;after{$i++}is redundant? (also wow you took the lead over bash again)
$endgroup$
– Cows quack
Dec 27 '18 at 18:45
$begingroup$
@Cowsquack nice! how did I not notice that?!
$endgroup$
– briantist
Dec 27 '18 at 18:58
add a comment |
$begingroup$
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 will be interpreted as a boolean for the conditional where 0 (which will happen on Christmas) is interpreted as False (don't enter the loop), and any other value is interpreted as True (enter the loop).
Since the integer is on the left now, the date string will be converted to the integer and math will be done, as opposed to the previous version where the 1225 integer was converted to string for the comparison.
Original Version
Windows PowerShell, 67 bytes
for(;(date|% *ys $i|% tost* Md)-ne1225){$i++};'Christmas'+' eve'*$i
Try it online!
Using a for loop as a while loop basically, because it's shorter. In the loop condition we check the current date (date, a shortened form of Get-Date), piped to ForEach-Object's alias %, using the form that can invoke a method by wildcarded name; in this case the method is AddDays() on the DateTime object, and the value we give it is $i.
This gets piped to ForEach-Object again to invoke the ToString() method, with format string Md (month, then day, minimal digits since we don't care for what comes next). This string is then tested to see if it's not equal -ne to the number 1225, which will be converted to a string for the comparison, saving me the quotes.
This is why it doesn't matter that the months and days are single digits, it will never be ambiguous because there's no other day of the year that would stringify to 1225.
The loop continues until the string is 1225. At the beginning of the program, $i will be zero so it will be comparing today's date, and the loop will never execute, but for any other day $i gets incremented in the loop body, so that we will have a count of how many days until the next Christmas, automatically accounting for leap years and whether or not Christmas passed this year.
After the loop we just output the string Christmas concatenated with the result of multiplying the string eve times the value of $i (which, on Christmas day, will be 0, resulting in no eves).
$endgroup$
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 will be interpreted as a boolean for the conditional where 0 (which will happen on Christmas) is interpreted as False (don't enter the loop), and any other value is interpreted as True (enter the loop).
Since the integer is on the left now, the date string will be converted to the integer and math will be done, as opposed to the previous version where the 1225 integer was converted to string for the comparison.
Original Version
Windows PowerShell, 67 bytes
for(;(date|% *ys $i|% tost* Md)-ne1225){$i++};'Christmas'+' eve'*$i
Try it online!
Using a for loop as a while loop basically, because it's shorter. In the loop condition we check the current date (date, a shortened form of Get-Date), piped to ForEach-Object's alias %, using the form that can invoke a method by wildcarded name; in this case the method is AddDays() on the DateTime object, and the value we give it is $i.
This gets piped to ForEach-Object again to invoke the ToString() method, with format string Md (month, then day, minimal digits since we don't care for what comes next). This string is then tested to see if it's not equal -ne to the number 1225, which will be converted to a string for the comparison, saving me the quotes.
This is why it doesn't matter that the months and days are single digits, it will never be ambiguous because there's no other day of the year that would stringify to 1225.
The loop continues until the string is 1225. At the beginning of the program, $i will be zero so it will be comparing today's date, and the loop will never execute, but for any other day $i gets incremented in the loop body, so that we will have a count of how many days until the next Christmas, automatically accounting for leap years and whether or not Christmas passed this year.
After the loop we just output the string Christmas concatenated with the result of multiplying the string eve times the value of $i (which, on Christmas day, will be 0, resulting in no eves).
edited Dec 27 '18 at 19:04
answered Dec 26 '18 at 12:40
briantistbriantist
3,010920
3,010920
$begingroup$
Apparently the;after{$i++}is redundant? (also wow you took the lead over bash again)
$endgroup$
– Cows quack
Dec 27 '18 at 18:45
$begingroup$
@Cowsquack nice! how did I not notice that?!
$endgroup$
– briantist
Dec 27 '18 at 18:58
add a comment |
$begingroup$
Apparently the;after{$i++}is redundant? (also wow you took the lead over bash again)
$endgroup$
– Cows quack
Dec 27 '18 at 18:45
$begingroup$
@Cowsquack nice! how did I not notice that?!
$endgroup$
– briantist
Dec 27 '18 at 18:58
$begingroup$
Apparently the
; after {$i++} is redundant? (also wow you took the lead over bash again)$endgroup$
– Cows quack
Dec 27 '18 at 18:45
$begingroup$
Apparently the
; after {$i++} is redundant? (also wow you took the lead over bash again)$endgroup$
– Cows quack
Dec 27 '18 at 18:45
$begingroup$
@Cowsquack nice! how did I not notice that?!
$endgroup$
– briantist
Dec 27 '18 at 18:58
$begingroup$
@Cowsquack nice! how did I not notice that?!
$endgroup$
– briantist
Dec 27 '18 at 18:58
add a comment |
$begingroup$
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
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
$endgroup$
$begingroup$
...do you need to assign t to itself in the incrementor? I don't have the docs in front of me, but if not, you could save two bytes more.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:38
1
$begingroup$
oh, it's a struct. Of course it is. Nevermind.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:39
1
$begingroup$
You can substitutet.Month<12|t.Day!=25with the shorter$"{t:Md}"!="1225". It uses an interpolated string and a custom DateTime formatting string.
$endgroup$
– Jeppe Stig Nielsen
Dec 28 '18 at 23:34
add a comment |
$begingroup$
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
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
$endgroup$
$begingroup$
...do you need to assign t to itself in the incrementor? I don't have the docs in front of me, but if not, you could save two bytes more.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:38
1
$begingroup$
oh, it's a struct. Of course it is. Nevermind.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:39
1
$begingroup$
You can substitutet.Month<12|t.Day!=25with the shorter$"{t:Md}"!="1225". It uses an interpolated string and a custom DateTime formatting string.
$endgroup$
– Jeppe Stig Nielsen
Dec 28 '18 at 23:34
add a comment |
$begingroup$
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
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
$endgroup$
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
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
edited Dec 28 '18 at 23:47
answered Dec 25 '18 at 7:52
danadana
73145
73145
$begingroup$
...do you need to assign t to itself in the incrementor? I don't have the docs in front of me, but if not, you could save two bytes more.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:38
1
$begingroup$
oh, it's a struct. Of course it is. Nevermind.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:39
1
$begingroup$
You can substitutet.Month<12|t.Day!=25with the shorter$"{t:Md}"!="1225". It uses an interpolated string and a custom DateTime formatting string.
$endgroup$
– Jeppe Stig Nielsen
Dec 28 '18 at 23:34
add a comment |
$begingroup$
...do you need to assign t to itself in the incrementor? I don't have the docs in front of me, but if not, you could save two bytes more.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:38
1
$begingroup$
oh, it's a struct. Of course it is. Nevermind.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:39
1
$begingroup$
You can substitutet.Month<12|t.Day!=25with the shorter$"{t:Md}"!="1225". It uses an interpolated string and a custom DateTime formatting string.
$endgroup$
– Jeppe Stig Nielsen
Dec 28 '18 at 23:34
$begingroup$
...do you need to assign t to itself in the incrementor? I don't have the docs in front of me, but if not, you could save two bytes more.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:38
$begingroup$
...do you need to assign t to itself in the incrementor? I don't have the docs in front of me, but if not, you could save two bytes more.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:38
1
1
$begingroup$
oh, it's a struct. Of course it is. Nevermind.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:39
$begingroup$
oh, it's a struct. Of course it is. Nevermind.
$endgroup$
– Stackstuck
Dec 28 '18 at 21:39
1
1
$begingroup$
You can substitute
t.Month<12|t.Day!=25 with the shorter $"{t:Md}"!="1225". It uses an interpolated string and a custom DateTime formatting string.$endgroup$
– Jeppe Stig Nielsen
Dec 28 '18 at 23:34
$begingroup$
You can substitute
t.Month<12|t.Day!=25 with the shorter $"{t:Md}"!="1225". It uses an interpolated string and a custom DateTime formatting string.$endgroup$
– Jeppe Stig Nielsen
Dec 28 '18 at 23:34
add a comment |
$begingroup$
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.
$endgroup$
$begingroup$
Nice work. Save 2 withPRINT'Christmas'+...and 2 more by usingDATEDIFF(D,instead ofDATEDIFF(DAY,
$endgroup$
– BradC
Jan 7 at 16:19
$begingroup$
@BradC Nice, thanks!
$endgroup$
– Neil
Jan 7 at 16:54
add a comment |
$begingroup$
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.
$endgroup$
$begingroup$
Nice work. Save 2 withPRINT'Christmas'+...and 2 more by usingDATEDIFF(D,instead ofDATEDIFF(DAY,
$endgroup$
– BradC
Jan 7 at 16:19
$begingroup$
@BradC Nice, thanks!
$endgroup$
– Neil
Jan 7 at 16:54
add a comment |
$begingroup$
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.
$endgroup$
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.
edited Jan 7 at 16:53
answered Dec 25 '18 at 20:00
NeilNeil
79.9k744178
79.9k744178
$begingroup$
Nice work. Save 2 withPRINT'Christmas'+...and 2 more by usingDATEDIFF(D,instead ofDATEDIFF(DAY,
$endgroup$
– BradC
Jan 7 at 16:19
$begingroup$
@BradC Nice, thanks!
$endgroup$
– Neil
Jan 7 at 16:54
add a comment |
$begingroup$
Nice work. Save 2 withPRINT'Christmas'+...and 2 more by usingDATEDIFF(D,instead ofDATEDIFF(DAY,
$endgroup$
– BradC
Jan 7 at 16:19
$begingroup$
@BradC Nice, thanks!
$endgroup$
– Neil
Jan 7 at 16:54
$begingroup$
Nice work. Save 2 with
PRINT'Christmas'+... and 2 more by using DATEDIFF(D, instead of DATEDIFF(DAY,$endgroup$
– BradC
Jan 7 at 16:19
$begingroup$
Nice work. Save 2 with
PRINT'Christmas'+... and 2 more by using DATEDIFF(D, instead of DATEDIFF(DAY,$endgroup$
– BradC
Jan 7 at 16:19
$begingroup$
@BradC Nice, thanks!
$endgroup$
– Neil
Jan 7 at 16:54
$begingroup$
@BradC Nice, thanks!
$endgroup$
– Neil
Jan 7 at 16:54
add a comment |
$begingroup$
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 (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
$endgroup$
add a comment |
$begingroup$
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 (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
$endgroup$
add a comment |
$begingroup$
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 (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
$endgroup$
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 (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
edited Dec 25 '18 at 9:32
answered Dec 25 '18 at 8:43
AdámAdám
29.6k271194
29.6k271194
add a comment |
add a comment |
$begingroup$
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()
# get the year of the Christmas to compare to
# if the current date is after this year's Christmas, the 6 day offset will give the next year
# otherwise, returns this year
(d+timedelta(6)).year
# next Christmas minus the current date
date(.....................,12,25)-d
# Christmas, plus (number of days until next Christmas) " Eve"s
print"Christmas"+" Eve"*(...................................).days
$endgroup$
add a comment |
$begingroup$
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()
# get the year of the Christmas to compare to
# if the current date is after this year's Christmas, the 6 day offset will give the next year
# otherwise, returns this year
(d+timedelta(6)).year
# next Christmas minus the current date
date(.....................,12,25)-d
# Christmas, plus (number of days until next Christmas) " Eve"s
print"Christmas"+" Eve"*(...................................).days
$endgroup$
add a comment |
$begingroup$
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()
# get the year of the Christmas to compare to
# if the current date is after this year's Christmas, the 6 day offset will give the next year
# otherwise, returns this year
(d+timedelta(6)).year
# next Christmas minus the current date
date(.....................,12,25)-d
# Christmas, plus (number of days until next Christmas) " Eve"s
print"Christmas"+" Eve"*(...................................).days
$endgroup$
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()
# get the year of the Christmas to compare to
# if the current date is after this year's Christmas, the 6 day offset will give the next year
# otherwise, returns this year
(d+timedelta(6)).year
# next Christmas minus the current date
date(.....................,12,25)-d
# Christmas, plus (number of days until next Christmas) " Eve"s
print"Christmas"+" Eve"*(...................................).days
edited Dec 27 '18 at 15:57
answered Dec 26 '18 at 21:12
TriggernometryTriggernometry
61517
61517
add a comment |
add a comment |
$begingroup$
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
$endgroup$
$begingroup$
77 bytes (i.e., save 3 bytes) by replacingputswithp: Try It Online link
$endgroup$
– Spencer Doak
Dec 30 '18 at 6:57
add a comment |
$begingroup$
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
$endgroup$
$begingroup$
77 bytes (i.e., save 3 bytes) by replacingputswithp: Try It Online link
$endgroup$
– Spencer Doak
Dec 30 '18 at 6:57
add a comment |
$begingroup$
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
$endgroup$
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
answered Dec 25 '18 at 13:26
iBugiBug
1,377731
1,377731
$begingroup$
77 bytes (i.e., save 3 bytes) by replacingputswithp: Try It Online link
$endgroup$
– Spencer Doak
Dec 30 '18 at 6:57
add a comment |
$begingroup$
77 bytes (i.e., save 3 bytes) by replacingputswithp: Try It Online link
$endgroup$
– Spencer Doak
Dec 30 '18 at 6:57
$begingroup$
77 bytes (i.e., save 3 bytes) by replacing
puts with p: Try It Online link$endgroup$
– Spencer Doak
Dec 30 '18 at 6:57
$begingroup$
77 bytes (i.e., save 3 bytes) by replacing
puts with p: Try It Online link$endgroup$
– Spencer Doak
Dec 30 '18 at 6:57
add a comment |
$begingroup$
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
$endgroup$
add a comment |
$begingroup$
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
$endgroup$
add a comment |
$begingroup$
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
$endgroup$
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
answered Dec 25 '18 at 20:01
TitusTitus
13.1k11238
13.1k11238
add a comment |
add a comment |
$begingroup$
JavaScript, 135 131 121 92 88 bytes
My first (naïve) solution (135b):
t=new Date();n=new Date();n.setMonth(11);n.setDate(25);'Christmas'+' Eve'.repeat((n>=t?n-t:(n.setFullYear(n.getFullYear()+1)-t))/864e5)
It sets 2 dates: now and Xmas of this year. If the latter hasn't passed yet, it just diffs them, if it has passed, diffs to next year's Xmas. Uses either diffs for the number of repeats.
(Trying to) Think Outside the Box (131b):
i=0;f=_=>{t=new Date();if(t.getMonth()!=11||t.getDate()!=25){i++;setTimeout(f,864e5)}else{alert('Christmas'+' Eve'.repeat(i))}};f()
The challange specifies WHICH output is required when running the program on a given day, but doesn't specify WHEN to return it...
This will just 'sleep' for a day, increment a counter by 1, and repeat till it's Xmas in order to give the output.
Since JavaScript doesn't guarantee the 'sleep' time, the actual result might be off.
It is also ugly for using the alert function, which means wer'e actually not dealing with pure JavaScript, but with browser APIs as well (we can use console.log at the cost of 6 extra bytes).
A better approach (121b):
t=new Date();i=0;while(t.getMonth()!=11||t.getDate()!=25){t=new Date(t.valueOf()+864e5);i++};'Christmas'+' Eve'.repeat(i)
Starting from today, increment the date by a day until it's Xmas, then use that loop's counter for the number of repeats required.
Improving (including going through a minifier and using 12Me21's trick to shave extra 5b) (92b):
for(s='Christmas',t=new Date;t.getMonth()/t.getDate()-.44;)t=new Date(t*1+864e5),s+=' Eve';s
Final touches (88b):
for(s='Christmas',t=new Date;t.getMonth()/(d=t.getDate())-.44;t.setDate(d+1))s+=' Eve';s
- For all of the above, REPL is assumed.
- See Vadim's submission - much better than mine!
$endgroup$
1
$begingroup$
I think you can uset.getMonth()/t.getDate-.48to check if date is not december 25th
$endgroup$
– 12Me21
Dec 26 '18 at 0:50
1
$begingroup$
Welcome to the site! You can use a 4 space indent to make your code blocks look better.
$endgroup$
– Wît Wisarhd
Dec 26 '18 at 3:51
1
$begingroup$
Welcome to PPCG!
$endgroup$
– Shaggy
Dec 26 '18 at 11:47
1
$begingroup$
98,printis needed since this is a program not a function, unless 1. you turn it into a lambda or 2. you state that you're using a REPL
$endgroup$
– ASCII-only
Dec 28 '18 at 1:28
1
$begingroup$
t=new Date(+t+864e5)is 1 byte shorter.
$endgroup$
– Andrew Svietlichnyy
Dec 29 '18 at 19:16
|
show 6 more comments
$begingroup$
JavaScript, 135 131 121 92 88 bytes
My first (naïve) solution (135b):
t=new Date();n=new Date();n.setMonth(11);n.setDate(25);'Christmas'+' Eve'.repeat((n>=t?n-t:(n.setFullYear(n.getFullYear()+1)-t))/864e5)
It sets 2 dates: now and Xmas of this year. If the latter hasn't passed yet, it just diffs them, if it has passed, diffs to next year's Xmas. Uses either diffs for the number of repeats.
(Trying to) Think Outside the Box (131b):
i=0;f=_=>{t=new Date();if(t.getMonth()!=11||t.getDate()!=25){i++;setTimeout(f,864e5)}else{alert('Christmas'+' Eve'.repeat(i))}};f()
The challange specifies WHICH output is required when running the program on a given day, but doesn't specify WHEN to return it...
This will just 'sleep' for a day, increment a counter by 1, and repeat till it's Xmas in order to give the output.
Since JavaScript doesn't guarantee the 'sleep' time, the actual result might be off.
It is also ugly for using the alert function, which means wer'e actually not dealing with pure JavaScript, but with browser APIs as well (we can use console.log at the cost of 6 extra bytes).
A better approach (121b):
t=new Date();i=0;while(t.getMonth()!=11||t.getDate()!=25){t=new Date(t.valueOf()+864e5);i++};'Christmas'+' Eve'.repeat(i)
Starting from today, increment the date by a day until it's Xmas, then use that loop's counter for the number of repeats required.
Improving (including going through a minifier and using 12Me21's trick to shave extra 5b) (92b):
for(s='Christmas',t=new Date;t.getMonth()/t.getDate()-.44;)t=new Date(t*1+864e5),s+=' Eve';s
Final touches (88b):
for(s='Christmas',t=new Date;t.getMonth()/(d=t.getDate())-.44;t.setDate(d+1))s+=' Eve';s
- For all of the above, REPL is assumed.
- See Vadim's submission - much better than mine!
$endgroup$
1
$begingroup$
I think you can uset.getMonth()/t.getDate-.48to check if date is not december 25th
$endgroup$
– 12Me21
Dec 26 '18 at 0:50
1
$begingroup$
Welcome to the site! You can use a 4 space indent to make your code blocks look better.
$endgroup$
– Wît Wisarhd
Dec 26 '18 at 3:51
1
$begingroup$
Welcome to PPCG!
$endgroup$
– Shaggy
Dec 26 '18 at 11:47
1
$begingroup$
98,printis needed since this is a program not a function, unless 1. you turn it into a lambda or 2. you state that you're using a REPL
$endgroup$
– ASCII-only
Dec 28 '18 at 1:28
1
$begingroup$
t=new Date(+t+864e5)is 1 byte shorter.
$endgroup$
– Andrew Svietlichnyy
Dec 29 '18 at 19:16
|
show 6 more comments
$begingroup$
JavaScript, 135 131 121 92 88 bytes
My first (naïve) solution (135b):
t=new Date();n=new Date();n.setMonth(11);n.setDate(25);'Christmas'+' Eve'.repeat((n>=t?n-t:(n.setFullYear(n.getFullYear()+1)-t))/864e5)
It sets 2 dates: now and Xmas of this year. If the latter hasn't passed yet, it just diffs them, if it has passed, diffs to next year's Xmas. Uses either diffs for the number of repeats.
(Trying to) Think Outside the Box (131b):
i=0;f=_=>{t=new Date();if(t.getMonth()!=11||t.getDate()!=25){i++;setTimeout(f,864e5)}else{alert('Christmas'+' Eve'.repeat(i))}};f()
The challange specifies WHICH output is required when running the program on a given day, but doesn't specify WHEN to return it...
This will just 'sleep' for a day, increment a counter by 1, and repeat till it's Xmas in order to give the output.
Since JavaScript doesn't guarantee the 'sleep' time, the actual result might be off.
It is also ugly for using the alert function, which means wer'e actually not dealing with pure JavaScript, but with browser APIs as well (we can use console.log at the cost of 6 extra bytes).
A better approach (121b):
t=new Date();i=0;while(t.getMonth()!=11||t.getDate()!=25){t=new Date(t.valueOf()+864e5);i++};'Christmas'+' Eve'.repeat(i)
Starting from today, increment the date by a day until it's Xmas, then use that loop's counter for the number of repeats required.
Improving (including going through a minifier and using 12Me21's trick to shave extra 5b) (92b):
for(s='Christmas',t=new Date;t.getMonth()/t.getDate()-.44;)t=new Date(t*1+864e5),s+=' Eve';s
Final touches (88b):
for(s='Christmas',t=new Date;t.getMonth()/(d=t.getDate())-.44;t.setDate(d+1))s+=' Eve';s
- For all of the above, REPL is assumed.
- See Vadim's submission - much better than mine!
$endgroup$
JavaScript, 135 131 121 92 88 bytes
My first (naïve) solution (135b):
t=new Date();n=new Date();n.setMonth(11);n.setDate(25);'Christmas'+' Eve'.repeat((n>=t?n-t:(n.setFullYear(n.getFullYear()+1)-t))/864e5)
It sets 2 dates: now and Xmas of this year. If the latter hasn't passed yet, it just diffs them, if it has passed, diffs to next year's Xmas. Uses either diffs for the number of repeats.
(Trying to) Think Outside the Box (131b):
i=0;f=_=>{t=new Date();if(t.getMonth()!=11||t.getDate()!=25){i++;setTimeout(f,864e5)}else{alert('Christmas'+' Eve'.repeat(i))}};f()
The challange specifies WHICH output is required when running the program on a given day, but doesn't specify WHEN to return it...
This will just 'sleep' for a day, increment a counter by 1, and repeat till it's Xmas in order to give the output.
Since JavaScript doesn't guarantee the 'sleep' time, the actual result might be off.
It is also ugly for using the alert function, which means wer'e actually not dealing with pure JavaScript, but with browser APIs as well (we can use console.log at the cost of 6 extra bytes).
A better approach (121b):
t=new Date();i=0;while(t.getMonth()!=11||t.getDate()!=25){t=new Date(t.valueOf()+864e5);i++};'Christmas'+' Eve'.repeat(i)
Starting from today, increment the date by a day until it's Xmas, then use that loop's counter for the number of repeats required.
Improving (including going through a minifier and using 12Me21's trick to shave extra 5b) (92b):
for(s='Christmas',t=new Date;t.getMonth()/t.getDate()-.44;)t=new Date(t*1+864e5),s+=' Eve';s
Final touches (88b):
for(s='Christmas',t=new Date;t.getMonth()/(d=t.getDate())-.44;t.setDate(d+1))s+=' Eve';s
- For all of the above, REPL is assumed.
- See Vadim's submission - much better than mine!
edited Dec 31 '18 at 23:24
answered Dec 25 '18 at 23:58
targumontargumon
1435
1435
1
$begingroup$
I think you can uset.getMonth()/t.getDate-.48to check if date is not december 25th
$endgroup$
– 12Me21
Dec 26 '18 at 0:50
1
$begingroup$
Welcome to the site! You can use a 4 space indent to make your code blocks look better.
$endgroup$
– Wît Wisarhd
Dec 26 '18 at 3:51
1
$begingroup$
Welcome to PPCG!
$endgroup$
– Shaggy
Dec 26 '18 at 11:47
1
$begingroup$
98,printis needed since this is a program not a function, unless 1. you turn it into a lambda or 2. you state that you're using a REPL
$endgroup$
– ASCII-only
Dec 28 '18 at 1:28
1
$begingroup$
t=new Date(+t+864e5)is 1 byte shorter.
$endgroup$
– Andrew Svietlichnyy
Dec 29 '18 at 19:16
|
show 6 more comments
1
$begingroup$
I think you can uset.getMonth()/t.getDate-.48to check if date is not december 25th
$endgroup$
– 12Me21
Dec 26 '18 at 0:50
1
$begingroup$
Welcome to the site! You can use a 4 space indent to make your code blocks look better.
$endgroup$
– Wît Wisarhd
Dec 26 '18 at 3:51
1
$begingroup$
Welcome to PPCG!
$endgroup$
– Shaggy
Dec 26 '18 at 11:47
1
$begingroup$
98,printis needed since this is a program not a function, unless 1. you turn it into a lambda or 2. you state that you're using a REPL
$endgroup$
– ASCII-only
Dec 28 '18 at 1:28
1
$begingroup$
t=new Date(+t+864e5)is 1 byte shorter.
$endgroup$
– Andrew Svietlichnyy
Dec 29 '18 at 19:16
1
1
$begingroup$
I think you can use
t.getMonth()/t.getDate-.48 to check if date is not december 25th$endgroup$
– 12Me21
Dec 26 '18 at 0:50
$begingroup$
I think you can use
t.getMonth()/t.getDate-.48 to check if date is not december 25th$endgroup$
– 12Me21
Dec 26 '18 at 0:50
1
1
$begingroup$
Welcome to the site! You can use a 4 space indent to make your code blocks look better.
$endgroup$
– Wît Wisarhd
Dec 26 '18 at 3:51
$begingroup$
Welcome to the site! You can use a 4 space indent to make your code blocks look better.
$endgroup$
– Wît Wisarhd
Dec 26 '18 at 3:51
1
1
$begingroup$
Welcome to PPCG!
$endgroup$
– Shaggy
Dec 26 '18 at 11:47
$begingroup$
Welcome to PPCG!
$endgroup$
– Shaggy
Dec 26 '18 at 11:47
1
1
$begingroup$
98,
print is needed since this is a program not a function, unless 1. you turn it into a lambda or 2. you state that you're using a REPL$endgroup$
– ASCII-only
Dec 28 '18 at 1:28
$begingroup$
98,
print is needed since this is a program not a function, unless 1. you turn it into a lambda or 2. you state that you're using a REPL$endgroup$
– ASCII-only
Dec 28 '18 at 1:28
1
1
$begingroup$
t=new Date(+t+864e5) is 1 byte shorter.$endgroup$
– Andrew Svietlichnyy
Dec 29 '18 at 19:16
$begingroup$
t=new Date(+t+864e5) is 1 byte shorter.$endgroup$
– Andrew Svietlichnyy
Dec 29 '18 at 19:16
|
show 6 more comments
$begingroup$
Bash, 68 65 bytes
seq 0 366|sed 's/.*/date -d&day/e;1iChristmas
/c 25/Q;cEve'|xargs
Try it online!
BSD date should be able to save a byte with something like date -v+Ad (can't test it), however, BSD sed would add more bytes to i and c, requiring them to have a <newline>.
seq 0 366 create a stream of integers from 0 to 366
|sed perform the following sed code over each line of stream input
ssubstitute
.*the pattern space
date -d&daywith this string, with the match filling the place of&
ereplace the pattern space with itself evaluated as bash, which computes the date&days from today in the default format ofWed Dec 26 18:22:33 UTC 2018
1on the first line of input
iinsert
Christmasthis string above the line, so being on top of the output
/c 25/if the current line has ac 25in it, meaning it's Dec 25
Qquit the program without printing the pattern space, abruptly stopping any more lines from being read
c(otherwise) change the current line toEve
|xargs and convert newlines to spaces
$endgroup$
$begingroup$
There's nothing reallybash-specific about this solution. It requires GNUdate,sedandseqthough.
$endgroup$
– Kusalananda
Dec 27 '18 at 21:00
$begingroup$
-4 bytes
$endgroup$
– Nahuel Fouilleul
Dec 28 '18 at 9:12
add a comment |
$begingroup$
Bash, 68 65 bytes
seq 0 366|sed 's/.*/date -d&day/e;1iChristmas
/c 25/Q;cEve'|xargs
Try it online!
BSD date should be able to save a byte with something like date -v+Ad (can't test it), however, BSD sed would add more bytes to i and c, requiring them to have a <newline>.
seq 0 366 create a stream of integers from 0 to 366
|sed perform the following sed code over each line of stream input
ssubstitute
.*the pattern space
date -d&daywith this string, with the match filling the place of&
ereplace the pattern space with itself evaluated as bash, which computes the date&days from today in the default format ofWed Dec 26 18:22:33 UTC 2018
1on the first line of input
iinsert
Christmasthis string above the line, so being on top of the output
/c 25/if the current line has ac 25in it, meaning it's Dec 25
Qquit the program without printing the pattern space, abruptly stopping any more lines from being read
c(otherwise) change the current line toEve
|xargs and convert newlines to spaces
$endgroup$
$begingroup$
There's nothing reallybash-specific about this solution. It requires GNUdate,sedandseqthough.
$endgroup$
– Kusalananda
Dec 27 '18 at 21:00
$begingroup$
-4 bytes
$endgroup$
– Nahuel Fouilleul
Dec 28 '18 at 9:12
add a comment |
$begingroup$
Bash, 68 65 bytes
seq 0 366|sed 's/.*/date -d&day/e;1iChristmas
/c 25/Q;cEve'|xargs
Try it online!
BSD date should be able to save a byte with something like date -v+Ad (can't test it), however, BSD sed would add more bytes to i and c, requiring them to have a <newline>.
seq 0 366 create a stream of integers from 0 to 366
|sed perform the following sed code over each line of stream input
ssubstitute
.*the pattern space
date -d&daywith this string, with the match filling the place of&
ereplace the pattern space with itself evaluated as bash, which computes the date&days from today in the default format ofWed Dec 26 18:22:33 UTC 2018
1on the first line of input
iinsert
Christmasthis string above the line, so being on top of the output
/c 25/if the current line has ac 25in it, meaning it's Dec 25
Qquit the program without printing the pattern space, abruptly stopping any more lines from being read
c(otherwise) change the current line toEve
|xargs and convert newlines to spaces
$endgroup$
Bash, 68 65 bytes
seq 0 366|sed 's/.*/date -d&day/e;1iChristmas
/c 25/Q;cEve'|xargs
Try it online!
BSD date should be able to save a byte with something like date -v+Ad (can't test it), however, BSD sed would add more bytes to i and c, requiring them to have a <newline>.
seq 0 366 create a stream of integers from 0 to 366
|sed perform the following sed code over each line of stream input
ssubstitute
.*the pattern space
date -d&daywith this string, with the match filling the place of&
ereplace the pattern space with itself evaluated as bash, which computes the date&days from today in the default format ofWed Dec 26 18:22:33 UTC 2018
1on the first line of input
iinsert
Christmasthis string above the line, so being on top of the output
/c 25/if the current line has ac 25in it, meaning it's Dec 25
Qquit the program without printing the pattern space, abruptly stopping any more lines from being read
c(otherwise) change the current line toEve
|xargs and convert newlines to spaces
edited Dec 26 '18 at 19:47
answered Dec 26 '18 at 18:38
Cows quackCows quack
13.7k52777
13.7k52777
$begingroup$
There's nothing reallybash-specific about this solution. It requires GNUdate,sedandseqthough.
$endgroup$
– Kusalananda
Dec 27 '18 at 21:00
$begingroup$
-4 bytes
$endgroup$
– Nahuel Fouilleul
Dec 28 '18 at 9:12
add a comment |
$begingroup$
There's nothing reallybash-specific about this solution. It requires GNUdate,sedandseqthough.
$endgroup$
– Kusalananda
Dec 27 '18 at 21:00
$begingroup$
-4 bytes
$endgroup$
– Nahuel Fouilleul
Dec 28 '18 at 9:12
$begingroup$
There's nothing really
bash-specific about this solution. It requires GNU date, sed and seq though.$endgroup$
– Kusalananda
Dec 27 '18 at 21:00
$begingroup$
There's nothing really
bash-specific about this solution. It requires GNU date, sed and seq though.$endgroup$
– Kusalananda
Dec 27 '18 at 21:00
$begingroup$
-4 bytes
$endgroup$
– Nahuel Fouilleul
Dec 28 '18 at 9:12
$begingroup$
-4 bytes
$endgroup$
– Nahuel Fouilleul
Dec 28 '18 at 9:12
add a comment |
$begingroup$
VBA (Excel), 108 bytes
Copy in a blank module. Prints to the Immediate window:
Sub X:s="Christmas":d=Now:For t=1 To (DateSerial(Year(d+6),12,25)-d):s=s &" Eve":Next:Debug.Print s:End Sub
Note: Using : instead of line breaks saves two bytes per line.
Notice that the VBA editor will insert additional spaces between keywords, operators, etc... and parenthesis after the Sub definition, but if you copy and paste this code it will work (I couldn't get rid of that space before the &).
Not bad for VBA (for once).
$endgroup$
1
$begingroup$
*Christmas:|
$endgroup$
– ASCII-only
Dec 26 '18 at 23:47
$begingroup$
@ASCII-only: removing the space before the&throws an error
$endgroup$
– Barranka
Dec 26 '18 at 23:49
$begingroup$
-1 bytes. Thanks to @ASCII-only for catching the typo
$endgroup$
– Barranka
Dec 27 '18 at 0:06
add a comment |
$begingroup$
VBA (Excel), 108 bytes
Copy in a blank module. Prints to the Immediate window:
Sub X:s="Christmas":d=Now:For t=1 To (DateSerial(Year(d+6),12,25)-d):s=s &" Eve":Next:Debug.Print s:End Sub
Note: Using : instead of line breaks saves two bytes per line.
Notice that the VBA editor will insert additional spaces between keywords, operators, etc... and parenthesis after the Sub definition, but if you copy and paste this code it will work (I couldn't get rid of that space before the &).
Not bad for VBA (for once).
$endgroup$
1
$begingroup$
*Christmas:|
$endgroup$
– ASCII-only
Dec 26 '18 at 23:47
$begingroup$
@ASCII-only: removing the space before the&throws an error
$endgroup$
– Barranka
Dec 26 '18 at 23:49
$begingroup$
-1 bytes. Thanks to @ASCII-only for catching the typo
$endgroup$
– Barranka
Dec 27 '18 at 0:06
add a comment |
$begingroup$
VBA (Excel), 108 bytes
Copy in a blank module. Prints to the Immediate window:
Sub X:s="Christmas":d=Now:For t=1 To (DateSerial(Year(d+6),12,25)-d):s=s &" Eve":Next:Debug.Print s:End Sub
Note: Using : instead of line breaks saves two bytes per line.
Notice that the VBA editor will insert additional spaces between keywords, operators, etc... and parenthesis after the Sub definition, but if you copy and paste this code it will work (I couldn't get rid of that space before the &).
Not bad for VBA (for once).
$endgroup$
VBA (Excel), 108 bytes
Copy in a blank module. Prints to the Immediate window:
Sub X:s="Christmas":d=Now:For t=1 To (DateSerial(Year(d+6),12,25)-d):s=s &" Eve":Next:Debug.Print s:End Sub
Note: Using : instead of line breaks saves two bytes per line.
Notice that the VBA editor will insert additional spaces between keywords, operators, etc... and parenthesis after the Sub definition, but if you copy and paste this code it will work (I couldn't get rid of that space before the &).
Not bad for VBA (for once).
edited Dec 27 '18 at 0:06
answered Dec 26 '18 at 23:45
BarrankaBarranka
1316
1316
1
$begingroup$
*Christmas:|
$endgroup$
– ASCII-only
Dec 26 '18 at 23:47
$begingroup$
@ASCII-only: removing the space before the&throws an error
$endgroup$
– Barranka
Dec 26 '18 at 23:49
$begingroup$
-1 bytes. Thanks to @ASCII-only for catching the typo
$endgroup$
– Barranka
Dec 27 '18 at 0:06
add a comment |
1
$begingroup$
*Christmas:|
$endgroup$
– ASCII-only
Dec 26 '18 at 23:47
$begingroup$
@ASCII-only: removing the space before the&throws an error
$endgroup$
– Barranka
Dec 26 '18 at 23:49
$begingroup$
-1 bytes. Thanks to @ASCII-only for catching the typo
$endgroup$
– Barranka
Dec 27 '18 at 0:06
1
1
$begingroup$
*
Christmas :|$endgroup$
– ASCII-only
Dec 26 '18 at 23:47
$begingroup$
*
Christmas :|$endgroup$
– ASCII-only
Dec 26 '18 at 23:47
$begingroup$
@ASCII-only: removing the space before the
& throws an error$endgroup$
– Barranka
Dec 26 '18 at 23:49
$begingroup$
@ASCII-only: removing the space before the
& throws an error$endgroup$
– Barranka
Dec 26 '18 at 23:49
$begingroup$
-1 bytes. Thanks to @ASCII-only for catching the typo
$endgroup$
– Barranka
Dec 27 '18 at 0:06
$begingroup$
-1 bytes. Thanks to @ASCII-only for catching the typo
$endgroup$
– Barranka
Dec 27 '18 at 0:06
add a comment |
$begingroup$
Bash +GNU date, 72 73 bytes
for((d=0;1`date +%d%m -d$dday`-12512;d++));{ x+= Eve;};echo Christmas$x
- one byte saved replacing
!=with-
- another removing extra space
- fix -3 bytes
d=0, becausedate -ddayis date+1 and doesn't work on 25/12
Try it online
$endgroup$
$begingroup$
Hmmm, why does=~not work in the for-loop conditional?
$endgroup$
– Cows quack
Dec 26 '18 at 19:14
$begingroup$
because the for loop condition is an arithmetic expression, words are coerced to integer also number starting with 0 are assumed in octal, that's why 1 is prepended
$endgroup$
– Nahuel Fouilleul
Dec 27 '18 at 8:04
add a comment |
$begingroup$
Bash +GNU date, 72 73 bytes
for((d=0;1`date +%d%m -d$dday`-12512;d++));{ x+= Eve;};echo Christmas$x
- one byte saved replacing
!=with-
- another removing extra space
- fix -3 bytes
d=0, becausedate -ddayis date+1 and doesn't work on 25/12
Try it online
$endgroup$
$begingroup$
Hmmm, why does=~not work in the for-loop conditional?
$endgroup$
– Cows quack
Dec 26 '18 at 19:14
$begingroup$
because the for loop condition is an arithmetic expression, words are coerced to integer also number starting with 0 are assumed in octal, that's why 1 is prepended
$endgroup$
– Nahuel Fouilleul
Dec 27 '18 at 8:04
add a comment |
$begingroup$
Bash +GNU date, 72 73 bytes
for((d=0;1`date +%d%m -d$dday`-12512;d++));{ x+= Eve;};echo Christmas$x
- one byte saved replacing
!=with-
- another removing extra space
- fix -3 bytes
d=0, becausedate -ddayis date+1 and doesn't work on 25/12
Try it online
$endgroup$
Bash +GNU date, 72 73 bytes
for((d=0;1`date +%d%m -d$dday`-12512;d++));{ x+= Eve;};echo Christmas$x
- one byte saved replacing
!=with-
- another removing extra space
- fix -3 bytes
d=0, becausedate -ddayis date+1 and doesn't work on 25/12
Try it online
edited Dec 28 '18 at 9:00
answered Dec 26 '18 at 14:46
Nahuel FouilleulNahuel Fouilleul
1,73228
1,73228
$begingroup$
Hmmm, why does=~not work in the for-loop conditional?
$endgroup$
– Cows quack
Dec 26 '18 at 19:14
$begingroup$
because the for loop condition is an arithmetic expression, words are coerced to integer also number starting with 0 are assumed in octal, that's why 1 is prepended
$endgroup$
– Nahuel Fouilleul
Dec 27 '18 at 8:04
add a comment |
$begingroup$
Hmmm, why does=~not work in the for-loop conditional?
$endgroup$
– Cows quack
Dec 26 '18 at 19:14
$begingroup$
because the for loop condition is an arithmetic expression, words are coerced to integer also number starting with 0 are assumed in octal, that's why 1 is prepended
$endgroup$
– Nahuel Fouilleul
Dec 27 '18 at 8:04
$begingroup$
Hmmm, why does
=~ not work in the for-loop conditional?$endgroup$
– Cows quack
Dec 26 '18 at 19:14
$begingroup$
Hmmm, why does
=~ not work in the for-loop conditional?$endgroup$
– Cows quack
Dec 26 '18 at 19:14
$begingroup$
because the for loop condition is an arithmetic expression, words are coerced to integer also number starting with 0 are assumed in octal, that's why 1 is prepended
$endgroup$
– Nahuel Fouilleul
Dec 27 '18 at 8:04
$begingroup$
because the for loop condition is an arithmetic expression, words are coerced to integer also number starting with 0 are assumed in octal, that's why 1 is prepended
$endgroup$
– Nahuel Fouilleul
Dec 27 '18 at 8:04
add a comment |
$begingroup$
Python 2, 128 bytes / Python 3, 130 bytes
of course, two less bytes with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
$endgroup$
1
$begingroup$
105 bytes
$endgroup$
– tsh
Dec 25 '18 at 13:00
$begingroup$
@tsh That's an amazing approach!
$endgroup$
– iBug
Dec 25 '18 at 13:18
1
$begingroup$
Python 2 doesn't need a space after print so it's 128 bytes
$endgroup$
– NieDzejkob
Dec 28 '18 at 12:48
3
$begingroup$
-2 bytes by implementingas Dby yourself
$endgroup$
– NieDzejkob
Dec 28 '18 at 13:05
add a comment |
$begingroup$
Python 2, 128 bytes / Python 3, 130 bytes
of course, two less bytes with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
$endgroup$
1
$begingroup$
105 bytes
$endgroup$
– tsh
Dec 25 '18 at 13:00
$begingroup$
@tsh That's an amazing approach!
$endgroup$
– iBug
Dec 25 '18 at 13:18
1
$begingroup$
Python 2 doesn't need a space after print so it's 128 bytes
$endgroup$
– NieDzejkob
Dec 28 '18 at 12:48
3
$begingroup$
-2 bytes by implementingas Dby yourself
$endgroup$
– NieDzejkob
Dec 28 '18 at 13:05
add a comment |
$begingroup$
Python 2, 128 bytes / Python 3, 130 bytes
of course, two less bytes with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
$endgroup$
Python 2, 128 bytes / Python 3, 130 bytes
of course, two less bytes with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
edited Dec 28 '18 at 12:49
answered Dec 25 '18 at 5:42
iBugiBug
1,377731
1,377731
1
$begingroup$
105 bytes
$endgroup$
– tsh
Dec 25 '18 at 13:00
$begingroup$
@tsh That's an amazing approach!
$endgroup$
– iBug
Dec 25 '18 at 13:18
1
$begingroup$
Python 2 doesn't need a space after print so it's 128 bytes
$endgroup$
– NieDzejkob
Dec 28 '18 at 12:48
3
$begingroup$
-2 bytes by implementingas Dby yourself
$endgroup$
– NieDzejkob
Dec 28 '18 at 13:05
add a comment |
1
$begingroup$
105 bytes
$endgroup$
– tsh
Dec 25 '18 at 13:00
$begingroup$
@tsh That's an amazing approach!
$endgroup$
– iBug
Dec 25 '18 at 13:18
1
$begingroup$
Python 2 doesn't need a space after print so it's 128 bytes
$endgroup$
– NieDzejkob
Dec 28 '18 at 12:48
3
$begingroup$
-2 bytes by implementingas Dby yourself
$endgroup$
– NieDzejkob
Dec 28 '18 at 13:05
1
1
$begingroup$
105 bytes
$endgroup$
– tsh
Dec 25 '18 at 13:00
$begingroup$
105 bytes
$endgroup$
– tsh
Dec 25 '18 at 13:00
$begingroup$
@tsh That's an amazing approach!
$endgroup$
– iBug
Dec 25 '18 at 13:18
$begingroup$
@tsh That's an amazing approach!
$endgroup$
– iBug
Dec 25 '18 at 13:18
1
1
$begingroup$
Python 2 doesn't need a space after print so it's 128 bytes
$endgroup$
– NieDzejkob
Dec 28 '18 at 12:48
$begingroup$
Python 2 doesn't need a space after print so it's 128 bytes
$endgroup$
– NieDzejkob
Dec 28 '18 at 12:48
3
3
$begingroup$
-2 bytes by implementing
as D by yourself$endgroup$
– NieDzejkob
Dec 28 '18 at 13:05
$begingroup$
-2 bytes by implementing
as D by yourself$endgroup$
– NieDzejkob
Dec 28 '18 at 13:05
add a comment |
$begingroup$
C (gcc), 157 bytes
I thought that I would be able to avoid including time.h but that just gave segment faults.
#include <time.h>
*t,u;f(){time(&u);t=localtime(&u);t[5]+=t[4]>10&t[3]>25;t[4]=11;t[3]=25;u-=mktime(t);printf("Christmas");for(u/=86400;u++;printf(" Eve"));}
Try it online!
$endgroup$
$begingroup$
IMO you should leave out the#include <stdlib.h>, not like it does anything at all here
$endgroup$
– ASCII-only
Dec 26 '18 at 9:02
$begingroup$
Suggest*t;f(u)instead of*t,u;f()and#import<time.h>instead of#include <time.h>and5[t=localtime(&u)]instead oft=localtime(&u);t[5]
$endgroup$
– ceilingcat
Dec 28 '18 at 20:40
add a comment |
$begingroup$
C (gcc), 157 bytes
I thought that I would be able to avoid including time.h but that just gave segment faults.
#include <time.h>
*t,u;f(){time(&u);t=localtime(&u);t[5]+=t[4]>10&t[3]>25;t[4]=11;t[3]=25;u-=mktime(t);printf("Christmas");for(u/=86400;u++;printf(" Eve"));}
Try it online!
$endgroup$
$begingroup$
IMO you should leave out the#include <stdlib.h>, not like it does anything at all here
$endgroup$
– ASCII-only
Dec 26 '18 at 9:02
$begingroup$
Suggest*t;f(u)instead of*t,u;f()and#import<time.h>instead of#include <time.h>and5[t=localtime(&u)]instead oft=localtime(&u);t[5]
$endgroup$
– ceilingcat
Dec 28 '18 at 20:40
add a comment |
$begingroup$
C (gcc), 157 bytes
I thought that I would be able to avoid including time.h but that just gave segment faults.
#include <time.h>
*t,u;f(){time(&u);t=localtime(&u);t[5]+=t[4]>10&t[3]>25;t[4]=11;t[3]=25;u-=mktime(t);printf("Christmas");for(u/=86400;u++;printf(" Eve"));}
Try it online!
$endgroup$
C (gcc), 157 bytes
I thought that I would be able to avoid including time.h but that just gave segment faults.
#include <time.h>
*t,u;f(){time(&u);t=localtime(&u);t[5]+=t[4]>10&t[3]>25;t[4]=11;t[3]=25;u-=mktime(t);printf("Christmas");for(u/=86400;u++;printf(" Eve"));}
Try it online!
edited Dec 26 '18 at 7:58
answered Dec 26 '18 at 0:51
ErikFErikF
1,29917
1,29917
$begingroup$
IMO you should leave out the#include <stdlib.h>, not like it does anything at all here
$endgroup$
– ASCII-only
Dec 26 '18 at 9:02
$begingroup$
Suggest*t;f(u)instead of*t,u;f()and#import<time.h>instead of#include <time.h>and5[t=localtime(&u)]instead oft=localtime(&u);t[5]
$endgroup$
– ceilingcat
Dec 28 '18 at 20:40
add a comment |
$begingroup$
IMO you should leave out the#include <stdlib.h>, not like it does anything at all here
$endgroup$
– ASCII-only
Dec 26 '18 at 9:02
$begingroup$
Suggest*t;f(u)instead of*t,u;f()and#import<time.h>instead of#include <time.h>and5[t=localtime(&u)]instead oft=localtime(&u);t[5]
$endgroup$
– ceilingcat
Dec 28 '18 at 20:40
$begingroup$
IMO you should leave out the
#include <stdlib.h>, not like it does anything at all here$endgroup$
– ASCII-only
Dec 26 '18 at 9:02
$begingroup$
IMO you should leave out the
#include <stdlib.h>, not like it does anything at all here$endgroup$
– ASCII-only
Dec 26 '18 at 9:02
$begingroup$
Suggest
*t;f(u) instead of *t,u;f() and #import<time.h> instead of #include <time.h> and 5[t=localtime(&u)] instead of t=localtime(&u);t[5]$endgroup$
– ceilingcat
Dec 28 '18 at 20:40
$begingroup$
Suggest
*t;f(u) instead of *t,u;f() and #import<time.h> instead of #include <time.h> and 5[t=localtime(&u)] instead of t=localtime(&u);t[5]$endgroup$
– ceilingcat
Dec 28 '18 at 20:40
add a comment |
$begingroup$
Groovy, 66 bytes
d=as Date
print'Christmas'+' Eve'*(new Date((d+6).year,11,25)-d)
Try it online!
Courtesy of @ASCII-only
$endgroup$
$begingroup$
You need to print it out since this is a full program not a function
$endgroup$
– ASCII-only
Dec 27 '18 at 23:25
$begingroup$
>Chistmas:/
$endgroup$
– ASCII-only
Dec 27 '18 at 23:32
$begingroup$
fixed, 149
$endgroup$
– ASCII-only
Dec 27 '18 at 23:36
$begingroup$
123
$endgroup$
– ASCII-only
Dec 27 '18 at 23:55
$begingroup$
taking your first one and using Groovy 2.5 slims it down to 115.
$endgroup$
– bdkosher
Dec 28 '18 at 0:01
|
show 7 more comments
$begingroup$
Groovy, 66 bytes
d=as Date
print'Christmas'+' Eve'*(new Date((d+6).year,11,25)-d)
Try it online!
Courtesy of @ASCII-only
$endgroup$
$begingroup$
You need to print it out since this is a full program not a function
$endgroup$
– ASCII-only
Dec 27 '18 at 23:25
$begingroup$
>Chistmas:/
$endgroup$
– ASCII-only
Dec 27 '18 at 23:32
$begingroup$
fixed, 149
$endgroup$
– ASCII-only
Dec 27 '18 at 23:36
$begingroup$
123
$endgroup$
– ASCII-only
Dec 27 '18 at 23:55
$begingroup$
taking your first one and using Groovy 2.5 slims it down to 115.
$endgroup$
– bdkosher
Dec 28 '18 at 0:01
|
show 7 more comments
$begingroup$
Groovy, 66 bytes
d=as Date
print'Christmas'+' Eve'*(new Date((d+6).year,11,25)-d)
Try it online!
Courtesy of @ASCII-only
$endgroup$
Groovy, 66 bytes
d=as Date
print'Christmas'+' Eve'*(new Date((d+6).year,11,25)-d)
Try it online!
Courtesy of @ASCII-only
edited Dec 28 '18 at 3:34
answered Dec 25 '18 at 14:58
bdkosherbdkosher
1213
1213
$begingroup$
You need to print it out since this is a full program not a function
$endgroup$
– ASCII-only
Dec 27 '18 at 23:25
$begingroup$
>Chistmas:/
$endgroup$
– ASCII-only
Dec 27 '18 at 23:32
$begingroup$
fixed, 149
$endgroup$
– ASCII-only
Dec 27 '18 at 23:36
$begingroup$
123
$endgroup$
– ASCII-only
Dec 27 '18 at 23:55
$begingroup$
taking your first one and using Groovy 2.5 slims it down to 115.
$endgroup$
– bdkosher
Dec 28 '18 at 0:01
|
show 7 more comments
$begingroup$
You need to print it out since this is a full program not a function
$endgroup$
– ASCII-only
Dec 27 '18 at 23:25
$begingroup$
>Chistmas:/
$endgroup$
– ASCII-only
Dec 27 '18 at 23:32
$begingroup$
fixed, 149
$endgroup$
– ASCII-only
Dec 27 '18 at 23:36
$begingroup$
123
$endgroup$
– ASCII-only
Dec 27 '18 at 23:55
$begingroup$
taking your first one and using Groovy 2.5 slims it down to 115.
$endgroup$
– bdkosher
Dec 28 '18 at 0:01
$begingroup$
You need to print it out since this is a full program not a function
$endgroup$
– ASCII-only
Dec 27 '18 at 23:25
$begingroup$
You need to print it out since this is a full program not a function
$endgroup$
– ASCII-only
Dec 27 '18 at 23:25
$begingroup$
>
Chistmas :/$endgroup$
– ASCII-only
Dec 27 '18 at 23:32
$begingroup$
>
Chistmas :/$endgroup$
– ASCII-only
Dec 27 '18 at 23:32
$begingroup$
fixed, 149
$endgroup$
– ASCII-only
Dec 27 '18 at 23:36
$begingroup$
fixed, 149
$endgroup$
– ASCII-only
Dec 27 '18 at 23:36
$begingroup$
123
$endgroup$
– ASCII-only
Dec 27 '18 at 23:55
$begingroup$
123
$endgroup$
– ASCII-only
Dec 27 '18 at 23:55
$begingroup$
taking your first one and using Groovy 2.5 slims it down to 115.
$endgroup$
– bdkosher
Dec 28 '18 at 0:01
$begingroup$
taking your first one and using Groovy 2.5 slims it down to 115.
$endgroup$
– bdkosher
Dec 28 '18 at 0:01
|
show 7 more comments
$begingroup$
Python 3, 106 Bytes
from datetime import*
d=date.today()
print("Christmas"+" Eve"*(date((d+timedelta(6)).year,12,25)-d).days)
$endgroup$
add a comment |
$begingroup$
Python 3, 106 Bytes
from datetime import*
d=date.today()
print("Christmas"+" Eve"*(date((d+timedelta(6)).year,12,25)-d).days)
$endgroup$
add a comment |
$begingroup$
Python 3, 106 Bytes
from datetime import*
d=date.today()
print("Christmas"+" Eve"*(date((d+timedelta(6)).year,12,25)-d).days)
$endgroup$
Python 3, 106 Bytes
from datetime import*
d=date.today()
print("Christmas"+" Eve"*(date((d+timedelta(6)).year,12,25)-d).days)
answered Dec 28 '18 at 22:29
Albert CappAlbert Capp
291
291
add a comment |
add a comment |
$begingroup$
Scala, 116 113 bytes
var d=new java.util.Date
print("Christmas")
while(!(""+d).contains("c 25")){print(" Eve");d.setDate(d.getDate+1)}
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
1
$begingroup$
I think you can usecontains("c 25")instead ofmatches(".*c 25.*")
$endgroup$
– 12Me21
Dec 29 '18 at 15:49
$begingroup$
Thanks, three bytes less! 😁
$endgroup$
– Kjetil S.
Dec 29 '18 at 15:55
$begingroup$
wow, nicely done, toString of date was nice
$endgroup$
– V. Courtois
Jan 2 at 8:09
add a comment |
$begingroup$
Scala, 116 113 bytes
var d=new java.util.Date
print("Christmas")
while(!(""+d).contains("c 25")){print(" Eve");d.setDate(d.getDate+1)}
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
1
$begingroup$
I think you can usecontains("c 25")instead ofmatches(".*c 25.*")
$endgroup$
– 12Me21
Dec 29 '18 at 15:49
$begingroup$
Thanks, three bytes less! 😁
$endgroup$
– Kjetil S.
Dec 29 '18 at 15:55
$begingroup$
wow, nicely done, toString of date was nice
$endgroup$
– V. Courtois
Jan 2 at 8:09
add a comment |
$begingroup$
Scala, 116 113 bytes
var d=new java.util.Date
print("Christmas")
while(!(""+d).contains("c 25")){print(" Eve");d.setDate(d.getDate+1)}
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
Scala, 116 113 bytes
var d=new java.util.Date
print("Christmas")
while(!(""+d).contains("c 25")){print(" Eve");d.setDate(d.getDate+1)}
Try it online!
Where c 25 is short for Dec 25.
edited Dec 29 '18 at 15:53
answered Dec 28 '18 at 22:08
Kjetil S.Kjetil S.
58915
58915
1
$begingroup$
I think you can usecontains("c 25")instead ofmatches(".*c 25.*")
$endgroup$
– 12Me21
Dec 29 '18 at 15:49
$begingroup$
Thanks, three bytes less! 😁
$endgroup$
– Kjetil S.
Dec 29 '18 at 15:55
$begingroup$
wow, nicely done, toString of date was nice
$endgroup$
– V. Courtois
Jan 2 at 8:09
add a comment |
1
$begingroup$
I think you can usecontains("c 25")instead ofmatches(".*c 25.*")
$endgroup$
– 12Me21
Dec 29 '18 at 15:49
$begingroup$
Thanks, three bytes less! 😁
$endgroup$
– Kjetil S.
Dec 29 '18 at 15:55
$begingroup$
wow, nicely done, toString of date was nice
$endgroup$
– V. Courtois
Jan 2 at 8:09
1
1
$begingroup$
I think you can use
contains("c 25") instead of matches(".*c 25.*")$endgroup$
– 12Me21
Dec 29 '18 at 15:49
$begingroup$
I think you can use
contains("c 25") instead of matches(".*c 25.*")$endgroup$
– 12Me21
Dec 29 '18 at 15:49
$begingroup$
Thanks, three bytes less! 😁
$endgroup$
– Kjetil S.
Dec 29 '18 at 15:55
$begingroup$
Thanks, three bytes less! 😁
$endgroup$
– Kjetil S.
Dec 29 '18 at 15:55
$begingroup$
wow, nicely done, toString of date was nice
$endgroup$
– V. Courtois
Jan 2 at 8:09
$begingroup$
wow, nicely done, toString of date was nice
$endgroup$
– V. Courtois
Jan 2 at 8:09
add a comment |
$begingroup$
JavaScript, 86 77 bytes
Using REPL it would be
for(c='Christmas',d=new Date;!/c 25/.test(d);d=new Date(+d+864e5))c+=' Eve';c
Kudos to ASCII-only for -9 bytes
$endgroup$
$begingroup$
77
$endgroup$
– ASCII-only
Dec 30 '18 at 8:33
$begingroup$
Bravo! You did much better than me. May I offer to shave an extra byte?for(c='Christmas',d=new Date;!/c 25/.test(d=new Date(+d+864e5));)c+=' Eve';cor this variant:for(s='Christmas',t=Date.now();!/c 25/.test(new Date(t+=864e5));)s+=' Eve';sboth are 76 bytes.
$endgroup$
– targumon
Dec 31 '18 at 23:42
add a comment |
$begingroup$
JavaScript, 86 77 bytes
Using REPL it would be
for(c='Christmas',d=new Date;!/c 25/.test(d);d=new Date(+d+864e5))c+=' Eve';c
Kudos to ASCII-only for -9 bytes
$endgroup$
$begingroup$
77
$endgroup$
– ASCII-only
Dec 30 '18 at 8:33
$begingroup$
Bravo! You did much better than me. May I offer to shave an extra byte?for(c='Christmas',d=new Date;!/c 25/.test(d=new Date(+d+864e5));)c+=' Eve';cor this variant:for(s='Christmas',t=Date.now();!/c 25/.test(new Date(t+=864e5));)s+=' Eve';sboth are 76 bytes.
$endgroup$
– targumon
Dec 31 '18 at 23:42
add a comment |
$begingroup$
JavaScript, 86 77 bytes
Using REPL it would be
for(c='Christmas',d=new Date;!/c 25/.test(d);d=new Date(+d+864e5))c+=' Eve';c
Kudos to ASCII-only for -9 bytes
$endgroup$
JavaScript, 86 77 bytes
Using REPL it would be
for(c='Christmas',d=new Date;!/c 25/.test(d);d=new Date(+d+864e5))c+=' Eve';c
Kudos to ASCII-only for -9 bytes
edited Dec 30 '18 at 8:50
answered Dec 29 '18 at 20:23
VadimVadim
1215
1215
$begingroup$
77
$endgroup$
– ASCII-only
Dec 30 '18 at 8:33
$begingroup$
Bravo! You did much better than me. May I offer to shave an extra byte?for(c='Christmas',d=new Date;!/c 25/.test(d=new Date(+d+864e5));)c+=' Eve';cor this variant:for(s='Christmas',t=Date.now();!/c 25/.test(new Date(t+=864e5));)s+=' Eve';sboth are 76 bytes.
$endgroup$
– targumon
Dec 31 '18 at 23:42
add a comment |
$begingroup$
77
$endgroup$
– ASCII-only
Dec 30 '18 at 8:33
$begingroup$
Bravo! You did much better than me. May I offer to shave an extra byte?for(c='Christmas',d=new Date;!/c 25/.test(d=new Date(+d+864e5));)c+=' Eve';cor this variant:for(s='Christmas',t=Date.now();!/c 25/.test(new Date(t+=864e5));)s+=' Eve';sboth are 76 bytes.
$endgroup$
– targumon
Dec 31 '18 at 23:42
$begingroup$
77
$endgroup$
– ASCII-only
Dec 30 '18 at 8:33
$begingroup$
77
$endgroup$
– ASCII-only
Dec 30 '18 at 8:33
$begingroup$
Bravo! You did much better than me. May I offer to shave an extra byte?
for(c='Christmas',d=new Date;!/c 25/.test(d=new Date(+d+864e5));)c+=' Eve';c or this variant: for(s='Christmas',t=Date.now();!/c 25/.test(new Date(t+=864e5));)s+=' Eve';s both are 76 bytes.$endgroup$
– targumon
Dec 31 '18 at 23:42
$begingroup$
Bravo! You did much better than me. May I offer to shave an extra byte?
for(c='Christmas',d=new Date;!/c 25/.test(d=new Date(+d+864e5));)c+=' Eve';c or this variant: for(s='Christmas',t=Date.now();!/c 25/.test(new Date(t+=864e5));)s+=' Eve';s both are 76 bytes.$endgroup$
– targumon
Dec 31 '18 at 23:42
add a comment |
$begingroup$
Lua, 137 118 bytes.
118 bytes
t,d,month,day=os.time,os.date,1,-6year=d"%Y"+(d"%D">"12/25"and 2or 1)print("Christmas",d" Eve":rep(d("%j",t(_G)-t())))
137 bytes (previous)
t,d=os.time,os.date a=d"*t"a.year,a.month,a.day=a.year+(d"%m%d">"1225"and 1 or 0),12,25 print("Christmas",("Eve "):rep((t(a)-t())/86400))
It's worth noting that it doesn't work in LuaJIT (syntax error)
$endgroup$
$begingroup$
Welcome to PPCG! Nice first post!
$endgroup$
– Riker
Dec 31 '18 at 4:14
add a comment |
$begingroup$
Lua, 137 118 bytes.
118 bytes
t,d,month,day=os.time,os.date,1,-6year=d"%Y"+(d"%D">"12/25"and 2or 1)print("Christmas",d" Eve":rep(d("%j",t(_G)-t())))
137 bytes (previous)
t,d=os.time,os.date a=d"*t"a.year,a.month,a.day=a.year+(d"%m%d">"1225"and 1 or 0),12,25 print("Christmas",("Eve "):rep((t(a)-t())/86400))
It's worth noting that it doesn't work in LuaJIT (syntax error)
$endgroup$
$begingroup$
Welcome to PPCG! Nice first post!
$endgroup$
– Riker
Dec 31 '18 at 4:14
add a comment |
$begingroup$
Lua, 137 118 bytes.
118 bytes
t,d,month,day=os.time,os.date,1,-6year=d"%Y"+(d"%D">"12/25"and 2or 1)print("Christmas",d" Eve":rep(d("%j",t(_G)-t())))
137 bytes (previous)
t,d=os.time,os.date a=d"*t"a.year,a.month,a.day=a.year+(d"%m%d">"1225"and 1 or 0),12,25 print("Christmas",("Eve "):rep((t(a)-t())/86400))
It's worth noting that it doesn't work in LuaJIT (syntax error)
$endgroup$
Lua, 137 118 bytes.
118 bytes
t,d,month,day=os.time,os.date,1,-6year=d"%Y"+(d"%D">"12/25"and 2or 1)print("Christmas",d" Eve":rep(d("%j",t(_G)-t())))
137 bytes (previous)
t,d=os.time,os.date a=d"*t"a.year,a.month,a.day=a.year+(d"%m%d">"1225"and 1 or 0),12,25 print("Christmas",("Eve "):rep((t(a)-t())/86400))
It's worth noting that it doesn't work in LuaJIT (syntax error)
edited Dec 31 '18 at 4:15
answered Dec 31 '18 at 4:08
Tae HanazonoTae Hanazono
192
192
$begingroup$
Welcome to PPCG! Nice first post!
$endgroup$
– Riker
Dec 31 '18 at 4:14
add a comment |
$begingroup$
Welcome to PPCG! Nice first post!
$endgroup$
– Riker
Dec 31 '18 at 4:14
$begingroup$
Welcome to PPCG! Nice first post!
$endgroup$
– Riker
Dec 31 '18 at 4:14
$begingroup$
Welcome to PPCG! Nice first post!
$endgroup$
– Riker
Dec 31 '18 at 4:14
add a comment |
$begingroup$
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
$endgroup$
add a comment |
$begingroup$
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
$endgroup$
add a comment |
$begingroup$
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
$endgroup$
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
answered Dec 25 '18 at 20:55
TitusTitus
13.1k11238
13.1k11238
add a comment |
add a comment |
$begingroup$
MATLAB, 91 bytes
n=datetime
x=datetime(year(n+6),12,25)
s='Christmas'
while days(x-n)>=1 n=n+1 s=[s,' Eve'] end
MATLAB Non-looper, 100 bytes
x=datenum(datetime(floor((now+5)/365.2425),12,25))
d=x-now
['Christmas' repmat(' Eve',1,min(d(d>=0)))]
$endgroup$
add a comment |
$begingroup$
MATLAB, 91 bytes
n=datetime
x=datetime(year(n+6),12,25)
s='Christmas'
while days(x-n)>=1 n=n+1 s=[s,' Eve'] end
MATLAB Non-looper, 100 bytes
x=datenum(datetime(floor((now+5)/365.2425),12,25))
d=x-now
['Christmas' repmat(' Eve',1,min(d(d>=0)))]
$endgroup$
add a comment |
$begingroup$
MATLAB, 91 bytes
n=datetime
x=datetime(year(n+6),12,25)
s='Christmas'
while days(x-n)>=1 n=n+1 s=[s,' Eve'] end
MATLAB Non-looper, 100 bytes
x=datenum(datetime(floor((now+5)/365.2425),12,25))
d=x-now
['Christmas' repmat(' Eve',1,min(d(d>=0)))]
$endgroup$
MATLAB, 91 bytes
n=datetime
x=datetime(year(n+6),12,25)
s='Christmas'
while days(x-n)>=1 n=n+1 s=[s,' Eve'] end
MATLAB Non-looper, 100 bytes
x=datenum(datetime(floor((now+5)/365.2425),12,25))
d=x-now
['Christmas' repmat(' Eve',1,min(d(d>=0)))]
edited Dec 29 '18 at 16:05
answered Dec 29 '18 at 15:39
AnthonyAnthony
1113
1113
add a comment |
add a comment |
$begingroup$
Scala, 123 bytes
Thanks to ASCII-only's work.
print("Christmas")
var d=new java.util.Date
while(d.getMonth()<11||d.getDate()!=25){print(" Eve");d.setDate(d.getDate()+1)}
Try it online!
Scala + Joda-Time, 140 bytes
import org.joda.time._
var s="Christmas"
var d=DateTime.now
while(d!=d.withDate(d.year().get(),12,25)){d=d.plusDays(1);s+=" Eve"};println(s)
Does not run in TIO since it requires Joda-Time library.
$endgroup$
$begingroup$
no joda, 154. sadly can't getjava.util.Dateto work here :/
$endgroup$
– ASCII-only
Dec 28 '18 at 0:12
$begingroup$
148
$endgroup$
– ASCII-only
Dec 28 '18 at 0:19
$begingroup$
Ah @ASCII-only I did not countobject Main extends App{}chars in my counting (cause I didn't in my other Scala answers either). If we take that out you beat me ^^
$endgroup$
– V. Courtois
Dec 28 '18 at 6:40
$begingroup$
ThewithDate()call is so expensive...
$endgroup$
– V. Courtois
Dec 28 '18 at 6:41
$begingroup$
1. remember you need to specify language as "Scala + Joda-Time" since you use an external library and 2. not going to use my changes? it's shorter plus doesn't need a library :P
$endgroup$
– ASCII-only
Dec 31 '18 at 6:17
|
show 7 more comments
$begingroup$
Scala, 123 bytes
Thanks to ASCII-only's work.
print("Christmas")
var d=new java.util.Date
while(d.getMonth()<11||d.getDate()!=25){print(" Eve");d.setDate(d.getDate()+1)}
Try it online!
Scala + Joda-Time, 140 bytes
import org.joda.time._
var s="Christmas"
var d=DateTime.now
while(d!=d.withDate(d.year().get(),12,25)){d=d.plusDays(1);s+=" Eve"};println(s)
Does not run in TIO since it requires Joda-Time library.
$endgroup$
$begingroup$
no joda, 154. sadly can't getjava.util.Dateto work here :/
$endgroup$
– ASCII-only
Dec 28 '18 at 0:12
$begingroup$
148
$endgroup$
– ASCII-only
Dec 28 '18 at 0:19
$begingroup$
Ah @ASCII-only I did not countobject Main extends App{}chars in my counting (cause I didn't in my other Scala answers either). If we take that out you beat me ^^
$endgroup$
– V. Courtois
Dec 28 '18 at 6:40
$begingroup$
ThewithDate()call is so expensive...
$endgroup$
– V. Courtois
Dec 28 '18 at 6:41
$begingroup$
1. remember you need to specify language as "Scala + Joda-Time" since you use an external library and 2. not going to use my changes? it's shorter plus doesn't need a library :P
$endgroup$
– ASCII-only
Dec 31 '18 at 6:17
|
show 7 more comments
$begingroup$
Scala, 123 bytes
Thanks to ASCII-only's work.
print("Christmas")
var d=new java.util.Date
while(d.getMonth()<11||d.getDate()!=25){print(" Eve");d.setDate(d.getDate()+1)}
Try it online!
Scala + Joda-Time, 140 bytes
import org.joda.time._
var s="Christmas"
var d=DateTime.now
while(d!=d.withDate(d.year().get(),12,25)){d=d.plusDays(1);s+=" Eve"};println(s)
Does not run in TIO since it requires Joda-Time library.
$endgroup$
Scala, 123 bytes
Thanks to ASCII-only's work.
print("Christmas")
var d=new java.util.Date
while(d.getMonth()<11||d.getDate()!=25){print(" Eve");d.setDate(d.getDate()+1)}
Try it online!
Scala + Joda-Time, 140 bytes
import org.joda.time._
var s="Christmas"
var d=DateTime.now
while(d!=d.withDate(d.year().get(),12,25)){d=d.plusDays(1);s+=" Eve"};println(s)
Does not run in TIO since it requires Joda-Time library.
edited Dec 31 '18 at 12:26
answered Dec 27 '18 at 13:17
V. CourtoisV. Courtois
708113
708113
$begingroup$
no joda, 154. sadly can't getjava.util.Dateto work here :/
$endgroup$
– ASCII-only
Dec 28 '18 at 0:12
$begingroup$
148
$endgroup$
– ASCII-only
Dec 28 '18 at 0:19
$begingroup$
Ah @ASCII-only I did not countobject Main extends App{}chars in my counting (cause I didn't in my other Scala answers either). If we take that out you beat me ^^
$endgroup$
– V. Courtois
Dec 28 '18 at 6:40
$begingroup$
ThewithDate()call is so expensive...
$endgroup$
– V. Courtois
Dec 28 '18 at 6:41
$begingroup$
1. remember you need to specify language as "Scala + Joda-Time" since you use an external library and 2. not going to use my changes? it's shorter plus doesn't need a library :P
$endgroup$
– ASCII-only
Dec 31 '18 at 6:17
|
show 7 more comments
$begingroup$
no joda, 154. sadly can't getjava.util.Dateto work here :/
$endgroup$
– ASCII-only
Dec 28 '18 at 0:12
$begingroup$
148
$endgroup$
– ASCII-only
Dec 28 '18 at 0:19
$begingroup$
Ah @ASCII-only I did not countobject Main extends App{}chars in my counting (cause I didn't in my other Scala answers either). If we take that out you beat me ^^
$endgroup$
– V. Courtois
Dec 28 '18 at 6:40
$begingroup$
ThewithDate()call is so expensive...
$endgroup$
– V. Courtois
Dec 28 '18 at 6:41
$begingroup$
1. remember you need to specify language as "Scala + Joda-Time" since you use an external library and 2. not going to use my changes? it's shorter plus doesn't need a library :P
$endgroup$
– ASCII-only
Dec 31 '18 at 6:17
$begingroup$
no joda, 154. sadly can't get
java.util.Date to work here :/$endgroup$
– ASCII-only
Dec 28 '18 at 0:12
$begingroup$
no joda, 154. sadly can't get
java.util.Date to work here :/$endgroup$
– ASCII-only
Dec 28 '18 at 0:12
$begingroup$
148
$endgroup$
– ASCII-only
Dec 28 '18 at 0:19
$begingroup$
148
$endgroup$
– ASCII-only
Dec 28 '18 at 0:19
$begingroup$
Ah @ASCII-only I did not count
object Main extends App{} chars in my counting (cause I didn't in my other Scala answers either). If we take that out you beat me ^^$endgroup$
– V. Courtois
Dec 28 '18 at 6:40
$begingroup$
Ah @ASCII-only I did not count
object Main extends App{} chars in my counting (cause I didn't in my other Scala answers either). If we take that out you beat me ^^$endgroup$
– V. Courtois
Dec 28 '18 at 6:40
$begingroup$
The
withDate() call is so expensive...$endgroup$
– V. Courtois
Dec 28 '18 at 6:41
$begingroup$
The
withDate() call is so expensive...$endgroup$
– V. Courtois
Dec 28 '18 at 6:41
$begingroup$
1. remember you need to specify language as "Scala + Joda-Time" since you use an external library and 2. not going to use my changes? it's shorter plus doesn't need a library :P
$endgroup$
– ASCII-only
Dec 31 '18 at 6:17
$begingroup$
1. remember you need to specify language as "Scala + Joda-Time" since you use an external library and 2. not going to use my changes? it's shorter plus doesn't need a library :P
$endgroup$
– ASCII-only
Dec 31 '18 at 6:17
|
show 7 more comments
$begingroup$
05AB1E, 93 89 bytes
žežfžg)V'ŒÎ[Y¨JŽ9ÚQ#Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝVð'»ˆ}J™
Try it online or Try it online with an emulated self-specified date of 'today'.
Explanation:
05AB1E doesn't have any builtins for dates, except for receiving the current year/month/day/hours/minutes/seconds/microseconds, so most bytes are used for manual calculations.
žežfžg)V # Get the current date and save it in variable `Y`
'ŒÎ '# Push compressed string "christmas"
[ # Start an infinite loop
Y¨JŽ9ÚQ # If the current date is December 25th:
# # Stop the infinite loop
Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝV
# Go to the next day, and set `Y` to it
ð # Push a space " "
'»ˆ '# Push compressed string "eve"
} # After the infinite loop:
J # Join everything on the stack together
™ # And make every word title-case (and output the result implicitly)
See this answer of mine to understand how we go to the next day. (PS: 1¾ǝ has been replaced with T`ǝ, since we use the counter_variable somewhere else as well.)
See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why '»ˆ is "eve"; 'ŒÎ is "christmas"; and Ž9Ú is 1225.
$endgroup$
$begingroup$
Clever golfing!
$endgroup$
– MilkyWay90
Jan 5 at 18:35
add a comment |
$begingroup$
05AB1E, 93 89 bytes
žežfžg)V'ŒÎ[Y¨JŽ9ÚQ#Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝVð'»ˆ}J™
Try it online or Try it online with an emulated self-specified date of 'today'.
Explanation:
05AB1E doesn't have any builtins for dates, except for receiving the current year/month/day/hours/minutes/seconds/microseconds, so most bytes are used for manual calculations.
žežfžg)V # Get the current date and save it in variable `Y`
'ŒÎ '# Push compressed string "christmas"
[ # Start an infinite loop
Y¨JŽ9ÚQ # If the current date is December 25th:
# # Stop the infinite loop
Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝV
# Go to the next day, and set `Y` to it
ð # Push a space " "
'»ˆ '# Push compressed string "eve"
} # After the infinite loop:
J # Join everything on the stack together
™ # And make every word title-case (and output the result implicitly)
See this answer of mine to understand how we go to the next day. (PS: 1¾ǝ has been replaced with T`ǝ, since we use the counter_variable somewhere else as well.)
See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why '»ˆ is "eve"; 'ŒÎ is "christmas"; and Ž9Ú is 1225.
$endgroup$
$begingroup$
Clever golfing!
$endgroup$
– MilkyWay90
Jan 5 at 18:35
add a comment |
$begingroup$
05AB1E, 93 89 bytes
žežfžg)V'ŒÎ[Y¨JŽ9ÚQ#Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝVð'»ˆ}J™
Try it online or Try it online with an emulated self-specified date of 'today'.
Explanation:
05AB1E doesn't have any builtins for dates, except for receiving the current year/month/day/hours/minutes/seconds/microseconds, so most bytes are used for manual calculations.
žežfžg)V # Get the current date and save it in variable `Y`
'ŒÎ '# Push compressed string "christmas"
[ # Start an infinite loop
Y¨JŽ9ÚQ # If the current date is December 25th:
# # Stop the infinite loop
Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝV
# Go to the next day, and set `Y` to it
ð # Push a space " "
'»ˆ '# Push compressed string "eve"
} # After the infinite loop:
J # Join everything on the stack together
™ # And make every word title-case (and output the result implicitly)
See this answer of mine to understand how we go to the next day. (PS: 1¾ǝ has been replaced with T`ǝ, since we use the counter_variable somewhere else as well.)
See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why '»ˆ is "eve"; 'ŒÎ is "christmas"; and Ž9Ú is 1225.
$endgroup$
05AB1E, 93 89 bytes
žežfžg)V'ŒÎ[Y¨JŽ9ÚQ#Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝVð'»ˆ}J™
Try it online or Try it online with an emulated self-specified date of 'today'.
Explanation:
05AB1E doesn't have any builtins for dates, except for receiving the current year/month/day/hours/minutes/seconds/microseconds, so most bytes are used for manual calculations.
žežfžg)V # Get the current date and save it in variable `Y`
'ŒÎ '# Push compressed string "christmas"
[ # Start an infinite loop
Y¨JŽ9ÚQ # If the current date is December 25th:
# # Stop the infinite loop
Y`2ô0Kθ4ÖUD2Qi28X+ë31s<7%É-}‹iY¬>0ëYT`ǝDÅsD12‹i>1ë1Dǝ¤>2}}ǝV
# Go to the next day, and set `Y` to it
ð # Push a space " "
'»ˆ '# Push compressed string "eve"
} # After the infinite loop:
J # Join everything on the stack together
™ # And make every word title-case (and output the result implicitly)
See this answer of mine to understand how we go to the next day. (PS: 1¾ǝ has been replaced with T`ǝ, since we use the counter_variable somewhere else as well.)
See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why '»ˆ is "eve"; 'ŒÎ is "christmas"; and Ž9Ú is 1225.
edited Jan 3 at 12:44
answered Jan 3 at 12:38
Kevin CruijssenKevin Cruijssen
36.6k555192
36.6k555192
$begingroup$
Clever golfing!
$endgroup$
– MilkyWay90
Jan 5 at 18:35
add a comment |
$begingroup$
Clever golfing!
$endgroup$
– MilkyWay90
Jan 5 at 18:35
$begingroup$
Clever golfing!
$endgroup$
– MilkyWay90
Jan 5 at 18:35
$begingroup$
Clever golfing!
$endgroup$
– MilkyWay90
Jan 5 at 18:35
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
$endgroup$
1
$begingroup$
I don't think this works for the 30th of November...
$endgroup$
– Neil
Dec 25 '18 at 9:56
$begingroup$
Fixed now, I forgot to add a check to if it was December or not
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 17:58
$begingroup$
Are you sure about Month > 25?
$endgroup$
– Neil
Dec 25 '18 at 19:12
$begingroup$
Fixed it now...
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 20:20
$begingroup$
Is the ?1:0 nessesary? doesn't & return an integer?
$endgroup$
– 12Me21
Dec 25 '18 at 23:33
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
$endgroup$
1
$begingroup$
I don't think this works for the 30th of November...
$endgroup$
– Neil
Dec 25 '18 at 9:56
$begingroup$
Fixed now, I forgot to add a check to if it was December or not
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 17:58
$begingroup$
Are you sure about Month > 25?
$endgroup$
– Neil
Dec 25 '18 at 19:12
$begingroup$
Fixed it now...
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 20:20
$begingroup$
Is the ?1:0 nessesary? doesn't & return an integer?
$endgroup$
– 12Me21
Dec 25 '18 at 23:33
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
$endgroup$
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
edited Dec 25 '18 at 20:19
answered Dec 25 '18 at 4:37
Embodiment of IgnoranceEmbodiment of Ignorance
701115
701115
1
$begingroup$
I don't think this works for the 30th of November...
$endgroup$
– Neil
Dec 25 '18 at 9:56
$begingroup$
Fixed now, I forgot to add a check to if it was December or not
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 17:58
$begingroup$
Are you sure about Month > 25?
$endgroup$
– Neil
Dec 25 '18 at 19:12
$begingroup$
Fixed it now...
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 20:20
$begingroup$
Is the ?1:0 nessesary? doesn't & return an integer?
$endgroup$
– 12Me21
Dec 25 '18 at 23:33
add a comment |
1
$begingroup$
I don't think this works for the 30th of November...
$endgroup$
– Neil
Dec 25 '18 at 9:56
$begingroup$
Fixed now, I forgot to add a check to if it was December or not
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 17:58
$begingroup$
Are you sure about Month > 25?
$endgroup$
– Neil
Dec 25 '18 at 19:12
$begingroup$
Fixed it now...
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 20:20
$begingroup$
Is the ?1:0 nessesary? doesn't & return an integer?
$endgroup$
– 12Me21
Dec 25 '18 at 23:33
1
1
$begingroup$
I don't think this works for the 30th of November...
$endgroup$
– Neil
Dec 25 '18 at 9:56
$begingroup$
I don't think this works for the 30th of November...
$endgroup$
– Neil
Dec 25 '18 at 9:56
$begingroup$
Fixed now, I forgot to add a check to if it was December or not
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 17:58
$begingroup$
Fixed now, I forgot to add a check to if it was December or not
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 17:58
$begingroup$
Are you sure about Month > 25?
$endgroup$
– Neil
Dec 25 '18 at 19:12
$begingroup$
Are you sure about Month > 25?
$endgroup$
– Neil
Dec 25 '18 at 19:12
$begingroup$
Fixed it now...
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 20:20
$begingroup$
Fixed it now...
$endgroup$
– Embodiment of Ignorance
Dec 25 '18 at 20:20
$begingroup$
Is the ?1:0 nessesary? doesn't & return an integer?
$endgroup$
– 12Me21
Dec 25 '18 at 23:33
$begingroup$
Is the ?1:0 nessesary? doesn't & return an integer?
$endgroup$
– 12Me21
Dec 25 '18 at 23:33
add a comment |
$begingroup$
Red, 89 86 84 78 76 bytes
-10 bytes thanks to ASCII-only!
does[a: now prin"Christmas"while[a/3 * 31 + a/4 <> 397][prin" Eve"a: a + 1]]
Try it online!
$endgroup$
$begingroup$
84
$endgroup$
– ASCII-only
Dec 26 '18 at 9:04
$begingroup$
@ASCII-only Hmm, of course! Thank you!
$endgroup$
– Galen Ivanov
Dec 26 '18 at 10:01
$begingroup$
78
$endgroup$
– ASCII-only
Dec 26 '18 at 23:45
$begingroup$
76
$endgroup$
– ASCII-only
Dec 27 '18 at 0:12
$begingroup$
@ASCII-only Your 76-byte version does not give correct result when run on Christmas: Date as an argument I feel stupid for not using onlynowand notnow/date. Thank you for your improvements!
$endgroup$
– Galen Ivanov
Dec 27 '18 at 7:20
|
show 3 more comments
$begingroup$
Red, 89 86 84 78 76 bytes
-10 bytes thanks to ASCII-only!
does[a: now prin"Christmas"while[a/3 * 31 + a/4 <> 397][prin" Eve"a: a + 1]]
Try it online!
$endgroup$
$begingroup$
84
$endgroup$
– ASCII-only
Dec 26 '18 at 9:04
$begingroup$
@ASCII-only Hmm, of course! Thank you!
$endgroup$
– Galen Ivanov
Dec 26 '18 at 10:01
$begingroup$
78
$endgroup$
– ASCII-only
Dec 26 '18 at 23:45
$begingroup$
76
$endgroup$
– ASCII-only
Dec 27 '18 at 0:12
$begingroup$
@ASCII-only Your 76-byte version does not give correct result when run on Christmas: Date as an argument I feel stupid for not using onlynowand notnow/date. Thank you for your improvements!
$endgroup$
– Galen Ivanov
Dec 27 '18 at 7:20
|
show 3 more comments
$begingroup$
Red, 89 86 84 78 76 bytes
-10 bytes thanks to ASCII-only!
does[a: now prin"Christmas"while[a/3 * 31 + a/4 <> 397][prin" Eve"a: a + 1]]
Try it online!
$endgroup$
Red, 89 86 84 78 76 bytes
-10 bytes thanks to ASCII-only!
does[a: now prin"Christmas"while[a/3 * 31 + a/4 <> 397][prin" Eve"a: a + 1]]
Try it online!
edited Dec 28 '18 at 7:18
answered Dec 25 '18 at 8:19
Galen IvanovGalen Ivanov
6,56711032
6,56711032
$begingroup$
84
$endgroup$
– ASCII-only
Dec 26 '18 at 9:04
$begingroup$
@ASCII-only Hmm, of course! Thank you!
$endgroup$
– Galen Ivanov
Dec 26 '18 at 10:01
$begingroup$
78
$endgroup$
– ASCII-only
Dec 26 '18 at 23:45
$begingroup$
76
$endgroup$
– ASCII-only
Dec 27 '18 at 0:12
$begingroup$
@ASCII-only Your 76-byte version does not give correct result when run on Christmas: Date as an argument I feel stupid for not using onlynowand notnow/date. Thank you for your improvements!
$endgroup$
– Galen Ivanov
Dec 27 '18 at 7:20
|
show 3 more comments
$begingroup$
84
$endgroup$
– ASCII-only
Dec 26 '18 at 9:04
$begingroup$
@ASCII-only Hmm, of course! Thank you!
$endgroup$
– Galen Ivanov
Dec 26 '18 at 10:01
$begingroup$
78
$endgroup$
– ASCII-only
Dec 26 '18 at 23:45
$begingroup$
76
$endgroup$
– ASCII-only
Dec 27 '18 at 0:12
$begingroup$
@ASCII-only Your 76-byte version does not give correct result when run on Christmas: Date as an argument I feel stupid for not using onlynowand notnow/date. Thank you for your improvements!
$endgroup$
– Galen Ivanov
Dec 27 '18 at 7:20
$begingroup$
84
$endgroup$
– ASCII-only
Dec 26 '18 at 9:04
$begingroup$
84
$endgroup$
– ASCII-only
Dec 26 '18 at 9:04
$begingroup$
@ASCII-only Hmm, of course! Thank you!
$endgroup$
– Galen Ivanov
Dec 26 '18 at 10:01
$begingroup$
@ASCII-only Hmm, of course! Thank you!
$endgroup$
– Galen Ivanov
Dec 26 '18 at 10:01
$begingroup$
78
$endgroup$
– ASCII-only
Dec 26 '18 at 23:45
$begingroup$
78
$endgroup$
– ASCII-only
Dec 26 '18 at 23:45
$begingroup$
76
$endgroup$
– ASCII-only
Dec 27 '18 at 0:12
$begingroup$
76
$endgroup$
– ASCII-only
Dec 27 '18 at 0:12
$begingroup$
@ASCII-only Your 76-byte version does not give correct result when run on Christmas: Date as an argument I feel stupid for not using only
now and not now/date. Thank you for your improvements!$endgroup$
– Galen Ivanov
Dec 27 '18 at 7:20
$begingroup$
@ASCII-only Your 76-byte version does not give correct result when run on Christmas: Date as an argument I feel stupid for not using only
now and not now/date. Thank you for your improvements!$endgroup$
– Galen Ivanov
Dec 27 '18 at 7:20
|
show 3 more comments
$begingroup$
Perl 5, 68 bytes
print"Christmas";print" Eve"while localtime($i++*86400+time)!~/c 25/
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
$begingroup$
Replacelocaltimewithgmtimeto save 3 bytes. After all, the question didn't state in which timezone Christmas is to be considered.
$endgroup$
– Abigail
Dec 29 '18 at 19:51
add a comment |
$begingroup$
Perl 5, 68 bytes
print"Christmas";print" Eve"while localtime($i++*86400+time)!~/c 25/
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
$begingroup$
Replacelocaltimewithgmtimeto save 3 bytes. After all, the question didn't state in which timezone Christmas is to be considered.
$endgroup$
– Abigail
Dec 29 '18 at 19:51
add a comment |
$begingroup$
Perl 5, 68 bytes
print"Christmas";print" Eve"while localtime($i++*86400+time)!~/c 25/
Try it online!
Where c 25 is short for Dec 25.
$endgroup$
Perl 5, 68 bytes
print"Christmas";print" Eve"while localtime($i++*86400+time)!~/c 25/
Try it online!
Where c 25 is short for Dec 25.
edited Dec 28 '18 at 22:16
answered Dec 28 '18 at 19:22
Kjetil S.Kjetil S.
58915
58915
$begingroup$
Replacelocaltimewithgmtimeto save 3 bytes. After all, the question didn't state in which timezone Christmas is to be considered.
$endgroup$
– Abigail
Dec 29 '18 at 19:51
add a comment |
$begingroup$
Replacelocaltimewithgmtimeto save 3 bytes. After all, the question didn't state in which timezone Christmas is to be considered.
$endgroup$
– Abigail
Dec 29 '18 at 19:51
$begingroup$
Replace
localtime with gmtime to save 3 bytes. After all, the question didn't state in which timezone Christmas is to be considered.$endgroup$
– Abigail
Dec 29 '18 at 19:51
$begingroup$
Replace
localtime with gmtime to save 3 bytes. After all, the question didn't state in which timezone Christmas is to be considered.$endgroup$
– Abigail
Dec 29 '18 at 19:51
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178003%2fencode-the-date-in-christmas-eve-format%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
6
$begingroup$
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:36
24
$begingroup$
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
$endgroup$
– Black Owl Kai
Dec 24 '18 at 23:38
6
$begingroup$
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
$endgroup$
– PyRulez
Dec 24 '18 at 23:41
1
$begingroup$
Can the date be a parameter?
$endgroup$
– Olivier Grégoire
Dec 26 '18 at 11:23
1
$begingroup$
@OlivierGrégoire uhm, I'll permit it iff the language does not have the ability to get the current date in another way.
$endgroup$
– PyRulez
Dec 26 '18 at 14:53