Skip to content

Commit

Permalink
Create count-odds.py
Browse files Browse the repository at this point in the history
simple loopless odd number counter
  • Loading branch information
gabedonnan authored Feb 13, 2023
1 parent 1f9eef0 commit 6afb3d8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions count-odds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Solution:
def countOdds(self, low: int, high: int) -> int:
return ((high - low) // 2) + (0 if (high % 2 == 0 and low % 2 == 0) else 1)

0 comments on commit 6afb3d8

Please sign in to comment.