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

Dashboard
Notifications
Mark all as read
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.

Why does this post require moderator attention?
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

+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
Why does this post require moderator attention?
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.

Why does this post require moderator attention?
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.

Why does this post require moderator attention?
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.

Why does this post require moderator attention?
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)

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

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

0 comment threads

+0
−0

C (clang), 64 bytes

main(s){printf(s="main(s){printf(s=%c%s%c,34,s,34);}",34,s,34);}

Try it online!

I originally found the quine from GeeksForGeeks, and it seems like that's the shortest it could be. I tried to golf it, but nothing really works, so I left it like this instead. Also, I renamed a as s because I was rewriting this without going back to the site.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!