Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Obligatory Quine Challenge

+9
−0

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (5 comments)

9 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+2
−0

BQN, 14 bytesSBCS

∾⟜•FMT"∾⟜•FMT"

Run online!

Assumes •FMT will format a string by placing it in quotes, which depends on the BQN system in use. After () applies its right operand •FMT to the argument string, then joins () the argument string to it.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+5
−0

Vyxal/Keg , 8 bytes

`:.,`:.,

Try it online! (Keg)

The explanations are the same for both languages, seeing as how Vyxal is heavily based on Keg.

Explained

`:.,`	# Push the string ":.,"
:.,	# Duplicate it, print it raw and then print it nice
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+4
−0

Husk, 8 bytes

S+s"S+s"

Try it online!

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+4
−0

BQN, 20 bytesSBCS

∾2/0‿8⊏↓"∾2/0‿8⊏↓"""

Run online!

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+3
−0

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)}

Try it in Scastie!

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+3
−0

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)

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

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
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Japt, 9 bytes

All credit to ETH on this one.

9îQi"9îQi

Test it

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 ²

Test it

"iQ ²"         :Literal string
      i        :Prepend
       Q       :  Quotation mark
         ²     :Repeat twice
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+0
−0

shortC, 38 bytes

Bs){Rs="Bs){Rs=%c%s%c,34,s,34",34,s,34

Try it online!

From GeeksForGeeks's C implementation.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »