Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

In as few bytes as possible, your job is to write a program that outputs:

3.14

In celebration of a late Pi day of course! :)

Rules

You can do it anyway you like, but there are some restrictions.

  • You may not use arithmetic operations anywhere in your program. This includes +, -, *, /, %, ^ (exponentiation), etc... This also includes incrementing (usually ++), decrementing (--), bitwise operations, and any built in functions that can be used as a replacement such as sum(), prod(), mod(), double(), pow(), sqrt(), inc(), dec(), etc... (Author's discretion)
  • The digits 3, 1, and 4 may not appear anywhere in your code.
  • You may not use any predefined variables/constants that your language may have as a replacement for 3, 1, and 4. (Author's discretion)
  • You may also not use any trigonometric functions such as sin(), cos(), tan(), arcsin(), arccos(), arctan(), sinh(), cosh(), tanh(), etc... (Author's discretion)
  • You may not use built-in or predefined values of Pi (or 3.14). No web requests.
  • Your program cannot require input of any kind (besides running it).
  • 3.14 is the only thing that you may output, it cannot be part of some longer/larger output..

Winner

The answer with the least amount of bytes on April 18th wins. Good luck!

Looking forward to clever answers from clever minds! Malbolge anyone? :P

share|improve this question
3  
You may want to clarify that ^ is the exponentiation operator, not bitwise XOR operator. –  ace Apr 10 at 16:05
2  
Are bitwise operators allowed? –  ProgramFOX Apr 10 at 16:07
1  
@ProgramFOX Well, they can be used as a replacement for normal operations, so, no. Not allowed. I'll edit the post. –  kukac67 Apr 10 at 16:09
1  
Web requests allowed? –  swish Apr 10 at 16:35
7  
@swish: I wouldn't use web requests, because that belongs to the list of Standard "loopholes" which are no longer funny –  ProgramFOX Apr 10 at 16:38

66 Answers 66

up vote 11 down vote accepted

CJam - 8 6

S`,'.E

CJam is a new language I am developing, similar to GolfScript - http://sf.net/p/cjam.
Here is the explanation:

S is a variable preinitialized to space (" ")
` generates the string representation of the last value - which is exactly " " (3 characters)
, calculates the string length (3)
'. is the dot character
E is a variable preinitialized to 14; 3, 1 and 4 are not allowed but it doesn't say anything about 14 :)

Credits to Doorknob for the backtick idea

share|improve this answer
1  
@Brilliand I would accept the use of E. –  kukac67 Apr 10 at 20:18
6  
@kukac67 While I haven't made an official release yet (coming today), I have already made the current CJam code available via hg. If you get the CJam code as of 1 day before you posted the question, it will run my program correctly (so I haven't made changes for solving this problem). But I won't really mind anyway. –  aditsu Apr 10 at 20:23
24  
time to develop HQ9+π... –  Nate Kerkhofs Apr 11 at 11:34
2  
@AnonymousPi Everybody is free to vote for the answers they choose. Maybe they're more impressed with other answers even if they're not as short. –  aditsu Apr 21 at 0:53
1  
Why do you have a variable preinitialized to 14? –  user2357112 May 20 at 2:54

PHP - 22 bytes

<?=date('n.j',8899e5);

Pi Day in year 1998 was really cool!

share|improve this answer
12  
@kukac67: n.j is the format, and 8899e5 is the Unix timestamp of March 14th in 1998. –  ProgramFOX Apr 10 at 17:43
7  
That is so clever. –  Amal Murali Apr 12 at 14:00
6  
You can save 7 characters by removing ,8899e5. It will be correct once a year. –  DKasipovic Apr 15 at 10:44
1  
@Timo You're right, but it contains the illegal digit "3" ;). –  Blackhole Apr 16 at 10:31
12  
@Blackhole 20 bytes: <?=date('w.W',78e5); April 1, 1970 was a Wednesday in week 14. –  primo Apr 17 at 8:53

C, 39

Assumes the machine is little-endian and uses IEEE floating-point standard.

main(){printf("%.2f",*(float*)"P@I@");}

The fun fact is that "P@I@" is actually not related to PI but is equivalent to 0x40494050 which is the representation of 3.144550323486328

http://ideone.com/uXVEtl

share|improve this answer
3  
That's pretty awesome. –  WChargin Apr 13 at 3:05
1  
Your code assumes type-punning on a little-endian machine. –  Nayuki Minase Apr 14 at 19:31
    
@NayukiMinase, yes you're right, it worth pointing it out. And it also assumes the use of IEEE floating-point standard. –  Mig Apr 14 at 22:03
    
And it contains undefined behavior (implicit declaration of variadic function) –  rubenvb Apr 15 at 14:35
5  
This code actually assumes that the machine is Michael's machine :-). –  xfix Apr 15 at 15:52

dc, 11 9 bytes

zE[.]znPp
  • z Push current stack depth (0) onto the stack
  • E Push E16 (==1410)
  • [.] Push the string "."
  • z Push current stack depth (3) onto the stack
  • n Pop 3 and print as number
  • P Pop "." and print as char
  • p Pop 14 and print as number with newline

Output:

$ dc <<< zE[.]znPp
3.14
$ 
share|improve this answer
    
So "use input base" is an operator? It sort of smells like an arithmetic operation, but probably still valid. –  Brilliand Apr 10 at 20:18
    
@Brilliand There's nothing I see in the question that bans base conversions. In fact the OP appears to be encouraging base conversions in a comment here codegolf.stackexchange.com/a/25681/11259 –  DigitalTrauma Apr 10 at 20:27
    
I do agree that it's valid; I'm just thinking that when the base conversion is an operator rather than part of the number syntax, it blurs the line between inline data and an arithmetic operation. –  Brilliand Apr 10 at 20:54
    
I think this should be 15 bytes? –  Registered User Apr 11 at 13:21
7  
@AdityaPatil Why? dc is a language and interpreter, just like all the other languages here. dc -e is just the invocation of that interpreter. I could have just as easily saved the 9-byte program in a file and run dc pi.dc. If these bytes need to be counted, then the same would have to apply to all other languages. e.g. include python in all python entries or ruby golfscript.rb in all golfscript entries. I believe the agreed convention here is not to include these, unless special options need to be passed. –  DigitalTrauma Apr 11 at 14:33

JavaScript (ES5) 20 bytes

A variation of m.buettner's JS solution.

(x='.'+0xE).length+x

Edit: JavaScript (ES5) 18 bytes

A variation of ComFreek's idea of using the base64 decode function.

atob('Mw')+'.'+0xE

Edit: Javascript (ES5) 16 bytes

If the unary + operator is allowed to cast a string to a number, it can be reduced to:

+atob('MDMuMTQ')
share|improve this answer
    
WOW! That is really clever! –  kukac67 Apr 10 at 16:38
9  
@NateEldredge This is string concatenation, not arithmetic. –  tomsmeding Apr 10 at 17:48
    
is the use of + accepted here? –  Lưu Vĩnh Phúc Apr 12 at 6:46
1  
I find the Javascript solution to be the most elegant and I was about to post mine until I noticed it had a '4' in it: atob('My4xNA=='), lol. –  Matt Borja Apr 15 at 22:16
1  
@Dennis you're right, it's still there. It's even there if I copy+paste the result from console. I'm not happy with it so I'll revert to the 16 byte solution. –  nderscore Apr 16 at 20:25

Haskell, 41 bytes

When is pi day in Australia?

p=(\(a:n:y:t:i:m:e:_)->[m,a,t,e])['.'..]

Edited to add: like the other Haskell answer, that outputs a string, so has quotes. You can score 33, and be strictly within the rules, but it's less fun:

p=putStr$map([','..]!!)[7,2,5,8]
share|improve this answer
    
Haha, wow. This is good! –  minitech Apr 11 at 14:17
    
Can you explain why this works? –  yhager Apr 16 at 0:33
3  
I like this one a lot, +1. But I think technically ".." is invoking the increment operator, which was forbidden. (Actually upvoting also invokes an increment operation, so it should be forbidden as well;-) –  Marc van Leeuwen Apr 16 at 12:35
    
I actually did think about that - I had an even shorter answer: p=[2.9,2.92..]!!([0,6..]!!2)...and in this one .. does look wrong. But Haskell is strongly typed, and the increment in the answer I gave is of Char not Num and isn't arithmetic-the thing that's actually banned. I'd need a fromEnum to convert the chars back to numbers to use them that way. Anyway, my conscience is clear :) –  bazzargh Apr 16 at 14:10
4  
@yhager: ['.'..] is the char sequence "./0123456..." (etc). (a:n:y:t:i:m:e:_) is a pattern match pulling out the first 7 characters, [m,a,t,e] reorders 4 of them into "3.14". Knowing that this is what you want to do, it's a matter of searching the dictionary to find words with the right structure. Which I did...eg another pair was "ugliest suit". Then you come up with a joke :) –  bazzargh Apr 16 at 14:18

Morse Code, 33 Bytes

morse -d ...-- .-.-.- .---- ....-

Technically speaking, the information only takes 21 bytes.

share|improve this answer
9  
We definitely need more golf solutions in morse code here... –  leftaroundabout Apr 11 at 14:19
21  
Technically speaking, I'd say 21 bits, not bytes –  Mig Apr 11 at 19:17
11  
@Michael since Morse code can be either a dot, dash, or space, wouldn't it require more than 1 bit to store 1 operation? –  smcg Apr 11 at 19:42
4  
@smcg ButSpacesAreForWeakPeopleWhoCan'tReadThingsLikeThis –  Cole Johnson Apr 13 at 0:26
6  
As much as I like morse code (and hence this solution) - but isn't that against rule 3: "You may not use any predefined variables/constants that your language may have as a replacement for 3, 1, and 4." or even rule 2: "The digits 3, 1, and 4 may not appear anywhere in your code."? –  kratenko Apr 14 at 16:17

J - 15 11 char

Made it shorter, using the fantastic i:.

5{i:28.26j9

Explained:

  • 28.26j9 - The complex number 28.26 + 9i.
  • i: - This is where the magic happens. i: on a complex number A+Bi, B≠0 takes B+1 equally spaced points from the interval [-A,A].
  • 5{ - Take element at index 5, which just so happens to be 3.14.

Previously, we had the following nonsense:

|.'.'2}":22b8d5

Explained by explosion:

         22b8d5  NB. 8d5 in base 22 = 4163
       ":        NB. convert to string
  '.'2}          NB. change character at index 2 to '.'
|.               NB. reverse to make '3.14'
share|improve this answer
    
Instead of |.'.'2}":22b8d5, you can save 2 characters by picking a number that doesn't require reversal: '.'1}":16bbc6 –  epicwisdom Apr 15 at 2:16
3  
@epicwisdom The digits 3, 1, and 4 are banned. I have to use a number in the form 41X3 because I am only allowed to modify the characters at indices 0 and 2. –  algorithmshark Apr 15 at 2:39

Linux command line, 35 bytes

This one is nowhere near winning, but here it is for the fun of it:

ping -w2 67502862|grep -oP '.\..\d'

Output (after 2 seconds):

$ ping -w2 67502862|grep -oP '.\..\d'
3.14
$
share|improve this answer
    
Quote from the question: "No web requests." –  Doorknob Apr 11 at 3:02
7  
@Doorknob ICMP echo request != web request. Regardless, the ping is to 4.6.3.14, from which I get no reply, so its not like I'm getting any useful information back from the internet –  DigitalTrauma Apr 11 at 3:39
10  
@Doorknob But if this still bothers you, we can do this :;ping -t${#?} -qc2 67502862|grep -oP '.\..\d'. This sets the TTL to 1, so the outgoing ICMP echo is dropped by your router before it ever gets anywhere near the internet –  DigitalTrauma Apr 11 at 4:22
1  
You can save 9 s by using ping -w2 67502862. (Ninja edit because before i was advising w1, almost broke the rules.) –  lolesque Apr 17 at 13:10
    
@lolesque Thanks. Doesn't improve the golf score though ;-) –  DigitalTrauma Apr 17 at 14:22

GolfScript, 18 13 12

'.'.`,\.,n`,

Old version:

'...','.'.,'....',

It's very artistic, only 3 unique characters! ;)

How it works:

# cmd   # stack
'...',  # 3
'.'.    # 3 '.' '.'
,       # 3 '.' 1
'....', # 3 '.' 1 4

Here's an explanation of the 12-char version (much more interesting, IMO):

'.' # '.'
.`, # '.' 3
\.  # 3 '.' '.'
,   # 3 '.' 1
n`, # 3 '.' 1 4

It works because n`, is 4, since n` is '"\n"'. Same logic for '.'`,. It also swaps instead of creating a new string to save a char (thanks @algorithmshark).

Alternate version:

'pi ','.'.,'day!',

or

'Hi ','.'.,'PPCG',

Or anything in those strings, really. :P

share|improve this answer
    
Only 3 different characters, cool :) –  aditsu Apr 10 at 19:17
    
Would '.'.`,\.,n`, work to save a char? Reusing the '.' by duplicating and swapping. –  algorithmshark Apr 10 at 19:33
    
@algorithmshark Yep, thanks! –  Doorknob Apr 10 at 23:52
    
This is very clever! +1 –  VisioN Apr 14 at 13:20
    
this does look like the morse code version –  pwned Apr 18 at 7:13

OP's answer.

Mathematica, 21 20 18

This feels cheap...

Range[2,5,.06][[20]]

or

Range[2,5,.02][[58]]

Figured out how to make it 18:

Range[-.86,5][[5]]

Haskell, 49 48 12

(48 includes the new line character)

p=[-6..]
r=concat$show(p!!9):".":(show$p!!20):[]

Run it by calling the r function.

Using the method as with Mathematica above, you can type this into GHCi:

[-2.86..]!!6

Java, 87 86

class P{public static void main(String[]a){System.out.print("tri".length()+"."+0xe);}}

Scala, 27

Translated from Java as suggested by Score_Under. (I don't really know Scala)

print("tri".length+"."+0xe)
share|improve this answer
    
Oh, 0xe is clever. Do you mind if I improve my JS answer with that? ;) –  Martin Büttner Apr 10 at 16:21
    
Most java can be directly converted to scala, which is usually shorter if you really want to save on the bytes - if you're using it as a script, the entire thing is just: print("tri".length+"."+0xe) –  Score_Under Apr 10 at 20:25
    
Yeah I thought of the same thing, which is shorter in Julia as [-.86:5][5] for 11, but figured it didn't count since ranges are just math. –  gggg Apr 16 at 23:53

JavaScript, 20 bytes

'...'.length+'.'+0xe

Use it in a console, so that the result is directly printed. Otherwise, alert(...) will add another 7 characters.

Same as my other answer, I just noticed it's a lot shorter in JS.

The idea of using 0xe for 14 is taken from the OP's submission with the OP's kind permission.

share|improve this answer
1  
Its fine, you can use it :) –  kukac67 Apr 10 at 16:30
1  
Alternative 20 byte solution: (x='.'+0xE).length+x –  nderscore Apr 10 at 16:35
    
@nderscore that's a pretty neat idea. If you post that as another answer, you'll get my upovote ;) –  Martin Büttner Apr 10 at 16:36

GNU date, 17 bytes

date -d2/5 +%u.%y

This one only guaranteed to work this year, but I don't see any limitation in the rules about this ;-)

The + is simply indicates the start of the format specifier for date and is not an arithmetic addition. Same with the -, indicating input date.

Output:

$ date -d2/5 +%u.%y
3.14
$
share|improve this answer
    
only guaranteed to work this year It's fine.. :) –  kukac67 Apr 10 at 19:33

Bash, 17 bytes

tr 0 .<<<$[62#MC]

Dash, 41 bytes

perl -pechomp,s/./$./<<$


..










.
share|improve this answer
    
+1, never seen anyone use Dash as a substitute for Bash –  TheDoctor Apr 10 at 23:23
    
Bash would complain loudly about the missing ending marker while Dash doesn't, so a Bash solution without error messages would require two extra bytes. –  Dennis Apr 11 at 0:21
    
+1 as well. I guess @TheDoctor forgot to click the upvote button? –  DigitalTrauma Apr 11 at 4:28
    
@DigitalTrauma oops... fixed –  TheDoctor Apr 11 at 14:11

Bash, 50

Help/error messages aren't external resources, they're a command's output!

If anything is rule abuse, this is it. It uses the coincidence that the help message given to STDERR by the exact command

ping6

is 314 characters long (at least on Ubuntu 13.10 with iputils-121221). EDIT: I appreciate that this is much less portable than I expected...

m=`ping6|&wc -c`
false
o=$?
echo ${m:0:o}.${m:o:2}

The first line takes the character length of the help message and stores it in a variable.

As in my other answers, the next few lines obtain the number 1 by taking the exit status of false (not very portable but this is after all!), then use that value to insert a decimal point in the last line

Output: 3.14

share|improve this answer
    
you sir are genius –  Joshua Apr 11 at 12:52
1  
Uh oh, "2.81" on Ubuntu 12.04 (iputils-101006). +1 all the same ;-) –  DigitalTrauma Apr 12 at 1:29
    
@DigitalTrauma according to info ping6 I have iputils-121221 –  professorfish Apr 13 at 6:26
    
also check out my chmod-abusing answer to this question at codegolf.stackexchange.com/a/25724/16402 –  professorfish Apr 14 at 16:48
1  
even shorter: ping6|&wc -c|sed 's/./&./' –  malkaroee Oct 19 at 10:01

Bash+TeX 28 bytes

If you have TeX installed:

tex -v|head -c8|cut -d\  -f2

The version number of TeX asymptotically approaches pi as the software improves. So, as time goes on, you can use this (nonconforming) implementation to print more and more digits!

tex -v|cut -d\  -f2 | head -n1

This printed 3.1415926 back in 2011; as of January 2014, it will print 3.14159265.

share|improve this answer
    
I love this one! –  gniourf_gniourf Apr 19 at 15:09
    
You can use tex -v|grep -oP '.\..\d' to save 4 bytes. (Regex stolen from DigitalTrauma's answer.) Anyway, +1 because I just thought of the same answer. –  ace Apr 19 at 22:26

Bash 23 22

seq 2 .02 5|sed -n 58p

Shell (without history expansion) 20

seq 2 .02 5|sed 58!d
share|improve this answer
    
seq 2 .06 5|sed -n 20p also works as given in OP's Mathematica answer. –  user80551 Apr 11 at 14:55
    
sed 58!d is slightly shorter. –  Dennis Apr 11 at 18:30
    
@Dennis Weird, gnome-terminal substitutes !d with dpkg ... which was the last command that I ran that began with d. Works fine in ksh but zsh says zsh: event not found: d so that's definitely getting substituted for something. –  user80551 Apr 11 at 18:44
    
That's because of Bash's history expansion. It's disabled by default for scripts, so if you save the same command in pi.sh and execute bash pi.sh, it will work fine. –  Dennis Apr 11 at 18:46

Python, 39 or 28 47 or 34

(Thank you Score_Under for golfing it down so much)

print"%s.%s%c"%(len('aaa'),len('a'),52)

+ here is the string concatenation operator, not addition.

Copying the 0xe trick from the OP, here's 28 chars with help from @psal

print('%X.%s'%(675,0xE))[2:]

Old versions:

print str(len('aaa'))+'.'+str(len('a'))+chr(52)

print str(len('aaa'))+'.'+str(0xe)

print"%s.%s"%(len('aaa'),0xe)
share|improve this answer
    
The second one can be shortened by removing the space after the print and using a "%s" format instead of str(). c.f. print"%s.%s"%(len('aaa'),0xe) at 29 bytes. You can do the same to the first one too: print"%s.%s%c"%(len('aaa'),len('a'),52) at 39 bytes. –  Score_Under Apr 10 at 20:31
    
@Score_Under Oh, I thought using %s still requires str. Thanks for the tip :) –  ace Apr 10 at 20:50
1  
another 29 bytes solution : print('%s,%s'%(0xE9,0xE))[2:] –  psal Apr 17 at 7:05
1  
... and in 28 bytes : print('%X.%s'%(675,0xE))[2:] –  psal Apr 17 at 7:28

GolfScript, 8 bytes

'??.'(\(

This program contains non-printable ASCII characters, so it cannot be directly pasted here. Instead, the question marks in the code above should be replaced with the bytes 03 and 0E in hexadecimal.

For convenience, here's a hex dump of the actual program. Unix / Linux users can run this hex dump through xxd -r to reconstruct the program:

0000000: 2703 0e2e 2728 5c28                      '...'(\(

Explanation:

  • The first five bytes of the program form a single-quoted string literal encoding the three characters with the ASCII codes 3, 14 and 46 (= ASCII period).

  • ( chops the first character off the string and pushes its ASCII code (3) on the stack. \ swaps the top two items on the stack, pulling the string back to the top, and the second ( chops another character off the string, again pushing its ASCII code (14) on the stack.

At the end of the program, the stack (excluding the empty input string) therefore looks like this:

3 "." 14

At the end of the program, the default behavior of the GolfScript interpreter is to stringify and print everything on the stack, yielding the desired output.

share|improve this answer
1  
Snap! I had exactly the same idea, just 12 hours too late. I guess I should read page 2 before posting... Oh well, rolling back, +1 to you. –  Dennis Apr 12 at 4:14

bash -- 39

We all know that the first few digits of Pi can be computed from the following statement:

May I have a large container of coffee

We need only 2 decimal places, right?

m=May
i=I
h=have
echo ${#m}.${#i}${#h}
share|improve this answer

Mathematica - 78

DateList["March"<>ToString@FromDigits@"E"]~DateString~{"MonthShort",".","Day"}
share|improve this answer
    
In the spirit of Pi Day! :D –  kukac67 Apr 10 at 17:01

Perl, 15 20 bytes

print 05706=~s/0/./r
print 0xbc6=~s/0/./r
share|improve this answer
    
Isn't PI__ something of a constant related to Pi? –  Asmageddon Apr 10 at 16:51
    
It's not a constant. It's two strings being XOR-ed. –  nderscore Apr 10 at 16:55
    
Bitwise operators aren't allowed. –  kukac67 Apr 10 at 16:56
    
Oh, they're not. Well, there goes my hypothetical solution. That said, if bitwise operators aren't allowed, is there even much else to do than count lengths of strings? –  Asmageddon Apr 10 at 16:57
    
There are several answers that use numbers in different bases. –  kukac67 Apr 10 at 16:58

tr + Bash, 17 bytes

tr a-j 0-9<<<d.be

The - chars here are not arithmetic subtraction operators. They indicate range.

Output:

$ tr a-j 0-9<<<d.be
3.14
$
share|improve this answer
    
Clever, although a character translation is really hidden arithmetics. –  Pierre Arlaud Apr 11 at 12:41
    
@ArlaudPierre True, though I would contend that pretty much all solutions here have hidden arithmetic one way or another. If you look at the actual machine instructions executed for any of these answers, I would think all have some bitwise or arithmetic instructions, which are banned from explicit use by the question. –  DigitalTrauma Apr 11 at 17:09
    
@ArlaudPierre The question requires the string "3.14" to be output. Regardless of the language, somewhere under the hood, this will degenerate to a write() call or similar. There will necessarily be some arithmetic under the covers to ensure the correct number of bytes is written, if nowhere else. I think the point of the question is to hide the necessary arithmetic/bitwise computations. –  DigitalTrauma Apr 11 at 17:14

C, 36

main(){printf("%d\b.%o\b",' ','`');}
share|improve this answer
1  
If we combine it with my answer, we can save 2 bytes to get a score of 34 : main(){printf("%d\b.%d",' ',0xe);} –  vsz Apr 11 at 19:28

JavaScript - 23 bytes

atob('Mw')+atob('LjE0')

Thanks to nderscore (see his comments)!

share|improve this answer
    
Nice :D I didn't even know about this –  kukac67 Apr 10 at 16:46
    
It contains 4 though ;) –  nderscore Apr 10 at 16:48
    
@nderscore Ah! You're right! Would btoa() work to get 3.14 somehow? –  kukac67 Apr 10 at 16:52
    
@kukac67 The base64 character set doesn't contain a period :( –  nderscore Apr 10 at 16:54
3  
23 byte "legal" version: atob('Mw')+atob('LjE0') and 14 byte "illegal" version: atob("My4xNA") –  nderscore Apr 10 at 17:41

BASH, 57

This is longer than most answers, but there is nothing bad in trying.

f=`echo aaaaaaaaaaaaa|wc -c`;e=`echo aa|wc -c`;echo $e.$f

gives

3.14
share|improve this answer
3  
Sorry for re-golfing everyone's answers :P, In the same vein as this I found: c=wc\ -c;echo `$c<<<..`.`$c<<<''``$c<<<...` –  Score_Under Apr 12 at 0:07

C#

 ((int)'ĺ').ToString("#\\.##");

ĺ is character 314, not a pre-defined variable or constant. the .ToString formats the output into a digit, a period, and then 2 more digits.

share|improve this answer
    
Nice, but it currently doesn't output, and it's not compilable. –  Rudi Kershaw Apr 16 at 9:27
    
Console.Write(((int)'ĺ').ToString("#\\.##")); –  Grax Apr 16 at 11:24

GolfScript, 13 10

{xy}.*'.'\

Thanks to Ilmari Karonen for the improved version!

x and y are non-printable characters (see http://www.asciitable.com/ for more info), respectively ETX and SO, which decode to 3 and 14.

What this code does should be pretty clear.

Note: The following rule

You may not use any predefined variables/constants that your language may have as a replacement for 3, 1, and 4. (Author's discretion)

is not broken, since ASCII characters are neither variables, nor constants.

share|improve this answer
    
The digits 3, 1, and 4 may not appear anywhere in your code. , Your program cannot require input of any kind (besides running it). –  user80551 Apr 11 at 10:41
    
The digits do not appear anywhere. There's no input. –  Vereos Apr 11 at 10:41
    
And your final code is...? –  user80551 Apr 11 at 10:42
    
{}.*.{}.*, and inside the brackets there are 2 non-printable characters, respectively (asciitable.com) ETX and SO –  Vereos Apr 11 at 10:43
2  
You could shorten this to {xy}.*'.'\ (10 chars). Mine's still shorter, though. ;-) But +1 for teaching me about { }.* (and { }.%), I'll have to keep that trick in mind. –  Ilmari Karonen Apr 11 at 17:51

New to the site and can't write comments yet, so I'll post it here. Just wondering about this Javascript solution:

'...'.length+'.'+0xe

and this rule:

3.14 is the only thing that you may output, it cannot be part of some longer/larger output..

If I run this code in my browser console, I get:

"3.14"

or using Node at the command line:

'3.14'

but if I run this code:

parseFloat('...'.length+'.'+0xe)

I get:

3.14

Using Node.js to run a .js file, I can write:

console.log('...'.length+'.'+0xe)

and get:

3.14
share|improve this answer
1  
There was never a limitation on what type the resulting value can be. So, string or number doesn't matter. The quotes around the string are not considered part of the output. –  nderscore Apr 14 at 19:53
    
Thank you for the clarification. –  Robert Munn Apr 14 at 20:13
    
Welcome to CodeGolf and Programming Puzzles @RobertMunn! This answer is valid as it obeys all the rules... Bear in mind that console tends to wrap strings in quotes when displaying them... You have used + but not arithmetically, it's being used as a concatenator, so that's valid... Also you could have made this smaller using alert rather than console.log... But otherwise, great effort. We hope you like it here... –  WallyWest Apr 15 at 2:58
    
That's pretty nice! You should consider adding the name of the language and byte count (e.g. Javascript, 20) –  Vereos Apr 15 at 7:32
1  
Thanks Ace, I'm just learning the rules here. I couldn't leave a comment so I posted separately, I guess this was more of a clarification on the rules kind of post, which nderscore and WallyWest clarified for me. I appreciate everyone's patience with a newb. –  Robert Munn Apr 15 at 18:43

Mathematica, 56 bytes

(l=ToString@StringLength@#&)@"..."<>"."<>l@"."<>l@"...."

Not much to say. I'm generating the digits as string lengths and concatenate them.

share|improve this answer

protected by Community Apr 17 at 1:14

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.