Obligatory Quine Challenge
Rules
Using your language of choice, golf a quine.
A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.
No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.
Additionally, your quine may not consist of only one data section. This includes HTML programs without tags (thus only printing their source), and the Golfscript program 1.
Scoring
The shortest program in bytes wins. Trailing newlines must be counted if your program outputs one.
Vyxal/Keg , 8 bytes `:. …
5y ago
BQN, 20 bytesSBCS ``` ∾2/0‿8 …
4y ago
[Husk], 8 bytes S+s"S+s …
5y ago
Scala 3, 80 bytes ```lang-sca …
5y ago
Jq, -rn 18 bytes ``` "|@js …
5y ago
BQN, 14 bytesSBCS ``` ∾⟜•FMT …
4y ago
h, 4 bytes ``` 1,-1 ``` …
4y ago
Japt, 9 bytes All credit to …
4y ago
[shortC], 38 bytes Bs){ …
4y ago
9 answers
BQN, 20 bytesSBCS
∾2/0‿8⊏↓"∾2/0‿8⊏↓"""
BQN's strings escape double quotes by doubling them, so that the string used to start with only contains a single quote, although the output needs to have four quote characters. This also means that the source string is displayed with lots of quotes in the REPL.
∾2/0‿8⊏↓"∾2/0‿8⊏↓"""
"∾2/0‿8⊏↓""" # Source for the function, followed by a quote
↓ # All suffixes
0‿8⊏ # Suffixes 0 and 8: all, and the last character
2/ # Copy each twice
∾ # Join it together
Documentation: Suffixes and Join.
0 comment threads
Husk, 8 bytes
S+s"S+s"
Basically Leo's original quine.
It concatenates the string evaluated version of S+s to itself.
So: "S+s" + "\"S+s\"" gives the original code.
0 comment threads
Scala 3, 80 bytes
@main def m={val s="@main def m={val s=%c%s%1$c;printf(s,34,s)}";printf(s,34,s)}
The printf replaces %c and %1$c in string s with the quote character (34 in decimal), and replaces %s with the contents of s.
0 comment threads
Jq, -rn 18 bytes
"|@json+."|@json+.
"|@json+." # the string
| # through the filter
@json # json encoded
+ # concatenated with
. # itself
* -rn flags are only to output normally and get no input (respectively)
0 comment threads
Japt, 9 bytes
All credit to ETH on this one.
9îQi"9îQi
9î :Repeat the following to length 9
Q : Quotation mark
i"9îQi : Prepend "9îQi"
And, for the sake of completeness, the original 10 byte Japt quine, again with all credit to ETH:
"iQ ²"iQ ²
"iQ ²" :Literal string
i :Prepend
Q : Quotation mark
² :Repeat twice
0 comment threads
h, 4 bytes
1,-1
Neither this program (by VilgotanL) nor the language (by Nerdaxe) are mine, but I think the latter is interesting and so I am submitting the former.
Step-by-step guide:
Accumulator and index of the current cell start at 0
Acc -> (value of 0th cell)th cell - 0 -> 1st cell -> -1 (0-indexing is used)
Acc is negative, so index of current cell -> 1st cell -> -1
When the index is negative, execution ends
When execution ends, the final program is printed
0 comment threads
shortC, 38 bytes
Bs){Rs="Bs){Rs=%c%s%c,34,s,34",34,s,34
From GeeksForGeeks's C implementation.

1 comment thread