-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathsolution.py
More file actions
28 lines (26 loc) · 714 Bytes
/
Copy pathsolution.py
File metadata and controls
28 lines (26 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/python3
# importing modules
import math
import os
import random
import re
import sys
# Complete the beautifulBinaryString function below.
def beautifulBinaryString(b):
# just need to count the number of occurences of the required substring '010'
# return this count
return b.count('010')
# main or driver code
if __name__ == '__main__':
# opening the output buffer
fptr = open(os.environ['OUTPUT_PATH'], 'w')
# taking input
n = int(input())
# taking string as input
b = input()
# getting the result
result = beautifulBinaryString(b)
# writing to the output buffer
fptr.write(str(result) + '\n')
# closing the output stream / buffer
fptr.close()