| Bytes | Lang | Time | Link |
|---|---|---|---|
| 055 | Bespoke | 250804T102528Z | Josiah W |
| 019 | JavaScript Node.js | 250507T140218Z | Steve Be |
| 009 | ☾ | 250322T120844Z | Joao-3 |
| 025 | SAKO | 250322T063346Z | Acrimori |
| 013 | Swift 5.9 | 240317T201710Z | macOSist |
| 056 | Itr | 230906T104138Z | bsoelch |
| 067 | COBOL | 230906T100000Z | Kai Burg |
| 007 | Pip | 230702T173222Z | The Thon |
| 009 | Desmoslang | 230530T030705Z | Dadsdy |
| 005 | Thunno 2 | 230528T190231Z | The Thon |
| 005 | Python REPL | 230330T224350Z | GuitarPi |
| 041 | Pascal | 230330T001557Z | Kai Burg |
| 025 | Go | 230329T153120Z | The Thon |
| nan | 230118T195024Z | The Thon | |
| 007 | Knight | 220802T100444Z | Bubbler |
| 007 | Flobnar | 220712T092119Z | Bubbler |
| 010 | Microscript II | 220524T124105Z | Ginger |
| 015 | Python 3 | 220509T170557Z | Sapherey |
| 003 | TIBasic | 220511T222432Z | Youserna |
| 009 | Zsh | 220509T070436Z | Qaziquza |
| 007 | DipDup | 220509T062421Z | alephalp |
| 115 | Pyramid Scheme | 220318T230009Z | emanresu |
| 013 | Pari/GP | 220121T095452Z | alephalp |
| 015 | Lexurgy | 220121T062954Z | bigyihsu |
| 005 | GNU dc | 211104T033531Z | Pedro Ma |
| 009 | Ly | 211002T095132Z | cnamejj |
| 067 | Malbolge | 211002T082415Z | user1004 |
| 053 | FerNANDo | 211002T080649Z | user1004 |
| 067 | CLCINTERCAL | 211002T073647Z | user1004 |
| 009 | Java JDK | 210908T144142Z | 0xff |
| 015 | abcn | 210908T143436Z | Eternal |
| 004 | Jelly | 210908T125116Z | Baby_Boy |
| 007 | Vyxal | 210908T111047Z | SjoerdPe |
| 013 | Julia 1.0 | 210818T152057Z | MarcMush |
| 013 | Python 3 | 210818T083312Z | Stephen |
| 005 | Vyxal D | 210818T082250Z | emanresu |
| 005 | BRASCA | 210413T140204Z | SjoerdPe |
| 015 | Racket | 210413T131630Z | MLavrent |
| 023 | Scratch | 210413T130431Z | Nolan |
| 011 | Grok | 210413T122748Z | Aaroneou |
| 007 | Width | 201015T090523Z | PkmnQ |
| 013 | Python 3 | 210409T051509Z | Rachit A |
| 909 | Pxem | 210408T135039Z | user1004 |
| 005 | Husk | 201015T020840Z | LegionMa |
| 029 | Turing Machine Code | 200615T132221Z | ouflak |
| 181 | Brainetry | 200613T224635Z | RGS |
| nan | It feels cheaty | 200613T211344Z | Cloudy7 |
| 011 | 7 | 200612T210659Z | Pizgenal |
| 024 | naz | 200130T050936Z | sporebal |
| 005 | W | 200130T075106Z | user8505 |
| 017 | AWK | 200130T043336Z | rootbeer |
| 075 | GolfScript | 190721T041850Z | user8505 |
| 013 | Python 3 | 191004T120028Z | Divy |
| 005 | 05AB1E | 191004T113022Z | Dorian |
| 1721 | 6502 | 190820T195955Z | lee |
| 013 | Python 3 | 190820T162937Z | Dat |
| 035 | x8664 Mac OS | 190820T155659Z | maviek |
| 021 | Lost | 190820T154617Z | Kevin Cr |
| nan | 190820T153459Z | Kamila S | |
| 071 | C# | 190820T131646Z | canttalk |
| 005 | ink | 190726T203205Z | Sara J |
| 021 | C gcc | 190709T135032Z | jdt |
| 029 | Whitespace | 190709T144231Z | Kevin Cr |
| 019 | Haskell | 190726T084413Z | Laikoni |
| 009 | Cubix | 190724T205943Z | MickyT |
| 026 | Bitwise Cyclic Tag But Way Worse | 190723T121348Z | Edgex42 |
| 009 | 33 | 190717T201930Z | TheOnlyM |
| 005 | Ohm v2 | 190718T165132Z | Cinaski |
| 015 | Pip | 190718T161340Z | Kenzie |
| 153 | Shakespeare Programming Language | 190717T173608Z | Robin Ry |
| 013 | Python 3 | 190709T164903Z | mypetlio |
| 013 | Python 3 | 190710T113218Z | jaaq |
| 009 | Rust closure | 190717T095553Z | ruohola |
| 017 | C++ clang lambda expression | 190712T164608Z | ruohola |
| 011 | Python 2 | 190715T073852Z | he77789 |
| 013 | MATLAB | 190710T204115Z | aaaaa sa |
| 015 | Octave | 190714T121658Z | Sanchise |
| 447 | Chef | 190710T162507Z | user2434 |
| 021 | Boolfuck | 190712T155514Z | Edgex42 |
| 009 | Zsh | 190713T054750Z | GammaFun |
| 005 | Pyth | 190712T171112Z | Sok |
| 009 | Excel | 190710T173305Z | willuwon |
| 013 | F# | 190712T130458Z | dumetrul |
| 009 | DOS/Windows Batch Language | 190712T112846Z | user8800 |
| 011 | Python 2 | 190709T134127Z | TFeld |
| 075 | Keg | 190711T135808Z | user8505 |
| 009 | AsciiDots | 190711T174307Z | DaCoolOn |
| 005 | Stax | 190709T150340Z | Khuldrae |
| 007 | SmileBASIC | 190711T131344Z | 12Me21 |
| 009 | Bash | 190710T150728Z | William |
| 011 | Perl 5 | 190711T122655Z | Chris |
| 027 | LOLCODE | 190711T070557Z | Charlie |
| 005 | BitCycle | 190711T065239Z | Jo King |
| 011 | Perl 5 | 190709T202012Z | Xcali |
| 007 | Underload | 190710T210402Z | Edgex42 |
| 065 | INTERCAL | 190709T200549Z | Unrelate |
| 011 | PHP | 190710T190743Z | John |
| 025 | Kotlin | 190709T135105Z | Quinn |
| 009 | Wolfram Language Mathematica | 190710T155234Z | att |
| 007 | PowerShell | 190709T143830Z | Veskah |
| 005 | Japt | 190710T124334Z | Oliver |
| 005 | 05AB1E | 190709T141126Z | Kevin Cr |
| 008 | cQuents | 190710T104738Z | Stephen |
| 053 | MarioLANG | 190710T102605Z | Charlie |
| 061 | ArnoldC | 190710T101352Z | Charlie |
| 017 | Grass | 190709T142105Z | Robin Ry |
| 009 | dc | 190710T081613Z | manatwor |
| 007 | PowerShell | 190710T054246Z | mazzy |
| 013 | Lua | 190709T164757Z | ouflak |
| 004 | AppleScript | 190709T134157Z | a stone |
| 013 | Forth gforth | 190709T174849Z | reffu |
| 004 | HTML | 190710T025046Z | tsh |
| 007 | JavaScript | 190710T020608Z | Oliver |
| 007 | Japt | 190709T175712Z | Shaggy |
| 119 | Shakespeare Programming Language | 190709T230746Z | Unrelate |
| 007 | Charcoal | 190709T203327Z | Neil |
| 004 | APL Dyalog Unicode | 190709T160919Z | Adá |
| 007 | Brachylog | 190709T192950Z | Unrelate |
| 013 | Gema | 190709T194540Z | manatwor |
| 005 | Gaia | 190709T193708Z | Giuseppe |
| 011 | Bash | 190709T193153Z | Grzegorz |
| 009 | Forth gforth | 190709T191619Z | mbomb007 |
| 004 | HQ9+ | 190709T183140Z | Helena |
| 007 | Runic Enchantments | 190709T142836Z | Draco18s |
| 022 | Dodos | 190709T173810Z | Erik the |
| 017 | brainfuck | 190709T151104Z | ovs |
| 007 | Retina | 190709T172255Z | Neil |
| 007 | Retina 0.8.2 | 190709T172013Z | Neil |
| 011 | R | 190709T165827Z | Robin Ry |
| 011 | BrainFlak | 190709T163439Z | Wheat Wi |
| 017 | Haskell | 190709T164420Z | Wheat Wi |
| 2340 | Lenguage | 190709T153730Z | Expired |
| 004 | MathGolf | 190709T145324Z | Kevin Cr |
| 003 | PowerShell | 190709T153000Z | jimmy230 |
| 003 | RProgN 2 | 190709T151635Z | dzaima |
| 005 | Jelly | 190709T135456Z | Erik the |
| 019 | SNOBOL4 CSNOBOL4 | 190709T144634Z | Giuseppe |
| 009 | APL Dyalog Unicode | 190709T145142Z | J. Sall& |
| 007 | Befunge93 | 190709T144356Z | ovs |
| 006 | Ruby | 190709T143752Z | histocra |
| 011 | Java 8 | 190709T142104Z | Kevin Cr |
| 011 | Elm 0.19 | 190709T141808Z | O.O.Bala |
| 009 | Batch | 190709T140537Z | Neil |
| 009 | Ruby | 190709T140107Z | G B |
| 007 | CJam | 190709T134545Z | Luis Men |
| 017 | Haskell | 190709T135436Z | Damien |
| 009 | PHP | 190709T135334Z | Luis fel |
| 011 | JavaScript Babel Node | 190709T134202Z | Luis fel |
Bespoke, 55 bytes
#with A-SCII 1, I solved it#such a method is messed up#
Note: # stands in for the unprintable ASCII 1 (SOH).
Outputs three copies of ASCII 1 (SOH). (I had wanted to use ASCII 111 (o) as all three characters, but that turned out to be 4 bytes larger.)
JavaScript (Node.js), 19 bytes
console.log('co;');
JavaScript (SpiderMonkey), 13 bytes
alert ('a()')
SAKO, 25 bytes
1)TEKST
0S1
STOP1
KONIEC0
Just a basic solution. I had to add 0 at the end to make it odd number of characters.
Swift 5.9, 13 bytes
print (") ")
This is basically a Swift version of this Python answer by @TFeld. Prints the last character ")", the middle character " " (a space), and the first character "\n" (a newline, printed thanks to print(_:separator:terminator:)'s default terminator of "\n").
Itr, 5 characters (6 bytes)
×'×3×
Explanation
×'×3×
× ; call × on the first two arguments (0 by default) and ignore the result
'× ; the character ×
3× ; repeated 3 times
COBOL, 67 B
The OpenCOBOL implementation does not seem to process non-lines (i. e. a character sequence that is not concluded by a newline character).
Therefore the COBOL source code contains a newline character.
However, I did not achieve printing a leading newline character (there was a space I could not get rid of).
So I extended the source code with some syntactically acceptable junk.
The 01 is not followed by a newline character.
000000 PROGRAM-ID.P.PROCEDURE DIVISION.DISPLAY"1I0"NO ADVANCING.
01
Output:
1I0
Pip, 7 bytes
R"R "
Attempt This Online! (Note the trailing space)
Explanation
\nR"R " ; Full program
\n ; No-op
"R " ; The string "R "
R ; Reversed
; No-op
; Implicit output
; (with newline)
Thunno 2, 5 bytes
` rr
Port of Kevin Cruijssen's 05AB1E answer. Prints r \n.
Alternative 5 bytes:
12£1
Port of Kevin Cruijssen's alternative 05AB1E answer. Prints 12\n.
Python REPL, 5 bytes
122-1
yields 121.
This probably works with many other interactive environments as well, but this is the shortest I could think of.
Pascal, 41 characters
NB: Despite appearing that way the source code has no trailing newline:
program p(output);begin write('.gp')end .
Go, 25 bytes
func()string{return"}nf"}
Function which returns a string.
Go, 35 bytes
import."fmt"
func f(){Print("} i")}
Function which prints to STDOUT.
Go, 51 bytes
package main
import."fmt"
func main(){Print(`}
p`)}
Full program which prints to STDOUT.
Thunno, \$7\log_{256}(96)\approx\$ 5.76 bytes
Z" rr
Port of Kevin Cruijssen's 05AB1E answer.
Explanation
\n\nZ" rr
\n\n # no-ops
Z" r # 2-char string: " r"
r # reverse to get "r "
# implicit output with newline
Knight, 7 bytes
O"OO"O
Prints OO<newline>.
Whitespace is ignored, O is monadic output function which prints the string "OO" without quotes and a trailing newline, and the last O is ignored because the parsing ends at O"OO".
Knight, 7 bytes
O-1 2-
Prints -1<newline>.
Flobnar, 7 bytes
0..0#@0
The character that is easiest to print is the digit 0. 5 bytes is impossible because it mandates three zero digits and a @ at one of the two positions (2nd or 4th), which makes the program print 0 only once. For 7 bytes, we skip a 0 with # and print zero twice using . (explicit decimal output); the third copy of 0 is produced as the value that @ evalautes to.
Microscript II, 10 bytes
Welcome to Backslash Hell
"\"\\\\\""
I suspect that a shorter version is possible.
Python 3, 15 15 bytes
print(" p")
Previous answer(Incorrect)
print("pp ")
The answer is no longer pp (◞‸◟)
TI-Basic, 3 bytes
i+1
i represents the imaginary number.
Pyramid Scheme, 115 bytes
^ ^
/ \ / \
/out\ /out\
^-----^-----
-^ ^-
-^ ^-
-^-
/ \
/chr\
^-----
-^
-^
/ \
/32 \
-----
The middle character is the space after the ^ on the fifth line. Prints three spaces.
GNU dc, 5 bytes
0p
n0
Pushes 0 to the stack, prints 0 with a new line, prints 0 without a new line and again pushes 0 to the stack.
n is a GNU implementation. Might not work with other versions.
Ly, 9 bytes
'o:oo"'"o
I had some more interesting versions (IMO anyway), but they were longer. :)
'o - push "o" on the stack
: - duplicate top of stack
oo - print both "o" chars
"'" - load a doublequote on the stack
o - print it
Prints output oo"
Malbolge, 67 bytes
Outputs n D. Eventually I thought a space is really necessary.
D'`_$"\\[||98V6Bu@tOq<.'98*ZjE&fe {Ab~,v*)]xZvonsl2ponmfN+cba`ed]#n
FerNANDo, 53 bytes
Outputs aaa, but is it accepted...?
a a a
z a a z z z z a
z a a z z z z a
z a a z z z z a
CLC-INTERCAL, 67 bytes.
Outputs 1#D. It was difficult to adjest program length. Eventually I decided to do \#9; this caused no side effects.
DO;1<-#9\#9DO;1SUB#1<-#100DO;1SUB#2<-#374DO;1SUB#3<-#276DOREADOUT;1
abcn, 15 bytes
a120gxgxnba98gx
Explanation :
a120 --> sets stack at 120
gx --> convert to ASCII and print (120 ==> x) as you can see x is last char
gx --> convert stack 120 again to ASCII and print `x` mid char (7th) is x
--> as well (a120gxg make 7 and nba98gx make 7 so we print x)
b --> stack set to -1 (useless just made so we print x twice and
--> not have to add more bytes)
a98 --> add to stack 98 (giving us 97)
gx --> convert to ASCII and print (97 == a) a is first char
prints xxa which is the right answer
Vyxal, 7 bytes
No flags used.
9 99J₴9
Explanation
9 - Push 9
99 - Push 99
J₴ - Concatenate and print
9 - Pushes another 9, but it never gets used.
Julia 1.0, 13 bytes
most python answers work with julia too, but here are a couple very julian 13-byters
"s" |>show;""
"t|\""|>print
Python 3, 13 bytes
print( ') p')
The last character is ')', the middle is number 7, a space and the first is the letter 'p'.
Vyxal D, 5 bytes
‛‛‛
Note the trailing space and newline.
Simply pushes ‛‛, and prints with trailing newline.
BRASCA, 5 bytes
9C9$9
Explanation
9 - Push 9
C - Set implicit output to number mode
9 - Push 9
$ - Swap the two nines
9 - Push 9
<implicit> - Output stack
Scratch, 23 bytes
when gf clicked
say[wcw
Grok, 11 bytes
iq i` wwwq # Prints "q i"
Width, 7 bytes
GAPSfeW
Outputs through STDERR.
I used a G to start the string. The ID of G is 39, which turns into eW. The ID of W is 55, which turns into AP. Then I just used Ai which is 50, and checked how close it was to A, saw it became R, then used Sf, which is 51, and becomes S.
Python 3, 13 bytes
print(")\"p")
Having " as the middle char is lucky, because then I can balance the parity of the code because it requires an escape sequence.
There's a few more Python 3 13-byters, so I imagine this is the shortest possible solution.
I don't there's a shorter solution with exit(), which prints to STDERR.
Pxem, Filename: 9 bytes + Content: 0 bytes = 9 bytes.
- Filename:
O.ooo.o.O - Content: empty
Brainetry, 181 bytes
This program starts and ends with an upper case L and also has it in the middle of its source code. This golfed version is based off of the program that comes after it.
To try this online, follow this repl.it link, paste my source code in the btry/replit.btry file and hit the green "Run" button.
L b
a b c d
a b c d e f g h
a b c d
a b c
a b c d e f g h
a b c d e
a b c
a b c d e f g h L
a b
a b
a b c d
a b c d
a b c d e f g h i
a b c
a b c d e f g
a b c d e f g
a b c d e f L
The verbose version also starts and ends with an uppercase L and has one of those in the exact middle of its source code.
Lo and
behold: this program has
a self referential property! This code prints its
first, middle and last
chars! How nice!
Of course I cheated a little and made
this program in such a
way that all
3 of those chars are the upper case L,
which I
also had
to properly place in
the middle of this
text to make sure they appeared in those positions.
A bit of
luck and a bit of mathematics allowed
me to accomplish this feat. Let me
check it... Woops, missed by one... LOL
It feels cheaty, but
Mornington Crescent, 1005 bytes
Take Northern Line to Euston
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Victoria
Take Victoria Line to Tottenham Hale
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take District Line to Gunnersbury
Take District Line to Acton Town
Take District Line to Acton Town
Take Piccadilly Line to Turnpike Lane
Take Piccadilly Line to Turnpike Lane
Take Piccadilly Line to Leicester Square
Take Northern Line to Leicester Square
Take Northern Line to Mornington Crescent
There are nine deliberately placed newlines after the first instruction to make the middle character the o of Take District Line to Upminster. The code prints out the first three characters of Tottenham Hale reversed to yield toT. Of course, this challenge was made easier by the fact that Mornington Crescent programs always start with the T of Take and end with the t of Mornington Crescent, barring any extra newlines.
Try it online!
7, 11 characters
57125574032
Prints 255.
Explanation:
The program pushes 5|7255|4632 onto the frame (which starts with ||). Then, the last section of the frame (4632) is executed.
4 swaps the last two sections, and adds another bar between them. The frame is now ||5|4632||7255.
6 pacifies the last section of the frame by converting the active commands 7255 (shown in bold) to their passive equivalents 1255, and removing the bar before it. The frame now looks like ||5|4632|1255.
3 outputs the last section of the frame (1255) and discards the last two sections. The initial 1 means "print the rest unchanged", so 255 is printed. Then, the last two sections are discarded, leaving ||5 on the frame.
2 duplicates the last section of the frame, leaving ||5|5. There are no more characters left on the command list, so the last section of the frame (5) is executed.
5 moves the last section of the frame (which is another 5) to the start of the command list to be executed immediately, and then discards it. This leaves ||5 on the frame.
This happens again, leaving 5 on the command list and | on the frame.
The last 5 moves the last section of the frame (i.e. nothing) to the command list, leaving an empty command list and an empty frame. This causes the program to exit successfully.
Notes:
The
57at the beginning and the2at the end are included because without them, one of the first, middle, or last characters would have been a7, and printing7is hard.The program can fit into 4 bytes, but the question asks to minimize characters.
naz, 28 24 bytes
0a9a3a9m3a2o0a0a0a0a0m2o
Explanation
0a9a3a9m3a2o # Output "o" twice
0a0a0a0a # Padding bytes
0m2o # Output "0" twice
Original 28-byte solution: 0a9a3a9m3a1o0a0a0a9s5s1o0m2o
W, 5 bytes
'+:+
Explanation
% Newline (no-op)
'+ % The addition operator
:+ % Multiply the character twice
% Print with a newline
```
GolfScript, 7 5 bytes
".".
Explanation
# A newline, just to hide the effect of the automatic trailing newline
"." # The . character: the last and middle character
. # Copy the character twice
# Implicitly output the whole stack without a delimiter.
# This returns ".." (the . character duplicated) and a trailing newline.
Python 3, 13 bytes
This should suffice. Although it has a new line at the end of the output. There is a space in between print and '(' to make the total count of characters odd.
print (')(p')
05AB1E, 5 bytes
×'×3×
× push a string of nothing, repeated nothing times (in other words, push an empty string)
'× push "×"
3× push "×", repeated 3 times
implicitly print top of stack
6502, 17/21 bytes
6502: 17 bytes if running in zero page
For initial testing I used Py65, a 6502-based microcomputer simulator written in Python. Starting Py65 with the command-line parameter -o ff moves the character output port to zero page address $FF, shaving three bytes from the code.
The program must be loaded and run at $0000, to guarantee outputing the correct three characters (in order) from the program with values 00 B5 A5.
Here are the program bytes and their respective disassembly view in Py65:
.mem 0000:0010
0000: a5 10 85 ff a9 11 4a aa b5 00 85 ff a5 00 85 ff 00
.d 0000:0010
$0000 a5 10 LDA $10
$0002 85 ff STA $ff
$0004 a9 11 LDA #$11
$0006 4a LSR A
$0007 aa TAX
$0008 b5 00 LDA $00,X
$000a 85 ff STA $ff
$000c a5 00 LDA $00
$000e 85 ff STA $ff
$0010 00 BRK
6502: 21 bytes if running outside zero page
Four additional bytes are required to allow the program to run outside of zero page. Three of the those bytes are the change in the LDA (load accumulator) instructions from zero page to absolute addressing. The fourth is the addition of a NOP (no operation) instruction, to maintain an odd number of bytes in the program.
This version of the program must be loaded and run at $0300, to guarantee outputing the correct three characters (in order) from the program with values 00 00 AD.
Here are the program bytes (character values) and their respective disassembly view:
.mem 0300:0314
0300: ad 14 03 85 ff a9 15 4a aa bd 00 03 85 ff ad 00 03 85
0312: ff ea 00
.d 0300:0314
$0300 ad 14 03 LDA $0314
$0303 85 ff STA $ff
$0305 a9 15 LDA #$15
$0307 4a LSR A
$0308 aa TAX
$0309 bd 00 03 LDA $0300,X
$030c 85 ff STA $ff
$030e ad 00 03 LDA $0300
$0311 85 ff STA $ff
$0313 ea NOP
$0314 00 BRK
6502: 21 bytes if running on an Apple II
We've come this far, so let's plop this baby on an Apple II. I don't normally tote around my Apple //c anymore, so I used a2ix on my Android phone.
Instead of sending characters to an addressed port, they will go to COUT (character output), a routine in system ROM.
$0300 is the usual spot for small assembly routines, so that's where I'll enter and list it. Running it yields a flashing space (60), inverse N (0E), and a normal " (A2). On the Apple II, ASCII characters are remapped across the 256-character range to achieve different character effects in text mode.
*300: A2 14 20 0E 03 A9 15 4A AA 20 0E 03 A2 00 BD 00 03 20 ED FD 60
*300L
0300- A2 14 LDX #$14
0302- 20 0E 03 JSR $030E
0305- A9 15 LDA #$15
0307- 4A LSR
0308- AA TAX
0309- 20 0E 03 JSR $030E
030C- A2 00 LDX #$00
030E- BD 00 03 LDA $0300,X
0311- 20 ED FD JSR $FDED
0314- 60 RTS
Relocating this to a free area of zero page (good luck!) would not yield any byte savings. While the absolute indexed LDA (load accumulator) at $030E could be switched to its zero page indexed counterpart to save one byte, an NOP (no operation) would have to be added to avoid additional code to support print two middle characters.
x86-64 (Mac OS), 35 bytes
b8 04 00 00 02 bf 01 00 00 00 48 be 20 00 00 00
00 00 00 00 ba 03 00 00 00 0f 05 48 31 c0 c3 00
b8 00 b8
can be disassembled to:
[bits 64]
section .text
global _main
_main:
mov rax, 0x2000004
mov rdi, 1
mov rsi, x
mov rdx, 3
syscall
xor rax, rax
ret
section .data
x: db 184, 0, 184
and compiled with:
$ nasm -fmacho64 FILE.asm
$ ld -fSystem FILE.asm
then run
$ ./a.out
<0xb8><0x00><0xb8>
Lost, 21 bytes
v<<<<<>>>>>
>%?"v>@"@
Outputs: v>@.
Try it online or verify that it's deterministic.
Explanation:
Explanation of the language in general:
Lost is a 2D path-walking language. Most 2D path-walking languages start at the top-left position and travel towards the right by default. Lost is unique however, in that both the start position AND starting direction it travels in is completely random. So making the program deterministic, meaning it will have the same output regardless of where it starts or travels, can be quite tricky.
A Lost program of 2 rows and 5 characters per row can have 40 possible program flows. It can start on any one of the 10 characters in the program, and it can start traveling up/north, down/south, left/west, or right/east.
In Lost you therefore want to lead everything to a starting position, so it'll follow the designed path you want it to. In addition, you'll usually have to clean the stack when it starts somewhere in the middle.
Explanation of the program:
All arrows, including the >v in the string, will lead the path towards the leading > on the second line. From there the program flow is as follows:
>: travel in an east/right direction%: Put the safety 'off'. In a Lost program, an@will terminate the program, but only when the safety is 'off'. When the program starts, the safety is always 'on' by default, otherwise a program flow starting at the exit character@would immediately terminate without doing anything. The%will turn this safety 'off', so when we now encounter an@the program will terminate (if the safety is still 'on', the@will be a no-op instead).?: Clean the top value on the stack. In some program flows it's highly likely we have a partial string on the stack, so we use this to wipe the stack clean of that potential string.": Start a string, which means it will push the integer code-points of the characters used (rather similar as the Whitespace program).v>@: Push the code-points for these characters, being118 62 64respectively": We're done pushing code-points of this string@: Terminate the program if the safety is 'off' (which it is at this point). After which all the values on the stack will be output implicitly. Using the-Aprogram argument flag these code-points will be output as characters instead.
Two things to note:
The top part could also have been v<<<<<<<< instead. Lost will wrap around to the other side when moving in a direction. So using v<<<<>>>> could be a slightly shorter path, and since it's the same byte-count anyway, why not use it. :)
Also, the first line contains an additional < and >. One of them is to avoid having the newline character as the middle of the program, which is rather difficult to output and would have only increased the byte-count. The second is to make the program length odd again, so we'd only have to output a single middle character instead of two.
DOS COM x86 binary
% xxd test.com
00000000: 31c9 4b88 2f80 ffef 75f8 8007 30b4 028a 1.K./...u...0...
00000010: 17cd 2180 3f00 7503 e905 00fe 0fe9 f3ff ..!.?.u.........
00000020: b402 8a17 cd21 8007 20b4 028a 17cd 2190 .....!.. .....!.
00000030: cd20 4b53 20 . KS
C#, 71 bytes
public class P{public static void Main(){System.Console.Write("pa}");}}
Try Online
I don't think I need to explain anything here
Whitespace, 31 29 bytes
[S aS S T S S S S S N
_Push_32][S N
S _Duplicate_32][S N
S _Duplicate_32][T N
S S _Print_as_character][T N
S S _Print_as_character][T N
S S _Print_as_character]
-2 bytes thanks to @RobinRyder.
Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (with raw spaces, tabs, and new-lines only).
Contains a no-op a (can be any non-whitespace character) to make the length odd. It is added before the first halve of the program so the middle character is a space as well, since the middle character would have become a newline if it was at the second halve of the program. All non-whitespace characters are ignored in Whitespace programs.
Cubix, 9 bytes
oN/
@oo
Reasonably boring one. Since the newlines in the first, middle and last positions are ignored by the interpreter the code wraps onto the following cube. Spaces could be used as well. eg oS/ @oo
o
N / @ o
o
NPushs 10 (newline) onto the stack./redirects around the cube.ooooutputs the newline 3 times./@redirects again and halts the program
Bitwise Cyclic Tag But Way Worse, 26 bytes
ÿ1111111122ÿ2000000002ÿ
Outputs ÿ ÿ ÿ. 26 bytes since ÿ is considered 2 bytes in UTF-8.
33, 9 bytes
a"a\\a"pa
The a's do nothing here, they're essentially NOPs in this code to make it shorter. My original thought was "p\\\""p, but that's 8 bytes, so it needs to print another \, making it 10 bytes "p\\\\\""p
This is a language I did create, but I made it legitimately, so I hope it's within the rules.
Pip, 15 bytes
O"}"xxL1{O"1O"}
Needs more golfing
Pip, 9 bytes
O"nn"x
n
shorter version with newline
Pip, 8 bytes
1x000Oh1
another one
Shakespeare Programming Language, 163 153 bytes
-10 bytes thanks to Jo King.
B,.Ajax,.Page,.Act I:.Scene I:.[Enter Ajax and Page]Ajax:You is
the sum ofa Big Big Big BIG BIG cat a
CAT.Speak thy.You is twice you.Speak thy!SPEAK THY!
My first SPL answer! Outputs !BB.
There is another SPL answer by Unrelated String; in that answer, they output only spaces in 119 bytes, or output non-space characters in 227 bytes. This one comes in between, and also outputs non-space characters.
Two tricks are used here:
- An SPL sentence can end with
!rather than., and!is easier to get since its ASCII codepoint is 33 (=\$2^5+1\$), whereas the codepoint of.is 46. - Doubling 33 gives 66, the codepoint of
B, hence the play title isBand I need the second "big" to be "Big", which works since SPL is case-insensitive.
Since I needed that capital B and an exclamation mark at the end, I decided to have Ajax shout louder and louder through the scene.
Python 3 12 13 bytes
input(r')ri')
Python 3, 19 bytes 13 bytes
print( ')(')
The print function appends a newline by default so the code starts with a newline. The last character of the code is a ")" so that's printed first. To make the number of characters uneven, a space in inserted before the argument of the print function. Please excuse the salaciousness of the code.
Outputs: )(\n
C++ (clang) (lambda expression), 17 bytes
[]{return "}n[";}
C++ (clang) (full program), 47 43 bytes
#import<ios>
int main() {std::puts("}n");}
Unfortunately had to leave an extra space in both of the solutions, to make them have an odd number of characters.
Python 2, 12 bytes 11 bytes
Placeholder to make the leading newline visible
print"\"t"
MATLAB, 1315 bytes
disp( ') d')
Outputs ) d
Previous version (15 bytes, less strict output):
'''';1;''''''''
Outputs '''
Octave, 15 bytes
fprintf(')(f' )
As far as I know, using fprintf is the only method of out that doesn't come with extraneous output.
Chef, 447 bytes
Last Middle First Milkshake.
This recipe prints its last, middle and first character.
You could also use it to make a milkshake.
Ingredients.
76 ml milk
32 ml chocolate syrup
46 teaspoons vanilla ice cream
Method.
Liquefy vanilla ice cream.
Put the milk into 1st mixing bowl.
Put the chocolate syrup into 1st mixing bowl.
Put the vanilla ice cream into 1st mixing bowl.
Pour contents of the 1st mixing bowl into the 1st baking dish.
Serves 1.
A serious submission, 196 177 bytes
thanks to A__
R.
Ingredients.
82 l a
103 l b
46 l c
Method.
Put a into mixing bowl.
Put b into mixing bowl.
Put c into mixing bowl.
Pour contents of mixing bowl into baking dish.
Serves 1.
Boolfuck, 29 21 bytes
;;;;;;;;;;;;;;;;;+
Outputs 3 null characters
Thanks to Jo King for the improved solution!
BitChanger, 23 bytes
<<<<<<<<<<}<<<}<}<}<
Very similar to the Boolfuck one: uses the fact the null characters require no bit changing to output with tape-based bit output
How it works:
Used as it is simple to output
<<<<<<<<<< Moves over to one left of the I/O bit
} Sets the I/O bit to one, for output
<<< Moves over to the bit that performs I/O
}<}<} Sets it to one 3 times, to output 3 null characters
< I used < to waste one byte so it could be an odd number of bytes
Zsh, 9 bytes
<<<\<\<
Hexdump, with first/middle/last bytes highlighted:
00000000: 0a0a 3c3c 3c5c 3c5c 3c ..<<<\<\<
F^ M^ L^ ^ ^ ^
Output is <<[newline].
Pyth, 5 bytes
10 1
Prints 10 followed by a newline. Try it online!
Newlines normally print the next result followed by a newline, but at the start of a program it is essentially a no-op. 10 is the literal value, which is printed followed by a newline. The space before the 1 suppresses the usual implicit printing, so the final 1 is ignored.
Excel, 9 bytes
=("))=" )
So many Parentheses.
Note: The returned middle character can actually be any character since it's the middle of the code.
F#, 13 bytes (characters)
So many esoteric languages that seem to be made specifically for code golfing… let's try a terse but 'normal' language like F#, where the following line (without a trailing newline) has 13 characters (13 bytes if the source file is saved as ANSI text):
printf"\"\"p"
Output:
""p
DOS/Windows Batch Language, 9 bytes
@echo @o@
Python 2, 13 11 bytes
print' t'
To make the whitespace clear:
$ xxd solution.py
0000000: 0a70 7269 6e74 2720 7427 20 .print' t'
$ python2 solution.py | xxd
0000000: 2074 0a t.
-2 bytes, thanks to wastl !
Keg, 7 5 bytes
1\':'
This prints ''1, which are the respective characters.
No Try It Online available for Keg.
Here is an uninteresting 4-byte answer:
1231
AsciiDots - 9 bytes
.---$'.$.
Output: .$.
The code starts with a ., ends with a ., and the middle character is a $.
The single quote in the middle sets the dot print mode to simply read characters straight into the output stream.
It is possible that this could be made smaller, but I'm starting to doubt that it can. In order to print three characters, the single quote must be used, as the double quote would require an end to the string in order to output. However, this means that the single quote has to a) be followed by three characters and b) cannot be the center character. In order to crunch this down to seven bytes, I was considering trying to reuse the dot's start as one of the printed characters (sort of like AsciiDot's quine program). However, I found that the shortest sequence available for printing was ($' which would have had to print four characters in the space of three, or three characters in the space of four. I also tried some hacky alternative methods like trying to print the dot's value (which is 0) as one of the characters. While there may be some system that works, I've found these to be rather complex and large. Thus, I think that the above is the smallest solution. (I will update if I find something smaller)
Stax, 5 bytes
.PPP
Run and debug it at staxlang.xyz!
The leading linefeed does nothing. .PP pushes the string PP, and the final P prints it with a trailing newline. The last character is P, the middle character is the first P, and the first character is a linefeed.
The implicit print's trailing linefeed invalidates the 4-byte solutions 1231 and .S.S (adapted from Weijun Zhou's quine).
SmileBASIC, 7 bytes
?":b?":
Output: :b?
(Probably works in most BASIC dialects)
The middle character can be anything except ", LF, and CR.
Bash, 9 11 9 bytes
First attempt:
echo e\ o
Output
e o
Second attempt:
echo -n e-e
Output:
e-e
Third attempt
echo oo
Note the leading newline and the double space
Output:
oo
LOLCODE, 27 bytes
HAI 1
VISIBLE "E H"
KTHXBYE
Trivial answer in LOLCODE. The 14th character is the space just before the string literal.
BitCycle, 5 bytes
11!1
Outputs 11 with a trailing newline. Only the first pair of 1s is actually printed.
Underload, 9 bytes 7 bytes
Thanks to Khuldraeseth na'Barya for the improved solution!
W(SSW)S
As for as I can tell, this is now unimprovable since:
- The first character has to be a no-op character, since every other instruction raises an error due to the stack being empty, with the exception being an opening bracket. However, it can't be that since there is no way to output an opening bracket on it's own in Underload.
- You need to use at least 5 characters to add the 3 output characters to the stack.
- You need to use S to output it.
INTERCAL, 65 bytes
PLEASE,1<-#3DO,1SUB#1<-#246DON'TPARSE!!
DO READ OUT ,1
DO GIVE UP
Padding the second half of the program to make the output PPP seems to be shorter than printing multiple distinct characters.
PLEASE ,1 <- #3 Declare that the length of the uint16 array ,1 is 3.
DO ,1 SUB #1 <- #246 Make the first element of ,1 246. (The other elements are 0.)
DON'T PARSE!! This statement is ignored and nonsense.
DO READ OUT ,1 Print ,1 using C-INTERCAL's "Turing Tape" I/O.
DO GIVE UP End the program.
This one almost works for 35 bytes, but it prints a space before the first newline:
PLEASE READ OUT#500DOGIVEUP
PowerShell, 8 7 bytes
' D'
Notice the two spaces after the last quote. Forgot that using implicit output puts a newline afterwards. Fixing that saved a byte though.
Alternative 7 byte solution with 3 unique chars by mazzy
"`"`""
05AB1E, 7 5 bytes
„ RR
Outputs R \n.
-2 bytes by taking inspiration from @Neil's Batch answer, so make sure to upvote him as well!
5 bytes alternative by @Grimy:
12,1
Outputs 12\n.
Initial 7 bytes answer:
'?„«'«?
Outputs ?«'.
Explanation:
# No-op newline
„ R # Push 2-char string " R"
R # Reverse this string to "R "
# (output the result implicitly with trailing newline)
# No-op newline
12, # Print 12 with trailing newline
1 # Push a 1 (no implicit printing, since we already did an explicit print)
'? '# Push 1-char string "?"
„«' '# Push 2-char string "«'"
« # Concatenate them both together
? # Output without trailing newline
cQuents, 8 bytes
1#11,2&1
Outputs 11,1.
Explanation
1 Prepend 1 to the output
#11,2 Default input is `11, 2`
& Output as many terms as the last input, comma seperated
1 Each term equals 1
So first 1 is prepended, then the input becomes 11,2. Then, we output 2 terms comma separated, which is 1,1, so the final output is 11,1.
MarioLANG, 53 bytes
+>(-[!)
+"===#+
++
++
++
++
++
+
)!) <...
=#==="==+
Output: +++. The 27th character is one of the + characters in the second column of the code.
ArnoldC, 61 bytes
IT'S SHOWTIME
TALK TO THE HAND "D I"
YOU HAVE BEEN TERMINATED
Trivial answer in ArnoldC. The 31st byte is the space just before the string literal.
Grass, 17 bytes
wWWwwwVVwWWwWWWww
-2 bytes thanks to jimmy23013.
Outputs www. Grass ignores all characters apart from w, W and v. The two Vs are thus ignored; they are there to ensure the middle character is a w – I have no idea how to output v or W in Grass… I could have used another character instead of V, but V preserves the aesthetic of the code.
PowerShell, 7 bytes
Another trivial solution. The first and the last lines contains LF.
"`nn"
PowerShell, 9 bytes
non-trivial, no byte sequence hacks. The first line contains LF only. The second line starts with a space.
echo hh
AppleScript, 4
1021
Outputs the last char (1), the middle chars (02), and the first char (1).
Any four-digit number with the same first and last digits and different middle digits works.
Forth (gforth), 13 bytes
: f ." ; :" ;
Code Explanation
: f \ start a new word definition
." ; :" ; \ print "; :"
; \ end the word definition
HTML, 4 bytes
^db^
^<X>_<X>^
I'm not sure if this is cheating... Really.
First one also worked as PHP or Text.
Japt, 7 bytes
''ixi''
''ixi''
'' :Literal "'"
i :Prepend
x : Literal "x" (any lowercase letter would work. Except i, of course)
i : Prepend
'' : Literal "'"
Alternatives
"\"ww"w
Riii'R
"Q\""+Q
Shakespeare Programming Language, 119 bytes
,.Ajax,.Page,.Act I:.Scene I:.[Enter Ajax and Page]
Ajax: You big big big big big cat.Speak thy.Speak thy.Speak thy.
Prints three spaces. Without printing spaces:
Shakespeare Programming Language, 227 bytes
,.Ajax,.Page,.Act I:.Scene I:.[Enter Ajax and Page]Ajax:You is the sum of a big big big big big big cat a big pig.
You is the sum of you a large huge large big pig.
Speak thy.Speak thy.You is the sum of you a big pig.Speak thy.
Like my newline-free INTERCAL answer, this is constructed to make the last character of the program the same as the middle character (although in this case it is not also the first), by un-golfing the second half of the code until they match. (I'm not sure if I could have constructed 46 in fewer bytes or not, or if I could have golfed other parts of the first half more.)
Charcoal, 7 bytes
←´←´´´X
Try it online! The final X could be any byte in the Charcoal code page except 0xFF and the two already in use. Works by printing the desired characters leftwards. Alternative approach, also 7 bytes:
←”y←←”y
Try it online! The final y could be any ASCII character but I picked y because of the symmetry. Works by printing two ←s leftwards so that the final character gets printed at the start of the output.
APL (Dyalog Unicode), 5 4 bytes
Full programs.
Boring solution from J.Sallé:
1231
Prints that number. A much more interesting solution:
010E1
APL ignores leading zeros, so this is simply scaled format for 10×10¹=100.
Brachylog, 7 bytes
"w\\""w
Thanks to Shaggy for correcting this to comply with the challenge specification.
Boring string literal, except thanks to the weird way Brachylog string literals work, the escaped backslash also still escapes the quote afterwards, so it's not actually that boring.
Gaia, 5 bytes
⌋ ”⌋
The ⌋ is just there as a no-op.
% helper function
⌋ ”⌋ % main function: push "⌋ " and convert to lowercase
% then implicitly print with trailing newline
Bash (15 11 characters)
echo -n e-e
which prints out
e-e
- -4 chars by not using
|rev
Forth (gforth), 9 bytes
Prints an escape-supporting string.
.\" ."
Also 9 bytes:
Prints three spaces.
." "
9 bytes with Stack Underflow:
." .. ".
The 2nd and 3rd solutions also work if you replace first quotations with ( and last quotes with ). Essentially, plenty of ways to do it in 9 bytes, but probably not any shorter.
HQ9+ 4 characters
+AQ+
Explanation:
+ ; increment accumulator
A ; nop
Q ; print itself
+ ; increment accumulator
Retina, 7 bytes
((K`(`(
Try it online! Retina 1 does not output a trailing newline by default, but fortunately it has the K command which allows us to specify a constant string output. The grouping construct ( is used to increase the number of distinct characters to meet the minimum requirement.
Retina 0.8.2, 7 bytes
01$*$$
Try it online! Retina 0.8.2 outputs a trailing newline by default, so the code starts with that. Conveniently, this also matches the default empty input, allowing the replace stage to get to work. It then suffices to come up with a string of even length > 2 that outputs the other 2 characters.
R, 11 bytes
cat("))c" )
Outputs ))c. Space added to make the number of characters odd: otherwise we would need to output 4 characters, and that would make the code longer anyway.
Brain-Flak, 11 bytes
(((())))
Explanation
We need to put 3 things on the stack. The fastest way to do that is to put 3 1s (or zeros) on the stack. Now since (code point 1) does nothing in Brain-Flak we can add these to the program at the first middle and last places. Now this feels a bit cheaty so here are two more answers that are less cheaty in my opinion.
Prints braces, 31 bytes
( (((((()()()()()){}){}){}))())
This answer prints braces so that the characters printed are actually relevant to the code, it does have one padding character to make the length odd so we only have to print 1 middle character.
Contains only braces, 32 bytes
(((()((((()(()()){}){}){}){}))))
This is a braces only program both the source and (consequently) the output are made up entirely of braces (character Brain-Flak actually cares about).
Lenguage, 292 2340 bytes
Thanks to Jimmy23013 for pointing out I need another 2048 bytes
2340 bytes of any character with the first, middle two and last characters being a null byte.
Prints 4 null characters.
MathGolf, 5 4 bytes
1231
-1 byte by using the trivial solution presented by @ErikTheOutgolfer in his Jelly answer, which works for any language with implicit output without trailing newline.
Original 5 bytes answer:
ùù xx
Outputs x ù.
Explanation:
ùù x # Push 3-char string "ù x"
x # Reverse it to "x ù"
# (output the entire string joined together implicitly without trailing newline)
PowerShell, 3 bytes
00000000: 0a0d 31 ..1
Works only in Microsoft Windows.
The output is unfortunately 8 bytes in UTF-16. But the question says output the characters, and not the bytes. Arguably UTF-16 is just one of the supported ways to represent the characters in PowerShell. They are not interpreted differently from an ASCII file.
Jelly, 5 bytes
001 0
The output has two distinct characters, but the code also has a third one.
Trivial 4-byte version:
1231
SNOBOL4 (CSNOBOL4), 19 bytes
OUTPUT = 'D='
END
Prints D=<newline>, using SNOBOL's trailing newline in OUTPUT.
D=
APL (Dyalog Unicode), 9 bytes
⎕←'''''⎕'
Both the last and middle characters are ', while the first is ⎕.
Befunge-93, 7 bytes
.", @0
Explanation
Output is 0 .
. pop value (0) from stack, output as number with a trailing space
" toggle string mode, wraps around and pushes every char to the stack
, pop value (".") from stack, output as character
spaces are no-ops
@ end the program
0 trailing 0 to match the output
Ruby, 6 bytes
p " "
This outputs " " plus a newline. The code ends with a ", the middle two characters are and ", and it starts with a newline.
Java 8, 11 bytes (as lambda function)
v->'"'+"'v"
Outputs "'v.
Java 8, 67 bytes (as full program)
interface M{static void main(String[]ar){System.out.print("}ni");}}
Outputs }ni.
Note the ar instead of a as argument. Otherwise the middle part had to be in, but printing that would make the size odd again, which would cause a paradox-loop..
Batch, 9 characters
@echo hh
The middle and last character are both h, and then the echo prints a newline by default, which is the first character of the script.