Created
May 26, 2018 06:57
-
-
Save HayatoDoi/6b8c36f4287e08407a652fafbdf119cc to your computer and use it in GitHub Desktop.
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
import socket | |
host:str = 'tekeisan-ekusutoriim.chall.beginners.seccon.jp' | |
port:int = 8690 | |
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
client.connect((host, port)) | |
for i in range(0,101): | |
response = client.recv(4096).decode('utf-8') | |
print(response, end='') | |
if i == 100: | |
break | |
response_split = response.split('\n') | |
response_split_len:int = len(response_split) | |
formula:str = response_split[response_split_len - 1] | |
formula_split = formula.split(' ') | |
n1:int = int(formula_split[0]) | |
operator:str = formula_split[1] | |
n2:int = int(formula_split[2]) | |
if operator == '+': | |
ans = n1 + n2 | |
elif operator == '-': | |
ans = n1 - n2 | |
else : | |
ans = n1 * n2 | |
client.sendall((str(ans) + '\n').encode('utf-8')) | |
print(ans) | |
client.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment