Skip to content
Snippets Groups Projects
Commit 9206fb3c authored by hacker717's avatar hacker717
Browse files

Перенос testing в маи

parent 191b1bd1
No related branches found
No related tags found
No related merge requests found
md.txt
output.ipynb
todo.txt
\ No newline at end of file
from sys import stdin
arr = []
for line in stdin:
arr += [int(i) for i in line.rstrip("\n").split()]
print(sum(arr))
\ No newline at end of file
file_name, n = input(), int(input())
c = 0
with open(file_name, "r", encoding="utf-8") as file:
for line in file:
c += 1
with open(file_name, "r", encoding="utf-8") as file:
line_number = 0
for line in file:
line_number += 1
if line_number > c - n:
print(line, end="")
\ No newline at end of file
import json
in_file, js_file = input(), input()
res = {"count": 0, "positive_count": 0, "min": float("inf"),
"max": float("-inf"), "sum": 0, "average": 0}
with open(in_file, "r", encoding="utf-8")as inp:
for line in inp:
for num in [int(i) for i in line.split()]:
res["count"] += 1
if num > 0:
res["positive_count"] += 1
res["min"] = min(res["min"], num)
res["max"] = max(res["max"], num)
res["sum"] += num
res["average"] = round((res["sum"] / res["count"]), 2)
with open(js_file, "w", encoding="UTF-8") as js:
json.dump(res, js, ensure_ascii=False, indent=2)
\ No newline at end of file
def count_even_cif(num):
c = 0
for i in num:
if int(i) % 2 == 0:
c += 1
return c
finputname, fevenname, foddname, feqname = [input() for _ in range(4)]
even, odd, eq = [], [], []
evenfile = open(fevenname, "w", encoding="utf-8")
oddfile = open(foddname, "w", encoding="utf-8")
eqfile = open(feqname, "w", encoding="utf-8")
with open(finputname, "r", encoding="utf-8")as inputfile:
for line in inputfile:
for num in line.rstrip("\n").split():
ev = count_even_cif(num)
if len(num) - ev > ev:
odd.append(num)
elif len(num) == 2 * ev:
eq.append(num)
else:
even.append(num)
evenfile.write(" ".join(even) + "\n")
oddfile.write(" ".join(odd) + "\n")
eqfile.write(" ".join(eq) + "\n")
even, odd, eq = [], [], []
evenfile.close()
oddfile.close()
eqfile.close()
\ No newline at end of file
from sys import stdin
import json
file_name = input()
d = {}
for line in stdin:
key, val = line.rstrip().split(" == ")
d[key] = val
with open(file_name, "r", encoding="UTF-8") as js:
data = json.load(js)
for key, val in d.items():
data[key] = val
with open(file_name, "w", encoding="UTF-8") as js:
json.dump(data, js, ensure_ascii=False, indent=2)
\ No newline at end of file
import json
jsusersname, jsupdatesname = input(), input()
data = []
with open(jsusersname, "r", encoding="UTF-8") as js:
data = json.load(js)
newdata = {}
for d in data:
newdata[d["name"]] = {}
for key, val in d.items():
if key == "name":
continue
newdata[d["name"]][key] = val
with open(jsupdatesname, "r", encoding="UTF-8") as js:
data = json.load(js)
for d in data:
name = d["name"]
for key, newval in d.items():
if key == "name":
continue
if key in newdata[name]:
val = newdata[name][key]
newdata[name][key] = sorted([val, newval], reverse=True)[0]
else:
newdata[name][key] = newval
with open(jsusersname, "w", encoding="UTF-8") as js:
json.dump(newdata, js, ensure_ascii=False, indent=2)
\ No newline at end of file
import json
from sys import stdin
name = "scoring.json"
data = []
with open(name, "r", encoding="utf-8") as js:
data = json.load(js)
testcnt = 0
for elem in data:
testcnt += len(elem["tests"])
c = 0
packc = 0
pointsum = 0
d = data[packc]
points = d["points"]
tests = d["tests"]
for line in stdin:
answer = line.rstrip("\n")
if c < len(tests):
if tests[c]["pattern"] == answer:
pointsum += int(points / len(tests))
c += 1
else:
packc += 1
d = data[packc]
points = d["points"]
tests = d["tests"]
c = 0
if c < len(tests):
if tests[c]["pattern"] == answer:
pointsum += int(points / len(tests))
c += 1
print(pointsum)
\ No newline at end of file
from sys import stdin
search_task = input().lower().split()
filenames = [line.rstrip("\n") for line in stdin]
is_something = False
for fname in filenames:
active_searches = []
ind = 0
f = False
with open(fname, "r", encoding="utf-8") as file:
for line in file:
for word in line.replace("&nbsp;", " ").rstrip("\n").lower().split():
if not word:
continue
if word == search_task[0]:
active_searches.append([word])
continue
if active_searches:
for i in range(len(active_searches) - 1, -1, -1):
if len(active_searches[i]) == len(search_task):
f = True
break
elif search_task[len(active_searches[i])] == word:
active_searches[i].append(word)
else:
del active_searches[i]
if f:
break
if active_searches:
for i in range(len(active_searches) - 1, -1, -1):
if len(active_searches[i]) == len(search_task):
f = True
break
if f:
break
if f:
print(fname)
is_something = True
if not is_something:
print("404. Not Found")
\ No newline at end of file
fname = "secret.txt"
with open(fname, "r", encoding="utf-8") as file:
for line in file:
string = line.rstrip("\n")
res = ''
for char in string:
b = bin(ord(char))[2:]
if len(b) % 8 != 0:
bytenum = len(b) // 8 + 1
b = "0" * (8 * bytenum - len(b)) + b
if len(b) <= 8:
res += chr(int(b, 2))
else:
res += chr(int(b[8:], 2))
print(res)
\ No newline at end of file
import os
types = ["Б", "КБ", "МБ", "ГБ"]
fname = input()
bytessum = 0
type = 0
bytessum = os.stat(fname).st_size
while bytessum >= 1024:
if bytessum == 3:
break
type += 1
bytessum = bytessum // 1024 + (bytessum % 1024 > 0)
print(f"{bytessum}{types[type]}")
inpname = "public.txt"
outname = "private.txt"
change = int(input())
with open(inpname, "r", encoding="utf-8") as inpfile:
with open(outname, "w", encoding="utf-8") as outfile:
for line in inpfile:
s = ''
for c in line:
code = ord(c)
if 65 <= code <= 90:
code += change
if code > 90:
while code > 90:
code = code - 26
elif code < 65:
while code < 65:
code = 26 + code
c = chr(code)
elif 97 <= code <= 122:
code += change
if code > 122:
while code > 122:
code = code - 26
elif code < 97:
while code < 97:
code = 26 + code
c = chr(code)
s += c
outfile.write(s)
from sys import stdin
high_arr = []
for line in stdin:
high = [int(i) for i in line.rstrip("\n").split()[1:]]
high_arr.append(high[1] - high[0])
print(round(sum(high_arr) / len(high_arr)))
\ No newline at end of file
fname = "numbers.num"
snum = 0
with open(fname, "rb") as file:
while (byte := file.read(2)):
snum += int.from_bytes(byte)
snum = snum % 2**16
print(snum)
\ No newline at end of file
from sys import stdin
code = []
for line in stdin:
if line.find("#") != 0:
print(line[: line.find("#")])
\ No newline at end of file
This diff is collapsed.
3.5/4.py 0 → 100644
from sys import stdin
sentences = []
for line in stdin:
sentences.append(line.rstrip("\n"))
search = sentences.pop(-1)
res = []
for sen in sentences:
if search.lower() in sen.lower():
res.append(sen)
print(*res, sep="\n")
\ No newline at end of file
from sys import stdin
res = set()
for line in stdin:
for word in line.rstrip("\n").split():
if word.lower() == word[::-1].lower():
res.add(word)
print(*sorted(list(res)), sep="\n")
\ No newline at end of file
3.5/6.py 0 → 100644
d = {
'А': 'A',
'а': 'a',
'Б': 'B',
'б': 'b',
'В': 'V',
'в': 'v',
'Г': 'G',
'г': 'g',
'Д': 'D',
'д': 'd',
'Е': 'E',
'е': 'e',
'Ё': 'E',
'ё': 'e',
'Ж': 'Zh',
'ж': 'zh',
'З': 'Z',
'з': 'z',
'И': 'I',
'и': 'i',
'Й': 'I',
'й': 'i',
'К': 'K',
'к': 'k',
'Л': 'L',
'л': 'l',
'М': 'M',
'м': 'm',
'Н': 'N',
'н': 'n',
'О': 'O',
'о': 'o',
'П': 'P',
'п': 'p',
'Р': 'R',
'р': 'r',
'С': 'S',
'с': 's',
'Т': 'T',
'т': 't',
'У': 'U',
'у': 'u',
'Ф': 'F',
'ф': 'f',
'Х': 'Kh',
'х': 'kh',
'Ц': 'Tc',
'ц': 'tc',
'Ч': 'Ch',
'ч': 'ch',
'Ш': 'Sh',
'ш': 'sh',
'Щ': 'Shch',
'щ': 'shch',
'Ы': 'Y',
'ы': 'y',
'Э': 'E',
'э': 'e',
'Ю': 'Iu',
'ю': 'iu',
'Я': 'Ia',
'я': 'ia'
}
string = ""
with open("cyrillic.txt", "r", encoding="utf-8") as input_file:
with open("transliteration.txt", "w", encoding="utf-8") as output_file:
for line in input_file:
string = line
new_string = ""
for i in string:
if i in d.keys():
new_string += d[i]
elif i.lower() in ["ь", "ъ"]:
continue
else:
new_string += i
output_file.write(new_string)
\ No newline at end of file
3.5/7.py 0 → 100644
file_name = input()
data = []
with open(file_name, "r", encoding="utf-8") as file:
for line in file:
data += [int(i) for i in line.rstrip("\n").split()]
print(len(data))
print(len([i for i in data if i > 0]))
print(min(data))
print(max(data))
print(sum(data))
print(round(sum(data) / len(data), 2))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment