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 – 2014-01-22T08:21:35.777
2Can I create a function, or is a whole program necessary? Can I output all the ascii characters and print
0
as the number of occurrences? – Justin – 2014-01-22T08:21:57.68316Is the output format strict, or it suffices to preserve the meaning? – John Dvorak – 2014-01-22T08:32:55.103
Your edit did not address my question. – Justin – 2014-01-22T09:00:16.720
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 – 2014-01-22T18:11:50.820what kind of sort order is that? – Spongman – 2014-01-23T18:57:55.147
@Spongman The missing one type – Eduard Florinescu – 2014-01-23T23:41:47.953
Function or complete program taking stdin and writing stdout? – MtnViewMark – 2014-01-24T15:25:46.197
The "shortest overall" does not follow the required output. Is that okay? – microbian – 2014-01-24T15:51:10.527
@microbian I see that as a soft requirement :) – Eduard Florinescu – 2014-01-24T15:52:40.517
@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 – 2014-01-24T18:51:36.027
@Spongman I used a dictionary for that, that's why, I will edit the question. – Eduard Florinescu – 2014-01-24T19:08:44.773
@EduardFlorinescu What about JavaScript? There is no standard input. You could say that the console is standard output. – Toothbrush – 2014-01-24T19:12:15.400
@toothbrush
prompt()
? readline for nodejs – Eduard Florinescu – 2014-01-24T19:14:35.463@toothbrush nodejs: http://stackoverflow.com/questions/5006821/nodejs-how-to-read-keystrokes-from-stdin
– Eduard Florinescu – 2014-01-24T19:21:38.770@EduardFlorinescu OK, thank you. I was thinking about in the browser. Is it OK to pass the string in a variable, then? – Toothbrush – 2014-01-24T19:35:09.243