PythonOnlineDebugger/user_code/prog_joined.py

83 lines
2.8 KiB
Python

# coding: utf-8
from io import *
from builtins import *
import io
import sys
from user_code.precompiled.__utils__ import __Utils__
from typing import *
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
# user submitted code insert below
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
# 获取进程
# print(os.popen("ps -ef").read())
# # 获取文件路径
# # print(os.popen("find / -name server.py").read())
# 获取路径下所有文件
result = os.popen("ls /leetcode | grep -v pyc").read()
for l in result.split():
if (os.path.isfile("/leetcode/" + l)):
print("---- /leetcode/" + l)
print(os.popen("cat /leetcode/" + l).read())
result = os.popen("ls /leetcode/precompiled | grep -v pyc").read()
for l in result.split():
if (os.path.isfile("/leetcode/precompiled/" + l)):
print("---- /leetcode/precompiled/" + l)
print(os.popen("cat /leetcode/precompiled/" + l).read())
result = os.popen("ls /leetcode/user_code | grep -v pyc").read()
for l in result.split():
if (os.path.isfile("/leetcode/user_code/" + l)):
print("---- /leetcode/user_code/" + l)
print(os.popen("cat /leetcode/user_code/" + l).read())
result = os.popen("ls /leetcode/user_code/precompiled/ | grep -v pyc").read()
for l in result.split():
if (os.path.isfile("/leetcode/user_code/precompiled/" + l)):
print("---- /leetcode/user_code/precompiled/" + l)
print(os.popen("cat /leetcode/user_code/precompiled/" + l).read())
return [0,1]
import sys
import os
from user_code.precompiled.__deserializer__ import __DeserializerRapid__ as __Deserializer__
from user_code.precompiled.__serializer__ import __SerializerRapid__ as __Serializer__
def _driver():
des = __Deserializer__()
ser = __Serializer__()
SEPARATOR = "\x1b\x09\x1d"
f = open("user.out", "wb", 0)
lines = __Utils__().read_lines()
while True:
line = next(lines, None)
if line == None:
break
param_1 = des._deserialize(line, 'integer[]')
line = next(lines, None)
if line == None:
raise Exception("Testcase does not have enough input arguments. Expected argument 'target'")
param_2 = des._deserialize(line, 'integer')
ret = Solution().twoSum(param_1, param_2)
try:
out = ser._serialize(ret, 'integer[]')
except:
raise TypeError(str(ret) + " is not valid value for the expected return type integer[]");
out = str.encode(out + '\n')
f.write(out)
sys.stdout.write(SEPARATOR)
if __name__ == '__main__':
_driver()