Comments on Output 256 in many different ways
Parent
Output 256 in many different ways
Challenge
Write as many functions, programs, or snippets of code, that result in 256. Your score is the number of separate solutions submitted in an answer.
The challenge? The characters used in one solution must not appear in any other solution. That is, there is no character used in more than one program.
Notes
- The bytes of the solution, in the encoding used by the interpreter/compiler running the solution, are what is used for distinctness checking. For example, if the answer is scored in UTF-8, one solution containing
á
means no other can containé
as both share the0xC3
byte, but an SBCS containing both would allow it. - Solutions must have at least one character (otherwise the empty program giving 256 would result in a score of $\infty$).
- The usage of bytes for scoring means that the maximum score ever achievable is 256 (but getting that would mean having a language where every character prints 256).
- The result can be either a number, that equals to 256 (or differs from it by a maximum of 0.001), or a string representing it in decimal form, possibly ending with
.0
. - Each submission can be of a different type (function, program, snippet), and can return in a different format (return value, STDOUT, console, etc.)
- Yes, snippets of code are allowed. So
256
is a valid solution in most languages. - Highest score wins!
JavaScript, 11 solutions …
4y ago
Japt, 10 11 13 15 solutions …
3y ago
[Raku], 18 solutions 25 …
4y ago
C, 8 solutions Standard C, …
4y ago
Japt, 27 Solutions This sta …
3y ago
Vyxal, 20 23 24 solutions T …
3y ago
BQN, 14 solutions (SBCS) Ru …
3y ago
[Husk], 9 solutions 1. Clas …
4y ago
[PowerShell], 4 solutions …
3y ago
Scala (`-language:postfixOps`) …
3y ago
[Ruby], 7 solutions ```ruby …
3y ago
Unlambda, 1 solution Since …
3y ago
Post
Raku, 18 solutions
256
٢٥٦
۲۵۶
߂߅߆
২৫৬
᠒᠕᠖
𑄸𑄻𑄼
4⁴
0x100
ord Q`Ā`
'~~~'~^'LKH'
888-88-88-88-88-88-88-88-8-8
99+99+9+9+9+9+9+9+?9+?9+?9+?9
($_=3333333)&&m|(3)(3)(3)(3)*|&&$3**$3
[[];[];[];[]]×[[];[];[];[]]×[[];[];[];[]]×[[];[];[];[]]
"{"{7%%7%7}{7%7}7"%7}{"{7%%7%7}{7%%7%7}7"%7}{"{7%%7%7}{7%%7%7}{7%%7%7}"%7}"
</ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / />/</ />
q:w!a\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na!.Int
The last solution use newline characters, so the \n
s should be replaced by linefeeds. These solutions are mostly helped by Raku's unicode operators and digits, as well as being able to convert from lists or strings to numbers freely, where lists are equal to their length.
1. through 7.
256
٢٥٦
۲۵۶
߂߅߆
২৫৬
᠒᠕᠖
𑄸𑄻𑄼
These are all numeric literals of 256 in different unicode digits (with no bytes overlapping). Yes, Raku supports this. No, I don't know why.
8.
4⁴
Four to the power of 4
9.
0x100
Hexadecimal of 256
10.
ord
Q`Ā`
Get the ordinal value of the 256th character.
11.
'~~~'~^'LKH'
String xor ~~~
with LKH
to get 256.
12.
888-88-88-88-88-88-88-88-8-8
Some basic arithmetic to get 256
13.
99+99+9+9+9+9+9+9+?9+?9+?9+?9
More arithmetic, using ?
to boolify 9 to True, which then is numerically 1.
14.
($_=3333333)&&m|(3)(3)(3)(3)*|&&$3**$3
Set $_
to 3333333, then match some 3s such that the fourth group is of length 4, then return that group to the power of itself (4**4
). This one might be a little iffy, since it relies on the existing $_
variable to be mutable, (which it is by default).
15.
[[];[];[];[]]×[[];[];[];[]]×[[];[];[];[]]×[[];[];[];[]]
Make a list of length 4 and multiply it by itself four times.
16.
"{"{7%%7%7}{7%7}7"%7}{"{7%%7%7}{7%%7%7}7"%7}{"{7%%7%7}{7%%7%7}{7%%7%7}"%7}"
Uses modulo and divisibility operators with string interpolation to generate numbers.
"{"{1}{0}7"%7}{"{1}{1}7"%7}{"{1}{1}{1}"%7}"
= "{2}{5}{6}"
= 256
17.
</ / ... / />/</ />
Create a list with length 512 and divide it by a list with length 2.
18.
q:w!a
a
...
a
a!.Int
Create a list of length 256 using the words quoting construct and then convert it to an integer.
Conclusion
I can certainly save some characters from some solutions to use later, but I've sort of run out operators that can convert them to numbers. I still have carriage returns for whitespace, so maybe there's a function I can still use.
1 comment thread