Skip to content

Instantly share code, notes, and snippets.

@benjholla
Last active August 25, 2018 15:01
Show Gist options
  • Save benjholla/5f57727305e52c84d515656ec617bfdd to your computer and use it in GitHub Desktop.
Save benjholla/5f57727305e52c84d515656ec617bfdd to your computer and use it in GitHub Desktop.
A simple quine using substring operations with an example runner script
/**
* This quine ignores whitespace and comments
* It could be run with the following bash script
*
* ----------------------------------------------
* #!/bin/bash
* while true; do
* rm -f Quine.class
* javac Quine.java
* rm -f Quine.java
* java Quine &> Quine.java
* done
* ----------------------------------------------
*
* @author Ben Holland
*/
public class Quine {
public static void main(String[] args) {
char quote = 34;
String code = "public class Quine { public static void main(String[] args) { char quote = 34; String code = ;System.out.print(code.substring(0,92) + quote + code + quote + code.substring(92,code.length())); } }";
System.out.print(code.substring(0,92) + quote + code + quote + code.substring(92,code.length()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment