12
Write a program that outputs a list of the number of occurrences of each unique character in its source code.
For example, this hypothetical program {Source_Print_1};
should produce this output:
; 1
P 1
S 1
_ 2
c 1
e 1
i 1
n 1
o 1
p 1
r 2
t 1
u 1
{ 1
} 1
The formatting should match this example. No extraneous whitespace is allowed, except an optional final newline.
Your program may not read its own source code from the source file.
The characters listed must be in one of two orders. Either the order of character values in the character encoding used by your language (probably ASCII), or the order the characters appear in your source.
This question inspired by this comment by Jan Dvorak.
3
Similar: http://codegolf.stackexchange.com/questions/34431/introspective-programming-code-that-analyzes-its-source-and-its-output
– Calvin's Hobbies – 2015-05-29T17:37:19.6101
A zero-length program would work in quite a few languages. Does this count as a standard loophole?
– Digital Trauma – 2015-05-29T20:38:10.9732Let's go with... yes. – Sparr – 2015-05-29T21:09:39.857
@DigitalTrauma: Added to the list.
– Dennis – 2015-05-30T01:09:41.530Can the code contain newlines? – jimmy23013 – 2015-05-30T03:00:45.207
1@user23013 good question. I did not consider newlines. I guess if you include them, I'd accept an answer that prints them out literally, so there would be one double-newline in the file somewhere. – Sparr – 2015-05-31T23:37:20.740