Skip to content

Commit d654806

Browse files
Improve Project Euler problem 112 solution 1 (TheAlgorithms#4808)
1 parent 629369a commit d654806

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

project_euler/problem_112/sol1.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def check_bouncy(n: int) -> bool:
4747
"""
4848
if not isinstance(n, int):
4949
raise ValueError("check_bouncy() accepts only integer arguments")
50-
return "".join(sorted(str(n))) != str(n) and "".join(sorted(str(n)))[::-1] != str(n)
50+
str_n = str(n)
51+
sorted_str_n = "".join(sorted(str_n))
52+
return sorted_str_n != str_n and sorted_str_n[::-1] != str_n
5153

5254

5355
def solution(percent: float = 99) -> int:

0 commit comments

Comments
 (0)