Back to Problem Solutions forum
Here's what I do:
read line 1 from stdin, split it and convert its members to uint
read line 2 from stdin, split it and convert its members to uint
create an array of size 21 (indices 0 to 20)
loop through line 2 array and increment the value at the respective index
double check: sum the members of the final array and compare with first argument of line 1
output result if number match, else raise exception
My results are always incorrect, although all test cases work fine.
Could anyone tell me where I might go wrong? I will provide code if necessary.
I've found what's wrong. Unlike other problems this one does not accept input with commas.
Hi!
I'm glad you get through it, though honestly I did not know that other problems accept input with commas - or probably I do not understand correctly what is input and how you use commas :)
I use D for programming and it has a wide support range for data to be processed in any way. So if you have an array of ints A = {1, 2, 3, 4, 5, 6} I will define this as int[] A = [1, 2, 3, 4, 5, 6];. When it comes to printing I simply type A.writeln;. Output will then literally be [1, 2, 3, 4, 5, 6].
And that's where the commas come from. I guess it worked with the easiest problems.