File tree Expand file tree Collapse file tree 1 file changed +4
-24
lines changed
Expand file tree Collapse file tree 1 file changed +4
-24
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,10 @@ def is_pangram(
2121 >>> is_pangram()
2222 True
2323 """
24- # Declare frequency as a set to have unique occurrences of letters
2524 frequency = set ()
26-
27- # Replace all the whitespace in our sentence
2825 input_str = input_str .replace (" " , "" )
2926 for alpha in input_str :
30- if "a" <= alpha .lower () <= "z" :
27+ if alpha .isalpha () :
3128 frequency .add (alpha .lower ())
3229 return len (frequency ) == 26
3330
@@ -73,23 +70,6 @@ def is_pangram_fastest(
7370 """
7471 return len ({char for char in input_str .lower () if char .isalpha ()}) == 26
7572
76-
77- def benchmark () -> None :
78- """
79- Benchmark code comparing different version.
80- """
81- from timeit import timeit
82-
83- setup = "from __main__ import is_pangram, is_pangram_faster, is_pangram_fastest"
84- print (timeit ("is_pangram()" , setup = setup ))
85- print (timeit ("is_pangram_faster()" , setup = setup ))
86- print (timeit ("is_pangram_fastest()" , setup = setup ))
87- # 5.348480500048026, 2.6477354579837993, 1.8470395830227062
88- # 5.036091582966037, 2.644472333951853, 1.8869528750656173
89-
90-
91- if __name__ == "__main__" :
92- import doctest
93-
94- doctest .testmod ()
95- benchmark ()
73+
74+
75+
You can’t perform that action at this time.
0 commit comments