Skip to content

Conversation

@adrianfusco
Copy link
Contributor

No description provided.

def isNumberPalindrome(number: int | str) -> bool:
if isinstance(number, int):
number = str(number)
return number == number[::-1]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This perhaps the shortest way to do so, but we might want to specify that it's not the fastest

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I meant [::-1], not the bitwise operator

def isNumberPalindrome(number: int | str) -> bool:
if isinstance(number, int):
number = str(number)
return number == number[::-1]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I meant [::-1], not the bitwise operator

@bregman-arie bregman-arie merged commit a2db75e into bregman-arie:master Nov 24, 2021
eshack94 pushed a commit to eshack94/devops-exercises that referenced this pull request Oct 21, 2023
* New questions and spell check (bregman-arie#181)

Added new questions related with KVM, Libvirt and DNF

* New answers

* Adding a note about which way is faster: Union vs Bitwise

* Add comment about slicing vs reversed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants