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

Q What about regex literals?
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

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


## R, 166 165 bytes

I made a PI based answer

pi-pi                         # 0
pi/pi                         # 1
(pi+pi)/pi                    # 2
floor(pi)                     # 3
ceiling(pi)                   # 4
ceiling(pi)+pi/pi             # 5
floor(pi+pi)                  # 6
ceiling(pi+pi)                # 7
floor(pi*pi)-pi/pi            # 8
floor(pi*pi)                  # 9
ceiling(pi*pi)                # 10
ceiling(pi^pi+pi+sqrt(pi))    # 42


# 80386 machine code, 73 bytes

Hexdump:

33 c0
33 c0 40
33 c0 40 40
33 c0 40 40 40
33 c0 40 40 40 40
33 c0 40 8d 04 80
33 c0 40 8d 04 80 40
33 c0 40 8d 04 80 40 40
33 c0 40 8d 04 c0 48
33 c0 40 8d 04 c0
33 c0 40 8d 04 c0 40
33 c0 40 8d 04 c0 8d 04 80 48 48 48


The snippets calculate the required value in the eax register, suitable as a return value from a function.

I used various combinations of the following instructions:

xor eax, eax         (33 c0)    eax = 0
inc eax              (40)       eax = eax + 1
dec eax              (48)       eax = eax - 1
lea eax, [eax+eax*4] (8d 04 80) eax = eax * 5
lea eax, [eax+eax*8] (8d 04 c0) eax = eax * 9


The numbers here are too small to use all the possibilities of the instruction set - the only noteworthy thing here is the easy multiplication by 5 and 9. For example, here is a 13-byte snippet whose result is 2016:

33 c0      xor eax, eax             eax = 0
40         inc eax                  eax = 1
8d 0c c0   lea ecx, [eax+eax*8]     ecx = 9
8d 04 89   lea eax, [ecx+ecx*4]     eax = 45
f7 e0      mul eax                  eax = 2025
2b c1      sub eax, ecx             eax = 2016


# Visual Basic for Applications, 68 bytes

VBA has a lot of builtin constants and public enums. I opted not to use any external or MS Office-specific library - only base VBA:

-x                     '=0  (2 bytes)
x^x                    '=1  (3 bytes)
vbGet                  '=2  (5 bytes)
vbLong                 '=3  (6 bytes)
vbLet                  '=4  (5 bytes)
vbDouble               '=5  (8 bytes)
vbYes                  '=6  (5 bytes)
vbNo                   '=7  (4 bytes)
vbSet                  '=8  (5 bytes)
vbObject               '=9  (8 bytes)
vbError                '=10 (7 bytes)
vbKeyPrint             '=42 (10 bytes)


Total = 68 bytes. Notice that by default, undeclared variables (such as x above) are all set to blank Variants, that may be interpreted, depending on context, as 0 or as an empty string. However, both operators - and ^ force it to be numeric. Also, in VBA, 0^0 is evaluated to 1 (instead of generating an error as one might expect). I'll also post an answer without constants.

• Interesting choice. Maybe try Excel too? – Adám Mar 2 '16 at 20:55
• Just did it! Thanks. – dnep Mar 3 '16 at 21:43

## Dyalog APL, 59 52 bytes

-7 bytes by @NBZ

I wasn't about to let one of @NBZ's questions go without an APL answer!

⍴⍬            0
⎕IO           1
⍴⎕SD          2
⎕WX           3
⍴⎕AI          4
⌈⍟⎕PW         5
⌊⍟⎕FR         6
⍴⎕TS          7
+⍨⍴⎕AI        8
⌊○○⎕IO        9; floor(pi^2 times ⎕IO)
⍴⎕D           10
⍎⌽⍕⌈*○≢#    42


In the last snippet, by NBZ, ≢# equals 1. ceil(e^(pi*1)) is calculated as 24, whose digits are then swapped.

Constants used:

• ⍬, is the empty numeric one-dimensional vector. Therefore, its shape ⍴⍬ is 0.
• # is a special vector of length 1.
• ⎕IO (index origin) starts at 1.
• ⎕AV, the character set, is of length 256.
• ⎕PW, the print width, is 79 characters.
• ⎕WX, window expose (whatever that is) is 3.
• ⎕FR, the float representation, is 645. I have no idea what this is either.
• ⎕D, "digits", is '0123456789'.
• ⎕TS, timestamp, has seven elements: Year, month, day, hr, min, sec, ms.
• ⎕SD, screen dimensions, has two elements: width and height.
• ⎕AI, account info, has four elements. I don't know what they are.
• Finally ;-) But you can do way better than that if you use full-fledged Dyalog APL. If you don't have one, it is easy to get. – Adám Dec 20 '15 at 3:14
• I already had Dyalog, but I didn't know there were so many system constants! – lirtosiast Dec 20 '15 at 19:54
• ⎕WX is a similar to ⎕ML; it controls the level of reserved-ness for names that are properties etc. of GUI objects. ⎕FR switches floats between 64 and 128 bit representation. ⎕AI is (UserName, CPUtime, SessionLength, KeyingTime. – Adám Dec 21 '15 at 2:16
• Better, but you are forgetting to think arrays! E.g. 0 and 1 can each be written with only two chars... – Adám Dec 21 '15 at 2:18
• 0=⍴⍬ 1=≢# 2=⍴⍬⍬ ... 42=⍎⌽⍕⌈*○≢# – Adám Dec 31 '15 at 18:29

# Jelly, 31

<blank>
‘
‘‘
‘‘‘
‘‘²
‘‘²‘
‘‘‘Ḥ
⁴H’
⁴H
‘‘‘²
⁵
⁴Ḥ⁵+


## Explanation

0: Outputs 0 by default

1. Increment
2. Increment twice
3. Increment thrice
4. Increment twice and square
5. Increment twice, square, and increment
6. Increment thrice and double
7. Halve sixteen and decrement
8. Halve sixteen
9. Increment thrice and square
10. Ten

42: Double sixteen and add ten

• I thought Jelly could do better. Are there no constants for 1 - 10? – Adám Mar 3 '16 at 12:06
• @Nᴮᶻ No. It only has constants for 256, 16, 10, space, and newline. – ASCII-only Mar 3 '16 at 12:07
• You may want to add that the empty program produces 0. – ETHproductions Mar 6 '16 at 21:49

# Haskell, 212 210 198 196 190 187 134 bytes

Edit: After reading in the FAQ that using pi is allowed, throwing everything away and doing it all using pionly saves a lot of bytes.

pi-pi                     -- 0.0,  5 bytes
pi/pi                     -- 1.0,  5 bytes
succ$pi/pi -- 2.0, 10 bytes floor pi -- 3, 8 bytes ceiling pi -- 4, 10 bytes succ.ceiling$pi           --   5, 15 bytes
floor$pi+pi -- 6, 11 bytes ceiling$pi+pi             --   7, 13 bytes
pred.floor$pi*pi -- 8, 16 bytes floor$pi*pi               --   9, 11 bytes
round$pi*pi -- 10, 11 bytes floor$pi**pi+pi+pi        --  42, 18 bytes


However, I still like the old approach more as using a number to generate other numbers feels a bit like cheating.

sum[]                     --  0,  5 bytes
length[LT]                --  1, 10 bytes
fromEnum GT               --  2, 11 bytes
length[LT ..]             --  3, 13 bytes
length$show[()] -- 4, 15 bytes length.show$False         --  5, 17 bytes
length$show[True] -- 6, 17 bytes length.show$Left()        --  7, 18 bytes
length.show$Right() -- 8, 19 bytes length$show[Just[]]       --  9, 19 bytes
length$show[LT ..] -- 10, 18 bytes fromEnum.succ.last$show() -- 42, 25 bytes


LT,EQ and GT are the values of the Ordering Type. As Ordering is an instance of Enum, fromEnum GT yields 2 and [LT ..] creates the list [LT,EQ,GT]. show converts all instances of the Show type class to strings.

Bonus:
42 in 42 bytes: length.show$Just$[LT ..]>>[EQ,GT]>>[GT,LT]
How long is nothing? length Nothing

Saved 3 bytes thanks to nimi and 3 bytes thanks to xnor.

• Save two bytes with 6: length$show[True]. 10: length$show[LT ..]. – nimi Aug 25 '16 at 20:45
• 42: fromEnum$succ$last$show(). – nimi Aug 25 '16 at 22:34 • sum[] gets you 0 – xnor Aug 25 '16 at 23:09 # PHP, 38 37 bytes Note: uses IBM-850 encoding. +_ #0 +~╬ #1 +~═ #2 +~╠ #3 +~╦ #4 +~╩ #5 +~╔ #6 +~╚ #7 +~Ã #8 +~ã #9 +~╬¤ #10 +~╦═ #42  # Explanation Undefined constants in PHP have their name as default value. The resulting string is then negated to result in "0", "42" etc. Finally, it's converted to integer using the leading +. # Tweaks • Saved a byte by exploiting the fact that converting any string results in 0 when converted to int, except when it matches /^[0-9.]+/ # Javascript, 159 chars No any variables Any line between  is a code snippet. The whole code is a test. It returns an array [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 42]. If returning string "42" instead of number 42 is ok, code can be made 3 schars less (remove |[]).  +[] -~[] !![]+!![] ~~Math.PI -~Math.PI -~Math.PI|!![] Math.PI<<!![] Math.PI<<!![]|!![] !![]<<Math.PI Math.PI*Math.PI^[] (-~Math.PI|!![])<<!![] -~Math.PI+[]+(!![]+!![])|[] .split('\n').filter(Boolean).map(eval)  # O, 36 bytes l Nl CA- DA- EA- FA- FA-) A((( A(( A( A A.+.+))  Mostly finding the difference of hex letters, CA- = 13-11 = 2 DA- = 14-10 = 3 ( and ) decrement and increment respectively, A(( = 10-1-1 = 8 .+ duplicates the top of the stack and adds it together A.+.+)) 10.+.+)) 20.+)) 40)) 42  The first two get the length of the stack (l), which zero, or one when a blank CodeBlock is pushed to the stack (N). • Could you may explain what happens here? – Adám Dec 18 '15 at 14:37 • @NBZ voila, good sir – phase Dec 18 '15 at 15:13 • If A through F are hex values, are they not numeric literals then? – Adám Dec 21 '15 at 14:06 ## k4, 41 bytes Most of this is a cheap hack—every builtin function in k has an internal id number, and . retrieves them. Entries of the form .(x) are implemented thus; others are commented. A question: are we supposed to generate the numbers or print them? E.g., for zero, should we return some numeric type containing zero as a value, or should we display the exact string 0? I ask because in there are several default settings that could be useful here, but they all have (32-bit) integer type, which means that in recent (3.x) versions of q/k4, they are displayed on the console with a type suffix of i appended. The following assumes 0i is a valid form of 0, but has alternatives in the comments. \p / 0: the default network port (none); alternatively, #(), the count of the empty list # / 1: the count of a null symbol atom; alternatively, if this is considered a character literal, use .(+) \W / 2: the default starting day of the week (monday), counting from saturday as 0; alternatively, .(-) .(*) / 3 .(%) / 4 #! / 5: the number of namespaces loaded by default (works in 3.2 or 3.3; in earlier versions, use this as 4 and .(&) as 5) .(|) / 6 \P / 7: the default numeric precision (7 significant figures); alternatively, #.j, the count of the .j namespace; alternatively, .(^) .(=) / 8 .(<) / 9 .(>) / 10 .(var) / 42  • you're just meant to push the numbers for use, you needn't print them. – cat Dec 19 '15 at 12:52 • Ah. The \x forms may still be invalid for a different reason then: for technical reasons, you can't actually use their return value for anything—to do that, you have to use a different form, ."\\x" (which wouldn't be any use here as it's six characters long). – Aaron Davies Dec 21 '15 at 6:40 # Pyth, 50 40 bytes Z hZ hhZ hhhZ hhhhZ hhhhhZ ttttT tttT ttT tT T yhyT  In Pyth, Z=0 and T=10. h is head, which means the next variable + 1. (e.g. hhZ == 2). t is tail, which means the next variable - 1 (e.g. tttT == 7). The last line is the fanciest: we essentially do double(1 + double(10)). Try it out here! • I would suggest 1) adding an explanation for what these do, and 2) adding a link to your code in the Pyth online interpreter, like so. – El'endia Starman Dec 18 '15 at 7:22 • y can be used to double the value of a number, for example, you can get 42 with yhyT which is like double(add_one(double(ten))) – FryAmTheEggman Dec 18 '15 at 15:07 • The loop is completely useless. Aside from the solution yhyT you could simply do hh*ThhhhZ. – Jakube Dec 19 '15 at 15:30 # C, 202 bytes enum{a}; // 0, 8 enum{a,b}; // 1, 10 enum{a,b,c}; // 2, 12 enum{a,b,c,d}; // 3, 14 enum{a,b,c,d,e}; // 4, 16 enum{a,b,c,d,e,f}; // 5, 18 enum{a,b,c,d};c*d; // 6, 18 enum{a,b,c,d,e};d+e; // 7, 20 enum{a,b,c};c<<c; // 8, 17 enum{a,b,c};b+(c<<c); // 9, 21 enum{a,b,c};c+(c<<c); // 10, 21 enum{a,b,c,d,e,f};c*f*e+c; // 42, 26  Printed Version, 730 bytes enum{a,b,c,d,e};char m[d]={(d<<e)+a,a};main(){printf(m);} // 0, 57 enum{a,b,c,d,e};char m[d]={(d<<e)+b,a};main(){printf(m);} // 1, 57 enum{a,b,c,d,e};char m[d]={(d<<e)+c,a};main(){printf(m);} // 2, 57 enum{a,b,c,d,e};char m[d]={(d<<e)+d,a};main(){printf(m);} // 3, 57 enum{a,b,c,d,e};char m[d]={(d<<e)+e,a};main(){printf(m);} // 4, 57 enum{a,b,c,d,e};char m[d]={(d<<e)+e+b,a};main(){printf(m);} // 5, 59 enum{a,b,c,d,e};char m[d]={(d<<e)+e+c,a};main(){printf(m);} // 6, 59 enum{a,b,c,d,e};char m[d]={(d<<e)+e+d,a};main(){printf(m);} // 7, 59 enum{a,b,c,d,e};char m[d]={(d<<e)+e+e,a};main(){printf(m);} // 8, 59 enum{a,b,c,d,e,f};char m[d]={(d<<e)+f+e,a};main(){printf(m);} // 9, 61 enum{a,b,c,d,e,f,g,h,i,j,k};char m[d]={k*d+h,k*k,a};main(){printf(m,k);} // 10, 72 enum{a,b,c,d,e,f,g,h,i,j,k};char m[d]={k*d+h,k*k,a};main(){printf(m,k*e+c);} // 42, 76  • @NBZ fixed the byte counts, I also assume that I cannot print 4 and 2 to produce 42, it has to be the value 42 – Khaled.K Dec 21 '15 at 9:44 • @KhaledAKhunaifer: You can do calculations inside enum{} like enum{z,o,t,e=t<<t} // e=8... – user19214 Dec 21 '15 at 10:16 • @yeti tip taken into account, also 3<<4 is 48 which is '0', useful to convert digits into ascii characters – Khaled.K Dec 21 '15 at 11:06 # 𝔼𝕊𝕄𝕚𝕟, 36 bytes (12 chars) Ḁ ḁ Ḃ ḃ Ḅ ḅ Ḇ ḇ Ḉ ḉ Ḋ Ḫ  Try it here (test-suite-style, Firefox only). There are variables for numbers from 0-256. (One of the benefits of choosing from UTF-8 is that you can dedicate a whole charset of 256 characters just to this kind of stuff. (Of course, byte count is a side effect.)) • It's nice being on top, but assuming ESMin is eligible for winning, why isn't this accepted? – cat Mar 1 '16 at 1:30 • Look at the byte count. (If you're looking at the leaderboard, it's buggy for ESMin.) – Mama Fun Roll Mar 1 '16 at 2:40 • Oh, yeah, I totally know how to read. – cat Mar 1 '16 at 2:42 • @ӍѲꝆΛҐӍΛПҒЦꝆ, I don't see a leaderboard in this question (though many a code-golf question does have one). Am I missing something (like, perhaps, a userscript that adds a leaderboard to every code-golf question that doesn't have one already)? – msh210 Mar 1 '16 at 22:45 • If you have the PPCG userscript, you will see the board. – Mama Fun Roll Mar 2 '16 at 2:45 # Perl 6, 84 81 bytes +$           #  0
++$# 1 -+^++$       #  2
-+^e         #  3
-+^π         #  4
1+-+^π       #  5
floor τ      #  6
-+^τ         #  7
floor e*π    #  8
floor π*π    #  9
-+^(τ+e)     # 10
-+^(e**e*e)  # 42


Constants used

> e
2.71828182845905
> π
3.14159265358979
> τ
6.28318530717959


An attempt at some explanation

#0: $ is an anonymous state variable, the + coerces it to a number, and by default its value is 0 #1: ++$ increases the state var by 1, giving us 1
#2: +^ as a prefix is the Integer bitwise negation operator, use that with ++$ (1) and we get -2, use - to negate it and give 2 #3: Use +^ with e, which is coerced to Int, giving -3 which then gets negated with - #4: Same as #3 but with π #5: Same as #4 but add 1 I think the rest are easy to follow with the above bits explained. # Haskell, 295 bytes 0: length[] 1: length[()] 2: length[(),()] 3: length[(),(),()] 4: length[(),(),(),()] 5: length[(),(),(),(),()] 6: length[(),(),(),(),(),()] 7: length[(),(),(),(),(),(),()] 8: length[(),(),(),(),(),(),(),()] 9: length[(),(),()]*length[(),(),()] 10: length[(),()]*length[(),(),(),(),()] 42: length[(),(),(),(),(),()]*length[(),(),(),(),(),(),()] # Visual Basic for Applications, no named constants, 134 bytes That's tougher: -x '=0 (2 bytes) x^x '=1 (3 bytes) x^x+x^x '=2 (7 bytes) x^x+x^x+x^x '=3 (11 bytes) Len(Year(x)) '=4 (12 bytes) Len(Year(x)&-x) '=5 (15 bytes) Day(x)Mod Month(x) '=6 (18 bytes) Len(Time())-x^x '=7 (15 bytes) Len(Time()) '=8 (11 bytes) Len(Time()&-x) '=9 (14 bytes) Len(Date()) '=10 (11 bytes) Day(x)+Month(x) '=42 (15 bytes)  Total = 134 bytes. Again, - and ^ force undeclared variables (Variants) to be treated as numeric, and in VBA 0^0 evals to 1. The concatenation operator force numbers to string form, so -x is 0 and &-x is & "0". For Day, Month and Year functions, zero corresponds to december 31, 1899. I also used the fact that (at least for most locales), VBA date strings have 10 characters and time strings have eight... Thanks! This was a funny challenge. # R, 100 bytes Copied the solutions for 6 and 7 from @MiloChen here. +F # | 0 | 2 bytes +T # | 1 | 2 bytes T+T # | 2 | 3 bytes T+T+T # | 3 | 5 bytes T+T+T+T # | 4 | 7 bytes T+T+T+T+T # | 5 | 9 bytes nrow(BOD) # | 6 | 9 bytes cars$s[pi]           # | 7     | 10 bytes
cars$s[pi]+T # | 8 | 12 bytes (pi*pi)%/%T # | 9 | 11 bytes (pi*pi)%/%T+T # | 10 | 13 bytes (pi^pi+pi+pi)%/%T # | 42 | 17 bytes # | total | 100 bytes  This saves some bytes compared to the 123 and 165 solutions. ## Hoon, 89 bytes @& @| +(|) +:!=(+) +:!=(-<) +:!=(->) +:!=(+<) +:!=(+>) +:!=(-<-) +:!=(-<+) +:!=(->-) +:!=(->->-)  0 is just "yes" (0) casted to an atom 1 is just "no" (1) casted to an atom 2 is incremented "no" - .+ automatically casts to an atom, so no need for @ 3 - 42 are the fun ones: It's using the != rune, which compiles an arbitrary Hoon expression to Nock. In this case, it's compiling axis navigation syntax into the Nock expression [0 axis], which I then take the tail of with +:expr. In Hoon, all variable accesses are actually just indexing into a binary tree, and it allows you to index manually as well. The syntax is alternating sets of -/+ and </>, each one being head/tails for the current node. I also use +axis, which is a bit shorter for 8, 9, and 42. • 8, 9, 42: Wouldn't that be literal numbers? – Adám Mar 3 '16 at 12:04 • Nope. They aren't literals, you can't cast them to numbers. If you ran +1 in the Hoon repl, it evaluates to the value at the top of the context the same way that - does. The only reason I'm able to get the number out of it is by compiling the code to the equivalent of Assembly and pulling the axis out of the formula. – RenderSettings Mar 4 '16 at 14:52 • I still think this is questionable. Can you get any number with the incantation +:!=(+​…)? – Adám Mar 7 '16 at 13:16 • Yes, the same way that you can get any number by pulling the index that -<- snippets compile to. Think of it more as compiling C "a=1; &a" and grabbing the index the mov is pulling from. Since all Hoon compiles down to (Nock)[github.com/urbit/urbit/blob/master/Spec/nock/5.txt], which is entirely based on tree indicies and a state machine over natural numbers, I think it's perfectly fine to grab numbers from the output. I could change it back to tree navigation syntax for 8/9/42, but it's the exact same emitted Nock code and means the same thing. It's just marginally shorter for them. – RenderSettings Mar 7 '16 at 18:42 • I think literal tree navigation would be more in the spirit of the OP. Otherwise, one could argue that 10 should be valid, because ceil(square(pi())) would evaluate to 10 anyway. – Adám Mar 7 '16 at 18:50 # Jolf, 26 bytes <empty> lέ lq mfπ Uά ½t mfτ mΓCt wwt wt t mQ  Okay, so I have a 42-builtin. I'm obsessed with that number. Also for forty-two, lm,t: the length of the integer partitions of ten. ## Explanations The empty program is a truth machine, and, since given no input, just output's a zero. lέ is the length of a tab, i.e., 1. lq is the length of the source code, i.e., 2. mfπ is the floor of pi, i.e., 3. Uά is the square root of 16, i.e., 4. ½t is half ten, i.e., 5. mfτ is the floor of tau (i.e. twice pi), i.e., 6 mΓCt is the length of the collatz sequence beginning with ten, i.e. 7. wwt is 10-1-1, i.e., 8. wt is 10-1, i.e., 9. t is 10. mQ is the builtin for 42. # Alternate solution Except for 0 and 10, a solution with @<char with charcode value of N> would be golfier solution for N, however, even though it doesn't use any literals (it actually reads the source code's next character), it isn't in the spirit of the challenge. This would tally 20 bytes. • Why is there a built in for 42? – Cyoce Aug 26 '16 at 21:12 • @Cyoce "Okay, so I have a 42-builtin. I'm obsessed with that number" ;) – Conor O'Brien Aug 26 '16 at 21:33 ## Ruby, 194 bytes []<=>[] [[]].size [[],[]].size Dir.name.size Hash.name.size Float.name.size Method.name.size Integer.name.size NilClass.name.size TrueClass.name.size FalseClass.name.size Integer.name.size*Method.name.size  # J, 4643 42 bytes Thanks to Nᴮᶻ for the help and exploration! %_ NB. Inverse of infinity _. NB. Indeterminate value, evaluates to 1 2:_ 3:_ 4:_ 5:_ 6:_ 7:_ 8:_ 9:_ +~5:_ NB. verb magic (7:*6:)_ NB. 7 * 6  Here are some other programs: (number): (representation) 1: *_ NB. signum of infinity same bytes 1: #a: NB. The tally of the Ace/Empty box +1 byte 1: 1:_ NB. The constant function with infinity; +1 byte 2: #__ NB. The tally of infinity gerund-ed with itself +1 byte 2: #_,_ NB. (same) +1 byte 2: #_;_ NB. (same) +1 byte 42: (*:+])6:_ NB. verb magic / 6 squared plus 6 +1 byte 42: +:<.o.7:_ NB. double floor pi times 7 +1 byte 42: <.(#a.)%6:_ NB. Tally of alphabet (256) divided by 6 (6:_) floored (<.); +3 bytes 42: a+*~(a=:6:_) NB. 6 squared plus 6. +4 bytes 42: (a=:6:_)+:*a NB. 6 squared plus 6. +4 bytes 42: #C.>.%:^@^2:_ NB. I'm not entirely sure how this works +5 bytes  • That's really neat. – Adám Mar 1 '16 at 20:31 • But then I'm using the literal 7 at the end. – Conor O'Brien Mar 1 '16 at 21:56 • 6 squared plus 6: (*:+])6:_ – Adám Mar 1 '16 at 22:42 • Another alternative for 42: 7 squared minus 7 (*:-])7:_ – M L Mar 11 '16 at 22:43 • @LeakyNun 7:_ is a function, which just happens to have a digit in its name. Here, it takes infinity (_) as argument, and returns seven. There is no function called 17:. Compare to TI-BASIC's 10^( which is a single-byte function with a funny name. – Adám Aug 23 '16 at 6:08 ## Perl6 (117 112) no state e-e e/e e.floor e.round pi.ceiling floor e+e tau.floor tau.ceiling floor pi*e floor pi*pi round pi*pi tau.floor*tau.ceiling  ## BASH, 318 bytes 0 to 3 are exit code, other ones are stored in A bytes count is split as follow :2-5-5-26-23-32-26-38-26-33-32-70 #0 ls #1 cd \\ #2 ls \\ #3 cd \\ A=$?
A=$(($A+$A+$A))
#4
ls \\
A=$? A=$(($A*$A))
#5
cd \\
A=$? A=$(($A+$A+$A+$A+$A)) #6 ls \\ A=$?
A=$(($A+$A+$A))
#7
cd \\
A=$? A=$(($A+$A+$A+$A+$A+$A+$A)) #8 ls \\ A=$?
A=$(($A*$A*$A))
#9
A=$? A=$(($A+$A+$A)) #10 ls \\ A=$?
A=$(($A+$A+$A+$A+$A))
#42
@
A=$? cd \\ B=$?
cd \\
C=$? C=$(($C+$C+$C)) B=$(($A-$B))
A=$(($B/$C))  7 is more than probably golfable a bit more, as is 42 • Can't you mix operations like + and *? – Adám Aug 26 '16 at 14:07 • I don't think so sadly, the only one where it could be useful is 7 and it need +4 for parenthesis to only remove 3 (the last +$A) – Sefa Aug 26 '16 at 14:32

# Haskell, 133 bytes

Pi-based, three floating point answers with the rest being integers:

 0: (5)  pi-pi
1: (5)  pi/pi
2: (10) (pi+pi)/pi
3: (8)  round pi
4: (10) ceiling pi
5: (15) succ.ceiling$pi 6: (11) floor$pi+pi
7: (13) ceiling$pi+pi 8: (16) floor$cosh pi-pi
9: (11) floor$pi*pi 10: (11) round$pi*pi
42: (18) floor\$pi**pi+pi+pi


## Racket 205 bytes

(- pi pi)
(/ pi pi)
(/(+ pi pi)pi)
(floor pi)
(ceiling pi)
(sub1(floor(+ pi pi)))
(floor(+ pi pi))
(ceiling(+ pi pi))
(floor(sub1(* pi pi)))
(floor(* pi pi))
(ceiling(* pi pi))
(floor(+ pi pi(expt pi pi)))


Output:

0.0
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
42.0


# Processing, 65 44 bytes

X
Y
Z
HSB
Z*Z
LINES
HSB*Z
TAB-Z
MITER
X+TAB
-~TAB
BOX+Y


### Explanation

Using the hint from the question, I decided to use Processing constants to produce these numbers. These constants contain a numerical value. So to gather them, I used PConstants.java.

Here is the list of all the constants I used:

X      == 0
Y      == 1
Z      == 2
HSB    == 3
LINES  == 5
MITER  == 8
TAB    == 9 (char)
BOX    == 41


After this, all that was left for me to do is to choose the combinations of these constants that produce the numbers 1 to 10 and 42. Finally, I ended up with these:

println(X);//0
println(Y);//1
println(Z);//2
println(HSB);//3
println(Z*Z);//2 * 2 = 4
println(LINES);//5
println(HSB*Z);//3 * 2 = 6
println(TAB-Z);//9 - 2 = 7
println(MITER);//8
println(X+TAB);//0 + 9 = 9
println(-~TAB);//-~9 = 10
println(BOX+Y);//41 + 1 = 42


Several notes:

TAB has a char value of 9, meaning that if I print TAB, I print a literal tab. So to convert it to an int, I just add 0 to it.

And that's it!

### Edit

I discovered PConstants.java. It appears to contain all of the constants that exist in Processing. All that research I did is on the Processing Reference is not needed anymore. Time to cut down on the bytes :)

# dc, 44

Score does not include newlines between each snippet.

If CJam's U, X, Y, Z, and A constants are allowed, then I assume dc's representation of 10-15 as A-F is also OK.

z
zZ
CI-
DI-
EI-
FI-
II+E-
II+D-
II+C-
II+B-
A
IB+CI-*


@yeti's answer is better.

• "Make 12 snippets/expressions..." - I don't think the print command counts in "snippet length". – user19214 Dec 17 '15 at 21:57
• @yeti yes, I see. Oh well, looks like you have me beat handily anyway. – Digital Trauma Dec 17 '15 at 22:01
• I started without using A...F and then saw your comment about A...F. So your solution influenced mine.... e.g.: 42 was IIZd+*dZ+ initially... – user19214 Dec 17 '15 at 22:02
• Can A F be used as part of a single number, or only stand-alone? – Adám Dec 21 '15 at 14:11
• 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 9:27

# beeswax, 50 46 bytes

(62 57 bytes, if IPs are not initialized)

Explanation of instructions:

P    increment top lstack value
M    decrement top lstack value
z    all lstack values = 0
F    all lstack values = top
G    get value from absolute(row,column) = lstack(2nd,3rd) value.
@    flip 1st and 3rd lstack values
.    top=top*2nd value
+    top=top+2nd value
!    bitwise NOT
(bel) ASCII control character 7, not printable


Instructions for number creation without using numbers, with multiple examples, if the byte lengths are the same. Prepend z if the bee is not in an initialized state:

 initialized  to 0                         not initialized to 0
prepend z
no instruction              [0,0,0]•       z
P                           [0,0,1]•       zP
PP                          [0,0,2]•       zPP
PPP                         [0,0,3]•       zPPP
PPF. or PPPP or PPF+        [0,0,4]•       zPPF.
PPF.P or PPF+P or PPPPP     [0,0,5]•       zPPF.P
PPPF+ or PPF++ or PPFP.     [0,0,6]•       zPPPF+
PPPF+P or PPF..M            [0,0,7]•       zPPF..M
(bel)*1FG                   [0,0,7]•  ← this would make ‘7’ one byte shorter
PPF..                       [0,0,8]•       zPPF..
PPPF.                       [0,0,9]•       zPPPF.
PPPF.P                      [0,0,10]•      zPPPF.P
*PFG                        [0,0,42]•      *PFG (in this configuration the IP is always initialized)


You can clone my beeswax GitHub repository here.

# Staq, 60 bytes

&              0
&i             1
&ii            2
&iii           3
&iiq           4
&iiqi          5
&iiqii         6
&iiiqdd        7
&iiiqd         8
&iiiq          9
&iiiqi        10
&iiqii&+qX+   42


Instructions:

& push 0 on top of stack
i increment top stack value
d decrement top stack value
q square top stack value
+ add top and 2nd stack values, put sum on top of stack
X delete 2nd stack value