A guru once said a perfect code selfie is best shot diagonally from upper left corner. A code selfie is almost like a Quine - but rotated 45 degree clockwise. Your mission is to code a program that outputs a code selfie.


  1. You can use any programming language.
  2. Your programs should not take any input from file, filename, network or anything else.

Mandatory criterias:

Selfies is about the motive and background, so blankspaces (and other not visible content like linefeeds and such) does not count as being part of the character count. All visible characters is restricted to be outputted on the correct 45 degree rotated position while all non-visible characters is not restricted to the correct 45 degree rotated position. Just like a color palette on a normal selfie, mandatory to a code selfie is that it contains atleast 16 of these characters: {a-zA-Z0-9}


If this example is valid sourcecode:

Output abcd
Output efgh
Output ijkl
Output mnop

The example code should output this:

  O u
 O u t
O u t p
 u t p u
  t p u t
   p u t
    u t   a  
     t   e b
        i f c
       m j g d
        n k h
         o l

This is code-golf, shortest sourcecode in bytes wins!

  • 2
    \$\begingroup\$ 16 of unique [a-zA-Z0-9] ? \$\endgroup\$ – Optimizer May 26 '15 at 9:04
  • \$\begingroup\$ How would we score a submission in Whitespace? \$\endgroup\$ – Sp3000 May 26 '15 at 9:20
  • \$\begingroup\$ Whitespace is not possible, since blankspaces does not count. Yes, 16 of unique [a-zA-Z0-9], not a total least 16 chars. \$\endgroup\$ – Plarsen May 26 '15 at 9:50
  • \$\begingroup\$ This challenge is biased against languages which require linebreaks in their code. It's much harder to support multiline for this challenge. \$\endgroup\$ – nderscore May 26 '15 at 16:20
  • 1
    \$\begingroup\$ @nderscore Perhaps you are correct about that. Well, we are all here for fun, right? Do the best out of the situation! ;) \$\endgroup\$ – Plarsen May 26 '15 at 20:12

Javascript (ES6), 72 bytes

16 unique alphanumeric character pallete: fjalert0plcgmixn

(f=j=>alert(`(f=${f})(0)`.replace(/./gmi,x=>' '.repeat(j++)+x+'\n')))(0)

m and i flags are added to the regexp to meet minimum palette requirements.


CJam, 30 28 25 bytes


This is kind of long due to the 16 character from A-Za-z0-9 limit.

This is a bit non-trivial variant of a standard quine in CJam. Will add explanations soon.

UPDATE - 2 bytes saved thanks to Martin, 3 bytes saved thanks to Dennis

Try it online here


Java, 312

class Z{public static void main(String[]a){String s="class Z{public static void main(String[]a){String s=%c%s%1$c,t;for(int i=0,j;i<326;System.out.println(t+s.format(s,34,s).charAt(i++)))for(j=i,t=%1$c%1$c;j-->0;)t+=' ';}}",t;for(int i=0,j;i<326;System.out.println(t+s.format(s,34,s).charAt(i++)))for(j=i,t="";j-->0;)t+=' ';}}

There are actually 326 bytes, but if I understand the rules correctly, I don't have to count the 14 spaces.

The program is basically a standard Java quine, plus a lot of whitespace.


Python 3, 139 characters - 10 spaces = 129 characters

sjxd='sjxd=%r;[print(" "*i+(sjxd%%sjxd)[i]) for i in range(len(sjxd%%sjxd))]';[print(" "*i+(sjxd%sjxd)[i]) for i in range(len(sjxd%sjxd))]

Since my code was one line, all I had to do was print the program diagonally. My string has the weird name 'sjxd' so that my code could have the 16 unique alphanumeric characters.


CSS, 69 bytes


Put in a blank html page to avoid conflict with other tags.

Palette: stylebfortanm45dgiplck (22 chars)


MATLAB, 40 bytes

Bit difficult with the whole recursion thing - how do you print your own source code when adding the code to a string to be printed increases the size of the source code itself. But, never the less, the following will do it:


The 123456; bit is there to meet the required 16 unique characters. The following are used:


The above code doesn't work on Octave for some reason, but does work in MATLAB. Below is the output:


Now if you don't mind the ans= bit that MATLAB enjoys putting, the following would work for 32 bytes:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.