Last active
September 26, 2017 08:41
-
-
Save CSaratakij/845f4d68af782ab546d52c9e18077920 to your computer and use it in GitHub Desktop.
Get expect number and check its total stack and total number for each input.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def run(): | |
inputNum = input("Expect Number : ") | |
inputNum = int(inputNum) | |
expectNum = inputNum | |
previousNum = 0 | |
currentNum = 0 | |
totalExpectNumber = 0 | |
currentStack = 0 | |
maxStack = 0 | |
while inputNum != 0: | |
inputNum = input("Enter number : ") | |
inputNum = int(inputNum) | |
previousNum = currentNum | |
currentNum = inputNum | |
if previousNum == currentNum == expectNum: | |
currentStack += 1 | |
if currentStack > maxStack: | |
maxStack = currentStack | |
else: | |
currentStack = 0 | |
if currentNum == expectNum: | |
totalExpectNumber += 1 | |
if totalExpectNumber <= 1: | |
maxStack = 0 | |
else: | |
if maxStack > 0: | |
maxStack += 1 | |
print("\n") | |
print("Result : ") | |
print("Max Stack", maxStack) | |
print("Total Number : ", totalExpectNumber) | |
if __name__ == "__main__": | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment