Skip to content

Commit

Permalink
P4, P36, P55, P112, P125: Added spaces to slice notation in Python so…
Browse files Browse the repository at this point in the history
…lutions.
  • Loading branch information
nayuki committed Jul 4, 2017
1 parent 47d123f commit ee51eff
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/p004.py
Expand Up @@ -14,7 +14,7 @@ def compute():
for j in range(100, 1000):
k = i * j
s = str(k)
if s == s[::-1] and k > ans:
if s == s[ : : -1] and k > ans:
ans = k
return str(ans)

Expand Down
4 changes: 2 additions & 2 deletions python/p036.py
Expand Up @@ -18,10 +18,10 @@ def compute():

def is_decimal_binary_palindrome(n):
s = str(n)
if s != s[::-1]:
if s != s[ : : -1]:
return False
t = bin(n)[2 : ]
return t == t[::-1]
return t == t[ : : -1]


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions python/p055.py
Expand Up @@ -14,8 +14,8 @@ def compute():

def is_lychrel(n):
for i in range(50):
n += int(str(n)[::-1])
if str(n) == str(n)[::-1]:
n += int(str(n)[ : : -1])
if str(n) == str(n)[ : : -1]:
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion python/p112.py
Expand Up @@ -14,7 +14,7 @@ def compute():
for i in itertools.count(1):
s = str(i)
t = "".join(sorted(s))
if s != t and s[::-1] != t:
if s != t and s[ : : -1] != t:
count += 1 # i is bouncy
if count * 100 == 99 * i:
return str(i)
Expand Down
2 changes: 1 addition & 1 deletion python/p125.py
Expand Up @@ -18,7 +18,7 @@ def compute():
if sigma >= 100000000:
break
s = str(sigma)
if s == s[::-1]: # Is palindrome
if s == s[ : : -1]: # Is palindrome
nums.add(sigma)
return str(sum(nums))

Expand Down

0 comments on commit ee51eff

Please sign in to comment.