aboutsummaryrefslogtreecommitdiffstats
path: root/1758
diff options
context:
space:
mode:
Diffstat (limited to '1758')
-rwxr-xr-x1758/main.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/1758/main.py b/1758/main.py
new file mode 100755
index 0000000..79325e8
--- /dev/null
+++ b/1758/main.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+
+class Solution:
+ def minOperations(self, s: str) -> int:
+ f_c = 0
+ b_c = 0
+ cond = 48
+ for c in s:
+ if ord(c) != cond:
+ f_c += 1
+
+ if cond == 48:
+ cond = 49
+ else:
+ cond = 48
+
+ if ord(c) != cond:
+ b_c += 1
+
+ print(f_c, b_c)
+ return min(f_c, b_c)
+
+
+def main():
+ solution = Solution()
+ print(solution.minOperations("0100"))
+ print(solution.minOperations("10"))
+ print(solution.minOperations("1111"))
+ print(solution.minOperations("1100010111"))
+
+
+if __name__ == "__main__":
+ main()