Skip to content

Instantly share code, notes, and snippets.

@fabian57
Last active August 29, 2015 14:14
Show Gist options
  • Save fabian57/655fea9249f9036d7c5c to your computer and use it in GitHub Desktop.
Save fabian57/655fea9249f9036d7c5c to your computer and use it in GitHub Desktop.
from official.ref.is_palindromic_1 import is_palindromic
result = 0
for i in range(1, 1000000):
if is_palindromic(str(i)) and is_palindromic(bin(i)[2:]):
result += i
print result
@laowantong
Copy link

Dans is_palindromic(str(bin(i))[2:]), tu peux enlever str, le résultat de bin est déjà une chaîne. Aucun problème sinon. Je me demande si utiliser [::-1] pour tester la palindromie, plus tôt que d'appeler notre fonction, serait plus rapide ou pas (sachant qu'on ne ferait pas de sortie prématurée dans ce cas)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment