Skip to content

Commit

Permalink
Improve Project Euler problem 112 solution 1 (TheAlgorithms#4808)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximSmolskiy authored Oct 6, 2021
1 parent 629369a commit d654806
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion project_euler/problem_112/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def check_bouncy(n: int) -> bool:
"""
if not isinstance(n, int):
raise ValueError("check_bouncy() accepts only integer arguments")
return "".join(sorted(str(n))) != str(n) and "".join(sorted(str(n)))[::-1] != str(n)
str_n = str(n)
sorted_str_n = "".join(sorted(str_n))
return sorted_str_n != str_n and sorted_str_n[::-1] != str_n


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

0 comments on commit d654806

Please sign in to comment.