Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
titletest case
linenumberstrue
testcases = {"bbbaacdafe": True,
             "aabbb": False, 
             "bbc": False, 
             "bbbaa" : False, 
             "abcdefghijklmnopqrstuvwxyzz": False, 
             "abcdefghijklmnopqrstuvwxyz": True, 
             "abcdefghijklmnopqrstuvwxyzqwertuiopasdfghjklxcvbnm": True, 
             "fyudhrygiuhdfeis": False, 
             "zaa": False, 
             "zyy": False,}

def test_solution(testcases) : 
    for t in testcases.keys():
        result = isBeautifulString(t)
        
        if testcases[t] != result:
            print(f"Wrong Case: {t} / expected: {testcases[t]} / your : {result}")
        
    print("Test Finished")


##  WIP RefactoringRefactoring

Code Block
languagepy
titleRefactoring
linenumberstrue
import string 

def isBeautifulString(inputString):
    cnts = [inputString.count(c) for c in string.ascii_lowercase]

    return cnts[::-1] == sorted(cnts)
  • python battery included 만세


ref

...