| Bytes | Lang | Time | Link |
|---|---|---|---|
| 041 | Brainfuck | 241127T141117Z | Joon Yor |
| 016 | AWK | 241126T142605Z | xrs |
| 012 | gammascript | 241126T104051Z | Gleb |
| 002 | HTML | 241109T103948Z | The Empt |
| 009 | Python 2 | 241108T200656Z | The Empt |
| 043 | Brainfuck | 241108T151200Z | madeforl |
| 007 | Punchcode | 240927T163257Z | madeforl |
| 008 | YASEPL | 240916T150911Z | madeforl |
| 041 | Pascal | 240902T040000Z | Kai Burg |
| 004 | 7 | 220714T013821Z | ais523 |
| 015 | Python | 210413T170556Z | SegFault |
| 003 | Jelly | 210413T165025Z | caird co |
| 1915 | JavaScript | 180221T025548Z | iovoid |
| 009 | R | 180221T025126Z | Giuseppe |
| 004 | Pyt | 180221T024928Z | mudkip20 |
Brainfuck, 41 bytes
-[+>+[+<]>+]>-[->+>+<<]>.++++.>-.<-.>.<+.
Uses comma , as a separator, however the question doesn't really specify if we need a separator so..
Brainfuck, 24 bytes
-[+>+[+<]>+]>-.++++.-.+.
Brainfuck+ (Modulo256), 29 27 bytes
-[+>+[+<]>+]>-.-<+:>.>:<.<:
Also uses a comma , as a separator, what's different about Modulo256 Brainfuck+ is that we can use the : operator to output the value of a cell instead of its ascii character.
And then again, without separators:
Brainfuck+ (Modulo256), 22 bytes
-[+>+[+<]>+]>-.;+:-:+:
AWK, 16 bytes
END{print"-101"}
Some AWK implementations will need BEGIN instead of END, however.
You could do it at 9 bytes, with an empty input:
awk '$0="-101"' <<< ""
gammascript, 49 12 bytes
write -1 0 1
cheesy. But since there's no other way to make it shorter, this works
try it online (the double newlines aren't really necessary in the code)
HTML, 2 bytes
10
- Nobody said you couldn't use base -1.
- Nobody said you couldn't use the same digit for multiple numbers.
- 1 is represented as
1. - 0 is represented as
0. - -1 is represented as
10, as this is in base -1.
Python 2, 9 bytes
print-101
There is nothing disallowing you to use the empty string as a separator…
Brainfuck, 43 bytes
+++++++++[>+++++>+<<-]>.++++.>++++.<-.+>.<.
I'm not good at brainfuck, so its fun to make these and hope i'm not overcomplicating it :3
Punchcode, 7 bytes
heres the punchtape text (uncompiled punchcode), with explanations
-START |
---OOO-O| set first item in tape to 0
---OOO--| subtract it by 1
----O-OO| print
---OO-OO| add 1
----O-OO| print
---OO-OO| add 1
----O-OO| print
YASEPL, 8 bytes
=i-<+<+<
translated to javascript:
let i = -1;
console.log(i);
i = i + 1;
console.log(i);
i = i + 1;
console.log(i);
Pascal, 41 Bytes
According to ISO standard 7185 “Standard Pascal” integer parameters to write/writeLn have an implementation‑defined default minimum printing width, provided the write destination is a text file (such as the program parameter output is).
program p(output);begin write(-1,0,1)end.
Expanded:
program signumCodomain(output);
begin
writeLn(output, −1, 0, +1);
{ which translates to
writeLn(output, −1:integerDefaultMinimumWidth,
0:integerdefaultMinimumWidth,
+1:integerdefaultMinimumWidth);
where `integerDefaultMinimumWidth` stands for an inaccessible
implementation‑defined `integer` value greater than or equal to `1`. }
end.
Presuming integerDefaultMinimumWidth was 11, the …Ln‑flavored program prints:
-1 0 1
Users of the FreePascal Compiler (FPC) need to insert a {$mode ISO} compiler directive in front of program, or specify the ‑MISO parameter to the command‐line of fpc.
Otherwise the default minimum width is 1, which just smushes all integer values together into one string without any separation.
7, 11 characters, 4 bytes
17370074023
Hexdump to prove byte count:
00000000: 3df0 3c09 =.<.
This challenge is very easy in most languages, so I decided to solve it in a language where it's actually an interesting problem.
Explanation
It took me ages to golf this down to 4 bytes – there are a really huge number of ways to do this with 12 characters, but reaching 11 is very difficult.
The only part of the code here that actually runs (after the first cycle, which just sets up the stack to mirror the structure of the program) is 4623 (which is the code generated by the code 4023 in the original program; the 4023 is a literal which pushes 4623 to the stack; as usual, I'm using non-bold for commands that just push code to the stack and bold for the commands they push). After the first cycle, each new cycle runs the top stack element, without actually popping it from the stack.
The 4 swaps the top two stack elements, and inserts a blank element between them (thus, a b goes to b blank a). Then the 6 analyzes the top element to determine what source code is most likely to have produced it, and appends the resulting source code to the element below it (which will be blank at this point because we just ran a 4). Thus, the net effect of 46 is to swap the top two stack elements, and replace the top stack element with (a guess at, but the guesses are always correct for this program) the source code that produced it.
2 duplicates the top stack element, and 3 outputs the top stack element, popping both it and the element below. Thus, the net effect of 23 is to output and pop the top stack element, without disturbing elements below it.
As such, the effect of our program 4623 is to pop and output the source code that produced the second stack element, whilst leaving the top stack element unchanged. The top stack element in question is the actively running program (which doesn't get popped when we start to run it), so once the program finishes running, it'll just run again, etc. – this is in effect an infinite loop which, for each element on the stack, outputs the source code that produced it (and eventually the program crashes due to stack exhaustion). As such, the data being given to the output routines is 00, 3, 1 (i.e. the sections of the source code in between 7s – the source code has already run to produce runnable code by this point, but the source is reconstructed from the runnable code rather than the runnable code actually being run).
The first 0 sent to the output routine selects numerical output mode. Then, 0, 3, 1 get output. The numerical value of a string in 7 is the total number of 1 and 7 characters it contains, minus the total number of 0 and 6 characters it contains. Thus, the values of these strings are -1, 0, and 1, as required by the question.
One complication is that if we try to output an empty string, we just get no output, rather than its numerical value of 0 being output: this is a special case needed because the output command 3 is the primary way to pop and discard stack elements (basically, you push an empty element above the one you want to pop, output that empty element and pop the element below as a side effect). A "clean" way to output 0 thus requires outputting a string like 01 which is nonempty and has a numerical value of zero. This program uses 3, which is shorter, but the numerical output formatter will append a comma when outputting strings ending 3 (in addition to outputting their numerical value). As a consequence, the output of the program is actually -1 0, 1, but this is permitted by the question. (All eight of the one-character strings either have a side effect when output via the numerical formatter, or else have a value different from zero, so outputting -1 0 1 exactly would make the program longer.)
Python - 15 bytes
print("-1 0 1")
I would say "Good luck improving this.", but past experience has taught me never to assume: though, this won't be easily beat (for i in range(3), %ding the spaces and %sing the 1s are all overweight, so you can eliminate those.)
JavaScript, 19 15 bytes
[-1,0,1].map(alert)
alert([-1,0,1])