aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2020-07-18 18:02:08 -0500
committerAnthony Wang2020-07-18 18:02:08 -0500
commit87edfb7a537ddb8f6a4dccdd80ff6e47e87ed0a2 (patch)
tree9885b66ab3bf3a6344ee349a5b718c23669c84fc
parenta9a4d119c4890c3627f014f0ff91628230d8493d (diff)
umm don't look at this repo please
-rw-r--r--photo.in2
-rw-r--r--photo.out1
-rw-r--r--photo.py36
-rw-r--r--triangles.in5
-rw-r--r--triangles.out1
-rw-r--r--triangles.py40
-rw-r--r--word.ans6
-rw-r--r--word.in2
-rw-r--r--word.out6
-rw-r--r--word.py15
10 files changed, 114 insertions, 0 deletions
diff --git a/photo.in b/photo.in
new file mode 100644
index 0000000..c51b36f
--- /dev/null
+++ b/photo.in
@@ -0,0 +1,2 @@
+5
+4 6 7 6 \ No newline at end of file
diff --git a/photo.out b/photo.out
new file mode 100644
index 0000000..2f627fa
--- /dev/null
+++ b/photo.out
@@ -0,0 +1 @@
+3 1 5 2 4 \ No newline at end of file
diff --git a/photo.py b/photo.py
new file mode 100644
index 0000000..5a49bc6
--- /dev/null
+++ b/photo.py
@@ -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()
diff --git a/triangles.in b/triangles.in
new file mode 100644
index 0000000..d41ac61
--- /dev/null
+++ b/triangles.in
@@ -0,0 +1,5 @@
+4
+0 0
+0 1
+1 0
+1 2 \ No newline at end of file
diff --git a/triangles.out b/triangles.out
new file mode 100644
index 0000000..d8263ee
--- /dev/null
+++ b/triangles.out
@@ -0,0 +1 @@
+2 \ No newline at end of file
diff --git a/triangles.py b/triangles.py
new file mode 100644
index 0000000..d1c6224
--- /dev/null
+++ b/triangles.py
@@ -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))
diff --git a/word.ans b/word.ans
new file mode 100644
index 0000000..95885d3
--- /dev/null
+++ b/word.ans
@@ -0,0 +1,6 @@
+hello my
+name is
+Bessie
+and this
+is my
+essay \ No newline at end of file
diff --git a/word.in b/word.in
new file mode 100644
index 0000000..d207c7d
--- /dev/null
+++ b/word.in
@@ -0,0 +1,2 @@
+10 7
+hello my name is Bessie and this is my essay \ No newline at end of file
diff --git a/word.out b/word.out
new file mode 100644
index 0000000..95885d3
--- /dev/null
+++ b/word.out
@@ -0,0 +1,6 @@
+hello my
+name is
+Bessie
+and this
+is my
+essay \ No newline at end of file
diff --git a/word.py b/word.py
new file mode 100644
index 0000000..6c407c2
--- /dev/null
+++ b/word.py
@@ -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) \ No newline at end of file