Created
October 6, 2021 00:25
-
-
Save stek29/8803a8b002dd1c8f7ff0c185f3306f96 to your computer and use it in GitHub Desktop.
simple Quine program ¯\_(ツ)_/¯
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func quine() { | |
var s = """ | |
func quine() { | |
var s = MEGIC | |
let slash = "\\\\" | |
let s1 = "\\n " | |
let s2 = "\\"\\"\\"" | |
var sInd = s.replacingOccurrences(of: "\\n", with: s1) | |
sInd = sInd.replacingOccurrences(of: slash, with: slash + slash) | |
sInd = s2 + s1 + sInd + s1 + s2 | |
if let r = s.range(of: "MEGIC") { | |
s = s.replacingCharacters(in: r, with: sInd) | |
} | |
print(s) | |
} | |
""" | |
let slash = "\\" | |
let s1 = "\n " | |
let s2 = "\"\"\"" | |
var sInd = s.replacingOccurrences(of: "\n", with: s1) | |
sInd = sInd.replacingOccurrences(of: slash, with: slash + slash) | |
sInd = s2 + s1 + sInd + s1 + s2 | |
if let r = s.range(of: "MEGIC") { | |
s = s.replacingCharacters(in: r, with: sInd) | |
} | |
print(s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment