umm don't look at this repo please

This commit is contained in:
Anthony Wang 2020-07-18 18:02:08 -05:00
parent a9a4d119c4
commit 87edfb7a53
10 changed files with 114 additions and 0 deletions

2
photo.in Normal file
View file

@ -0,0 +1,2 @@
5
4 6 7 6

1
photo.out Normal file
View file

@ -0,0 +1 @@
3 1 5 2 4

36
photo.py Normal file
View file

@ -0,0 +1,36 @@
with open("photo.in", "r") as fin:
L = list(fin)
N = int(L[0])
b = []
for bi in L[1].split():
b.append(int(bi))
for start in range(1, N + 1): # N
a = [ start ]
for i in range(0, N - 1): # N
a.append(b[i] - a[i])
valid = True
appeared = {}
for i in range(0, N):
appeared[a[i]] = False
for i in range(0, N):
if a[i] < 1:
valid = False
elif a[i] > N:
valid = False
elif appeared[a[i]] == True:
valid = False
appeared[a[i]] = True
if valid == True:
with open("photo.out", "w") as fout:
firstLine = True
for ai in a:
if firstLine == True:
firstLine = False
else:
fout.write(" ")
fout.write(str(ai))
exit()

5
triangles.in Normal file
View file

@ -0,0 +1,5 @@
4
0 0
0 1
1 0
1 2

1
triangles.out Normal file
View file

@ -0,0 +1 @@
2

40
triangles.py Normal file
View file

@ -0,0 +1,40 @@
with open("triangles.in", "r") as fin:
L = list(fin)
N = int(L[0])
X = []
Y = []
for i in range(1, N + 1):
x, y = map(int, L[i].split())
X.append(x)
Y.append(y)
ans = 0
for i in range(0, N):
for j in range(i + 1, N):
for k in range(j + 1, N):
base = 0
height = 0
if X[i] == X[j]:
height = abs(Y[j] - Y[i])
elif X[j] == X[k]:
height = abs(Y[k] - Y[j])
elif X[k] == X[i]:
height = abs(Y[i] - Y[k])
else:
continue
if Y[i] == Y[j]:
base = abs(X[j] - X[i])
elif Y[j] == Y[k]:
base = abs(X[k] - X[j])
elif Y[k] == Y[i]:
base = abs(X[i] - X[k])
else:
continue
if base*height > ans: ans = base*height
with open("triangles.out", "w") as fout:
fout.write(str(ans))

6
word.ans Normal file
View file

@ -0,0 +1,6 @@
hello my
name is
Bessie
and this
is my
essay

2
word.in Normal file
View file

@ -0,0 +1,2 @@
10 7
hello my name is Bessie and this is my essay

6
word.out Normal file
View file

@ -0,0 +1,6 @@
hello my
name is
Bessie
and this
is my
essay

15
word.py Normal file
View file

@ -0,0 +1,15 @@
with open("word.in", "r") as fin:
L = list(fin)
N, K = map(int, L[0].split()) # "10" "7"
with open("word.out", "w") as fout:
curLen = 0 # current length of line
for word in L[1].split(): # go through each word
if curLen + len(word) > K: # place on new line
fout.write("\n")
fout.write(word)
curLen = len(word)
else: # place on current line
if curLen > 0:
fout.write(" ")
fout.write(word)
curLen += len(word)