25
3
To celebrate Rounded Pi Day, you must take advantage of today's date to make a program that takes in a circle's diameter and outputs its circumference by multiplying the diameter by 3.1416, where 3.1416 must be obtained using today's date.
Input 3
Output 9.4248
etc.
Does not take the date as input. You do not have to use all components of the date but the digits of pi must come from formatting a Date object or using a date object to obtain it. The answers so far look good.
Not sure what else to specify. All the answers so far meet what I was expecting.
My constraint was that you must use components of the date to come up with Pi. You can of course use the components, multiply by 0 then add 3.1416, but that's boring and wastes precious chars!
Shortest code wins!
61What's so special about 14/3/16? – Neil – 2016-03-14T13:01:10.283
5define using today's date. I could get the date as a number, divide by itself and multiply by a predefined constant for
pi
– Luis Mendo – 2016-03-14T13:02:34.050Should we support a point? I mean, should the code be able to calculate for 0 diameter? – manatwork – 2016-03-14T13:43:12.780
@manatwork We can assume that the arg is an integer or floating point number > 0. – jmasterx – 2016-03-14T13:52:36.400
@Neil in the US, we format it MM/DD/YY, so today is 3/14 today. The OP is presumably in the US themself. – Anonymous Penguin – 2016-03-14T14:04:59.460
2I think the challenge would be more clear if the actual task was something like "multiply the input by
MM.DDYY
". – ETHproductions – 2016-03-14T14:09:07.5577@Neil: Because 3/14/16 and 31/4/16 are not valid actual dates in D/M/Y format. There aren't 14 months, and April only has 30 days. I personally think we should wait until 6/28/32 (M/D/Y) or maybe 6/2/83 (D/M/Y), but that's a whole other holy war. – Darrel Hoffman – 2016-03-14T14:38:54.247
8@DarrelHoffman You're a Tau man I see. – jmasterx – 2016-03-14T14:46:18.707
3@DarrelHoffman So close with that 31/4/16... – Neil – 2016-03-14T16:09:11.793
Is a floating point number valid? I.E. Input of 3 yields 9.424800000000001 – Winny – 2016-03-14T17:46:07.187
16Sadly, its only PI day in the US cultural area. Europeans, with their silly lexigraphcially-sensible date ordering, don't get to have yearly PI days. Spare a sad thought for them, as you're eating your pi(e) today. – T.E.D. – 2016-03-14T18:03:30.320
2@T.E.D. But Europeans get Pi Approximation Day, July 22! – Mike Kellogg – 2016-03-14T18:46:13.533
4@MikeKellogg - So on "Pi Approximation Day", do they eat Chicago-style pizza? :-) – T.E.D. – 2016-03-14T18:52:11.487
2What counts as obtained using today's date? For example, can I obtain 16 as
2016 % 20
? – Dennis – 2016-03-14T19:17:30.0434Really should state that "today's date" is in M/D/Y format, as half the world formats date in other ways. – Mindwin – 2016-03-14T19:34:41.273
US date ordering makes a lot more sense than any other system. The terms of possibilities go up, [1-12]/[1-30ish]/[00-99]. Therefore the magnitudes are all increasing. – Will Sherwood – 2016-03-14T21:02:13.263
3Hey everyone! Today is actually
2016-03-14
. – SuperJedi224 – 2016-03-14T21:49:24.2601@WillSherwood That's a strange thing to sort by. Now, redefining the length of a month so that pattern occurs when sorting by size of an increment might be sensible. – Brilliand – 2016-03-14T22:15:56.630
1@T.E.D. Silly? I find european format more intuitive – rpax – 2016-03-14T22:53:40.223
1@rpax "lexigraphcially-sensible", he was probably was being sarcastic – None – 2016-03-15T19:13:25.290
I feel stupid for how long it took me to realize why no one was using brainf*ck – tox123 – 2016-03-15T23:18:18.080
@WillSherwood the ISO 8601 international standard YYYY-MM-DD makes the most sense. No one can read it wrongly and it will always sort correctly by chronological order. The US way makes the least sense. Why should magnitudes increasing? Sorting and reading is what people care
– phuclv – 2016-03-16T03:53:58.0071@DarrelHoffman some people prefer 22/7 as Pi day – phuclv – 2016-03-16T03:54:41.450
@LưuVĩnhPhúc the date 22/7 doesn't exist because there are only 12 months in a year though – Will Sherwood – 2016-03-16T04:08:03.303
1@WillSherwood it exists in most of the world except those who write 3/14/16 (well, a few other countries who write 16/14/3, too) – phuclv – 2016-03-16T04:33:49.457
@WillSherwood -_- – Code Jockey – 2016-03-16T15:59:21.627
But this year's Pi day was more accurate than last year's.
– TRiG – 2016-03-16T17:46:36.360Why isn't Pi Day 22/7 i.e. 22nd of July? Wouldn't that be more appropriate? – phuclv – 2016-03-24T14:59:33.047