Ad
  • Custom User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I like the solution but I suggest you to try to implement a more pythonic solution. Keep working hard my friend

  • Default User Avatar

    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.

  • Default User Avatar

    thank you very much ! I have the same idea with you, but fail to count the single letter. thank you !

  • Custom User Avatar

    My solution was very similar, and honestly I smacked my head when I realized I could have just used sets.

  • Default User Avatar

    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.

  • Custom User Avatar

    List is the worst option...

  • Default User Avatar

    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.

  • Default User Avatar

    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.

  • Custom User Avatar

    Thus we do not have to maintain counters of chars at all. I think your comment is very useful one.

  • Default User Avatar

    Sorry mate.

  • Loading more items...