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


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


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


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

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

63 Answers 63


CJam - 8 6


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

  • 1
    \$\begingroup\$ @Brilliand I would accept the use of E. \$\endgroup\$ – kukac67 Apr 10 '14 at 20:18
  • 6
    \$\begingroup\$ @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. \$\endgroup\$ – aditsu quit because SE is EVIL Apr 10 '14 at 20:23
  • 33
    \$\begingroup\$ time to develop HQ9+π... \$\endgroup\$ – Nzall Apr 11 '14 at 11:34
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ – aditsu quit because SE is EVIL Apr 21 '14 at 0:53
  • 2
    \$\begingroup\$ Why do you have a variable preinitialized to 14? \$\endgroup\$ – user2357112 supports Monica May 20 '14 at 2:54

PHP - 22 bytes


Pi Day in year 1998 was really cool!

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

C, 39

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


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


  • 3
    \$\begingroup\$ That's pretty awesome. \$\endgroup\$ – wchargin Apr 13 '14 at 3:05
  • 1
    \$\begingroup\$ Your code assumes type-punning on a little-endian machine. \$\endgroup\$ – Nayuki Apr 14 '14 at 19:31
  • \$\begingroup\$ @NayukiMinase, yes you're right, it worth pointing it out. And it also assumes the use of IEEE floating-point standard. \$\endgroup\$ – Michael M. Apr 14 '14 at 22:03
  • \$\begingroup\$ And it contains undefined behavior (implicit declaration of variadic function) \$\endgroup\$ – rubenvb Apr 15 '14 at 14:35
  • 5
    \$\begingroup\$ This code actually assumes that the machine is Michael's machine :-). \$\endgroup\$ – Konrad Borowski Apr 15 '14 at 15:52

dc, 11 9 bytes

  • 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


$ dc <<< zE[.]znPp
  • \$\begingroup\$ So "use input base" is an operator? It sort of smells like an arithmetic operation, but probably still valid. \$\endgroup\$ – Brilliand Apr 10 '14 at 20:18
  • \$\begingroup\$ @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 \$\endgroup\$ – Digital Trauma Apr 10 '14 at 20:27
  • \$\begingroup\$ 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. \$\endgroup\$ – Brilliand Apr 10 '14 at 20:54
  • \$\begingroup\$ I think this should be 15 bytes? \$\endgroup\$ – Registered User Apr 11 '14 at 13:21
  • 9
    \$\begingroup\$ @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. \$\endgroup\$ – Digital Trauma Apr 11 '14 at 14:33

JavaScript (ES5) 20 bytes

A variation of m.buettner's JS solution.


Edit: JavaScript (ES5) 18 bytes

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


Edit: Javascript (ES5) 16 bytes

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

  • \$\begingroup\$ WOW! That is really clever! \$\endgroup\$ – kukac67 Apr 10 '14 at 16:38
  • 9
    \$\begingroup\$ @NateEldredge This is string concatenation, not arithmetic. \$\endgroup\$ – tomsmeding Apr 10 '14 at 17:48
  • \$\begingroup\$ is the use of + accepted here? \$\endgroup\$ – phuclv Apr 12 '14 at 6:46
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Matt Borja Apr 15 '14 at 22:16
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – nderscore Apr 16 '14 at 20:25

Haskell, 41 bytes

When is pi day in Australia?


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:

  • \$\begingroup\$ Haha, wow. This is good! \$\endgroup\$ – Ry- Apr 11 '14 at 14:17
  • \$\begingroup\$ Can you explain why this works? \$\endgroup\$ – yhager Apr 16 '14 at 0:33
  • 5
    \$\begingroup\$ 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;-) \$\endgroup\$ – Marc van Leeuwen Apr 16 '14 at 12:35
  • \$\begingroup\$ 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 :) \$\endgroup\$ – bazzargh Apr 16 '14 at 14:10
  • 6
    \$\begingroup\$ @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 :) \$\endgroup\$ – bazzargh Apr 16 '14 at 14:18

Morse Code, 33 Bytes

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

Technically speaking, the information only takes 21 bytes.

  • 11
    \$\begingroup\$ We definitely need more golf solutions in morse code here... \$\endgroup\$ – ceased to turn counterclockwis Apr 11 '14 at 14:19
  • 26
    \$\begingroup\$ Technically speaking, I'd say 21 bits, not bytes \$\endgroup\$ – Michael M. Apr 11 '14 at 19:17
  • 14
    \$\begingroup\$ @Michael since Morse code can be either a dot, dash, or space, wouldn't it require more than 1 bit to store 1 operation? \$\endgroup\$ – smcg Apr 11 '14 at 19:42
  • 5
    \$\begingroup\$ @smcg ButSpacesAreForWeakPeopleWhoCan'tReadThingsLikeThis \$\endgroup\$ – Cole Johnson Apr 13 '14 at 0:26
  • 8
    \$\begingroup\$ 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."? \$\endgroup\$ – kratenko Apr 14 '14 at 16:17

J - 15 11 10 char

Made it shorter, using the fantastic i:.



  • 6.28j8 - The complex number 6.28 + 8i.
  • 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].
  • 6{ - Take element at index 6, which just so happens to be 3.14.

Previously, we had the following nonsense:


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'
  • \$\begingroup\$ Instead of |.'.'2}":22b8d5, you can save 2 characters by picking a number that doesn't require reversal: '.'1}":16bbc6 \$\endgroup\$ – rationalis Apr 15 '14 at 2:16
  • 3
    \$\begingroup\$ @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. \$\endgroup\$ – algorithmshark Apr 15 '14 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'
  • \$\begingroup\$ Quote from the question: "No web requests." \$\endgroup\$ – Doorknob Apr 11 '14 at 3:02
  • 9
    \$\begingroup\$ @Doorknob ICMP echo request != web request. Regardless, the ping is to, from which I get no reply, so its not like I'm getting any useful information back from the internet \$\endgroup\$ – Digital Trauma Apr 11 '14 at 3:39
  • 10
    \$\begingroup\$ @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 \$\endgroup\$ – Digital Trauma Apr 11 '14 at 4:22
  • 1
    \$\begingroup\$ You can save 9 s by using ping -w2 67502862. (Ninja edit because before i was advising w1, almost broke the rules.) \$\endgroup\$ – lolesque Apr 17 '14 at 13:10
  • \$\begingroup\$ @lolesque Thanks. Doesn't improve the golf score though ;-) \$\endgroup\$ – Digital Trauma Apr 17 '14 at 14:22

GolfScript, 18 13 12


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!',


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

Or anything in those strings, really. :P

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

OP's answer.

Mathematica, 21 20 18

This feels cheap...




Figured out how to make it 18:


Haskell, 49 48 12

(48 includes the new line character)


Run it by calling the r function.

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


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)

  • \$\begingroup\$ Oh, 0xe is clever. Do you mind if I improve my JS answer with that? ;) \$\endgroup\$ – Martin Ender Apr 10 '14 at 16:21
  • \$\begingroup\$ 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) \$\endgroup\$ – Score_Under Apr 10 '14 at 20:25
  • \$\begingroup\$ 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. \$\endgroup\$ – gggg Apr 16 '14 at 23:53

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


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

  • \$\begingroup\$ you sir are genius \$\endgroup\$ – Joshua Apr 11 '14 at 12:52
  • 1
    \$\begingroup\$ Uh oh, "2.81" on Ubuntu 12.04 (iputils-101006). +1 all the same ;-) \$\endgroup\$ – Digital Trauma Apr 12 '14 at 1:29
  • \$\begingroup\$ @DigitalTrauma according to info ping6 I have iputils-121221 \$\endgroup\$ – user16402 Apr 13 '14 at 6:26
  • \$\begingroup\$ also check out my chmod-abusing answer to this question at codegolf.stackexchange.com/a/25724/16402 \$\endgroup\$ – user16402 Apr 14 '14 at 16:48
  • 2
    \$\begingroup\$ even shorter: ping6|&wc -c|sed 's/./&./' \$\endgroup\$ – malkaroee Oct 19 '14 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.

  • \$\begingroup\$ I love this one! \$\endgroup\$ – gniourf_gniourf Apr 19 '14 at 15:09
  • \$\begingroup\$ 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. \$\endgroup\$ – user12205 Apr 19 '14 at 22:26

JavaScript, 20 bytes


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.

  • 1
    \$\begingroup\$ Its fine, you can use it :) \$\endgroup\$ – kukac67 Apr 10 '14 at 16:30
  • 1
    \$\begingroup\$ Alternative 20 byte solution: (x='.'+0xE).length+x \$\endgroup\$ – nderscore Apr 10 '14 at 16:35
  • \$\begingroup\$ @nderscore that's a pretty neat idea. If you post that as another answer, you'll get my upovote ;) \$\endgroup\$ – Martin Ender Apr 10 '14 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.


$ date -d2/5 +%u.%y
  • \$\begingroup\$ only guaranteed to work this year It's fine.. :) \$\endgroup\$ – kukac67 Apr 10 '14 at 19:33

Bash, 17 bytes

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

Dash, 41 bytes

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


  • \$\begingroup\$ 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. \$\endgroup\$ – Dennis Apr 11 '14 at 0:21
  • \$\begingroup\$ +1 as well. I guess @TheDoctor forgot to click the upvote button? \$\endgroup\$ – Digital Trauma Apr 11 '14 at 4:28
  • \$\begingroup\$ @DigitalTrauma oops... fixed \$\endgroup\$ – TheDoctor Apr 11 '14 at 14:11

Bash 23 22

seq 2 .02 5|sed -n 58p

Shell (without history expansion) 20

seq 2 .02 5|sed 58!d
  • \$\begingroup\$ seq 2 .06 5|sed -n 20p also works as given in OP's Mathematica answer. \$\endgroup\$ – user80551 Apr 11 '14 at 14:55
  • \$\begingroup\$ sed 58!d is slightly shorter. \$\endgroup\$ – Dennis Apr 11 '14 at 18:30
  • \$\begingroup\$ @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. \$\endgroup\$ – user80551 Apr 11 '14 at 18:44
  • \$\begingroup\$ 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. \$\endgroup\$ – Dennis Apr 11 '14 at 18:46

Python, 39 or 28 47 or 34

(Thank you Score_Under for golfing it down so much)


+ here is the string concatenation operator, not addition.

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


Old versions:

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

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

  • \$\begingroup\$ 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. \$\endgroup\$ – Score_Under Apr 10 '14 at 20:31
  • \$\begingroup\$ @Score_Under Oh, I thought using %s still requires str. Thanks for the tip :) \$\endgroup\$ – user12205 Apr 10 '14 at 20:50
  • 1
    \$\begingroup\$ another 29 bytes solution : print('%s,%s'%(0xE9,0xE))[2:] \$\endgroup\$ – onionpsy Apr 17 '14 at 7:05
  • 1
    \$\begingroup\$ ... and in 28 bytes : print('%X.%s'%(675,0xE))[2:] \$\endgroup\$ – onionpsy Apr 17 '14 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                      '...'(\(


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

  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Dennis Apr 12 '14 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?

echo ${#m}.${#i}${#h}

Mathematica - 78

  • \$\begingroup\$ In the spirit of Pi Day! :D \$\endgroup\$ – kukac67 Apr 10 '14 at 17:01

Perl, 15 20 bytes

print 05706=~s/0/./r
print 0xbc6=~s/0/./r
  • \$\begingroup\$ Isn't PI__ something of a constant related to Pi? \$\endgroup\$ – Llamageddon Apr 10 '14 at 16:51
  • \$\begingroup\$ It's not a constant. It's two strings being XOR-ed. \$\endgroup\$ – nderscore Apr 10 '14 at 16:55
  • \$\begingroup\$ Bitwise operators aren't allowed. \$\endgroup\$ – kukac67 Apr 10 '14 at 16:56
  • \$\begingroup\$ 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? \$\endgroup\$ – Llamageddon Apr 10 '14 at 16:57
  • \$\begingroup\$ There are several answers that use numbers in different bases. \$\endgroup\$ – kukac67 Apr 10 '14 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.


$ tr a-j 0-9<<<d.be
  • \$\begingroup\$ Clever, although a character translation is really hidden arithmetics. \$\endgroup\$ – Pierre Arlaud Apr 11 '14 at 12:41
  • \$\begingroup\$ @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. \$\endgroup\$ – Digital Trauma Apr 11 '14 at 17:09
  • \$\begingroup\$ @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. \$\endgroup\$ – Digital Trauma Apr 11 '14 at 17:14

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


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

C, 36

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

JavaScript - 23 bytes


Thanks to nderscore (see his comments)!

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



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

  • \$\begingroup\$ Nice, but it currently doesn't output, and it's not compilable. \$\endgroup\$ – Rudi Kershaw Apr 16 '14 at 9:27
  • \$\begingroup\$ Console.Write(((int)'ĺ').ToString("#\\.##")); \$\endgroup\$ – Grax32 Apr 16 '14 at 11:24

GolfScript, 13 10


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.

  • \$\begingroup\$ The digits 3, 1, and 4 may not appear anywhere in your code. , Your program cannot require input of any kind (besides running it). \$\endgroup\$ – user80551 Apr 11 '14 at 10:41
  • \$\begingroup\$ The digits do not appear anywhere. There's no input. \$\endgroup\$ – Vereos Apr 11 '14 at 10:41
  • \$\begingroup\$ And your final code is...? \$\endgroup\$ – user80551 Apr 11 '14 at 10:42
  • \$\begingroup\$ {}.*.{}.*, and inside the brackets there are 2 non-printable characters, respectively (asciitable.com) ETX and SO \$\endgroup\$ – Vereos Apr 11 '14 at 10:43
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Ilmari Karonen Apr 11 '14 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:


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:


or using Node at the command line:


but if I run this code:


I get:


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


and get:

  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – nderscore Apr 14 '14 at 19:53
  • \$\begingroup\$ 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... \$\endgroup\$ – WallyWest Apr 15 '14 at 2:58
  • \$\begingroup\$ That's pretty nice! You should consider adding the name of the language and byte count (e.g. Javascript, 20) \$\endgroup\$ – Vereos Apr 15 '14 at 7:32
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Robert Munn Apr 15 '14 at 18:43

Mathematica, 56 bytes


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


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