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.
I feel that you could use
Counter
instead. It automatically creates a dictionary from the string instead of using a for loop to create it.You could check out what I did for an example.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I did the same answer but I think it's was not needed.
this statement: if char in char_dict ...
Because dicts update his values in the same char spot.
This comment is hidden because it contains spoiler information about the solution
I like the solution but I suggest you to try to implement a more pythonic solution. Keep working hard my friend
Once any character occurs twice, you may terminate right away and return False. You can put the condition from your second for loop in the first for loop.
If "Aabcdefghijklmnopqrstuvwxyz.." was given, you can already decide by checking the first two characters.
thank you very much ! I have the same idea with you, but fail to count the single letter. thank you !
My solution was very similar, and honestly I smacked my head when I realized I could have just used sets.
if list are worse then I may suggest sets?
and btw, the idea I meant wasn't about dict or list more than about why counting frequencies of words when all we need to do is terminating when the first repeatition occurs.
List
is the worst option...I know there are many solutions however why do you want to use dictionaries? you are counting the frequencies of the letters which is not needed
you can terminate right away when a repeat is occur, I did that in my solution you can check it if you like however, you can solve this with list, tuples dict and sets
I would say list would be the best since there is no need to use a dictionary.
If you're concerned with performance it might work better to check the dict for duplicates in the first loop, so you can return early on massive inputs that aren't isograms. You wouldn't have to loop through the dict since you know what letter would be a duplicate that hadn't shown up as one earlier.
Thus we do not have to maintain counters of chars at all. I think your comment is very useful one.
Sorry mate.
Loading more items...