# No strings (or numbers) attached

If you like this, consider participating in:

Make 12 snippets/expressions, in the same language, that result in the numbers 0 through 10, and 42 respectively, but without writing any literal numeric, string, or character data.

Build-in data, like PI() and ALPHABET(), are fine, and so are e.g. CJam's U, X, Y, Z, and A constants, and Processing's BLEND, CHORD, CENTER, BREAK, and LINES.

Every snippet must be able to stand on its own, i.e. they may not be interdependent. However, inside a single snippet, you may assign a variable and use it freely, as long as you refer to it directly by name, and not through a string containing its name.

All the snippets must be valid on the submitter’s computer at the time of submission (as reported by SE), but may not rely on unusual local conditions like number of files in a directory, the exact date or time, or specific input from the user.

### Examples of valid snippets

3: INT(LOG10(YEAR(TODAY()))) because it remains true in the foreseeable future
4: CUBICROOT(LEN(CHARACTERSET())) because a 256 letter character set is very common
8: SQRT(SYSTEMTYPE()) because 64-bit systems are very common

### Examples of invalid snippets

5: LEN(USERNAME()) because most people do not use “Admin” as login :-)
9: LOG10(SYSTEMMEMORY()) because it only works on systems with exactly 1 GB of memory
42: CODE("*") because it contains a string/character literal

The result of each snippet must result in an actual number (value, int, float, etc.) that can be used for further calculations using the same language as the snippet, i.e not a text string representing that number.

Only character based languages allowed.

Score is total byte count of all the 12 snippets combined. Newlines separating the snippets are not counted in.

Note that the above rules may prevent some languages from participating, even if they are Turing complete.

### FAQ

Q Can the programs accept any input?
A Yes, but you may not just ask for input and enter the relevant number.

Q Are physical digits (non-data) digits allowed?
A Yes, e.g. LOG10().

Q Do Symbols in Ruby count as literals?
A Yes.

Q Does score include newlines between each snippet?
A No.

Q Is TI-BASIC "character based" enough to be valid?
A Yes.

Q Do false and true count as number literals?
A No, they are acceptable.

Q Can we use a number literal to call a function if that's the only way and the number doesn't influence the output of the function?
A Yes, if that is the normal way to write code in your language.

Q My language assumes there is a [something] at the start of each program/expression. Must I include it, or should my snippets just work if placed in the middle of a program/expression?
A They should just work in the middle of a program/expression.

A Forbidden, except for languages that only do regexes.

Q Is one piece of code that could print all the specified numbers acceptable?
A No, they have to be separate and mutually independent.

Q May I assume a boilerplate like int main() {}... or equivalent?
A Yes.

Q What output datatypes are allowed?
A Any numeric datatype, like int, float, etc.

Q Do I need to print the result of each snippet?
A No, making the result available for subsequent use is enough.

Q Are pre-set variables allowed?
A Yes, and they become reset (if changed) for every snippet.

Q Are π and e considered number literals?
A No, you may use them.

Q May I return 4 and 2 in different cells for 42?
A No, they must be connected as one number.

Q Bytes or characters?
A Bytes, but you may choose any desired codepage.

Q May constant functions and preset variables like J's 9:, Actually's 9, and Pretzel's 9 be used?
A Yes, if the vocabulary is finite (19 for J, 10 for Actually and Pretzel).

• If 0-9 are not number literals but are pre-populated variables, would they be fair game? – Cyoce Aug 28 '16 at 7:58
• @Cyoce So 10 is {1, 0} and not 2×5? – Adám Aug 29 '16 at 9:34
• no, there is simply another syntax for literals that is not base-10, so 0-9 are not literals. They hold the value of 0-9, but are considered variables – Cyoce Aug 29 '16 at 15:17
• @Cyoce Then it's fine. What language is that? – Adám Aug 29 '16 at 18:56
• pretzel (a language I'm working on). – Cyoce Aug 29 '16 at 22:47

# Hexagony, 13 bytes


1
2
3
4
5
6
7
8
9
10
42


Try it online!

In Hexagony, 0 through 9 are functions that multiply the current memory by 10, and then add the number represented by the function name. Therefore, the first snippet is empty as memories start off as 0.

For example, if the current memory is 65, executing the function 3 will make the current memory 653.

(To downvoters: downvote all you want; I am ready.)

• Sneaky, but gets my upvote and tick. – Adám Aug 23 '16 at 13:30

# Funciton, 1222 bytes

Apart from numeric literals, there are two ways I can produce a value (any value at all) in Funciton: stdin and lambda expressions. Stdin is a single box while a full lambda expression requires more syntax, so I’m going with stdin. However, while stdin could be anything, all of the following work regardless of what input is provided.

All of the library functions used here existed before the challenge was posted.

## 0 (40 bytes in UTF-16)

╔╗┌┐
║╟┤└┼┬┐
╚╝└─┘└┘


This uses the raw syntax for less-than. A value is never less than itself, so the result of this is 0.

## 1 (52 bytes in UTF-16)

╔╗┌─╖┌─╖
║╟┤⌑╟┤ɕ╟
╚╝╘═╝╘═╝


⌑ returns a lazy sequence containing a single element and ɕ counts the number of elements. (The lazy sequence is lazy enough that this snippet doesn’t actually evaluate stdin at all!)

## 2 (70 bytes in UTF-16)

╔╗┌─╖┌─╖┌─╖
║╟┤⌑╟┤ʂ╟┤ɕ╟
╚╝╘═╝╘═╝╘═╝


= 2¹. ʂ generates all subsequences of a sequence, and thus turns a sequence of n elements into one with 2ⁿ.

## 3 (88 bytes in UTF-16)

╔╗┌─╖┌─╖┌─╖┌─╖
║╟┤⌑╟┤ʂ╟┤ɕ╟┤♯╟
╚╝╘═╝╘═╝╘═╝╘═╝


= 2 + 1. ♯ increments a value by 1.

## 4 (88 bytes in UTF-16)

╔╗┌─╖┌─╖┌─╖┌─╖
║╟┤⌑╟┤ʂ╟┤ʂ╟┤ɕ╟
╚╝╘═╝╘═╝╘═╝╘═╝


= 2².

## 5 (106 bytes in UTF-16)

╔╗┌─╖┌─╖┌─╖┌─╖┌─╖
║╟┤⌑╟┤ʂ╟┤ʂ╟┤ɕ╟┤♯╟
╚╝╘═╝╘═╝╘═╝╘═╝╘═╝


= 4 + 1.

## 6 (106 bytes in UTF-16)

╔╗┌─╖┌─╖┌─╖┌─╖┌─╖
║╟┤⌑╟┤ʂ╟┤ɕ╟┤♯╟┤!╟
╚╝╘═╝╘═╝╘═╝╘═╝╘═╝


= 3 factorial.

## 7 (110 bytes in UTF-16)

┌───┐┌─╖┌─╖┌─╖╔╗
│┌─╖├┤ɕ╟┤ʂ╟┤⌑╟╢║
└┤A╟┘╘═╝╘═╝╘═╝╚╝
╘╤╝


= A(2, 2) (Ackermann function).

## 8 (118 bytes in UTF-16)

┌────┐┌─╖┌─╖┌─╖╔╗
│┌──╖├┤ɕ╟┤ʂ╟┤⌑╟╢║
└┤<<╟┘╘═╝╘═╝╘═╝╚╝
╘╤═╝


= 2 << 2 (shift-left).

## 9 (128 bytes in UTF-16)

┌───┐┌─╖┌─╖┌─╖┌─╖╔╗
│┌─╖├┤♯╟┤ɕ╟┤ʂ╟┤⌑╟╢║
└┤×╟┘╘═╝╘═╝╘═╝╘═╝╚╝
╘╤╝


= 3 × 3.

## 10 (146 bytes in UTF-16)

┌───┐┌─╖┌─╖┌─╖┌─╖┌─╖╔╗
│┌─╖├┤♯╟┤ɕ╟┤ʂ╟┤ʂ╟┤⌑╟╢║
└┤+╟┘╘═╝╘═╝╘═╝╘═╝╘═╝╚╝
╘╤╝


= 5 + 5.

## 42 (170 bytes in UTF-16)

┌──────┐┌─╖┌─╖┌─╖┌─╖┌─╖╔╗
│┌─╖┌─╖├┤!╟┤♯╟┤ɕ╟┤ʂ╟┤⌑╟╢║
└┤♯╟┤×╟┘╘═╝╘═╝╘═╝╘═╝╘═╝╚╝
╘═╝╘╤╝


= 6 × (6 + 1).

• +1 for the Ackermann function. – intrepidcoder Dec 18 '15 at 18:42
• I wish I could upvote more than once... – user46167 Dec 19 '15 at 0:28

# JavaScript, 144141140138132125 123 bytes

With help from @edc65, @Sjoerd Job Postmus, @DocMax, @usandfriends, @Charlie Wynn and @Mwr247!

result.textContent = [

+[]                          ,// 0  (3 bytes)
-~[]                         ,// 1  (4 bytes)
-~-~[]                       ,// 2  (6 bytes)
-~-~-~[]                     ,// 3  (8 bytes)
-~Math.PI                    ,// 4  (9 bytes)
-~-~Math.PI                  ,// 5  (11 bytes)
-~-~-~Math.PI                ,// 6  (13 bytes)
Date.length                  ,// 7  (11 bytes)
(a=-~-~[])<<a                ,// 8  (13 bytes) = (2 << 2)
(a=~Math.E)*a                ,// 9  (13 bytes) = (-3 * -3)
(a=-~-~[])<<a|a              ,// 10 (15 bytes) = ((2 << 2) | 2)
(a=Date.length)*--a           // 42 (19 bytes) = (7 * 6)

];
<pre id="result"></pre>

• Try 4: -~Math.PI – edc65 Dec 18 '15 at 7:32
• @edc65 Thanks! I thought there would be something I could do with PI. :) – user81655 Dec 18 '15 at 7:34
• For 5, 6 you can also use -~-~Math.PI and -~-~-~Math.PI saving another byte (twice). – Sjoerd Job Postmus Dec 18 '15 at 13:48
• Save one on 42 with (escape+NaN).length. P.S. Today I learned that JavaScript is really weird... – Mwr247 Mar 1 '16 at 22:17
• I was gonna say that NaN counts as a number, but it's literally Not a Number :P – ETHproductions Mar 2 '16 at 21:44

# Mouse-2002, 272617 14 bytes

The first snippets push 0-10, and ZR+ pushes 25 then 17 and 25 17 + 42 = is 1.

A
B
C
D
E
F
G
H
I
J
K
ZR+

• It says "a snippet or expression" so you can remove all the !'s – user46167 Dec 19 '15 at 0:45
• @cat I can't speak for the questioner, but I think that means stand alone from each other - no defining a function in one, then using it in another. However, each snippet doesn't need to be an entire program, it can assume the boilerplate int main() {}... equivalent that will make it run. – TessellatingHeckler Dec 19 '15 at 3:16

# CJam, 27 24 bytes

U    e# 0
X    e# 1
Y    e# 2
Z    e# 3
Z)   e# 3 + 1
YZ+  e# 2 + 3
ZZ+  e# 3 + 3
AZ-  e# 10 - 3
YZ#  e# 2³
A(   e# 10 - 1
A    e# 10
EZ*  e# 14 × 3


Thanks to @MartinBüttner for -1 byte!

Try it online!

# Brainfuck, 70 bytes

+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
--[>+<++++++]>-


Each line must be run individually.

The first 10 are self explanatory: we increment the value of the cell via each plus.

The 42 is a lot more complex. It relies on the fact the most brainfuck interpreter use 8-bit cells, meaning that all operations on it are done modulo 256. The -- sets cell #0 to 254. Then we enter a loop which runs until cell #0 is 0. Each iteration adds 1 to cell #1 and adds 6 to cell #0. This loops runs 43 times, so cell #1 is 43. Finally, we subtract 1 from cell #1 to make it 42.

I got the most efficient 42 ever found from http://esolangs.org/wiki/Brainfuck_constants

• @someonewithpc 4 and 2 is different from 42: the OP says The result of each snippet must result in an actual number that can be used for further calculations using the same language as the snippet, i.e not a text string representing that number. You can do calculations on 42 directly, but it's not the same for 4 and 2 in separate cells. – p1xel Dec 19 '15 at 23:00
• Oh, ok. I had missed that.. – someonewithpc Dec 19 '15 at 23:01

## Darkness, 339 303 bytes

This is where Darkness really shines. Get it? :~)!

Without printing (replaced the space with \s in the first line since it won't show otherwise):

\s

█

██

███

████

█████

██████

███████

████████

█████████

██████████

██████████████████████████████████████████


With printing:

■

█■

██■

███■

████■

█████■

██████■

███████■

████████■

█████████■

██████████■

██████████████████████████████████████████■


Each line must be run individually in this case since the program terminates in the light (a space). However, it is possible to write this on one or several lines in the same program.

Regular darkness (█) increments a register by 1, and the ■ instruction (some sort of mini-darkness) outputs the contents of the register.

• I don't think this asks for full programs, just snippets. – Erik the Outgolfer Oct 6 '16 at 15:59

## Perl 5, 867571 66 bytes

All ^Fs are literal control characters (0x06 in ASCII), and hence a single byte.

$[ # array start index, defaults to 0 2 !$[         # !0 is 1                                                           3
$^F # max sys file descriptor number, 2 on all sane systems 2 ++$^F       # 2 + 1                                                             4
~-$] # 5 - 1 4 int$]       # $] is Perl version, int truncates 5 length$~    # 1 + 5                                                             8
~~exp$^F # floor(e^2) 7$^F<<$^F # 2 bitshift-right 2 6 -!$[+ord$/ # -1 + 10 10 ord$/       # input record separator, newline by default, ord gets ASCII val    5
ord($"^$/)  # 32 + 10                                                          10


Thanks to msh210 for saving 11 bytes and Dom Hastings for 9 bytes!

• Perl is strange. zoitz.com/comics/perl_small.png – ldam Dec 18 '15 at 15:49
• downgoated because "max sys file descriptor number, 2 on all sane systems = 3" but i have 65+ – cat Dec 20 '15 at 12:28
• (i'm just joking, i upvoted of course) – cat Dec 20 '15 at 12:29
• You ever read the comments on an SE post and think, "wow, which dumbass wrote that"? That's me right now, at myself. – cat Mar 1 '16 at 22:13
• !$[+ord$/ # -1 + 10 — I don’t understand. In line 2 you say that !$[ gives you 1, not −1, so this snippet gives 11. – Timwi Mar 6 '16 at 13:50 ## MATL, 30 bytes O l H I K Kl+ HI* KYq HK* IH^ K:s IH^:sI-  H, I, and K are predefined constants for 2, 3, and 4 (like pi). O and l are functions that returns a matrix of zeros (O) or ones (l), the default size is 1x1. : makes a vector, and s sums it, so K:s makes a vector from 1 to 4 and sums it to get 10. Yq is the n-th prime function, so KYq is the 4th prime, 7. • That Yq function (and its implementation) was a very nice suggestion of yours :-) – Luis Mendo Dec 18 '15 at 1:26 • IK+ would work just as well for 7, but it's a bit too boring :P – David Dec 18 '15 at 2:34 # Prolog, 113 99 bytes Snippets: e-e % 0.0 e/e % 1.0 e/e+e/e % 2.0 ceil(e) % 3 ceil(pi) % 4 ceil(e*e-e) % 5 ceil(e+e) % 6 floor(e*e) % 7 ceil(e*e) % 8 ceil(pi*e) % 9 ceil(pi*pi) % 10 ceil(e^e*e) % 42  Combines the mathematical constants e and pi in different ways converted to int. Edit: Saved 14 bytes by utilizing floats for 0-2. • anything wrong with e/e=1? – Level River St Dec 17 '15 at 22:29 • @steveverrill: it will become a float (1.0). I interpreted the challenge description to mean that the numbers should be integers. Most of these, if not all could be shortened otherwise. – Emigna Dec 18 '15 at 7:18 • @steveverrill Floats are fine. We just need the right value. – Adám Dec 20 '15 at 3:29 # PHP, 157145 91 bytes First time posting on Code Golf, figured I'd give it a shot. I'll get better eventually :P If you see any obvious (to you) spots where I could save characters, let me know. EDIT: Realized I didn't need the semicolons, since these are just snippets. EDIT2: Thanks to Blackhole for many suggestions! LC_ALL DNS_A ~~M_E ~~M_PI LOCK_NB LC_TIME LOG_INFO INI_ALL IMG_WBMP SQL_DATE SQL_TIME LOG_INFO*INI_ALL  # Python 2, 191159158157156149 146 bytes My first submission ever, I hope I got everything right ! Based on the time I spent on this, I guess there's surely a better one for a few of them. # 0 | Bytes : 5 int() # 1 | Bytes : 5 +True # 2 | Bytes : 6 -~True # 3 | Bytes : 8 -~-~True # 4 | Bytes : 10 -~-~-~True # 5 | Bytes : 12 -~-~-~-~True # 6 | Bytes : 14 -~-~-~-~-~True # 7 | Bytes : 16 -~-~-~-~-~-~True # 8 | Bytes : 15 a=True;a<<a+a+a # 9 | Bytes : 19 a=True;(a<<a+a+a)+a # 10 | Bytes : 20 int(+True+int()) # 42 | Bytes : 16 ~-len(license) # Especially proud of this one ! Total byte count: 146  Many thanks to FryAmTheEggman ! • Welcome to PPCG :) I'm not 100% sure about this challenge but I think using True as an idiom for 1 should be acceptable, as I don't know when they aren't equivalent as snippets. – FryAmTheEggman Dec 20 '15 at 21:59 • Oh, you're right ! Not using it for the 1 itself, because True is not 1 but for all the computation based on 1, it helps ! Editing now. – Joachim Jablon Dec 20 '15 at 22:02 • Use #8 len(id(id)). Then 8, 9, and 10 will be shorter. Also, maybe add a hyperlink to Try it online. – mbomb007 Mar 3 '16 at 16:12 • You can get 9 with len({()}) for 11 bytes, and that gives you 7 through 10 shorter. – xnor Aug 25 '16 at 23:06 # C#, no usings, 234 bytes new int() // 0 -~new int() // 1 -~-~new int() // 2 -~-~-~new int() // 3 -~-~-~-~new int() // 4 -~-~-~-~-~new int() // 5 -~-~-~-~-~-~new int() // 6 -~-~-~-~-~-~-~new int() // 7 -~-~-~-~-~-~-~-~new int() // 8 (int)System.ConsoleKey.Tab // 9 (int)System.TypeCode.UInt32 // 10 (int)System.ConsoleKey.Print // 42  This is much more boring than I initially thought it was going to be. I had pretty varied ideas, such as new[]{true}.Length and true.GetHashCode() and typeof(int).Name.Length and uint.MinValue etc., but new int() beat them all. • Would the rules allow you to do something like var a = new int(); and then use a in each snippet? – ldam Dec 18 '15 at 15:51 • @LoganDam: I find it more interesting if every expression has to stand on its own. That’s also why I didn’t use any using declarations. – Timwi Dec 18 '15 at 22:57 • Whoa what are those for 9/10/42 :Oo – user46167 Dec 19 '15 at 0:35 • @ev3commander: They are simply the shortest-named enum values defined in mscorlib that have the necessary integer value. For ConsoleKey.Tab, the value 9 is not surprising (9 is also the ASCII of the tab character). The others are probably arbitrary. – Timwi Dec 19 '15 at 1:49 • Shorter one for 8: int a=-~-~new int();a<<a – LegionMammal978 Dec 25 '15 at 23:51 # PowerShell, 147 bytes These use + to implicitly cast things to integers. The later numbers use Enums from the .Net Framework unerpinnings of PowerShell which happen to have the right values. +$a                          #0, 3 bytes (unset vars are $null, +$null == 0)
+$? #1, 3 bytes (bool previous result, default$true, +$true == 1)$?+$? #2, 5 bytes (same as #1, twice)$?+$?+$?                     #3, 8 bytes (beats [Int][Math]::E)
$?+$?-shl$? #4, 11 bytes (-shl is shift-left)$?+$?+$?+$?+$?               #5, 14 bytes
$?+$?+$?-shl$?               #6, 14 bytes (enum value, + casts to integer)
+[TypeCode]::Int16           #7, 18 bytes
$?+$?-shl$?+$?               #8, 14 bytes
+[consolekey]::tab           #9, 18 bytes
+[TypeCode]::UInt32          #10, 19 bytes
+[consolekey]::Print         #42, 20 bytes

#Total:                      147 bytes


• -~-~-~ used in JavaScript, C# and PHP answers would be - -bnot - -bnot - -bnot in PowerShell.

• x^y exponentiation used in Perl answers, or x**y in Python or JavaScript ES7, would be [Math]::Pow($x,$y)

• constants e and Pi are the character-heavy [Math]::E and [Math]::PI

• x^y is xor in JavaScript. JavaScript (ES7) has ** for exponents. Source – mbomb007 Mar 3 '16 at 16:18
• @mbomb007 Ah, thanks - I've updated my note on that. – TessellatingHeckler Mar 4 '16 at 3:56
• @mbomb007 I still think that's kind of silly – SuperJedi224 Mar 15 '16 at 15:50
• @SuperJedi224 Why? That's how Python does it. And xor is an important operator. – mbomb007 Mar 15 '16 at 16:23

# DC, 35 bytes

K
KZ
IZ
Iv
EI-
FI-
IZd*
IIZ/
Ivd+
IIv-
IIZ-
IKZ-
I
EdE++


To test the snippets append a f to print the stack and pass that string to dc:

$echo 'EdE++f' | dc 42  • I believe that E and F here are digits (even when they are greater than the input radix). Evidence for this is that they combine as digits; e.g. F0 -> 150. You can see the same behaviour with decimal digits once you change input and output radix. – Toby Speight Mar 2 '16 at 8:52 • There are lots of other answers using similar stuff... why should I be the only one where this is not ok? – user19214 Mar 2 '16 at 9:26 • You shouldn't - if there are other solutions using digits, then they aren't valid answers either. – Toby Speight Mar 2 '16 at 9:27 • I don't care any more! Codegolf even accepts a graphic mandelbrot set program as solution to the task to write an ascii art mandelbrot program... codegolf needs a big reset and when restarted I may or may not care about rules again... :-Þ – user19214 Mar 2 '16 at 9:29 ## TI-BASIC, 41 bytes 0~10: X cosh(X int(e int(π -int(-π int(√(π³ int(π+π int(e² int(eπ int(π² Xmax  42: int(π²/ecosh(π  In TI-BASIC, all uninitialized single-letter variables start at 0, and Xmax (the right window boundary of the graph screen) starts at 10. The mathematical constant π is one byte, but e is two bytes. • Isn't π considered numeric data? – vsz Dec 18 '15 at 12:35 • @vsz perhaps, but it isn't a number literal. The op even says so. – SuperJedi224 Dec 18 '15 at 14:01 • @NBZ very good point. My bad. – GamrCorps Dec 20 '15 at 4:35 # Python 2, 306275 274 bytes I used the fact that for any x (integer and not 0) the expression x/x equals 1 and played around with some bitwise operations. I adjusted the snippets such that they still meet the requirements (thanks @nimi this saved me 24 bytes), but you have to manually test them. Here is the code and individual byte counts: zero.py Bytes: 7 len({}) -------------------------- one.py Bytes: 12 r=id(id) r/r -------------------------- two.py Bytes: 17 r=id(id) -(~r/r) -------------------------- three.py Bytes: 20 r=id(id) -(~r/r)|r/r -------------------------- four.py Bytes: 20 r=~id(id)/id(id) r*r -------------------------- five.py Bytes: 26 r=~id(id)/id(id) (r*r)|r/r -------------------------- six.py Bytes: 25 r=~id(id)/id(id) (r*r)|-r -------------------------- seven.py Bytes: 27 r=~id(id)/id(id) -~(r*r|-r) -------------------------- eight.py Bytes: 24 r=-(~id(id)/id(id)) r<<r -------------------------- nine.py Bytes: 29 r=-(~id(id)/id(id)) r-~(r<<r) -------------------------- ten.py Bytes: 31 r=~id(id)/id(id) -r*((r*r)|r/r) -------------------------- answer.py Bytes: 37 r=-(~id(id)/id(id)) (r<<r*r)|(r<<r)|r -------------------------- Total byte count: 274  • You can save bytes with i=id(id);r=~i/i – Cyoce Aug 26 '16 at 16:52 ## Javascript (Browser Env), 155136 130 bytes +[] -~[] -~-~[] -~-~-~[] -~-~-~-~[] -~-~-~-~-~[] -~-~-~[]<<-~[] -~-~-~-~-~-~-~[] -~[]<<-~-~-~[] ~(~[]+[]+-[]) -~[]+[]+-[] -~(top+top.s).length // Requires browser environment  Thanks to: @Ismael Miguel: 155 -> 136 -> 130 bytes • You can use -~[]+[]+-[] to produce 10. It will return a string, but it's still usable as a number. Also, you can use -~(top+top.s).length to calculate 42 (-8 bytes) and drop your dependency on Google Chrome. To save more 3 bytes, use (P=Math.PI)*P>>+[] to calculate 9. – Ismael Miguel Dec 18 '15 at 19:57 • Sorry, forgot a few bytes you can shave. You can use ~(~[]+[]+-[]) to generate 9. That should cut down a few more bytes. – Ismael Miguel Dec 18 '15 at 23:06 • curiously, +[12] gives 12 and +[1, 2] gives NaN. I hate JS – cat Dec 19 '15 at 12:56 • @cat It's because of JavaScript's weird cast system. Arrays cast to strings like [1,2,3] => "1,2,3" and strings cast to numbers like "12" => 12 but if there are non-number characters in the string the cast returns NaN. +[1,2] casts to a string then a number but the string contains a comma so "1,2" becomes NaN. – user81655 Dec 19 '15 at 22:56 • @user81655 that. is. HORRID. – cat Dec 19 '15 at 23:00 ## Seriously, 39 33 bytes Stuff in parentheses is explanations:  (single space, pushes size of stack, which is 0 at program start) u (space pushes 0, u adds 1 (1)) ⌐ (space pushes 0, ⌐ adds 2 (2)) u⌐ (space pushes 0, u adds 1 (1), ⌐ adds 2 (3)) ⌐⌐ (space pushes 0, ⌐⌐ adds 2 twice (4)) ⌐P (space pushes 0, ⌐ adds 2 (2), P pushes the 2nd prime (5)) Hl▓ (H pushes "Hello, World!", l pushes length (13), ▓ pushes pi(13) (6)) QlP (Q pushes "QlP", l pushes length (3), P pushes the 3rd prime (7)) Ql╙ (Q pushes "QlP", l pushes length (3), ╙ pushes 2**3 (8)) úl▓ (ú pushes the lowercase English alphabet, l pushes length (26), ▓ pushes pi(26) (9)) u╤ (space pushes 0, u adds 1 (1), ╤ pushes 10**1 (10)) HlPD (H pushes "Hello, World!", l pushes length (13), P pushes the 13th prime (43), D subtracts 1 (42))  Hexdumps of programs: 20 2075 20a9 2075a9 20a9a9 20a950 486cb2 516c50 516cd3 a36cb2 2075d1 486c5044  Thanks to quintopia for 6 bytes! • I suppose Seriously uses a 256 char codepage that includes pseudo graphic chars? – Adám Dec 18 '15 at 14:34 • @NBZ CP437 – user45941 Dec 18 '15 at 15:46 • You can save a byte on 6 with Hl▓ – quintopia Dec 20 '15 at 14:19 • The same idea with ú saves a byte on 9 – quintopia Dec 20 '15 at 14:28 • HlPD saves 2 bytes on 42, and QlP saves a byte on 7, and Qlª saves a byte on 9, and Ql╙ saves a byte on 8. I think that gets Seriously down to 33 bytes all told, tying Pyth. – quintopia Dec 21 '15 at 4:31 # dc, 42 bytes K zz OZ zzz+ OZd* OdZ/ zzzz* Ozz+- OdZ- Oz- O Od+dz++  ## Results 0 1 2 3 4 5 6 7 8 9 10 42  There aren't many ways to generate new numbers with dc. I use O: output base, initially 10; K: precision, initially 0; z stack depth, initially 0; Z significant digits of operand. We combine these with the usual arithmetic operators. # Test program #!/bin/bash progs=( \ "K" \ "zz" \ "OZ" \ "zzz+" \ "OZd*" \ "OdZ/" \ "zzzz*" \ "Ozz+-" \ "OdZ-" \ "Oz-" \ "O" \ "Od+dz++" \ ) a=0 results=() for i in "${progs[@]}"
do
results+=($(dc -e "${i}p"))
(( a+=${#i} )) done echo "#dc,$a bytes"
echo
printf '    %s\n' "${progs[@]}" echo echo '##Results' echo printf ' %s\n' "${results[@]}"


# Math++, 92 bytes total

0 (1 bytes): a

1 (2 bytes):!a

2 (3 bytes):_$e 3 (4 bytes): _$pi

4 (7 bytes): _$e+_$e

5 (8 bytes): _($e+$e)

6 (9 bytes): _$pi+_$pi

7 (8 bytes): _($e*$e)

8 (9 bytes): _($e*$pi)

9 (10 bytes): _($pi*$pi)

10 (12 bytes): _$e*_($e+$e) 42 (19 bytes): _($pi+$pi)*_($e*$e) # MS Excel formulas, 163151150 143 bytes Not exactly a programming language, but here it goes... 0: -Z9 (03 bytes) 1: N(TRUE) (07 bytes) 2: TYPE(T(Z9)) (11 bytes) 3: TRUNC(PI()) (11 bytes) 4: TYPE(TRUE) (10 bytes) 5: ODD(PI()) (09 bytes) 6: FACT(PI()) (10 bytes) 7: ODD(PI()+PI()) (14 bytes) 8: EVEN(PI()+PI()) (15 bytes) 9: TRUNC(PI()*PI()) (16 bytes) 10: EVEN(PI()*PI()) (15 bytes) 42: EVEN(CODE(-PI())-PI()) (22 bytes)  PI() is used in most cases as it is the shorter way (that I am aware of) to introduce a numeric value without using a number or string literal. N converts various things (incl. booleans) to numbers, and T converts various things to text. TYPE returns 2 for a text argument and 4 for a boolean argument. TRUNC discards fractional part (i.e. rounds positive numbers down), EVEN rounds up to the next even number, and ODD rounds up to the next odd number. CODE(-PI()) is the ASCII code of the first character of the conversion to text of -π, i.e. 45 (for "-"). EDIT: Removed equal signs from the byte count (-12!) - as pointed out by Nᴮᶻ in the comments, they are not supposed to be included. EDIT 2: Assuming the rest of the worksheet is empty, it is possible to use a reference to an empty cell as zero (again, suggested by Nᴮᶻ) provided that we include a minus sign (or use it in other numeric expression) to resolve type ambiguity. • 0=Z9​​​​​​​​​ – Adám Mar 3 '16 at 22:24 • Removed the =s, thanks. Regarding your suggestion, I avoided cell references on purpose, to make sure the formulas are independent of table contents - if Z9 contains a text, =Z9 won't return zero anymore. I decided not to assume anything about the table. – dnep Mar 3 '16 at 22:46 • anyway, you made me loot at it again, and I realized I could at least save 1 byte by using to 0 the same logic that I used to 1... – dnep Mar 3 '16 at 23:06 • But some languages have all variables set to 0 if they are not set to something else. In this context, I would see Excel as a language with (theoretically infinite) memory cells A1:ZZZ..:999... and no distinction between program code and data (i.e. may be self-modifying). Since each snippet is independent of the others, I assume it is in A1, and the rest of the sheet it blank. (For programs, I would have one whole statement in each cell A1, A2, etc.) – Adám Mar 7 '16 at 13:11 • 42=ROW(Z42)​​ – Adám Mar 7 '16 at 14:16 ## Mathematica, 101 bytes a-a a/a ⌊E⌋ ⌈E⌉ ⌈π⌉ ⌊E+E⌋ ⌈E+E⌉ ⌊E*E⌋ ⌈E*E⌉ ⌈E*π⌉ ⌈π*π⌉ ⌊π*π^π/E⌋  I'm pretty sure some of these are suboptimal. Those rounding brackets are really expensive. For consistency, the first two could also be E-E and E/E of course, but I thought it's quite nifty to get 0 and 1 from a computation with undefined variables. • @NBZ Sorry, forgot about 0. If a gets the value 0 afterwards, that's not an issue, as long as it's unused when a/a is evaluated. – Martin Ender Dec 18 '15 at 14:37 • @NBZ The byte count is simply the UTF-8 byte count. – Martin Ender Dec 18 '15 at 14:37 # Japt, 3433 30 bytes 1 byte saved thanks to @ThomasKwa T °T C-A D-A E-A F-A G-A °G-A Iq ´A A H+A  Here's what each of the different chars means: T 0 A 10 B 11 C 12 D 13 E 14 F 15 G 16 H 32 I 64 q sqrt on numbers ° ++ ´ --  • Does Japt take hexadecimal numbers by default? If so, then A through F would be numeric literals... – Adám Dec 21 '15 at 14:10 • @NBZ A-I are variables that are, by default, assigned to various numbers, as shown above. A-F are assigned to 10-15. Does this invalidate those variables? – ETHproductions Dec 21 '15 at 14:52 • No. I was just wondering if, say 12AB3 was valid. Now I know it isn't. No literals here, move along. :-) – Adám Dec 21 '15 at 17:31 # Marbelous, 98 bytes Not terribly exciting, it relies on the ?n devices which turn any marble into a random value in the range 0..n (inclusive) a side effect of this is that ?0 turns any marble into a 0 regardless of input. I think the use of literals is permitted because the value does not affect the outcome and there is no other way to call a function once in Marbelous. 0: 00 # A hexadicemal literal: value 0 ?0 # Turn any marble into a random value from the range 0..0 (inclusive)  1: 00 ?0 +1 # increment by one  ... 9: 00 ?0 +9  10: 00 ?0 +A # increment by 10  42: 00 ?0 +L # increment by 21 +L  • It sure looks like 0...L are numeric literals. – Adám Dec 20 '15 at 12:50 • @NBZ They're not, you can't use them independently. +0 through +Z are like builtin functions. It's boring but valid. – overactor Dec 20 '15 at 14:10 ## ><>, 86 bytes • 0: ln; • 1: lln; • 2: llln; • 3: lll+n; • 4: lll:+n; • 5: llll+n; • 6: llll++n; or llll:+n; • 7: lllll+n; • 8: lllll:+n; • 9: lllll++n; or llllll+n; • 10: llll+:+n; or lll:l+*n; • 42: llll*ll+*n; Relies on stack size to get its literals. • You can probably remove the n on each because functions in stack-based languages can leave the output on the stack for -11 bytes. – redstarcoder Dec 5 '16 at 14:43 • @redstarcoder then I could even remove the ; for a total of 22 bytes and consider the end of the function reached at the end of the line, but it's a little ambiguous since ><> doesn't have out-of-the-box functions. – Aaron Dec 5 '16 at 15:29 • Technically if you want functions in ><>, your functions have to accept a return position (x & y) on the stack in addition to their parameters, make sure these aren't in the way while doing calculations ([ comes in handy in that context), then jump to the return position after having finished execution. I had done a POC a while ago, check it out if you're interested – Aaron Dec 5 '16 at 15:36 • I've actually seen your post before, and good work! I did a meta post about the ambiguities of functions. What I'm saying is this is typically allowed, with the ;. The reason I say to leave in ; is because otherwise there's no way of denoting when the function ends without a .. Most people seem to consider this fair but I could try to write a specific meta post here if you're concerned. – redstarcoder Dec 5 '16 at 15:44 • @redstarcoder thanks for the info ! I feel like suffixing the ><> snippets by . would be the best way to stick to the definition of function as described in the most upvoted answer of the meta post, however I agree ; is a good alternative which requires less explanation. – Aaron Dec 5 '16 at 16:39 # DUP, 68 bytes [ [ [ [)]! [ )]! [ )]! [)~_]! [ )~_]! [ )~_]! [ )~_]! [)$+]!
[ )$+~_$+]!


Try it here.

There are a LOT of ways to do this, but I'm abusing the return stack for this one.

# Explanation

To fully figure this out, you need to understand DUP's behavior regarding lambdas. Instead of pushing the lambda itself to the stack, it actually pushes the current IP to the stack when the lambda is detected. That can explain the first 3 snippets, which involve lambdas.

The next snippets use the return stack. When ! is executed, the current IP is pushed to the return stack, and the top of the stack is set as the new IP to start lambda execution. ) pops a number from the return stack onto the data stack.

That's pretty much enough to explain the rest of the snippets. If you still don't get it, keep in mind that the Step button is quite handy!

# 05AB1E, 4038 24 bytes

¾
X
Y
XÌ
Y·
T;
T;>
T;Ì
TÍ
T<
T
žwT+

• Push counter_variable
• Push 1
• Push 2
• Push 1+2
• Push 2*2
• Push 10/2
• Push (10/2)+1
• Push (10/2)+2
• Push 10-2
• Push 10-1
• Push 10
• Y· is more stack-clean than Yx, X can be used instead of º here (it defaults to 1, º means len(stack)>1, so it does not default to anything). Also, your bytecount is 24, not 35 (CP-1252, newlines do not count if they are separate snippets). – Erik the Outgolfer Dec 4 '16 at 20:40
• I know it wasn't possible yet at the time you posted this, but 6 can be ₆t now (push 36, square-root) to save a byte (Try it online). – Kevin Cruijssen Mar 29 '19 at 10:40

## Pyth, 3534 33 bytes

-1 byte by @Mimarik

There are a number of possibilities for some programs.

0, 1 byte

Z


1, 2 bytes

hZ
!Z


2, 3 bytes

hhZ
eCG
eCd
lyd
lyb
lyN


3, 3 bytes

ld


4, 3 bytes

lb
eCN


5, 4 bytes

hlb
telG


6, 3 bytes

elG


7, 4 bytes

tttT
helG


8, 3 bytes

ttT


9, 2 bytes

tT


10, 1 byte

T


42, 4 bytes

yhyT


All of these involve either basic double (y), +1 (h) and -1 (t) commands, or l (length of a string). The Z variable is initialized to zero.

For 5, b is initialized to a newline character. Backtick gives "\n" (including the quotes, and the length of that string is 4.

Try them here!

## R, 123 bytes

+!pi                #  0  -   4 bytes
+TRUE               #  1  -   5 bytes
nchar(NA)           #  2  -   9 bytes
floor(pi)           #  3  -   9 bytes
cars$d[pi] # 4 - 10 bytes ncol(CO2) # 5 - 9 bytes nrow(BOD) # 6 - 9 bytes cars$s[pi]          #  7  -  10 bytes
sum(dim(BOD))       #  8  -  13 bytes
floor(pi*pi)        #  9  -  12 bytes
ceiling(pi*pi)      # 10  -  14 bytes
nrow(CO2)/nchar(NA) # 42  -  19 bytes
# Total 123 bytes
`