From 6afb3d8c3a75e75c2cca04809aff84e14c82fae8 Mon Sep 17 00:00:00 2001 From: Gabriel Donnan <47415809+gabedonnan@users.noreply.github.com> Date: Mon, 13 Feb 2023 10:14:00 +0000 Subject: [PATCH] Create count-odds.py simple loopless odd number counter --- count-odds.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 count-odds.py diff --git a/count-odds.py b/count-odds.py new file mode 100644 index 0000000..0a4a4be --- /dev/null +++ b/count-odds.py @@ -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)