Skip to content

Instantly share code, notes, and snippets.

@aaronshaver
Created April 6, 2022 23:13
Show Gist options
  • Save aaronshaver/520887c47947dec4240358a7f611ea65 to your computer and use it in GitHub Desktop.
Save aaronshaver/520887c47947dec4240358a7f611ea65 to your computer and use it in GitHub Desktop.
bit_count() function new in Python 3.10 counts true bits in a binary number
# https://leetcode.com/problems/minimum-bit-flips-to-convert-number/
def minBitFlips(self, start: int, goal: int) -> int:
return (start ^ goal).bit_count()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment