Add files via upload

master
JesterHey 2 years ago committed by GitHub
parent 52c2e53968
commit 5c2b3fa7e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1 @@
{"my_api":"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"}

@ -1,5 +1,6 @@
import os import numpy as np
def getalljsons() -> list: import pandas as pd
return [i for i in os.listdir() if i.endswith('.json')] np.random.seed(0)
for i in getalljsons(): df1 = pd.DataFrame(np.random.randint(0,10,size=(5, 6)), columns=list('ABCDEF'))
os.remove(i) print(df1)
print(df1.head(2)[['A','B']])

@ -0,0 +1,11 @@
import requests
headers = {
'Cookie': 'autologin_trustie=bb3a180a619e2e75610e06dcb8181f1951692d36; _educoder_session=497c9154b70e3a840e04f3fba8096472',
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Referer': 'https://www.educoder.net/tasks/27V4D95N/1191512/8p2s3yzoxuit?coursesId=27V4D95N'
}
url = 'https://data.educoder.net/api/myshixuns/gorxjivf6b/challenges.json'
response = requests.get(url=url,headers=headers)
print(len(response.json()))
response.close()

@ -101,7 +101,7 @@ def get_shixunanswer_from_api(jsonfile:dict,client:AsyncOpenAI,promot:str) -> di
else: else:
language = get_shixunjson(os.getcwd())[0].split('.')[0].split('_')[-1] language = get_shixunjson(os.getcwd())[0].split('.')[0].split('_')[-1]
data = jsonfile data = jsonfile
promot1 = f'现在,我想让你扮演一个资深而经验丰富的程序员来解一个问题,我的问题将由三个部分组成,第一部分是问题的描述,第二部分是问题的需求,第三部分是问题的代码,我需要你按照我的模板编写代码,使用的代码语言是{language}。并且你返回的代码应当是带有注释的。再次注意,请返回完整的,格式正确的,可读的代码!' promot1 = f'现在,我想让你扮演一个资深而经验丰富的程序员来解一个问题,我的问题将由三个部分组成,第一部分是问题的描述,第二部分是问题的需求,第三部分是问题的代码,我需要你按照我的模板编写代码,使用的代码语言是{language}。并且你返回的代码应当是带有注释的。再次注意,请返回完整的,格式正确的,可读的代码!并且,在没有特殊要求的情况下,不用给出用于运行补全后代码的示例代码'
# 异步函数来获取答案 # 异步函数来获取答案
async def get_answer(key,value) -> str: async def get_answer(key,value) -> str:
''' '''
@ -157,7 +157,7 @@ def get_programming_answer_from_api(jsonfile:list,client:AsyncOpenAI,promot:str)
else: else:
language = get_shixunjson(os.getcwd())[0].split('.')[0].split('_')[-1] language = get_shixunjson(os.getcwd())[0].split('.')[0].split('_')[-1]
data = jsonfile data = jsonfile
promot2 = f'现在,我想让你扮演一个资深而经验丰富的程序员来解一个问题,我的问题会有两个部分组成,第一部分是问题的描述,第二部分是你需要补全或者完善的代码。你需要阅读,理解我的问题描述,然后补全或者完善代码,使用的代码语言是{language}。再次注意,请返回完整的,格式正确的,输入由用户给出的,可读的代码!' promot2 = f'现在,我想让你扮演一个资深而经验丰富的程序员来解一个问题,我的问题会有两个部分组成,第一部分是问题的描述,第二部分是你需要补全或者完善的代码。你需要阅读,理解我的问题描述,然后补全或者完善代码,使用的代码语言是{language}。再次注意,请返回完整的,格式正确的,输入由用户给出的,可读的代码!并且,在没有特殊要求的情况下,不用给出用于运行补全后代码的示例代码'
# 异步函数来获取答案 # 异步函数来获取答案
async def get_answer(value:dict) -> str: async def get_answer(value:dict) -> str:
pro_id = value['id'] pro_id = value['id']
@ -205,8 +205,7 @@ def get_programming_answer_from_api(jsonfile:list,client:AsyncOpenAI,promot:str)
if __name__ == '__main__': if __name__ == '__main__':
promot='' promot=''
ans = get_programming_answer_from_api(jsonfile=get_programmingjson(os.getcwd()),client=client,promot=promot) ans = get_shixunanswer_from_api(load_json_data(get_shixunjson(os.getcwd())[0]),client=client,promot=promot)
print(ans) print(ans)
rewrite_programming_json(json_names=get_programmingjson(os.getcwd()), rewrite_shixun_json(get_shixunjson(os.getcwd())[0],ans)
new_data=ans)
#new_data = get_programming_answer_from_api(get_programmingjson(os.getcwd()),client=client,promot=promot2) #new_data = get_programming_answer_from_api(get_programmingjson(os.getcwd()),client=client,promot=promot2)

@ -8,12 +8,11 @@
3课程id,实训id 3课程id,实训id
4写入本地json文件中 4写入本地json文件中
''' '''
globals()['retry'] = 0
#导入所需模块 #导入所需模块
import platform import platform
import os import os
import json import json
import time
from selenium.webdriver import Chrome from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
@ -23,12 +22,10 @@ from lxml import etree
import time import time
import requests import requests
from cloud import is_exist,download from cloud import is_exist,download
global retry
retry = 0
#配置参数 #配置参数
opt = Options() opt = Options()
opt.add_experimental_option('detach', True) opt.add_experimental_option('detach', True)
opt.add_argument('--headless') #opt.add_argument('--headless')
platf = platform.platform() platf = platform.platform()
def is_practice(url:str) -> bool: def is_practice(url:str) -> bool:
obj=re.compile(r'www.educoder.net/tasks') obj=re.compile(r'www.educoder.net/tasks')
@ -45,188 +42,201 @@ def is_programming(url:str) -> bool:
# 另外目前好像只有实训作业有这些参数其他的作业例如编程作业就没有所以先判断一下是否为实训作业可以通过用户输入的url判断 # 另外目前好像只有实训作业有这些参数其他的作业例如编程作业就没有所以先判断一下是否为实训作业可以通过用户输入的url判断
# 主要是看educoder.net/后面是否有tasks如果有则是实训作业否则不是实训作业 # 主要是看educoder.net/后面是否有tasks如果有则是实训作业否则不是实训作业
#为方便main.py调用将判断函数写入函数中以下部分封装为函数 #为方便main.py调用将判断函数写入函数中以下部分封装为函数
def get_parameters(url: str, user_name: str, password: str): def get_parameters(url: str, user_name: str, password: str,retry:int=2):
''' '''
用于获得实训作业的参数 用于获得实训作业的参数
url:实训网址 url:实训网址
user_name:用户名 user_name:用户名
password:密码 password:密码
''' '''
url = url global challenge_id
user_name = user_name while retry <= 2:
password = password print('正在获取参数')
if is_practice(url): url = url
#构造selenium对象 user_name = user_name
safari = Chrome(options=opt) password = password
safari.get(url) if is_practice(url):
#模拟登录 #构造selenium对象
safari.implicitly_wait(10) safari = Chrome(options=opt)
safari.find_element(By.ID, 'login').send_keys(user_name) safari.get(url)
safari.find_element(By.ID, 'password').send_keys(password) #模拟登录
safari.find_element(By.ID, 'password').send_keys(Keys.ENTER) safari.implicitly_wait(10)
time.sleep(2) safari.find_element(By.ID, 'login').send_keys(user_name)
#判断是否登录成功 safari.find_element(By.ID, 'password').send_keys(password)
try: safari.find_element(By.ID, 'password').send_keys(Keys.ENTER)
safari.find_element(By.XPATH, time.sleep(2)
'//*[@id="task-left-panel"]/div[1]/a[1]') #判断是否登录成功
except BaseException:
print('登录失败 请检查输入信息是否正确')
# 关闭浏览器
safari.quit()
# #重新调用login_ui.py
# if 'Windows' in platf:
# os.system('python login_ui.py')
# else:
# os.system('python3 login_ui.py')
#获取cookieUser-Agent
Cookie = safari.get_cookies()
User_Agent = safari.execute_script('return navigator.userAgent')
cookie = f'autologin_trustie={Cookie[1]["value"]}; _educoder_session={Cookie[0]["value"]}'
#先获取到shixun_id便于先判断云端文件是否存在
cur_url = url
identity = cur_url.split('/')[-1].split('?')[0]
id_url = f'https://data.educoder.net/api/tasks/{identity}.json?'
headers = {
'Cookie': cookie,
'User-Agent': User_Agent,
'Referer': cur_url
}
response = requests.get(url=id_url, headers=headers)
shixun_id = dict(response.json())['challenge']['shixun_id']
language = requests.get(f'https://data.educoder.net/api/tasks/{identity}/rep_content.json',headers=headers).json()['content']['language']
#判断云端文件是否存在
exist = is_exist(f'{shixun_id}_{language}.json')
if exist:
try:
print('云端文件已存在,正在下载')
download(f'{shixun_id}.json')
# 检测本地文件是否下载完成
while True:
try:
if os.path.exists(f'{shixun_id}_{language}.json'):
print('下载完成')
safari.quit()
return
break
except Exception as e:
print(e)
except Exception as e:
print(e)
else: #不存在,则继续执行本程序
print('云端文件不存在,正在爬取')
#获取关卡数
#点击展开关卡页面
time.sleep(3)
safari.find_element(
By.XPATH, '//*[@id="task-left-panel"]/div[1]/a[1]').click()
#关卡数量由 class = "flex-container challenge-title space-between" 的元素数量决定
time.sleep(3)
htmltxt = safari.page_source
html = etree.HTML(htmltxt)
task_num = html.xpath(
'count(//*[@class="flex-container challenge-title space-between"])'
)
task_num = int(task_num)
print(f'关卡数量为{task_num}')
#回到第一关
time.sleep(3)
safari.find_element(
By.XPATH,
'//*[@id="task-left-panel"]/div[3]/div[3]/div/div/div/div/div[1]/div[1]/a'
).click()
#对于每一关,获取参数
#每一关的参数由以下元素组成:
'''
/html/body/div[1]/div/div/div/div[2]/section[1]/div[3]/div[3]/div/div/div/div/div[3]/div[1]/a
/html/body/div[1]/div/div/div/div[2]/section[1]/div[3]/div[3]/div/div/div/div/div[4]/div[1]/a
'''
obj1 = re.compile(
r'<h3 id="任务描述">任务描述</h3><p>(?P<describe>.*?)</p>', re.S)
obj2 = re.compile(
r'<h3 id="编程要求">编程要求</h3><p>(?P<require>.*?)</p>', re.S)
#初始化一个字典,用于存放所有关卡的参数
total = {}
i = 1
try: try:
while i <= task_num: safari.find_element(By.XPATH,'//*[@id="task-left-panel"]/div[1]/a[1]')
cur_url = Referer = safari.current_url except BaseException:
identity = cur_url.split('/')[-1].split('?')[0] print('登录失败 请检查输入信息是否正确')
id_url = f'https://data.educoder.net/api/tasks/{identity}.json?' # 关闭浏览器
#获取课程id safari.quit()
headers = { # #重新调用login_ui.py
'Cookie': cookie, # if 'Windows' in platf:
'User-Agent': User_Agent, # os.system('python login_ui.py')
'Referer': Referer # else:
} # os.system('python3 login_ui.py')
try: #获取cookieUser-Agent
time.sleep(1)
Cookie = safari.get_cookies()
User_Agent = safari.execute_script('return navigator.userAgent')
cookie = f'autologin_trustie={Cookie[1]["value"]}; _educoder_session={Cookie[0]["value"]}'
#先获取到shixun_id便于先判断云端文件是否存在
cur_url = safari.current_url
identity = cur_url.split('/')[-1].split('?')[0]
print(identity)
id_url = f'https://data.educoder.net/api/tasks/{identity}.json?'
headers = {
'Cookie': cookie,
'User-Agent': User_Agent,
'Referer': cur_url
}
response = requests.get(url=id_url, headers=headers)
shixun_id = dict(response.json())['challenge']['shixun_id']
language = requests.get(f'https://data.educoder.net/api/tasks/{identity}/rep_content.json',headers=headers).json()['language']
identifier = response.json()['myshixun']['identifier']
print(identifier)
response.close()
#判断云端文件是否存在
exist = is_exist(f'{shixun_id}_{language}.json')
if exist:
try:
print('云端文件已存在,正在下载')
download(f'{shixun_id}.json')
# 检测本地文件是否下载完成
while True:
try:
if os.path.exists(f'{shixun_id}_{language}.json'):
print('下载完成')
safari.quit()
return
break
except Exception as e:
print(e)
except Exception as e:
print(e)
else: #不存在,则继续执行本程序
print('云端文件不存在,正在爬取')
#获取关卡数
#点击展开关卡页面
time.sleep(2)
safari.find_element(
By.XPATH, '//*[@id="task-left-panel"]/div[1]/a[1]').click()
# 展开后服务器会返回一个challenges.json文件里面包含了所有关卡的参数
# https://data.educoder.net/api/myshixuns/{identifier}/challenges.json 这个链接就是返回的json文件
identifier_url = f'https://data.educoder.net/api/myshixuns/{identifier}/challenges.json'
resp2 = requests.get(url=identifier_url, headers=headers)
#获取关卡数量
print(resp2.json())
task_num = len(resp2.json())
resp2.close()
#回到第一关
time.sleep(2)
safari.find_element(
By.XPATH,
'//*[@id="task-left-panel"]/div[3]/div[3]/div/div/div/div/div[1]/div[1]/a'
).click()
#对于每一关,获取参数
#每一关的参数由以下元素组成:
'''
/html/body/div[1]/div/div/div/div[2]/section[1]/div[3]/div[3]/div/div/div/div/div[3]/div[1]/a
/html/body/div[1]/div/div/div/div[2]/section[1]/div[3]/div[3]/div/div/div/div/div[4]/div[1]/a
'''
obj1 = re.compile(
r'<h3 id="任务描述">任务描述</h3><p>(?P<describe>.*?)</p>', re.S)
obj2 = re.compile(
r'<h3 id="编程要求">编程要求</h3><p>(?P<require>.*?)</p>', re.S)
#初始化一个字典,用于存放所有关卡的参数
total = {}
i = 1
try:
while i <= task_num:
time.sleep(2)
cur_url = Referer = safari.current_url
identity = cur_url.split('/')[-1].split('?')[0]
id_url = f'https://data.educoder.net/api/tasks/{identity}.json?'
#获取课程id
headers = {
'Cookie': cookie,
'User-Agent': User_Agent,
'Referer': Referer
}
response = requests.get(url=id_url, headers=headers) response = requests.get(url=id_url, headers=headers)
challenge_id = dict(response.json())['challenge']['id'] challenge_id = response.json()['challenge']['id']
shixun_id = dict(response.json())['challenge']['shixun_id'] shixun_id = response.json()['challenge']['shixun_id']
except BaseException: print(f'{i}关的id为{challenge_id},爬取成功')
print('获取课程id失败') #获取任务描述(如果存在的话)
#获取任务描述(如果存在的话) time.sleep(2)
time.sleep(3) page_source = safari.page_source
page_source = safari.page_source describe = obj1.findall(page_source)
describe = obj1.findall(page_source) #获取编程要求(如果存在的话)
#获取编程要求(如果存在的话) require = obj2.findall(page_source)
require = obj2.findall(page_source) #获取编辑器中的代码,采用requests抓取https://data.educoder.net/api/tasks/{identity}/rep_content.json中的content中的content
#获取编辑器中的代码,采用requests抓取https://data.educoder.net/api/tasks/{identity}/rep_content.json中的content中的content # 然后然后这个content是一个base64编码的字符串需要解码
# 然后然后这个content是一个base64编码的字符串需要解码 code = requests.get(
code = requests.get( f'https://data.educoder.net/api/tasks/{identity}/rep_content.json',
f'https://data.educoder.net/api/tasks/{identity}/rep_content.json', headers=headers).json()['content']['content']
headers=headers).json()['content']['content'] #把参数存入字典再转换为json格式
#把参数存入字典再转换为json格式 task = {
task = { 'describe':
'describe': describe[0] if len(describe) != 0 else '',
describe[0] if len(describe) != 0 else '', 'require':
'require': require[0] if len(require) != 0 else '',
require[0] if len(require) != 0 else '', 'code':
'code': code,
code, 'verified':
'verified': False, #这个参数是用来标记答案是否被用户认证为正确答案的初始值为False
False, #这个参数是用来标记答案是否被用户认证为正确答案的初始值为False 'last_modified':
'last_modified': time.strftime(
time.strftime( '%Y-%m-%d %H:%M:%S', time.localtime(
'%Y-%m-%d %H:%M:%S', time.localtime( time.time())), #这个参数是用来标记答案最后一次被修改的时间,初始值为当前时间
time.time())), #这个参数是用来标记答案最后一次被修改的时间,初始值为当前时间 'language':
'language': language if language != None else ''
language if language != None else '' }
} print(f'{i}关的参数为{task}')
#把每一关的参数存入总的字典中 #把每一关的参数存入总的字典中
total[challenge_id] = task total[challenge_id] = task
#去往下一关 print('当前参数为')
safari.implicitly_wait(10) print(total)
if i == 1: #去往下一关
i += 1 safari.implicitly_wait(10)
safari.find_element(By.XPATH,f'//*[@id="task-right-panel"]/div[4]/div/div[2]/a').click() if i <= 1:
elif i < task_num: i += 1
i += 1 safari.find_element(By.XPATH,f'//*[@id="task-right-panel"]/div[4]/div/div[2]/a').click()
safari.find_element(By.XPATH,f'//*[@id="task-right-panel"]/div[4]/div/div[2]/a[2]').click() elif i < task_num:
else: i += 1
i += 1 safari.find_element(By.XPATH,f'//*[@id="task-right-panel"]/div[4]/div/div[2]/a[2]').click()
except Exception as e: else:
print(e) i += 1
print(f'{i}关参数获取参数失败') except Exception as e:
#判断爬取到的代码是否存在空值或者键的数量是否与关卡数量相等,如果不相等,则说明爬取失败,需要重新爬取 print(e)
print(f'{i}关参数获取参数失败')
# if len(total) != task_num: #判断爬取到的代码是否存在空值或者键的数量是否与关卡数量相等,如果不相等,则说明爬取失败,需要重新爬取
# print('参数爬取失败,正在重新爬取') if len(total) != task_num:
# get_parameters(url,user_name,password) if retry <= 2:
# else: print('参数有数量不对等,正在重新爬取')
# for i,j in total.items(): retry -= 1
# if j['code'] == '': continue
# print('参数爬取失败,正在重新爬取') else :
# get_parameters(url,user_name,password) print('参数爬取失败,超过最大重试次数,爬取失败')
return
#把参数写入本地json文件中文件名字与shixun_name相同键为course_id值为一个列表列表中每个元素为一个字典字典中包含每一关的参数 elif len(total) == task_num:
with open(f'{shixun_id}_{language}.json', 'w', encoding='utf-8') as f: for i,j in total.items():
json.dump(total, f, ensure_ascii=False, indent=4) if j['code'] == '' and retry <= 2:
print('参数爬取完成') print('参数有空值,正在重新爬取')
#关闭浏览器 retry -= 1
safari.quit() continue
else: #把参数写入本地json文件中文件名字与shixun_name相同键为course_id值为一个列表列表中每个元素为一个字典字典中包含每一关的参数
print('这不是一个实训作业') with open(f'{shixun_id}_{language}.json', 'w', encoding='utf-8') as f:
return json.dump(total, f, ensure_ascii=False, indent=4)
print('参数爬取完成')
#关闭浏览器
safari.quit()
return
else:
print('这不是一个实训作业')
return
def get_parameters_of_programming(url:str,user_name:str,password:str): def get_parameters_of_programming(url:str,user_name:str,password:str):
''' '''
@ -235,6 +245,7 @@ def get_parameters_of_programming(url:str,user_name:str,password:str):
user_name:用户名 user_name:用户名
password:密码 password:密码
''' '''
print('正在获取参数')
url = url url = url
user_name = user_name user_name = user_name
password = password password = password
@ -266,7 +277,7 @@ def get_parameters_of_programming(url:str,user_name:str,password:str):
Cookie = safari.get_cookies() Cookie = safari.get_cookies()
User_Agent = safari.execute_script('return navigator.userAgent') User_Agent = safari.execute_script('return navigator.userAgent')
cookie = f'autologin_trustie={Cookie[1]["value"]}; _educoder_session={Cookie[0]["value"]}' cookie = f'autologin_trustie={Cookie[1]["value"]}; _educoder_session={Cookie[0]["value"]}'
heders = { headers = {
'Cookie':cookie, 'Cookie':cookie,
'User-Agent':User_Agent, 'User-Agent':User_Agent,
'Referer':url 'Referer':url
@ -297,13 +308,12 @@ def get_parameters_of_programming(url:str,user_name:str,password:str):
i = 1 i = 1
while i<=task_num: while i<=task_num:
# 对于每一关,获取参数 # 对于每一关,获取参数
time.sleep(1)
cur_url = safari.current_url cur_url = safari.current_url
identity = cur_url.split('/')[-1].split('?')[0] identity = cur_url.split('/')[-1].split('?')[0]
resp = requests.get(f'https://data.educoder.net/api/myproblems/{identity}.json',headers=heders) resp = requests.get(f'https://data.educoder.net/api/myproblems/{identity}.json',headers=headers)
# 提取resp中的题目id题干代码等参数 # 提取resp中的题目id题干代码等参数
problem_data = resp.json() problem_data = resp.json()
# 初始化一个字典,用于存放所有关卡的参数
total = {}
# 题目id # 题目id
pro_id = problem_data['hack']['id'] pro_id = problem_data['hack']['id']
language = problem_data['hack']['language'] language = problem_data['hack']['language']
@ -345,8 +355,8 @@ def get_parameters_of_programming(url:str,user_name:str,password:str):
print('不是编程作业') print('不是编程作业')
if __name__ == '__main__': if __name__ == '__main__':
url = 'https://www.educoder.net/myproblems/9kwnlzvcegsa?type=1' url = 'https://www.educoder.net/tasks/27V4D95N/1363622/bkxl9wqvfjos?coursesId=27V4D95N'
user_name = 'hnu202311020126' user_name = 'hnu202311020126'
password = 'hzy123456' password = 'hzy123456'
get_parameters_of_programming(url,user_name,password) get_parameters(url,user_name,password)
print('结束测试') print('结束测试')

@ -21,8 +21,6 @@ from trans_to_txt import transToTxt,transToTxt_programming,get_programmingjson,g
import json import json
import os import os
from printtxt import print_txt,get_all_txt_file from printtxt import print_txt,get_all_txt_file
global finished
finished = False
# 调用login_ui获得用户输入的用户名、密码和实训网址 # 调用login_ui获得用户输入的用户名、密码和实训网址
show_image() show_image()
show_login() show_login()
@ -40,7 +38,7 @@ url = userinfo['url']
ispractice = is_practice(url=url) ispractice = is_practice(url=url)
if ispractice: if ispractice:
# 调用get_params.py获得参数完成后本地应该有一个json文件里面有参数 # 调用get_params.py获得参数完成后本地应该有一个json文件里面有参数
get_parameters(url,user_name,password) get_parameters(url=url,user_name=user_name,password=password)
else: else:
get_parameters_of_programming(url=url,user_name=user_name,password=password) get_parameters_of_programming(url=url,user_name=user_name,password=password)
print('参数获取完成!') print('参数获取完成!')

@ -50,7 +50,7 @@ class TypewriterEffectApp(QWidget):
self.index = 0 self.index = 0
self.timer = QTimer(self) self.timer = QTimer(self)
self.timer.timeout.connect(self.displayNextCharacter) self.timer.timeout.connect(self.displayNextCharacter)
self.timer.start(20) self.timer.start(5)
def displayNextCharacter(self): def displayNextCharacter(self):
if self.index < len(self.content): if self.index < len(self.content):

@ -0,0 +1,21 @@
class Solution:
def maxArea(self, height) -> int:
# 设x,y是某两根柱子的索引
# 要找的是表达式 abs(x-y) * min(height[x],height[y]) 之最大值
# 初始化两个指针,分别指向数组头和尾的索引
# 若向内移动长板,min()函数的值不变或变小s必然变小
# 若向内移动短板,min()函数的值可能变大s可能变大
i,j = 0,len(height) - 1
cur_max = (j-i) * min(height[i],height[j])
while i<j:
dis = j - i
cur_v = dis * min(height[i],height[j])
if cur_v > cur_max:
cur_max = cur_v
else:
pass
if height[i] <= height[j]:
i += 1
else:
j -= 1
return cur_max

@ -47,5 +47,6 @@ if __name__ == '__main__':
print('测试部分') print('测试部分')
# jsons = get_shixunjson(os.getcwd()) # jsons = get_shixunjson(os.getcwd())
# transToTxt(jsons) # transToTxt(jsons)
jsons = get_programmingjson(os.getcwd()) jsons = get_shixunjson(os.getcwd())
transToTxt_programming(jsons=jsons) print(jsons)
transToTxt(jsons)

Loading…
Cancel
Save