21
4
The code should take a string as input from keyboard:
The definition of insanity is quoting the same phrase again and again and not expect despair.
The output should be like this(not sorted in any particular order):
: 15
. : 1
T : 1
a : 10
c : 1
e : 8
d : 4
g : 3
f : 2
i : 10
h : 3
m : 1
o : 4
n : 10
q : 1
p : 3
s : 5
r : 2
u : 1
t : 6
y : 1
x : 1
All ASCII characters count unicode is not a requirement, spaces, quotes,etc and input should come from keyboard / not constants, attributes, output should be printed with new line after each character like in the above example, it should not be returned as string or dumped as hashmap/dictionary etc, so x : 1 and x: 1 are ok, but {'x':1,... and x:1 are not.
Q: Function or complete program taking stdin and writing stdout?
A: Code needs to be a program taking input using standard in and display the result via standard out.
Scoreboard:
Shortest overall: 5 bytes
Shortest overall: 7 bytes


3All ascii characters as input? Or just printable? Or up to unicode? Will there be newlines? – Justin – 12 years ago
2Can I create a function, or is a whole program necessary? Can I output all the ascii characters and print
0as the number of occurrences? – Justin – 12 years ago16Is the output format strict, or it suffices to preserve the meaning? – John Dvorak – 12 years ago
Your edit did not address my question. – Justin – 12 years ago
5You didn't say if the output needs to be sorted alphabetically. You didn't say if the separator needs to be
" : "(note the two spaces after the:) or if other(shorter) seperators are fine. You didn't address the unicode/encoding issue. – CodesInChaos – 12 years agowhat kind of sort order is that? – Spongman – 12 years ago
@Spongman The missing one type – Eduard Florinescu – 12 years ago
Function or complete program taking stdin and writing stdout? – MtnViewMark – 12 years ago
The "shortest overall" does not follow the required output. Is that okay? – microbian – 12 years ago
@microbian I see that as a soft requirement :) – Eduard Florinescu – 12 years ago
@Eduard Florinescu, yeah, but the trouble is that your output IS sorted - losely as if it were read from a binary heap. yet you do not specify if that is a requirement. you say "The output should be" which implies that the order should be maintained. – Spongman – 12 years ago
@Spongman I used a dictionary for that, that's why, I will edit the question. – Eduard Florinescu – 12 years ago
@EduardFlorinescu What about JavaScript? There is no standard input. You could say that the console is standard output. – Toothbrush – 12 years ago
@toothbrush
prompt()? readline for nodejs – Eduard Florinescu – 12 years ago@toothbrush nodejs: http://stackoverflow.com/questions/5006821/nodejs-how-to-read-keystrokes-from-stdin
– Eduard Florinescu – 12 years ago@EduardFlorinescu OK, thank you. I was thinking about in the browser. Is it OK to pass the string in a variable, then? – Toothbrush – 12 years ago