Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
because count is an object. the ternary operation is checkin if the property (key: value) is in the count object already. if yes, it adds 1 to the stored value, if not it sets/adds the property.
so if string = 'example', the first run is going to see that count is empty, so count['e'] doesn't exist, and it will set count[e] = 1. then you have count = {e: 1}.
wow, this is pretty dumb by me lol. boo
hm, i see now that my code is redundant
learn maths yeah... :) mee too 3 hours to try to recreate the world...
hahaha, we're all here to learn. i didn't even realize.
I see, thank you to both of you. I'll try again + read the instruction
I've copied your solution locally to my computer -- as akar-0 said, in future if you use markdown it's much easier for people to troubleshoot -- your logic is basically fine, your code currently has 2 errors in its implementation.
The first error is a small "programming" error, which is introducing inaccuracies - check your mathematical operations in your code to see if you can find a place where you aren't working correctly with integer values.
The second error is a more important "mathematical" error: you don't need to use large test cases to debug it: try your code on the following string and then calculate the correct answer manually (pen and paper) to see where you are going wrong:
'ABBB' your code gives 8, correct answer is 4. Try to figure out where the discrepancy comes from.
Please use markdown to format your code or it's not readable, it is explained there: https://docs.codewars.com/training/troubleshooting/#post-discourse
Your code has probably the same problem as several persons that have posted questions recently (see comments below). Some operation you are doing is introducing useless inaccuracies, I guess.
This one was decided to stay !
hm, i can get the test cases but i haven't figured out what to do in certain cases yet.
definitely make sure to read it carefully and compare your output with the example.
had fun figuring it out, have a lot to learn from the solutions!
haha, i tried to do this and didn't really pull it off (slightly different way)
pretty fun, would like to revisit to see if i can do it better
good bc it forces you to try to use math due to the test cases.
Loading more items...