Happy Rounded Pi Day

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!

jmasterx

Posted 2016-03-14T12:24:10.963

Reputation: 509

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.050

Should 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.557

7@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.043

4Really 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.260

1@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.007

1@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.360

Answers

8

05AB1E, 16 13 bytes

žfžežg¦¦J*4°/

Try it online.

Unfortunately a bug with floats makes this a byte longer :/

Thanks to Adnan for golfing off 3 bytes.

Explanation

žfžežg¦¦J*4°/
žfžežg         push month day year
      ¦¦       slice off the first two chars from the year (2016 -> 16)
        J      join them together into a number
         *     multiply by input
          4°/  divide by 1e4

a spaghetto

Posted 2016-03-14T12:24:10.963

Reputation: 10 647

¦¦ instead of 2000- is three bytes shorter ;) – Adnan – 2016-03-14T16:11:28.297

11+1 žfžežg sounds like a nice Czech word :) – yo' – 2016-03-15T09:02:57.267

In UTF-8, this totals 19 bytes. – OldBunny2800 – 2016-03-16T21:21:06.560

3@OldBunny2800 05AB1E uses CP1252 for encoding. – a spaghetto – 2016-03-16T21:21:36.180

Bug with floats? – CalculatorFeline – 2016-04-07T05:18:45.713

@CatsAreFluffy I should be able to do žf'.žežg¦¦J* (which is a byte shorter), but strings weren't auto-coercing to floats properly. – a spaghetto – 2016-04-07T16:58:39.220

19

C, 32 bytes

#define f(d)d*time(0)/464083315.

If losing a little more accuracy is fine, I can get it down to about 29 bytes being still accurate to 4 digits past the decimal (as of the time of this posting):

#define f(d)d*time(0)/46408e4

Josh

Posted 2016-03-14T12:24:10.963

Reputation: 2 783

#include<time.h>? – cat – 2016-03-14T15:08:24.263

Also, where's the executable code? this is just something for the preprocessor to copy/paste; a snippet. We like runnable implementations here. – cat – 2016-03-14T15:09:10.050

3@tac most C compilers do not require you to #include standard library headers. Including them manually is almost always a good idea, but omitting them makes code golfing in C a lot easier. – Josh – 2016-03-14T15:21:26.373

12@tac the answer behaves mostly the same as a function. Several answers on here are standalone functions as well. I don't see the point in providing a sample main function to demonstrate how to call this single argument macro. – Josh – 2016-03-14T15:25:07.997

1@tac I think the standard [code-golf] rules is that unless forbidden functions are ok. – Mindwin – 2016-03-14T19:32:47.183

I don't think this is valid; the number being multiplied by is never exactly 3.1416. The question says "multiplying the diameter by 3.1416, where 3.1416 must be obtained using today's date.", not "multiplying the diameter by an approximation to pi obtained using today's date." However, it's unfair to downvote when the question is closed. – lirtosiast – 2016-03-15T03:40:39.977

@lirtosiast I understand where you are coming from, but I feel I stayed on the legal side of the grey line. Quoting the current spec, 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. – Josh – 2016-03-15T12:54:40.690

14

AppleScript, 122 120 bytes

set a to current date
(display dialog""default answer"")'s text returned*(month of a+day of a*.01+year of a*1e-4 mod.01)

Variable a

Variable a is a date object. I call all of my date information off of it.

Month, day, and year

The month, day, and year calls actually return an object that normally returns a string. To properly use it as a number, I have surrounded it on both sides with mathematical operations to automatically cast it to a number.

1e-4

1e-4 is a byte shorter than .0001.

mod.01

. acts as a separator to the AppleScript autocorrect. By using this, I can use modulo and still keep it a byte for myself.

No return statement/log

The last value calculated automatically is returned by the program. I output the number calculated via the return box.

And here's a gif of it running!

pi day gif

Addison Crump

Posted 2016-03-14T12:24:10.963

Reputation: 10 763

8Forget Java, this has got to be the most verbose language – Downgoat – 2016-03-15T14:52:44.177

@Downgoat I guess that it's supposed to be "readable like English" or something... we use it a bit at one of my jobs and I really dislike whenever I have to make changes to such scripts. – Chris Cirefice – 2016-03-15T15:49:46.940

@ChrisCirefice Yeah, no - this language has some annoying pieces to it. i.e. volume system volume. – Addison Crump – 2016-03-15T16:00:18.987

13

Mathematica + coreutils, 20 bytes

<<"!date +%m.%d%y"#&

Luckily, Mathematica interprets the output of an external command as an expression. In this case the output is a valid float, so that multiplication with the function argument # is implied.

murphy

Posted 2016-03-14T12:24:10.963

Reputation: 635

That's a combination I didn't know existed. – CalculatorFeline – 2016-04-05T07:07:32.260

12

Lua, 30 27 Bytes

print(...*os.date"%m.%d%y")

Multiply the first command-line argument by the current date in format mm.ddyy, which is actually 03.1416.

Katenkyo

Posted 2016-03-14T12:24:10.963

Reputation: 2 857

9

Bash + bc, 25 20 bytes

date +%m.%d%y\*$1|bc

Thanks to manatwork for saving five bytes.

Usage:

$ ./pi-round.sh 3
9.4248

andlrc

Posted 2016-03-14T12:24:10.963

Reputation: 1 613

That here-string notation is so long: date +%m.%d%y\*$1|bc – manatwork – 2016-03-14T14:28:32.437

@manatwork you are correct! I was playing around with the same myself but couldn't figure out how to combine it. Thanks! – andlrc – 2016-03-14T14:31:44.723

6

PowerShell v2+, 46 28 25 bytes

$args[0]*(Date -F "M.dy")

Pretty straightforward. Takes input $args[0] and multiplies it by the date formatted as M.dy (the Get- is implied). Note that this may take a long time to run on v2 as it iterates possible substitutions for Date (e.g., checking your %PATH% environment variable, etc.) before settling on Get-Date.

AdmBorkBork

Posted 2016-03-14T12:24:10.963

Reputation: 41 581

Can you cut the space after -f? – briantist – 2016-03-15T04:02:36.820

1@briantist Sadly, not here. We're abusing PowerShell's pattern recognition, since the actual flag is -Format. With flags like this, you just need to be unambiguous (for example, if you had -Debug and -Delimiter as potential options, you would need at least three letters to differentiate). Removing the space means PowerShell tries to parse the flag -F"M.dy" but can't find an argument that matches, and so throws an error. – AdmBorkBork – 2016-03-15T12:23:47.540

ahhh I see it now. That's what I get for reading this on a train after a long day. I was interpreting it as the -f operator. Makes total sense now. – briantist – 2016-03-15T13:27:21.920

6

R 3.2.4, 55 51 47 bytes

edit I realized I could use scan thanks @FryAmTheEggMan. Reduced 4 bytes thanks to @MickyT.

scan()*as.numeric(format(Sys.Date(),'%m.%d%y'))

First attempt at a golf. Happy pi day!

bouncyball

Posted 2016-03-14T12:24:10.963

Reputation: 401

1Welcome to PPCG :) I'm no R programmer, but you don't need to supply a named function, just an expression that evaluates to a function. So I'm pretty sure you can drop the f=. – FryAmTheEggman – 2016-03-14T16:11:09.213

2You can go even further and do scan()*as.numeric(format(Sys.Date(),'%m.%d%y')) – MickyT – 2016-03-14T16:17:59.993

2as.double instead of as.numeric saves an additional byte – Flounderer – 2016-03-15T04:09:43.387

5

Pyth, 19 bytes

*Qvs[.d4\..d5>2`.d3

Try it here!
Only works at 2016-03-14 of course.

Explanation

*Qvs[.d4\..d5>2`.d3   # Q = input

     .d4              # current month
        \.            # dot between month and day
          .d5         # current day of the month
             >2`.d3   # last 2 digits of the year
   s[                 # concat everything into a string
  v                   # eval -> convert to float
*Q                    # multiply with input to get the circumference

Denker

Posted 2016-03-14T12:24:10.963

Reputation: 6 639

5

GNU Awk, 23 characters

$0*=strftime("%m.%d%y")

Sample run:

bash-4.3$ awk '$0*=strftime("%m.%d%y")' <<< 3
9.4248

manatwork

Posted 2016-03-14T12:24:10.963

Reputation: 17 865

5

PHP, 45 26 25 24 bytes

Uses Windows-1252 encoding

<?=$argv[1]*date(~‘Ñ•†);

Run like this:

echo '<?=$argv[1]*date(~‘Ñ•†);' | php -- 3
  • Saved 19 bytes by using date() instead of DateTime::format
  • Saved a byte by using the echo tag
  • Saved a byte by using ISO-8859 encoding and negating the format string, so no need for double quotes. Might mess up your terminal a bit when running it from CLI, but works.

aross

Posted 2016-03-14T12:24:10.963

Reputation: 1 583

If you assume register_globals to true, you can use $n via /?n=3 in the url. – Martijn – 2016-03-15T09:23:42.043

@Martijn That requires PHP 4.1 or setting it using the php.ini file. aross said before that wants to steer away from such method. – Ismael Miguel – 2016-03-15T09:28:13.090

4

JavaScript, 41 39 characters

This uses a proprietary Firefox-only method.

d=>new Date().toLocaleFormat`%m.%d%y`*d

Thanks to:

  • Ismael Miguel for the template string suggestion (-2 characters).

Sample run (Firefox Web Console):

> (d=>new Date().toLocaleFormat`%m.%d%y`*d)(3)
9.4248

Note: this will fail in Firebug Console. Seems that Firebug performs some expansion on the template string, transforming `%m.%d%y` into `%__fb_scopedVars(m).d%y` before passing it to the code.

manatwork

Posted 2016-03-14T12:24:10.963

Reputation: 17 865

1-2 bytes: d=>new Date().toLocaleFormat`%m.%d%y`*d – Ismael Miguel – 2016-03-15T09:29:26.973

Oh. [facepalm] No idea why, I usually forget that trick. Although I use the template strings regularly. – manatwork – 2016-03-15T09:33:17.690

I know. I really don't get either. What I'm trying to get is a way to remove that new from there. – Ismael Miguel – 2016-03-15T09:35:39.770

I tried it on Firefox and it worked fine. I copy-pasted from the console. Since I've replaced ('...') with 2 backticks, that's 2 bytes. – Ismael Miguel – 2016-03-15T09:41:23.563

4

Python 2, 58 chars

import time
print float(time.strftime("%m.%d%y"))*input()

Try it!

Explanation:

import time                                   # Import time time module
print                                         # Print the following
      float(                                  # Cast to float
            time.strftime("%m.%d%y"))         # Format the time as MM.DDYY
                                     *input() # Multiply by input

Loovjo

Posted 2016-03-14T12:24:10.963

Reputation: 7 357

3

Ruby, 40 bytes

->n{n*Time.new.strftime('%m.%d%y').to_f}

Doorknob

Posted 2016-03-14T12:24:10.963

Reputation: 68 138

2

Mathematica, 54

.0001FromDigits[Now@{"Month","Day","YearShort"},100]#&

shrx

Posted 2016-03-14T12:24:10.963

Reputation: 462

2

SpecBAS, 39 bytes

1 INPUT n: ?n*VAL DATE$(TIME,"mm.ddyy")

Nothing out of the ordinary. Formats date as a string then multiplies the input by the VAL (value) of that string.

Brian

Posted 2016-03-14T12:24:10.963

Reputation: 1 209

Interpreter / compiler link? – cat – 2016-03-14T15:06:06.677

https://sites.google.com/site/pauldunn/ – Brian – 2016-03-14T16:06:30.763

I've edited the link into your answer – cat – 2016-03-14T16:07:54.257

2

Vitsy + coreutils, 19 bytes

'y%d%.m%+ etad',W*N

Explanation:

'y%d%.m%+ etad',W*N
'y%d%.m%+ etad'       Push 'date +%m.%d%y' to the stack.
               ,      Execute as shell.
                W     Grab input from STDIN and eval it.
                 *    Multiply the top two items
                  N   Output as a number.

Cannot be run in safe mode, as this uses the Runtime's exec method.

Addison Crump

Posted 2016-03-14T12:24:10.963

Reputation: 10 763

2

Python 3, 74 54 bytes

using the time module instead of datetime like Loovjo's Answer

import time
lambda n:n*float(time.strftime('%m.%d%y'))

previous solution

from datetime import*
lambda n:n*float(datetime.now().strftime('%m.%d%y'))

Erwan

Posted 2016-03-14T12:24:10.963

Reputation: 691

2

@Zenadix The meta consensus is that unnamed functions are OK.

– FryAmTheEggman – 2016-03-14T16:09:42.207

2

Pyke, 16 15 bytes, ASCII encoding

C867wä%J"bT4^/*

Explanation:

C867            - b,c,d = year, day, month
    wä          - a = base_96("ä") - 100
      %         - a = a%b
       J"       - a = "".join([a,c,d])
         b      - b = base(a, 10)
          T4^   - a = 10^4
             /  - a = a/b
              * - imp_print(a*eval_or_not(input))

or 11 bytes (non-competitive), (adds string singles, 2 digit year, string sumables)

C856\.R3sb*

Explanation:

C856        - a,b,c = 2d_year, day, month
    \.      - d = "."
      R3    - a,b,c = b,c,a
        s   - a = sum(a,b,c)
         b  - a = base(a, 10)
          * - imp_print(a*eval_or_not(input))

Blue

Posted 2016-03-14T12:24:10.963

Reputation: 26 661

I'm guessing this is a different Pyke than http://pyke.sourceforge.net/ ? Can you post a link to the language spec?

– Robert Fraser – 2016-03-15T04:08:37.637

https://github.com/muddyfish/PYKE/tree/master – Blue – 2016-03-15T07:19:34.893

Just wondering, what encoding does Pyke use? If it's UTF-8, this is 16 bytes. – OldBunny2800 – 2016-03-16T21:30:54.457

1

@OldBunny2800 It doesn't matter; in this case it uses good old ascii as all code points are below 255. According to http://meta.codegolf.stackexchange.com/a/5879/32686, the answer can define it's own encoding at no cost

– Blue – 2016-03-16T21:42:20.997

2

Oracle 11g, 50 49 bytes

SELECT &n*to_char(sysdate,'MM.DDYY')FROM dual;

one less byte, thanks to @MickyT

Argenis García

Posted 2016-03-14T12:24:10.963

Reputation: 223

you can drop the space before the FROM – MickyT – 2016-03-14T18:05:31.093

2

Google Sheets, 13 bytes

Bytes are calculated with one byte per character, zero bytes per cell except for the designated input cell, two bytes. The equals sign to start a formula is not counted. (I don't know if this is standard, please correct me if I am wrong.)

Run snippet to see the code.

table {
  empty-cells: show;
}
table,
th,
td {
  border: 1px solid black;
}
<table border="1">
  <tr>
    <th></th>
    <th>1</th>
    <th>2</th>
    <th>3</th>
  </tr>
  <tr>
    <td>A</td>
    <td>&lt;input></td>
    <td style="text-align:right">3.1416</td>
    <td style="font-family:'Ubuntu Mono',monospace">=<span style="color:rgb(257,142,29)">A1</span>*<span style="color:rgb(126,55,148)">A2</span>
    </td>
  </tr>
</table>

This works because you can define your own date formats in Google Sheets. I made it so that it is <month>.<day><year>.

OldBunny2800

Posted 2016-03-14T12:24:10.963

Reputation: 1 379

You might want to ask on meta about this scoring system. ;P – Addison Crump – 2016-03-16T21:27:48.940

Will do when I have time (maybe tonight in Maryland) – OldBunny2800 – 2016-03-16T21:29:53.983

1

JavaScript ES6, 68 66 bytes

Saved 2 bytes thanks to dev-null!

x=>x*((a=new Date).getMonth()+1+"."+a.getDate()+(a.getYear()-100))

Anonymous function. Some uses:

f(1)    == 3.1416
f(5)    == 15.708
f(f(2)) == 19.73930112

Conor O'Brien

Posted 2016-03-14T12:24:10.963

Reputation: 36 228

1You should try using with – Ismael Miguel – 2016-03-15T09:36:32.947

1

Tcl/Tk, 58 bytes

puts [expr {[gets stdin]*[clock f [clock se] -f %N.%d%g]}]

(That's a complete program. If you want to cheat and remove the explicit puts statement then it's only 51 bytes -- you'd have to start tclsh and type/paste the following in directly, though:)

expr {[gets stdin]*[clock f [clock se] -f %N.%d%g]}

Dúthomhas

Posted 2016-03-14T12:24:10.963

Reputation: 541

1

MATL, 17 bytes

Z'2$'mm.ddyy'XOU*

Try it online!

Z'              % get current date and time as float 
2$'mm.ddyy'XO   % format as a string with custom format 
U               % convert to number 
*               % multiply by implicit input 

Luis Mendo

Posted 2016-03-14T12:24:10.963

Reputation: 87 464

1

Java 114 bytes

public double p(double d){
  return (d*Double.parseDouble(new SimpleDateFormat("MM.ddyy").format(new Date())));
}

Jeff I

Posted 2016-03-14T12:24:10.963

Reputation: 79

96 bytes: float p(float d){return d*Float.parseFloat(new SimpleDateFormat("MM.ddyy").format(new Date()));} – Addison Crump – 2016-03-14T18:04:52.407

1

Racket, 112 characters

(define d(seconds->date(current-seconds)))(*(read)(+(date-month d)(*(date-day d).01)(*(-(date-year d)2e3)1e-4)))

Reads the number from input in standard reader syntax.

Winny

Posted 2016-03-14T12:24:10.963

Reputation: 1 120

1

TI-84 Basic, 30 bytes

Works on TI-83/84 calculators; E is the scientific notation token and ~ is the negative token.

Prompt D:getDate:D(Ans(2)+E~4Ans(1)-.2+.01Ans(3

Test Case

D=?3
          9.4248

Timtech

Posted 2016-03-14T12:24:10.963

Reputation: 12 038

1

R 48 bytes

d*as.double(format(Sys.Date(),format="%m.%d%y"))

Jeff I

Posted 2016-03-14T12:24:10.963

Reputation: 79

1

TI-BASIC, 16 13 9 bytes

Xround(π,1+min(getDate

We round π to a number of decimal places equal to the minimum of {month,day,year}, and then multiply it by the input.

This is a function that takes input through X. Store it to one of the Y-variables, for example Y1, and then call like Y1([number]) on the homescreen.

lirtosiast

Posted 2016-03-14T12:24:10.963

Reputation: 20 331

There seems to be some disagreement that taking input via Ans is allowed.

– AdmBorkBork – 2016-03-15T15:55:13.557

How is this only 13 bytes? Not counting Input A, I count 22 characters. – OldBunny2800 – 2016-03-16T21:15:53.187

1@OldBunny2800 TI-BASIC is token based, each atom is represented as one or two bytes. – Adám – 2016-03-16T21:22:10.070

@OldBunny2800 The code page is here.

– lirtosiast – 2016-03-16T22:10:31.393

1

APL, 19 bytes

⎕×0.01⊥⌽⍎2⌽8↑2↓⍕⎕TS

⎕TS is 2016 3 14 12 34 56 789 i.e. March 14rd, 2016 right before 12:35 pm
make into string, i.e. '2016 3 14 12 34 56 789'
8↑2↓ drop first two ('20') then take next eight ('16 3 14 ')
2⌽ rotate two characters, giving ' 3 14 16'
make into numbers (3 14 16)
reverse the list, giving 16 14 3
0.01⊥ evaluate in base ¹⁄₁₀₀, = 16 × 0.01² + 15 × 0.01¹ + 3 × 0.01⁰ = 0.0016 + 0.15 + 3 = 3.1416
⎕× multiply with input

or

⎕×1E¯4⊥⌽⍎2⌽7↑2↓⍕⎕TS

⎕TS is 2016 3 14 12 34 56 789, i.e. March 14rd, 2016 right before 12:35 pm
make into string, i.e. '2016 3 14 12 34 56 789'
7↑2↓ drop first two ('20') then take next seven ('16 3 14')
2⌽ rotate two characters, giving ' 3 1416'
make into numbers (3 1416)
reverse the list, giving 1416 3
1E¯4⊥ evaluate in base ¹⁄₁₀₀₀₀, = 1416 × 0.01¹ + 3 × 0.01⁰ = 0.1416 + 3 = 3.1416
⎕× multiply with input

Adám

Posted 2016-03-14T12:24:10.963

Reputation: 37 779

How does this work? – OldBunny2800 – 2016-03-16T20:49:36.077

1@OldBunny2800 Clear? – Adám – 2016-03-16T21:09:15.053

Yes, thank you, but in UTF-8 this is 38 bytes. – OldBunny2800 – 2016-03-16T21:14:48.573

What encoding is APL in? – OldBunny2800 – 2016-03-16T21:24:35.670

1@OldBunny2800 APL uses its own code page -- each of these characters are one byte. (This was before ASCII mind you...) – a spaghetto – 2016-03-16T21:26:48.773

0

VBScript, 88 bytes

D=Date
MsgBox(WScript.Arguments(0)*(Month(D)+CDbl("."+CStr(Day(D))+CStr(Year(D)-2000))))

I can probably save some bytes by using an input box instead. Call it like argument_name arg.

Conor O'Brien

Posted 2016-03-14T12:24:10.963

Reputation: 36 228

Doesn't VBScript implicitly convert to String? – DDPWNAGE – 2016-03-16T07:03:56.700

@DDPWNAGE I don't think it does. – Conor O'Brien – 2016-03-16T10:58:51.327

0

Mouse-2002, 45 bytes

&MONTH 10000*&DOM 100*+&YEAR 2000-+0.0001*?*!

Sample use:

> &MONTH 10000*&DOM 100*+&YEAR 2000-+0.0001*?*!
5
15.708

Explanation:

  • We're going to take the current month, day and year and turn them to a decimal.
  • First, we need to add 3 * 10000, 14 * 100 and 2016 - 2000, to get one number we can work with.
  • Next, we'll need to multiply this integer (31416) by 0.0001 to get 3.1416.
  • Then, we'll ask for a number as input ?, multiply by 3.1416 and print the result.

cat

Posted 2016-03-14T12:24:10.963

Reputation: 4 989

0

Groovy, 41 characters

{it*(new Date().format('M.dyy')as float)}

Sample run:

groovy:000> ({it*(new Date().format('M.dyy')as float)})(3)
===> 9.424799680709839

manatwork

Posted 2016-03-14T12:24:10.963

Reputation: 17 865

0

Julia, 40 bytes

d->(float)(strftime("%m.%d%y",time()))*d

Sample run:

julia> (d->(float)(strftime("%m.%d%y",time()))*d)(3)
9.4248

manatwork

Posted 2016-03-14T12:24:10.963

Reputation: 17 865

0

jq, 36 bytes

(now|strftime("%m.%d%y")|tonumber)*.

Sample run:

bash-4.3$ jq '(now|strftime("%m.%d%y")|tonumber)*.' 3
9.4248

On-line test

manatwork

Posted 2016-03-14T12:24:10.963

Reputation: 17 865

0

FORTH, 64 bytes

: p time&date 100 mod -rot 100 * + 100 * + 4 roll * 10000 / . ;

The result is rounded to the nearest integer. Usage: 10 p prints 31

AShelly

Posted 2016-03-14T12:24:10.963

Reputation: 4 281

0

Factor, 120 151 80 84 76 bytes

Holy cats, I love this language.

now "%m.%d" strftime now "%Y" strftime 2 tail append [ string>number ] bi@ *

Point-free, so expects the number on the stack:

(scratchpad) : roundpi ( n -- i ) now "%m.%d" strftime now "%Y" strftime 2 tail append [ string>number ] bi@ * ;
(scratchpad) 3 roundpi print
9.454800000000001

Translation of: Mouse.

cat

Posted 2016-03-14T12:24:10.963

Reputation: 4 989