Jelly, 47 integers, 519 bytes
e
BI$⁼#
⁾⁾⁾Ụ^/
ı***ıḞḞ
5
6
7
.::::
9
EȮ<
⁻GṘ
=`p`VV×`DQV
~A~A~A~A~A~A~A~A~A~A~A~A~A
⁷ṾṾṾw
⁴ḟ€⁴Ṁ
mmmmċ
ṭṭṭṭṭṭṭṭḍḄḄḄḄḄḄḄḄḄ
+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ
CNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNC
ĖḌĖḌ
ṫṣȦJṫȦ⁸ȦJ
22
“@ṃ»
!ḤḤ!
³HH
ØaM
;;;;;;;;;;;;;;;;;;;;;;;;;;;¬¬ḅ¬
irið8c
⁶ḲĠṂ°İṂĊ
œṡ¹ẆẆTUṖṖṖṖP
ȷ½RṪ
LµdddddµFL
33
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWŒḊ
ẇɓæ«æ«æ«æ«æ«|æ«|
⁹ṚḢ²
‘‘‘0‘‘‘‘‘‘‘
’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’ạ
-____---__________
”(O
⁵ḶxḶ⁵ị⁵ḶxḶḣṢ
⁽{ʂ%⁽{}
ẊẠżv©żvżvżvọ®®Ạżvżvżvọ®
44
111111l11&K1111111Kl11&
,SS¶ỊỊ,ÇS¶ÇÑÇÇÇÑ
ÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆn
Every line is a separate, full program.
Try it online! (includes test suite and intersection checker)
How it works
Every full program without command-line arguments executes its main link (defined on the last line) niladically, i.e., without input. If the first link in the chain is a nilad, it is consumed, called, and both the main link's argument and return value are set to the result; if the first link in the chain is a monad or a dyad, it is not consumed and the implicit argument and return value 0 is used instead. In both cases, the remainder of the chain is executed monadically.
Jelly mangles its output in several cases. Notably, a singleton array is printed without its surrounding brackets, so 42 and [42] and indistinguishable after printing. We'll use this on several occasions.
1 – 10
e
The exists atom tests if the return value 0 belongs to the argument 0. It does, so e
returns 1.
BI$⁼#
BI$
is a quicklink, specifically a monadic chain formed by the quick $
grouping the binary atom B
and the increments atom I
. Combined, they convert an integer into the array of its digits in base 2, then compute the forward differences of the resulting digits. If the array has only one element, there are no forward differences and I
returns an empty array (falsy); if there are at least two digits, I
returns a non-empty array (truthy).
The quick #
consumes the previous quicklink and applies it to 0, 1, 2, … until enough matches are found an returns the array of matches. The required amount is calculated by ⁼
, which compares the return value/argument 0 to itself, yielding 1. Thus, the whole program returns [2], the first non-negative integer with two digits in base 2.
⁾⁾⁾Ụ^/
⁾⁾⁾
is a string literal, specifically the string ⁾⁾. The grade up atom Ụ
sorts its indices by their corresponding values; since both characters are equal, this yields [1, 2]. The resulting array is reduced with bitwise XOR ^/
, so the whole program returns 3.
ı***ıḞḞ
ı
initializes argument and return value to the imaginary unit i. *
is the exponentiation dyad, whose right argument defaults to the main link's argument. Thus, ***ı
computes ((ii)i)i ≈ 4.81 + 0i, the Ḟ
atom (floor for real arguments, real part for complex ones) computes the real part (4.81), then Ḟ
floors, yielding 4.
5
6
7
These three programs consist of a single literal and do exactly what you'd expect.
.::::
The literal .
is a shorthand for 0.5 and initializes argument and return value. The integer division dyad's (:
) right argument defaults to the main links argument, so ::::
computes 0.5/0.5/0.5/0.5/0.5, yielding 8.
9
Another literal.
EȮ<
The all equal atom E
returns 1 if all elements in its argument are equal, and 0 if not. An integer argument z is promoted to [z], so E
will returns 1 for the implicit argument 0.
Now, the output atom Ȯ
prints 1 to STDOUT. We then compare 1 with the implicit argument 0 using the less than atom <
. The result is (1 < 0) = 0, and it is printed implicitly when the program finishes.
11 – 20
⁻GṘ
The grid atom G
tries to make a visually pleasing table from its argument. For a plain integer argument (here: 0), it simply wraps it in an array. The flat not-equal atom ⁻
compares the implicit argument 0 with the result to the right ([0]), yielding 1 since its arguments are not equal. The representation atom Ṙ
prints 1 to STDOUT and returns its result. At the end of the program, the final return value is printed implicitly, so we end up with an output of 11.
=`p`VV×`DQV
The self quick `
turns a dyad into a monad by calling it with identical left and right arguments. First, =`
compares the implicit argument 0 with itself, yielding 1.
The Cartesian product atom p
expects lists as its arguments, so it promotes the integer 1 to the range [1, …, 1] = [1]. p`
takes the Cartesian product of [1] and itself, yielding [[1, 1]].
The eval atom V
turns all flat arrays (containing only numbers and characters) into strings, then evaluates the resulting strings as niladic Jelly programs. [[1, 1]] is first turned into [“11”], then V
evals the string, yielding [11]. Once more, V
turns this array into "11", then evals it to yield 11.
Now, ×`
multiplies 11 with itself, yielding 121. The decimal atom turns 121 into [1, 2, 1], the unique atom Q
discards the second 1, and V
once more turns a list of digits into the integer that results from concatenating them, returning 12.
~A~A~A~A~A~A~A~A~A~A~A~A~A
~
is the bitwise NOT atom. With two's complement arithmetic, it maps an argument z to ~z = -(z+1). A
is the absolute value atom, so it maps -(z+1) = z+1. With the initial return value 0, the thirteen copies of ~A
return 13.
⁷ṾṾṾw
The constant ⁷
holds the newline character '\n' and initializes the argument and return value.
The uneval atom Ṿ
attempts to create a string representation of its argument z such that a Jelly program consisting of this code would return z.
The first call dutifully returns the string "”\n", which is a character literal. The next call returns "””,”\n" – a pair of character literals. The third and final call returns "””,””,”,,””,”\n" – a quintuplet of character literals.
Finally, the window index atom w
promotes its right argument '\n' to the string "\n" and find the first index of a substring starting with "\n". This returns 14.
⁴ḟ€⁴Ṁ
⁴
is the constant 16. The quicklink filterfalse each (ḟ€
) promotes its left argument 16 to the range [1, …, 16], then iterates over its elements.
For each element z, ḟ⁴
is executed, first promoting z to [z], then removing all (if any) occurrences of 16. This yields the array [[1], [2], …, [14], [15], []], where the last array is empty because it contained 16.
Finally, the maximum atom Ṁ
selects [15].
mmmmċ
The modular atom m
– called with arguments x (array) and y (integer) usually takes every |y|th element of x, starting with the first if y > 0, with the last if y < 0. However, when y = 0, it returns x concatenated with its reverse.
The left integer argument 0 is first promoted to [0]. The first copy of m
concatenates [0] with itself, yielding [0, 0]. The remaining copies turn this result into [0, 0, 0, 0], then [0, 0, 0, 0, 0, 0, 0, 0], and finally [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].
At last, the count atom ċ
counts the number of times the implicit argument 0 appears in the resulting array, returning 16.
ṭṭṭṭṭṭṭṭḍḄḄḄḄḄḄḄḄḄ
ṭ
is the tack atom and appends its left argument to its right one. Since ṭ
and the following ḍ
are dyadic, all calls to ṭ
pass the implicit argument 0 as the right argument to ṭ
. The first call returns [0, 0], the second [0, [0, 0], and the eighth and last [0, [0, [0, [0, [0, [0, [0, [0, 0]]]]]]]].
ḍ
is the divisibility atom; for arguments x and y, it returns 1 is x is divisible by y, 0 if not. Ḅ
is a no-op for integers, so ḍḄ
tests 0 for divisibility by each integer in the constructed array. 0 is divisible by itself, so we get [1, [1, [1, [1, [1, [1, [1, [1, 1]]]]]]]].
Now, the unbinary atom Ḅ
operates on flat arrays. For a pair [a, b], it simply returns 2a + b. As mentioned earlier, Ḅ
is a no-op for integers: an integer argument c is promoted to [c], and [c] in any base is simply c.
The first call to Ḅ
reduces [1, 1] to 3, thus yielding [1, [1, [1, [1, [1, [1, [1, 3]]]]]]]. The next call reduces [1, 3] to 5, the next one [1, 5] to 7, and so forth until the ninth Ḅ
returns 17.
+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ+Ṇ
Ṇ
is the flat logical NOT atom and maps the implicit argument 0 to 1. +
is the addition atom, so each of the eighteen copies of +Ṇ
increment the previous return value (initially 0). The whole program thus returns 18.
CNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNC
C
is the complement atom and maps its argument z to 1-z. N
is the negate atom and maps its argument z to -z. Together, CN
maps z to -(1-z) = z-1, so the eighteen copies turn the implicit argument 0 into -18. A final application of C
yields 1 - (-18) = 19
.
ĖḌĖḌ
The enumerate atom Ė
enumerates the items in an array, creating index-value pairs. The implicit argument 0 is promoted to [0], then Ė
yields [[1, 0]]. The undecimal atom converts a flat array from base 10 to integer, yielding [10] in this particular case.
The second call to Ė
transforms [10] into [[1, 10]], which the second Ḍ
finally transforms into [20].
21 – 30
ṫṣȦJṫȦ⁸ȦJ
The tail atom ṫ
(a dyad) select the postfix of its left argument that starts at the index (1-based and modular) specified in its right argument, promoting a left integer argument x to [x]. When called with both arguments set to 0, ṫ
returns [0].
The any and all atom Ȧ
returns 1 if its argument is truthy and contains no zeroes at any depth, 0 otherwise. Here, we simply use it as an identity function to return the implicit argument 0. The split at atom ṣ
partitions its left argument [0] at occurrences of its right argument 0, so it returns [[], []] here.
The indices atom J
discards the elements of the return value and replaces them with their indices, yielding the range [1, 2] in this specific case. Ȧ
and ṫ
both work as before, so they reduce [1, 2] to the postfix that starts at the last index, yielding [2].
In niladic links, the constant ⁸
holds []. This is an unparseable nilad, i.e., it doesn't fit into the chain in any way. As a result, the previous return value ([2]) is printed to STDOUT, then replaced with the nilad's value ([]).
Since [] is falsy, Ȧ
transforms it into 0. The J
atom promotes 0 to [0], then returns the list of its indices ([1]), which is printed implicitly when the program finishes.
22
Another literal. Repdigits seem to be the best place to use them.
“@ṃ»
This uses Jelly's inbuilt string compression. The indices of @ and ṃ in Jelly's code page are 64 and 220 and string literals can contain 250 different characters, so this first computes the integer 250 × 65 + 220 = 16470.
16470 is divisible by 3, so the quotient 16470/3 = 5490 encodes a printable ASCII character or a linefeed. There are 96 of these and 5490 = 96 × 57 + 18, meaning that we've decoded the printable ASCII character at the 0-based index 18, which is '2'.
We're left with 57, which is also divisible by 3, so the quotient 57/3 = 19 = 96 × 0 + 19 encodes printable ASCII character at the 0-based index 18, which is '3'.
This leaves 0; the decoding process stops. The generated characters are concatenated to form "23"
!ḤḤ!
The factorial atom !
turns the implicit argument 0 into 1. Two invocations of the unhalve atom Ḥ
turn 1 into 2, then 2 into 4. Finally, !
computes 4! = 24.
³HH
In absence of command-line arguments, the constant ³
holds 100. Two invocations of the H
turns 100 into 50, then 50 into 25.
ØaM
The constant Øa
holds the lowercase alphabet. The maximal atom M
yields all indices of maximal items, and since z is the largest lowercase letter, the result is [26].
;;;;;;;;;;;;;;;;;;;;;;;;;;;¬¬ḅ¬
Twenty-six copies of the concatenate atom ;
concatenate the initial return value 0 and twenty-six instances of the default argument 0, building an array of 27 zeroes.
¬
is the logical NOT atom, so ;¬
appends a 1 to the array of zeroes. The next ¬
negates all elements in the array, leaving us with an array of 27 ones and 1 zero.
ḅ
is the unbase atom and converts a digit array from its left argument from the base specified in its right argument to integer. ḅ¬
converts from unary to integer, so it simply performs a sum. For an array of 27 ones, this returns 27.
irið8c
The index of atom i
promotes its left argument 0 to [0], then find the index of its right argument 0 in that array, yielding 1.
The range atom r
constructs an ascending or descending range from it's left argument to its right one. The right argument is the implicit argument 0, so this yields [1, 0]. A second invocation of i
finds the index of 0 in [1, 0], yielding 2.
ð
begins a new, dyadic chain. Since the preceding chain was niladic, both left and right argument of this chain will be equal the first chain's return value (2). c
in the combinations atom. With left argument 8 and right argument 2, it counts all unique, unordered 2-combinations of a set of 8 elements, returning 8C2 = 8!/(6!2!) = 28.
⁶ḲĠṂ°İṂĊ
The constant ⁶
holds a space character and sets argument and return value to ' '. The words atom Ḳ
promotes the character ' ' to the singleton string " " and splits it at spaces, yielding [[], []].
The group atom Ġ
groups all indices of equal elements. Since both elements of the last return value are equal, it returns [[1, 2]] here. The minimum atom extracts a minimal (the only) element of this array, yielding [1, 2].
The degree atom °
converts both integers from sexagesimal degrees to radians, yielding 1° × 2π/360° = π/180 and 2° × 2π/360° = π/90. The inverse atom takes the multiplicative inverses, yielding 180/π ≈ 57.3 and 90/π ≈ 28.6.
Then, Ṃ
once more takes the minimum, yielding 28.6. Finally, the ceil atom Ċ
transforms 28.6 into 29.
œṡ¹ẆẆTUṖṖṖṖP
The identity atom ¹
returns 0 for the implicit argument 0. The split around atom œṡ
promotes both of its arguments (both 0) to [0], then splits [0] around contiguous subarrays equal to [0]. This yields [[], []].
The sliding window atom Ẇ
builds all contiguous subarrays of its argument. The first instance transforms [[], []] into [[[]], [[]], [[], []]], the second instance transforms [[[]], [[]], [[], []]] into
[[[[]]], [[[]]], [[[], []]], [[[]], [[]]], [[[]], [[], []]], [[[]], [[]], [[], []]]].
The truth atom T
lists all indices of truthy elements. None of the arrays at the first level are empty, so this yields [1, 2, 3, 4, 5, 6]. The upend atom U
reverses this array, yielding [6, 5, 4, 3, 2, 1].
Four copies of the pop atom Ṗ
remove the last four elements, leaving us with [6, 5]. Finally, the product atom P
transforms this array into 30.
31 – 40
ȷ½RṪ
ȷ
is a shorthand for 1 × 103 = 1000. The square root atom ½
yields 31.6, which the range atom R
transforms into [1, …, 31]. Finally, the tail atom Ṫ
extracts the last element, returning 31.
LµdddddµFL
The length atom L
promotes the implicit argument 0 to [0], then takes the length to yield 1. µ
starts a new, monadic chain, and the result 1 becomes its argument.
For arguments x and y, the divmod atom d
yields [x/y, x%y]. Each call will have y = 1, so the result will always be [x, 0].
The first call starts with x = 1, yielding [1, 0]. d
only operates on integers, so it vectorizes in subsequent calls. The second call yields [[1, 0], [0, 0]], the third [[[1, 0], [0, 0]], [[0, 0], [0, 0]]], and the fifth and last one an array of depth 5 that contains a single one and 31 zeroes.
µ
once more starts a new, monadic chain, and the array from before becomes its argument. The flat atom F
unnests this array, yielding a flat array of a single one and 31 zeroes. Finally, L
takes the length of the resulting, returning 32.
33
Another repdigit, another literal.
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWŒḊ
Each instance of the wrap atom transforms its argument z into [z]. With the initial return value of 0, all 34 instances together yield [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]. Finally, the depth atom ŒḊ
computes the maximal depth of the resulting array, returning 34.
ẇɓæ«æ«æ«æ«æ«|æ«|
The window exists atom ẇ
promotes both of its arguments (both default to 0) to [0], then tests if**[0]** occurs as a contiguous subarray of [0]. It does, so ẇ
returns 1.
ɓ
begins a new, dyadic chain. Since the preceding chain was niladic, both left and right argument of this chain will be equal the first chain's return value (1). The chain makes use of two different, dyadic atoms: bitshift left (æ«
) and bitwise OR (|
).
A dyadic chain that starts with three or more dyads initially calls the first dyad with the chain's arguments. Here, this gives 1 << 1 = 2. The six subsequent dyads are grouped into pairs (so-called forks), where the rightmost dyad is called first with the chain's arguments, then the leftmost one is called with the previous return values to both sides.
For æ«æ«
, we get 2 << (1 << 1) = 2 << 2 = 8. Then, æ«æ«
computes 8 << (1 << 1) = 8 << 2 = 32. Now, |æ«
gets us 32 | (1 << 1) = 32 | 2 = 34.
Finally, the trailing |
acts like a hook and is called with the previous return value as its left argument and the chain's right argument as its right one. This returns 34 | 1 = 35.
⁹ṚḢ²
In absence of a second argument, the constant ⁹
holds 256. The reverse atom promotes 256 to the array [2, 5, 6] and reverses it to yield [6, 5, 2]. Then, the head atom Ḣ
extracts the first element, and the square atom ²
returns **6² = 36*.
‘‘‘0‘‘‘‘‘‘‘
The increment atom ‘
increments its argument by 1, so ‘‘‘
turn the initial return value 0 into 3. The following 0 is an unparseable nilad, i.e., it doesn't fit into the chain in any way. As a result, the previous return value (3) is printed to STDOUT, then replaced with the nilad's value (0).
The following 7 copies of ‘
turn this 0 into 7, which is printed implicitly when the program finishes.
’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’ạ
The decrement atom ’
decrements its argument by 1, so thirty-eight copies turn the initial return value 0 into -38. The absolute difference atom ạ
computes the unsigned difference between -38 and the implicit argument 0, returning 38.
-____---__________
-
is a shorthand for -1 and sets the link's argument and return value to -1. Each _
is an instance of the dyadic subtraction atom, whose right argument will default to -1 if missing.
First, -____-
computes (-1) - (-1) - (-1) - (-1) - (-1) = 3. The following -1 is an unparseable nilad, so the previous return value (3) is printed to STDOUT, then replaced with the nilad's value (-1).
Next, -_
computes (-1) - (-1) = 0, where the literal -
sets the left argument of _
and uses the return value as the right one. The following nine copies of _
subtract the default argument -1 from the return value, yielding 9, which is printed implicitly when the program finishes.
”(O
”(
is a character literal and the ordinal atom O
looks up its Unicode code point, yielding 40.
41 – 47
⁵ḶxḶ⁵ị⁵ḶxḶḣṢ
In absence of a third command-line argument, the constant ⁵
holds 10. The unlength atom Ḷ
creates a 0-based range, specifically [0, …, 9] for argument 10, to both sides of the repeat in place atom x
. The latter matches elements of its left argument with repetitions of its right one, and repeats each of the elements the corresponding number of times. With [0, …, 9] as both left and right argument, we thus get zero zeroes, one one, two twos, etc.
The index into atom ị
fetches the element of its right argument at the index specified in its left one. With left argument 10 (⁵
to its left) and right argument [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, …, 9] (previous result), this gives 4.
The chain up to this point is followed by an unparseable nilad ⁵
, so the previous return value (4) in printed to STDOUT, the return value is set to 10, and the rest of the chain is parsed as usual.
As before, ⁵ḶxḶ
will yield the array [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, …, 9]. This time, we call the sorted atom Ṣ
on the argument 10, which promotes 10 to [1, 0], then sorts it to yield [0, 1]. The dyadic head atom now fetches the prefixes of lengths 0 and 1 from the result to the left, leaving us with [[], [1]]. When printed, nothing but 1 will remain visible.
⁽{ʂ%⁽{}
⁽
and its two following characters constitute a numeric literal. If j and k are their code points in Jelly's code page and (j, k) < (124, 250), we get the integer 1001 + 250j + k. The code points of '{', '}', and 'ʂ' are 123, 125, and 167, so the left literal evaluates to 1001 + 250 × 123 + 167 (= 31918), while the right one evaluates to 1001 + 250 × 123 + 125 (= 31876).
Since the left integer is less than twice as big as the right one, the result is (… + 167) % (… + 125) = (… + 167) - (… + 125) = 167- 125 = 42.
ẊẠżv©żvżvżvọ®®Ạżvżvżvọ®
The shuffle atom Ẋ
randomizes the order of its argument's elements; a numeric argument z is promoted to the range [1, …, z] beforehand. For the implicit argument 0, this range is empty and Ẋ
yields []. The all atom Ạ
returns 1 if all of its argument's elements are truthy, 0 if not. Since an empty array does not contain falsy elements, Ạ
returns 1 here.
The zip with atom ż
(a dyad) takes arguments x and y and transposes the pair [x, y]. For integers x and y, this simply yields [[x, y]], so this particular ż
, called with arguments 1 and 0 (the implicit argument), returns [[1, 0]]. The dyadic eval atom v
turns all flat arrays (containing only numbers and characters) i the left argument into strings, then evaluates the resulting strings as monadic Jelly programs with its right argument as the programs' arguments. Since ["10"] consists solely of literals, this ignores the right argument of v
and simply results in [10].
The copy quick ©
attaches to v
and copies its result into the register. Later occurrences of the recall atom ®
(a nilad) will fetch [10] from the register.
The next three copies of żv
work as before, mapping [10] to [[10, 0] to [100] to … to [10000]. The order atom ọ
tests how many times its left argument is divisible by its right one, so here, it computes the order of 10 (fetched with ®
) in 10000 = 104, yielding [4].
The following ®
is an unparseable nilad, so the previous return value ([4]) is printed to STDOUT, then replaced with the nilad's value (10). We apply Ạ
next, yielding 1. (This is required as a nilad followed by a dyad would be parseable at this point.)
As before, żvżvżv
appends three zeroes to the current return value, turning 1 into [1000]. Finally, ọ®
computes the order of 10 in 1000 = 103, and 3 is printed to STDOUT when the program finishes.
44
Yet another repdigit, yet another literal.
111111l11&K1111111Kl11&
First and foremost, the literal 111111
sets the argument and initial return value to 111111. The other runs of 1
are also literals.
l
is the logarithm atom , which computes the logarithm of its left argument to the base specified in the right one. When called on 111111 with right argument 11, we get log11111111 ≈ 4.85.
The words atom K
joins a list argument at spaces, after promoting a numeric/character z to [z]. Here, we simply use it to turn the link's argument 111111 into [111111]. (We do not require an array here, but we have run out of identity atoms.) The bitwise AND atom &
takes the return values to both sides, casts them to integer if required, and computes their bitwise AND. In this particular case, it returns [4.85 & 111111] = [4 & 111111] = [4].
The following 1111111
is an unparseable nilad, so the previous return value ([4]) is printed to STDOUT, then replaced with the nilad's value (1111111). K
then turns this integer into [1111111]. (This is once again not really required, but a nilad followed by a dyad would be parseable at this point.)
As before, l11
computes log111111111 ≈ 5.81, then &
returns [5.81 & 111111] = [5 & 111111] = [5].
,SS
ỊỊ,ÇS
ÇÑÇÇÇÑ
This is the only program that consists of multiple user-defined links. The last link is the main link and executes when the program starts, the remaining ones are helper links. The quick Ç
always refers to the link above the current one and executes it monadically. Likewise, the quick Ñ
always refers to the link below the current one (wrapping around) and also executes it monadically.
The top link consists of the pair atom ,
– a dyad that turns arguments x and y into [x, y] – and the sum atom S
– a monad that promotes an integer argument z to [z] and reduces an array argument by addition. When the link ,SS
is called with an integer argument n, it computes Σ[n, Σn] = Σ[n, n] = 2n.
The middle link consists of the above atoms, the aforementioned quick Ç
, and the insignificant atom Ị
– a monad that yields 1 for numeric arguments z with -1 ≤ z ≤ 1, but 0 for all others. Applying Ị
twice to an integer argument n essentially replaces it with 1, as the output of the first Ị
(the input of the second one) is always insignificant. This result is then paired with the return value of Ç
(called with argument n), and the resulting pair is reduced by S
. In total, we compute Σ[(|n| ≤ 1) ≤ 1, 2n] = Σ[1, 2n] = 2n + 1.
With these two helper links in place, the main link can now construct any non-negative integer by looking at its binary digits. With an initial return value of 0, the chain ÇÑÇÇÇÑ
computes the final result (((((0 × 2 + 1) × 2) × 2 + 1) × 2 + 1) × 2 + 1) × 2 = ((5 × 2 + 1) × 2 + 1) × 2 = 46.
ÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆnÆn
The next prime atom finds the smallest positive prime number that is strictly greater than its argument. With initial return value 0, fifteen invocations of Æn
compute the fifteenth prime number, which is 47.
4The 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. – Dennis – 2017-06-04T22:45:31.493
Related: https://codegolf.stackexchange.com/q/50537/25180
– jimmy23013 – 2017-06-05T10:35:09.013Are command line arguments allowed if they follow the same rules in that they are part of the program when it comes to repetition? – MildlyMilquetoast – 2017-06-06T15:58:02.310
@MistahFiggins I'd assume so, but they'd also count towards the bytecount (minus the
-
used to denote them) – Skidsdev – 2017-06-06T16:12:05.4231Regarding 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)? – Kevin Cruijssen – 2017-06-06T17:45:43.897
1@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 needfrom 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 :) – Stewie Griffin – 2017-06-06T18:05:53.117@StewieGriffin Ok, no that answers it. In that case I can't do
import static java.awt.SystemColor.*;
without counting and then useTEXT_TEXT
as 13. Thought so, but was just making sure. – Kevin Cruijssen – 2017-06-06T18:10:49.563Is it possible for the source code to contain unprintable chars (if it is in your 1 byte rule obviously)? (for this)
– V. Courtois – 2017-07-28T10:06:23.147-1 for the white space rule. – tuskiomi – 2017-08-18T15:50:02.363
1You 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 :-) – Stewie Griffin – 2017-08-18T17:31:23.067
1@StewieGriffin I would at least allow spaces, but hey, I'm not you. – tuskiomi – 2017-08-18T18:30:18.217
Are we allowed leading zeroes? – Jo King – 2018-07-05T15:10:42.270
1Is it okay that my answer uses multi-byte characters but doesn't have any conflicts between the bytes? – Jo King – 2018-07-06T04:21:11.353