From c8e41daa475cac3d75814b60bd2915bd4786721f Mon Sep 17 00:00:00 2001 From: Sangeeth Lal P S <57190119+pssangeethlal@users.noreply.github.com> Date: Sat, 10 Oct 2020 18:40:55 +0530 Subject: [PATCH 1/3] Added jumping on the clouds problem.py Added jumping on the clouds problem.py --- Python/Jumping on the clouds.py | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Python/Jumping on the clouds.py diff --git a/Python/Jumping on the clouds.py b/Python/Jumping on the clouds.py new file mode 100644 index 00000000..f227c272 --- /dev/null +++ b/Python/Jumping on the clouds.py @@ -0,0 +1,49 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys +def jumpingOnClouds(c): #0 0 1 0 0 1 0 + n = len(c) + jmp = 0 + while n > 1: + if n != 2: + if c[1] == 0 and c[2] == 0: + + jmp += 1 + c[:2] = '' + n -= 2 + elif c[1] == 1 and c[2] == 0: + jmp += 1 + c[:2] = '' + n -= 2 + else: + c[:1] = '' + jmp += 1 + n -= 1 + + + else: + if c[1] == 0: + c[:1] = '' + jmp += 1 + n -= 1 + n -= 1 + + return jmp + + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + n = int(input()) + + c = list(map(int, input().rstrip().split())) + + result = jumpingOnClouds(c) + + fptr.write(str(result) + '\n') + + fptr.close() From 8ac377a0a2ded8554870c7ec04308e0ac0801d35 Mon Sep 17 00:00:00 2001 From: Sangeeth Lal P S <57190119+pssangeethlal@users.noreply.github.com> Date: Sat, 10 Oct 2020 18:55:41 +0530 Subject: [PATCH 2/3] Added Counting valleys.py Added counting valleys problem by Sangeeth lal --- Python/Counting Valleys.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Python/Counting Valleys.py diff --git a/Python/Counting Valleys.py b/Python/Counting Valleys.py new file mode 100644 index 00000000..fe657a0e --- /dev/null +++ b/Python/Counting Valleys.py @@ -0,0 +1,35 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + + +def countingValleys(n, s): + lvl = 0 + vly = 0 + for i in s: + if i == 'U': + lvl += 1 + else: + lvl -= 1 + if i == 'U' and lvl == 0: + vly += 1 + return vly + + + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + n = int(input()) + + s = input() + + result = countingValleys(n, s) + + fptr.write(str(result) + '\n') + + fptr.close() From 3063a334c93788a8f1d2eeb4cb3d8d68d32c7a4b Mon Sep 17 00:00:00 2001 From: Sangeeth Lal P S <57190119+pssangeethlal@users.noreply.github.com> Date: Sat, 10 Oct 2020 19:10:32 +0530 Subject: [PATCH 3/3] Update Jumping on clouds.py Emma is playing a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. She can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus 1 or 2. She must avoid the thunderheads. Determine the minimum number of jumps it will take Emma to jump from her starting postion to the last cloud. It is always possible to win the game. --- Python/Jumping on the clouds.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Python/Jumping on the clouds.py b/Python/Jumping on the clouds.py index f227c272..02b84d2e 100644 --- a/Python/Jumping on the clouds.py +++ b/Python/Jumping on the clouds.py @@ -1,5 +1,4 @@ #!/bin/python3 - import math import os import random