167
\$\begingroup\$

Challenge:

Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer 1, the second one 2 and so on.

You can not reuse any characters between the programs. So, if the first program is: x==x, then you may not use the characters x and = again in any of the other programs. Note: It's allowed to use the same character many times in one program.

Scoring:

The winner will be the submission that counts the highest. In case there's a tie, the winner will be the submission that used the fewest number of bytes in total.

Rules:

  • You can only use a single language for all integers
  • Snippets are allowed!
  • To keep it fair, all characters must be encoded using a single byte in the language you choose.
  • The output must be in decimal. You may not output it with scientific notation or some other alternative format. Outputting floats is OK, as long as all digits that are shown behind the decimal point are 0. So, 4.000 is accepted. Inaccuracies due to FPA is accepted, as long as it's not shown in the output.
  • ans =, leading and trailing spaces and newlines etc. are allowed.
  • You may disregard STDERR, as long as the correct output is returned to STDOUT
  • You may choose to output the integer to STDERR, but only if STDOUT is empty.
  • Symbol independent languages (such as Lenguage) are disallowed
  • Letters are case sensitive a != A.
  • The programs must be independent
  • Whitespace can't be reused
  • You must use ASCII-digits in the output

Explanations are encouraged!

\$\endgroup\$
13
  • 4
    \$\begingroup\$ The language Headsecks only cares about the lower three bits of every character and would trivially achieve a score of 64. It's partially symbol-independent, but not completely. I think the last rule should cover partially symbol-independent languages as well, but I'm not sure how to phrase it. \$\endgroup\$ – Dennis Jun 4 '17 at 22:45
  • 1
    \$\begingroup\$ Regarding the snippet rule, do we still need to include usings/imports? And are static imports allowed (without making them part of the snippet that is)? \$\endgroup\$ – Kevin Cruijssen Jun 6 '17 at 17:45
  • 1
    \$\begingroup\$ @KevinCruijssen you can omit boilerplate stuff that's needed for every programs/functions. For instance, you don't need #include <iostream> and other boilerplate stuff in C++. You do need from numpy import *. Note: I'm not a programmer, so I don't know all the nuances. We can discuss in chat if something is unclear :) \$\endgroup\$ – Stewie Griffin Jun 6 '17 at 18:05
  • 1
    \$\begingroup\$ You have the right to vote however you like @tuskiomi, but in my opinion it's a good rule. Whitespace characters are just bytes, just as any other character. Why should they be treated differently? Also, the language Whitespace would win by a landslide, since it contains only space, tab and line shift. Thanks for saying why you downvoted though :-) \$\endgroup\$ – Stewie Griffin Aug 18 '17 at 17:31
  • 1
    \$\begingroup\$ @StewieGriffin I would at least allow spaces, but hey, I'm not you. \$\endgroup\$ – tuskiomi Aug 18 '17 at 18:30

67 Answers 67

4
\$\begingroup\$

Braingolf, score 14, 81 bytes

1-  ^
2-  2
3-  3
4-  4
5-  5
6-  6
7-  7
8-  8
9-  9
10- "
    "
11- llllllllllll
12- VR# d<Mv/_R_
13- 111-1-1-1-1-1-1-1-1-1-1-1-1--
14- H.............&+

Characters used: 123456789^"e\nJ-+lVR# d<Mv/_&

Things to note that might be useful:

P can also be used at the start of a program to push a 1, as an empty stack is considered palindromic (does the same thing as H)

Main issue with this is + has already been used, and I can't think of any other way in Braingolf to turn any amount of 1s into anything higher than 1

Explanation:

1

^  
^   niladic exponentiation, 0^0.
    This is undefined mathematically, however python, in which
    Braingolf's interpreter is written, returns 1
    implicit output of last item on stack

2-9

2    push integer literal
     implicit output of last item on stack

10

"\n"  push charcode of newline, 10
      implicit output of last item on stack

11

llllllllllll
l             push length of stack (0)
 l            push length of stack (1)
  .........l  push length of stack (11)
              implicit output of last item on stack

12

VR# d<Mv/_R_
VR            create stack2 then return to stack1
  #<space>    push 32
    d         split 32 into 3, 2
     <        move first item to end of stack
      M       move last item to stack2
       v      switch to stack2
        /     monadic division, always returns 1
         _    print last item on stack (1)
          R   return to stack1
           _  print last item on stack (2)

13

111-1-1-1-1-1-1-1-1-1-1-1-1--
111                            Push 3 1s [1, 1, 1]
   -                           Subtract last 2 items [1, 0]
    1-                         Push 1 and subtract [1, -1]
      1-1-1-1-1-1-1-1-1-1-1-   Push 11 more 1s and subtract each one [1, -12]
                            -  Subtract [13]
                               implicit output of last item on stack

14

H.............&+
H                 Push 1, empty stack is always palindromic
 .............    Duplicate the 1 13 times, stack now has 14 1s
              &+  Sum entire stack
                  implicit output of last item on stack
\$\endgroup\$
3
  • \$\begingroup\$ Using two digits in the same entry seems like a waste. What about doing 10 as "<newline>", 9 as 9, and 13 as 1111111111111++++++++++++? \$\endgroup\$ – Ørjan Johansen Jun 6 '17 at 21:01
  • \$\begingroup\$ Or alternatively 111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-- if you have more use for the + elsewhere. \$\endgroup\$ – Ørjan Johansen Jun 6 '17 at 21:08
  • \$\begingroup\$ @ØrjanJohansen Oh wow, thanks! \$\endgroup\$ – Skidsdev Jun 7 '17 at 8:17
4
\$\begingroup\$

Forth, score 10 11 12 13 14, 196 bytes

Tokens are case-insensitive, which helps a bunch. Also, TIO allows a bunch of different whitespace characters as token separators.

1

j
j
j
<
>
abs

2 - 14

J	J	=	J	J	=	-	J	J	=	-	J	J	=	-
3
4
5
6
7
8
9
0xA
11
222222+++++
I I / I I / LSHIFT I I / LSHIFT I I / LSHIFT I I / I I / LSHIFT I I / LSHIFT I I / OR OR
kkkkkkkkkkkkkkdepth

Try it online - slightly weird/inconvenient. And #14 uses stack depth, so it must occur after printing the others.

Explanation:

    1. Use some comparisons to obtain True, which evaluates to -1, then take the absolute value. See #2 for a description of j. This uses linefeeds to separate the tokens.
    1. J is a loop counter, used for inner loops, and is also some large number when not inside a user-defined loop. Checking if it equals itself returns -1 (True). Using subtraction, I obtain 2. This uses tabs to separate the tokens.
    1. This uses vertical tabs
      
      (ASCII 11) to separate the tokens. See the TIO link.
    1. I pushes the loop counter, which is some large unknown number when outside a loop. Divide it by itself to get 1. I use bit-shifting with lshift and OR.
    1. Push k, another loop counter, a bunch of times, then get the stack depth. This uses form feeds (ASCII 12) to separate the tokens. Select the line to see there are actually characters there. Using shift + arrow keys while having the line selected will show that there is an invisible character after each k.

I can lower the byte count by using more unique bytes (like *), but for the moment I'm going to use as few unique bytes as possible.

\$\endgroup\$
4
  • \$\begingroup\$ Can you use something like variable v v @ v @ = negate for 1, freeing 1 up for 11? \$\endgroup\$ – Neil Jun 7 '17 at 10:05
  • \$\begingroup\$ @Neil I found some better options. I don't know if there are enough whitespace characters left to use as token separators. \$\endgroup\$ – mbomb007 Jun 7 '17 at 16:54
  • \$\begingroup\$ Great! I like to think I got you thinking anyway, even if you didn't use my specific suggestion. \$\endgroup\$ – Neil Jun 7 '17 at 19:51
  • \$\begingroup\$ @Neil I did use it in an older revision, but it wasn't long before I changed to using I I /. \$\endgroup\$ – mbomb007 Jun 7 '17 at 21:48
4
\$\begingroup\$

MarioLANG, score 2, 3+925 bytes

It's-a-me, Mario.

1 :

    +
    :

I can count 1 when I see a +, adding 1 to cell0 (which contains 0 by default) and : prints the content of current cell as a number to STDOUT. Then I fall to death. Mamma mia! Kill me online!

2 :

    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    .


With my second life, I can count 2 by -ing on cell0 which goes to 255... then fall to death again :( viewing many many -s during the fall... down to char 2, then . prints the content of current cell to STDOUT as a char. Kill me again!

Since this language has only two output methods, I don't think there is any way to count up to 3... Mario needs to improve.

\$\endgroup\$
1
  • \$\begingroup\$ (If I am right,) snippets are allowed, and you only need to return an integer. The output method does not matter. \$\endgroup\$ – user85052 Sep 14 '19 at 14:48
3
\$\begingroup\$

Jelly, score 22, 177 bytes

1: Ṇ  : logical NOT. When there is no input, 0 is assumed, so this returns NOT(0)=1
2: ~A~A  : ~ is bitwise NOT and A is absolute value, implicit 0 input
         : 0~ = -1;   0~A = 1;   0~A~ = -2;  0~A~A = 2.
3: 3  : literal 3
4: -ı-²²×-Ḟ:
   -ı-     : literal complex number -1-1j
   ²²×-    : square (2j), then square(-4), then multiply by (×) negative 1 (-) to get 4+0i
   Ḟ       : get the real component, which is 4
5: 5  : literal 5
6: 6  : literal 6
7: 7  : literal 7
8: 8  : literal 8
9: ØDṪ : tail(Ṫ) of list of digits (ØD) to return 9
10: ⁵  : literal 10
11: 11 : literal 11
12: CNCNCNCNCNCNCNCNCNCNCNC : again, 0 is taken as input because there is no input
                            : C is complement and N is negate
                            : so each NC returns 1-(-n)=n+1 and is equivalent to increment, returning 12
13: “>>>>>»L    : encodes "#GlomAbducens" with “>>>>>» then returns the length in characters (13) with L
14: ‘‘‘‘‘‘‘‘‘‘‘‘‘‘   : default input is 0 again, and each ‘ increments it to get 14
15: Ị;Ị;Ị;Ị;Ị;Ị;Ị;Ị;Ị;Ị;Ị;Ị;Ị;Ị;ỊS : default input is 0 again.
                                   : each Ị returns abs(0)<1 = 1
                                   : these are concatenated together with ; then summed with S to get 15
16: ⁴  : builtin literal 16
17: ,,,,,,,,,,,,,,,,,ŒḂŒḊ : Each , is the pair dyad: x,y = [x,y] and x,[y,z] = [x,[y,z]]. 
                          : Thus each , increased the depth by 1, then ŒḊ returns the depth: 17
18: 9Ḥ : 9 doubled = 18
19: E+E+E+E+E+E+E+E+E+E+E+E+E+E+E+E+E+E+E : each E returns areallelementsidentical([0]) = 1
                                          : 19 of these are summed with +
20: 44440b44ạ/ : 44440 base 44 = [22,42,0].
               : ạ/ takes the absolute difference of terms: ||22-42|-0| = 20
21: ”TOHH : ”T is the character literal "T". OHH returns its ascii value 84 (O) halved twice (HH) = 21
22: literal 22

Try all at once or Try one at a time (argument is which output you want).

Unused characters:

¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑÞßæçðȷñ÷øœþ !"#$%&'()*.:<=?@BFGIJKMPQRUVWXYZ[\]^_`acdefghijklmnopqrstuvwxyz{|}¶°¹³⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḲḶṂỌṚṢṬỤṾẈỴẒȦĊĖḞĠḢİĿṀṄȮṖṘṠẆẊẎŻḅḍẹḥịḳḷṃṇọṛṣṭụṿẉỵẓȧḃċḋėḟġḣŀṁṅȯṗṙṡṫẇẋẏż«’
\$\endgroup\$
3
  • \$\begingroup\$ You're using A for both 2 and 4, no? \$\endgroup\$ – Dennis Jun 3 '17 at 22:37
  • \$\begingroup\$ @Dennis My TIO link was correct, but my explanation was different. Fixed \$\endgroup\$ – fireflame241 Jun 3 '17 at 23:37
  • 1
    \$\begingroup\$ I see. Btw if you put 22¹£€Y in the main link, you can execute all snippets at once. tio.run/##y0rNyan8///hzjauOsc6Ry5jLt0jG3UPbTq0icuUy4zLnMuC6/… \$\endgroup\$ – Dennis Jun 4 '17 at 5:01
3
\$\begingroup\$

Java, 1 :(

public class P{ static{ System.out.println("1"); }}
\$\endgroup\$
1
  • 24
    \$\begingroup\$ Welcome to PPCG! Unless most other challenges, this challenge allows for snippets instead of full programs, so I think you can improve on the score. \$\endgroup\$ – Laikoni Jun 4 '17 at 16:37
3
\$\begingroup\$

dc, score 20, 102 bytes

I'm assuming since functions/snippets count and returned values count that leaving the value on the stack counts. Otherwise, since dc has no implicit print and four distinct print commands, the max would be 4. We'll expect a clear stack for each of these, though I guess it only matters for one. Several of these will pollute the stack; top of stack is the value.

1
OOOOO++++a
3
4
5
6
7
8
9
A
B
C
D
E
F
2dd^^
KKKKKKKKKKKKKKKKKz
.000000000000000000X
[,,,,,,,,,,,,,,,,,,,]Z
II-II-I-I--

1 and 3-9 should be obvious. Likewise A-F work for 10-15 regardless of input base. 50 is the code point for ASCII 2, so for 2 we add our output base (10) to itself until we get up to 50 and convert it with a. For 16, we do (2^2)^2. For 17, we use 17 Ks to put the default precision (0, but this number is irrelevant) on the stack and then count the stack depth (z). For 18, we use X to count the fractional digits in .000000000000000000. 19 is a string made up of 19 commas, and then Z returns the length of a string. Finally we do 20 by using I to get our input base (10), and essentially doing (10-10)-(((10-10)-10)-10) or 0-_20.

\$\endgroup\$
3
\$\begingroup\$

Pyt, score 18, 91 bytes

1: ⅕¬č
2: 2
3: 3
4: 4
5: 5
6: 6
7: ⅐π⁷∜Ř↑
8: 11+1+1+1+1+1+1+
9: φᵱ~˜²Á
10: 7⬡₉
11: é⁴ƖḋƩ
12: ½⅙*⅟
13: ⅓⅑÷řΠḞ
14: ¾⅛/Ŀ⁻⁻⁻⁻
15: 0!⁺⁺⁺⁺△
16: ⅝⅝-⅝-⌊Åᴇ9√Ṗ⇹-¼⅒≥-
17: ɳ₫Ħ
18: 8⬠₅

Explanation

1: ⅕¬č

Pushes 1/5

Takes the logical inverse of 1/5 (False)

Takes the cosine of that (1) [cos(False cast as an integer)=cos(0)=1]


2: 2

Pushes 2


3: 3

Pushes 3


4: 4

Pushes 4


5: 5

Pushes 5


6: 6

Pushes 6


7: ⅐π⁷∜Ř↑

Pushes 1/7

Pushes π

Raises π to the 7th power

Takes the fourth root of π^7

Pushes [int(1/7),...,int(π^(7/4))] (i.e., [0,1,...,7])

Returns the maximum of that array (7)


8: 11+1+1+1+1+1+1+

Adds eight ones together


9: φᵱ~˜²Á

Pushes φ (the golden ratio - (1+√5)/2=1.618...)

Gets the partition number of 1 (φ cast to an integer)

Negates [1]

Gets the unsigned two's-complement** of [-1] (3) [Due to a mistake in how I implemented this, (-1)˜ returns 3]

Squares [3]

Pushes elements of array onto stack (i.e., pushes 9)


10: 7⬡₉

Pushes 7

Pushes the 7th hexagonal number (92)

Divides by 9 (10) (Python 2-style integer division (i.e., 92/9=10))


11: é⁴ƖḋƩ

Pushes e

Raises e to the 4th power

Casts to an integer (54)

Gets the prime factorization of 54 ([2,3,3,3])

Sums the list (13)


12: ½⅙*⅟

Pushes 1/2

Pushes 1/6

Multiplies (1/12)

Takes the multiplicative inverse of 1/12 (12)


13: ⅓⅑÷řΠḞ

Pushes 1/3

Pushes 1/9

Takes the ceiling of 1/9 (1)

Calculates int(1/(1/3)) (3)

Pushes [1,2,3]

Takes the product of the elements in the list (6)

Returns the 6th Fibonacci number (13) (with F(0)=F(1)=1)


14: ¾⅛/Ŀ⁻⁻⁻⁻

Pushes 3/4

Pushes 1/8

Divides 3/4 by 1/8 (6)

Returns the 6th Lucas number (18)

Decrements 4 times (14)


15: 0!⁺⁺⁺⁺△

Pushes 0! (1)

Increments 4 times (5)

Returns the 5th triangle number (15)


16: ⅝⅝-⅝-⌊Åᴇ9√Ṗ⇹-¼⅕≥-

Pushes 5/8 twice

Subtracts 5/8 from 5/8 (0)

Pushes 5/8

Subtracts 5/8 from 0 (-5/8)

Floors -5/8 (-1)

Takes the absolute value (1)

Calculates 10^1 (10)

Pushes 9

Takes the square root (3)

Raises 3 to itself (3^3=27)

(The stack is now [10,27])

Flips the stack ([27,10])

Subtracts 10 from 27 (17)

Pushes 1/4

Pushes 1/10

Pushes 1/4>1/10 (True)

Subtracts 1 (True cast to an integer) from 17


17: ɳ₫Ħ

Pushes "0123456789"

Interprets as an integer and flips the digits (987654321)

Calculates the Hamming weight of 987654321


18: 8⬠₅

Pushes 8

Pushes the 8th hexagonal number (92)

Divides by 5 (again, Python 2-style integer division (92/5=18))


Try them all online!

\$\endgroup\$
5
  • \$\begingroup\$ I find ⅕ in both 1 and 16, ² in both 9 and 15, and Ʃ in both 11 and 16. \$\endgroup\$ – Ørjan Johansen Jan 21 '18 at 2:09
  • \$\begingroup\$ Lemme go fix those \$\endgroup\$ – mudkip201 Jan 21 '18 at 2:25
  • 1
    \$\begingroup\$ Okay, fixed. Now there shouldn't be any duplicates. \$\endgroup\$ – mudkip201 Jan 21 '18 at 2:36
  • 1
    \$\begingroup\$ Does Pyt use any non-accented letters? I don't think I've ever seen one used in a Pyt program before... \$\endgroup\$ – caird coinheringaahing Apr 11 '18 at 19:49
  • \$\begingroup\$ By design, it doesn't. \$\endgroup\$ – mudkip201 Apr 16 '18 at 16:21
3
\$\begingroup\$

Befunge-98 (PyFunge), score 20, 89 bytes

!
2
3
4
5
6
7
8
9
a
b
c
d
e
f
y\-.@
11111111111111111++++++++++++++++
'\x12
"\x13"
0gg0g###########################\x14

All are snippets except for 16, which is a full program. Some control characters are present, I've written them in the form \x?? here.

Explanations

1. !

Pop an implicit zero off the empty stack and perform a logical negation to get 1.

2. - 15.

Numeric literals

16. y\-.@

Full program. y is the "Get SysInfo" instruction. The first number dictates whether or not some of the Befunge-98 features have been implemented (details) - by default in PyFunge this is 15. The second number is the cell size in bytes, for which PyFunge returns -1, as it uses arbitrary precision integers. Swapping those numbers and subtracting them gives 16. .@ = output as number then exit.

17. 11111111111111111++++++++++++++++

A mysterious one.

18. '\x12

Pushes the code of character 18 onto the stack.

19. "\x13"

Pushes the string onto the stack. Strings actually get pushed backwards - do not be alarmed!

20. 0gg0g###########################\x14

g gets a character code by coordinates. The first g gets the character at (0, 0), which is 48, the next gets the character at (0, 48), which is 32 (by default, the plane is filled with spaces), and the third gets the character at (32, 0), which is the control character 20.

Unused characters

These are the remaining instructions, none of which appear very useful for creating numbers:

Control flow: <>^v? []_|@;hjklmtqrxz

Input/output: &~.,io

Arithmetic: */%w

Stack: $:un{}

Other: ()=spABCDEFGIHJKLMNOPQRSTUVWXYZ

Unrecognized instructions reflect the IP (yet another control flow operation).

\$\endgroup\$
3
\$\begingroup\$

Wolfram Language (Mathematica), score 16

#&'
Floor@E
3
4
5
6
7
8
9
DDD=(DD(DD)DD(DD)DD(DD)DD(DD)DD(DD))~D~DD;DD=D~D~D;DDD
11
0!+0!+0!+0!+0!+0!+0!+0!+0!+0!+0!+0!
-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I
Sum[u	u,{u,Pi}]
L|L|L|L|L|L|L|L|L|L|L|L|L|L|L//Length
2 2 2 2

Try it online!

Characters used: !#&'()*+,-/0123456789;=@DEFILPS[]eghilmnortu{|}~

1: #&'
Derivative of the identity function: the constant function that returns 1

2: Floor@E
\$\lfloor e\rfloor\$, where \$e\approx2.7183\$

3-9, 11: Literals

10: DDD=(DD(DD)DD(DD)DD(DD)DD(DD)DD(DD))~D~DD;DD=D~D~D;DDD
\$\frac{\mathrm d}{\mathrm d\textit{DD}}(\textit{DD}^{10})|_{\textit{DD}=\frac{\mathrm dD}{\mathrm dD}}=10(1)^9\$

12: 0!+0!+0!+0!+0!+0!+0!+0!+0!+0!+0!+0!
Add \$0!=1\$ twelve times

13: -I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I-I*I
Subtract \$i*i=-1\$ thirteen times

14: Sum[u u,{u,Pi}]
\$\sum_{u=1}^\pi(u\,u)\$.
Takes \$u\$, incrementing by 1, while \$u\le\pi\$, so the sum is equal to \$1^2+2^2+3^2=1+4+9\$

15: L|L|L|L|L|L|L|L|L|L|L|L|L|L|L//Length
Length (number of arguments) of Alternatives[L,L,...L] (15 Ls in this case)

16: 2 2 2 2
Product of four 2s

\$\endgroup\$
3
+50
\$\begingroup\$

Factor, 12 bytes, score 2

1 .
"2"print

Try it online!

I don't think we can go further :-(

Explanation

1        # Push 1 to the stack
.        # Pops one input from stack
"2"      # Push "2" to stack
print    # Print to STDOUT
\$\endgroup\$
1
  • \$\begingroup\$ Looks familiar... \$\endgroup\$ – hdrz Mar 25 at 14:35
2
\$\begingroup\$

Jelly, score 13, 36 bytes

1
2
3
4
5
6
7
8
9
10 : ⁷ŒṘLRS
 This gets the literal `'\n'`, gets the length (4, incl quotes), generates a list (`[1, 2, 3, 4]`) and sums all elements.

11 : ⁴ḤÆC
This doubles (`Ḥ`) 16 (`⁴`), then counts all primes less than that (which is 11).

12 : ³DIAU‘V 
This takes 100 (`³`), gets the absolute increments between digits (`DIA`, results in `[1, 0]`), reverses the list, increments all elements and makes a string out of it with `V` (technically, it evals the list `[1, 2]` and feeding Jelly numbers just makes it print 'm as literals).

13 : ⁵+⁵’’’’’’’ 
This just is 10+10-7.

Try it online

\$\endgroup\$
0
2
\$\begingroup\$

Turtlèd, score 4, 11 bytes

(I got it lower with snippets but then it made the task trivial(er) (answers just being digits) so I rolled it back)

'1
"2
@3,
#4#.

commands explanation:

' - writes to the grid the next character

" - writes to the grid all the characters to the next ", or end of program

@ - sets the char var to the next character in program

, - write the char var on the grid

#foo# - set the string var to foo

. - write the pointed char of the string var. initially the first char

Test them here

\$\endgroup\$
2
\$\begingroup\$

Aceto, score 12 14 16 18 19

The multi-character-snippets are given here in linear form for space reasons.

pi is more than 0; cast to float:

Pwf

Just push the corresponding number:

2
3
4
5
6
7
8
9

Convert the implicit 0 to a character (\0x0), then to a boolean (True), then push it on the stack to the right. Move to the left stack and push a zero back on the main stack (and go there). Go to the right stack, and turn on sticky mode, then move the True back to the main stack twice (and go there). Multiply True with True (1), then implode the string. Because this is quite big, I show it here in the "real" 2D form:

)k*£
]{[
(}
cb

Push 1 twice, then implode:

11¥

Negate the implicit zero (True), push another zero and negate it (True, True), bitwise shift (2), push another 0 and negate it (2, True), cast to integer (2, 1), join top two values as strings ("12"), cast to integer (12):

!0!«0!iJi

Invert the zero (-1), negate it (1), duplicate it twice (1, 1, 1), sum up (1, 2), duplicate (1, 2, 2), sum up (1, 4), duplicate (1, 4, 4), sum up (1, 8), swap (8, 1), duplicate four times (8, 1, 1, 1, 1, 1), sum up all (13):

a~dd+d+d+sdddd+++++

Push a Shift-Out character literal, convert to its codepoint (^N stands for the character at ASCII codepoint 14):

'^No

Push a random number 15 times, then push the stack length:

RRRRRRRRRRRRRRRl

Push e 3 times and integer-divide twice. Do this three times. Then do exponentiation twice:

eee//eee//eee//FF

Decrement 17 times, then absolute value:

DDDDDDDDDDDDDDDDD±

Equality of zero and zero. Memorize this. Load it 18 times. Continue subtracting and queueing (move a value from the bottom of the stack to the top), until we arrive at negative 18, memorize this, load and subtract, load and subtract. Because this is quite big, I show it here in the "real" 2D form:

L-Q-Q-Q-
LQ-Q-Q-Q
LLQ-Q-Q-
LL-Q-Q-Q
LLLLQ-Q-
LLLL-Q-Q
MLLLQ--
=LLL-ML

Increment 19 times:

IIIIIIIIIIIIIIIIIII

Characters still left:

  • 2D movement (assumed useless): <>^vNSEW|_#
  • I/O and unreliable things: ™τ,prtT?
  • Stack operations: ø
  • jumps: $@&j§
  • rest: "%.:;ABCGHKOUVXYZ\`ghkmnquxyz»×€∑

Ideas:

  • Do something with the range commands (e.g. 3z** for 6)
\$\endgroup\$
2
\$\begingroup\$

C#, 12 (35 bytes) 13 (74 68 62 bytes)

Math.E/Math.E
2
3
4
5
6
7
8
9
-~-~-~-~-~-~-~-~-~-~new long()
11
0xC
'N'%'A'

Try it here.

  • Math.E divided by itself results in 1
  • new long() is 1, and the -~s increases this to 10
  • 0xC is hexadecimal for 12
  • 'N' = 78 and 'A' = 65, and 78 modulo 65 is 13
\$\endgroup\$
2
\$\begingroup\$

Perl 5, score 19, 234 bytes

Whilst some of the items are the same as @Full Decent's answer I added many and didn't utilise the fact that $_ would be preinitialised to a value because of the script being executed.

Note: for 10, that is a literal newline in the quotes.

__LINE__
2
3
//- -//- -//- -//
int$]
6
7
8
9
ord"
"
11
m<>+m<>+m<>+m<>+m<>+m<>+m<>+m<>+m<>+m<>+m<>+m<>
(555555555555&555555555)%55
push@W,W,W,W,W,W,W,W,W,W,W,W,W,W,W
0xF
4*4
VQ^gf
yyyyyyyyyyyyyyyyyy=~y~y~~
eval''.eval''.lc'MAP{P}H..Z'
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Very fun! What a solid answer. \$\endgroup\$ – William Entriken Aug 23 '17 at 3:04
2
\$\begingroup\$

Ruby 1.8.7, 12 13 14 15

Ruby's strict typing makes this one pretty difficult...

+1 number from GB.

$$**($$-$$)
2
%q{%d}%Math::PI
4
5
6
7
8
9
"size..size".size
11
3+3+3+3
?\r
'==============~'=~/~/
0xF
\$\endgroup\$
8
  • 8
    \$\begingroup\$ I'm not familiar with Ruby. What's the reason for using 8 to make 2 and 2 to make 8? \$\endgroup\$ – D Krueger Jun 5 '17 at 12:27
  • \$\begingroup\$ @DKrueger I was messing around with my numbers so much that it eventually ended up that way, but is completely unnecessary. \$\endgroup\$ – Value Ink Jun 5 '17 at 18:24
  • \$\begingroup\$ in REPL the value of $. is 1, then you could use the =~ operator to make 15 (like 'verylongstring'=~/x/) \$\endgroup\$ – G B Jun 6 '17 at 10:54
  • \$\begingroup\$ @GB Using $. robs me of using .size for 14. Although, I just realized that I'm doing a lot of unnecessary stuff in my calculation of 1. \$\endgroup\$ – Value Ink Jun 6 '17 at 18:49
  • \$\begingroup\$ Maybe using $$**($$-$$) for 1 can help? \$\endgroup\$ – G B Jun 7 '17 at 8:16
2
\$\begingroup\$

Brain-Flak, score 1, 2 bytes

()

Try it online!

Snippet that evaluates to 1. You can't go any further.

\$\endgroup\$
3
  • \$\begingroup\$ 10/10. or really (()()()()()()()()()())/(()()()()()()()()()()) \$\endgroup\$ – Christopher Aug 20 '17 at 22:39
  • \$\begingroup\$ @2EZ4RTZ / isn't something Brain-Flak has... \$\endgroup\$ – Erik the Outgolfer Aug 21 '17 at 8:14
  • \$\begingroup\$ As in 10 out of 10. \$\endgroup\$ – Christopher Aug 21 '17 at 11:49
2
\$\begingroup\$

Implicit, score 18, 118 bytes

ö
###
3
2^
5
6
7
8
9
10
la-
zA/zA/zA/zA/zA/zA/zA/zA/zA/zA/zA/zA/Þ
OB_
..............
óóóóóóóóóóóóóóó]
4*4
ìé%éééééé
=:+:::::::::++++++++

All these rely on implicit output.

  1. ö pushes iswhole(input). Input is 0 when the input field is left blank, and 0 is whole.
  2. ### pushes the length of the stack, then the length of the stack, then the length of the stack.
  3. 3 pushes 3.
  4. 2^ pushes 2 and squares it..
  5. 5 pushes 5.
  6. 6 pushes 6.
  7. 7 pushes 7.
  8. 8 pushes 8.
  9. 9 pushes 9.
  10. 10 pushes 10.
  11. la- pushes the character codes for l and then a and subtracts them.
  12. zA/ yields 1, repeated 12 times yields a stack with 12 instances of 1. Þ sums them all.
  13. OB_ pushes the character codes for O and B and performs modulo on them.
  14. .............. increments 0 14 times.
  15. óóóóóóóóóóóóóóó] increments the notepad 15 times and pulls it.
  16. 4*4 pushes 4, multiplies it by 4.
  17. ìé%éééééé pushes 0 as a string, increments all char codes by 1, prints, increments by 6.
  18. =:+:::::::::++++++++ pushes 1, duplicates, adds, then does a bunch of duplication/addition.
\$\endgroup\$
2
\$\begingroup\$

Julia 0.7/0.6, Score: 13 (83 bytes)

pi\pi
T=[true true]*[true;true];T[true]
3
4
5
gamma(2^2)
7
8
9
0xA|0
11
6+6
'O'-'B'

Obtains 2 via matrix multiplication of Booleans. For 6, we use the gamma (Γ) function (gamma(n) == factorial(n-1)). For 10, 0xA has to be |-ed with 0 since we want the output in decimal notation, not hexadecimal.

I wrote it for Julia 0.7, but it works in Julia 0.6 too without a hitch.

Let me know if there are ways to go beyond 13 (or if I've made some mistake by repeating a character anywhere here).

\$\endgroup\$
2
\$\begingroup\$

JavaScript (ES7), score 17

Credits to ETHproductions and darrylyeo.

""**""
Math.E|NaN
3
C=CSS==CSS;C<<C<<C
5
6
7
8
9
++[[]][+[]]+[+[]]
11
4444444444444444444%44
222>>2>>2
`${{}&{}}xe`&`${{}&{}}xe`
0XF
((((((((((((((((~URL)^(~URL/~URL))/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL^~URL)/~URL
- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''- -!''
\$\endgroup\$
5
  • \$\begingroup\$ Very impressive. Let's see... Math.E|NaN could be Math.E|Math, and all of the {}s would be /~/ (and you don't need the two innermost pairs of parens). Sorry if this isn't really helpful, I'm in golf-the-charset mode :P \$\endgroup\$ – ETHproductions Jun 4 '17 at 19:29
  • \$\begingroup\$ You could probably save a gajillion bytes if you swapped 4 and 16, btw \$\endgroup\$ – ETHproductions Jun 4 '17 at 19:30
  • \$\begingroup\$ Oh wait, you're using . in both 2 and 14 :( \$\endgroup\$ – ETHproductions Jun 4 '17 at 19:31
  • \$\begingroup\$ Ah... that needs to be fixed. \$\endgroup\$ – GOTO 0 Jun 4 '17 at 19:34
  • \$\begingroup\$ @JoKing Oops! Fixed. \$\endgroup\$ – GOTO 0 Jul 17 '18 at 20:48
2
\$\begingroup\$

05AB1E, score 48 49, 685 bytes

X
Y
žqò
4
5
6
7
8
9
T
11
∞ćìć
≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ≠≠ˆ¯≠≠βΩ
ŽŽŽttî
¶∊∊∊¶¢
‹oooo
AaĆĆĆAaĆĆ&R
‘I‘C
@ØØØ
›°°x
•L
22
Ê>>>>>>>>>>>>>>>>>>>>>>>
‚‚˜œāθ
₅Ô
₂
$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—$—O
₁hhhh
0±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä±Ä
’U’Î\ö
₄;;;;;ï
Q·····
33
dd+++++õdd+õdd+
¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¾
₆
ËŠËŠËJf`
ªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªvN
šššššššššššššššššššššššššššššššššššššššg
ĀD(-D(-D(-DD(-D(-(-
“ÙÙÙÙÙÙk““k“k
”*”ÇM
Ƶó¦
®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®®Æ
__ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ)ƶ¤
ΘÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
₃<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
тÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
' HÂ

Try it online!

Still improvable, but 48 is enough to beat Jelly's 47.

The test bench messes up snippet 40, so here's 40 as a standalone program.

\$\endgroup\$
1
\$\begingroup\$

Pyth, score 18, 207 bytes

.!0
2
3
4
5
6
7
8
C\  
T
11
s[JsP9J
++++++++++++KqkkKKKKKKKKKKKK
-------------gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ_gZZ
hhhhhhhhhhhhhh!Y
yyyy^>bb>bb
a<ddttttttttttttttttt<dd
l"llllllllllllllllll

Test suite

Any help welcome although I won't respond immediatly, so feel free to edit.

\$\endgroup\$
1
  • \$\begingroup\$ @totallyhuman Or maybe even l"llllllllllllll \$\endgroup\$ – Okx Jun 4 '17 at 9:32
1
\$\begingroup\$

Chip, score 1

t*ae*f

Yep, only 1.

The above code (plus at least one of the flags -w, -z, or -o) outputs the value 0x31, which is the ascii code point for the digit '1', then terminates itself:

t        If active, terminate execution after printing the current output byte
 *       Activate neighboring elements
  a      If active, set output bit 0x01 to 1
   e     If active, set output bit 0x10 to 1
    *    Activate neighboring elements
     f   If active, set output bit 0x20 to 1

Since e and f are required in order to output every digit (as they are the only way to set those bits), we can't go any higher than a single digit.

\$\endgroup\$
1
\$\begingroup\$

Fission 2, Score: 2, 10 bytes

1: R'1!;

2: *"2"L

Try it online!

As far as I know, this is as high as you can possibly get in Fission, as the program has to start at one of RLUD characters, and you have to use " or ! to output

In hindsight this can probably be improved by taking advantage of Snippets are allowed!

Explanation

1:

R'1!;
R       Spawn atom with 1 mass, 0 energy, moving right
 '1     Set atom's mass to ASCII value of 1
   !    Print character represented by atom's mass
    ;   Destroy atom

2:

*"2"L
    L   Spawn atom with 1 mass, 0 energy, moving left
   "    Enter printing mode, print all chars atom moves over
  2     Print 2
 "      End printing mode
*       Terminate program
\$\endgroup\$
1
\$\begingroup\$

><>, Score 2, 8 Total Bytes

Can't go any higher, there are only 2 output commands: n for numbers, and o for characters.

1n;

Prints 1, as a number.

'2'ov

Pushes 2's ascii value to the stack. Prints it as a character. Loops forever, since there's no way to end the program without re-using a semicolon.

\$\endgroup\$
4
  • \$\begingroup\$ There's a ><> answer already, which does a lot better since answers can be "snippets". \$\endgroup\$ – Ørjan Johansen Nov 18 '17 at 18:56
  • \$\begingroup\$ Ah, I see. Oh well ¯_(ツ)_/¯ \$\endgroup\$ – Bolce Bussiere Nov 18 '17 at 19:30
  • \$\begingroup\$ Also, you can end the program using any non-instruction, dividing by 0 or doing any instruction without a sufficient amount of items in the stack \$\endgroup\$ – Jo King Dec 30 '17 at 12:41
  • \$\begingroup\$ Also, I think you dropped this: \ \$\endgroup\$ – mudkip201 Jan 21 '18 at 2:40
1
\$\begingroup\$

C (clang), 50 bytes, score 13

!NULL
2
3
4
5
6
7
8
9
1e1
'l'-'a'
0xC
*"\r"

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ @ØrjanJohansen Fixed \$\endgroup\$ – Logern Nov 7 '18 at 3:43
  • \$\begingroup\$ @JoKing fixed, but it loses one number. \$\endgroup\$ – Logern Nov 7 '18 at 14:05
  • \$\begingroup\$ Up to 15, if I didn't make mistakes. \$\endgroup\$ – user77406 Nov 13 '18 at 16:33
  • \$\begingroup\$ Optionally, if <float.h> isn't considered boilerplate enough, RAND_MAX>>SEEK_END>>...>>SEEK_END/SEEK_END will obtain the same result, and are from <stdlib.h> and <stdio.h>. \$\endgroup\$ – user77406 Nov 13 '18 at 16:51
1
\$\begingroup\$

(K+R)eg, score 32

Our task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The integer is already on the stack, so it should have already returned the integer. The method of outputting does not matter.

  • 1-9 implicit outputs the respective integer. We are using control characters for this. In order to save the 1 character, we should do \x03\x02> instead.
  • 10(TIO):
\

  • 11-31 Yes, you need control characters! In order to return a specified number, you only need to convert the integer to its ASCII character form. Unfortunately this is in the ASCII range, and implicit integer output does not work.

Returning 13 is a special case(TIO):

;
  • 32 Great, so this is automatically pushed onto the stack.

So I can't think of more methods.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Couldn't you push 33 to the stack by pushing 2 Unicode characters that have a difference of 33, then subtracting? \$\endgroup\$ – EdgyNerd Sep 14 '19 at 16:00
1
\$\begingroup\$

MAWP 2.0, score 12, 40 bytes

:                       Outputs the 1 on stack
2              ------|     
3                    |
4                    |
5                    |
6                     > Number literals
7                    |
8                    |
9                    |
10             ------| 
__________              Pushes length of stack 10 times, snippet for 11
!!++!+!+                Duplicates and adds 1 on stack, snippet for 12

The most basic I could come up with. Try it!

\$\endgroup\$
2
  • \$\begingroup\$ I think this is optimal, since you've used all the commands that can push things to the stack. The only other thought would be split up the 10 command and push 10 using 0 while moving 1 to 11. I am a little confused over the + command though, since that isn't mentioned in the documentation. Is that meant to replace M? \$\endgroup\$ – Jo King Oct 7 '20 at 9:00
  • \$\begingroup\$ @JoKing MAWP has been replaced with +-*$ in 2.0, I've written documentation for it in esolangs but forgot to transfer it to the interpreter \$\endgroup\$ – Dion Oct 7 '20 at 9:10
1
\$\begingroup\$

Rust, score 12

column![]/ //the column macro expands to the column it was invoked in, then divided by self
column![]  //Newlines used to make sure they are aligned properly
2 
3 
4
1<<1<<1|1 //one bit shifted left twice, then bitwise or with one
6
7
8
9
5+5 
0x0b //byte literal
'L' as isize % '@' as isize //character literals cast into unicode values, then modulus operation performed

Try it online!

I haven't used any method calls yet, but can't come up with a useful one that doesn't reuse letters and is in the prelude.

\$\endgroup\$
0
\$\begingroup\$

Perl REPL, score 16

Get Perl REPL by using perl -nE'say eval'.

__LINE__
2
3
4
5
6
length
8
9
cos,abs
11
0xC
$.
7+7
!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()+!rmdir()
//- -//- -//- -//- -//- -//- -//- -//- -//- -//- -//- -//- -//- -//- -//- -//

Other things I tried:

(ord Z)-(ord K)

And here are some ideas of how to cheat:

  • umask
  • tell
  • getppid
  • getpgrp
  • wait
  • system
  • time
  • srand
  • localtime
  • gmtime
  • ls|wc -l <---- cheating, has preconditions
\$\endgroup\$
4
  • \$\begingroup\$ There's a lot more that can be done here \$\endgroup\$ – William Entriken Jun 5 '17 at 15:32
  • 13
    \$\begingroup\$ + in both 14 and 15. \$\endgroup\$ – Ole Tange Jun 5 '17 at 15:50
  • 3
    \$\begingroup\$ I feel that $. is cheating, as it would not work without the previous commands having run. I'd consider it acceptable in the first spot only. \$\endgroup\$ – Ørjan Johansen Jun 5 '17 at 17:27
  • \$\begingroup\$ There's a + in both your 14 and your 15. \$\endgroup\$ – Erik the Outgolfer Aug 21 '17 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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