-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
73,247 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,4 +276,5 @@ TSWLatexianTemp* | |
*.lpz | ||
|
||
# Testing scripts | ||
**/script.py | ||
**/script.py | ||
**/output.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
tests = int(input()) | ||
|
||
for _ in range(tests): | ||
x1, y1, x2, y2, ax, ay, bx, by = [int(s) for s in input().split()] | ||
blocked = [(ax, ay), (bx, by)] | ||
|
||
x_dist = abs(x1 - x2) | ||
y_dist = abs(y1 - y2) | ||
|
||
dist = abs(x1 - x2) + abs(y1 - y2) # taxicab distance | ||
|
||
if x_dist == 0: | ||
# If a or b in between shortest path | ||
if (ax == x1 and min(y1, y2) < ay < max(y1, y2)) or (bx == x1 and min(y1, y2) < by < max(y1, y2)): | ||
dist += 2 # add 2 to taxicab distance | ||
|
||
elif y_dist == 0: | ||
# If a or b in between shortest path | ||
if (ay == y1 and min(x1, x2) < ax < max(x1, x2)) or (by == y1 and min(x1, x2) < bx < max(x1, x2)): | ||
dist += 2 # add 2 to taxicab distance | ||
|
||
if x_dist >= 2 and y_dist >= 2: | ||
# only need to check adjacent tiles of start and end | ||
pass | ||
|
||
print(dist) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
10 | ||
BABA ABBA | ||
ORANGE CHERRY | ||
MOUNTAINEERS ENUMERATIONS | ||
HE EH | ||
FOUR FOAL | ||
SWORD WORDS | ||
BANANA BATMAN | ||
MANKINI COMPANY | ||
SUBTRACTIONS OBSCURANTIST | ||
UNDEMOCRATISE DOCUMENTARIES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
\addcontentsline{toc}{subsection}{Anagram} | ||
\LARGE \circled{0} \textbf{Example Problem - Anagram} \normalsize | ||
|
||
{\itshape A Rag Man.} | ||
|
||
This problem is intended to get you familiar with how submission works. | ||
|
||
A pair of strings are called anagrams of each other if they share the same letters, but in a different order. | ||
Your task: determine whether given pairs of strings are anagrams. | ||
|
||
\vspace{8pt} | ||
\hrule | ||
|
||
\textbf{Input} | ||
|
||
The first line of the input contains an integer $t$, denoting the number of test cases. | ||
|
||
The next $t$ lines of the input consist of two space-separated strings $w_1$ and $w_2$. | ||
|
||
\textbf{Constraints} | ||
|
||
\begin{itemize} | ||
\item $1 \leq t \leq 10$ | ||
\item $1 \leq |w_1| = |w_2| \leq 13$ | ||
\item $w_1$ and $w_2$ will be uppercase. | ||
\end{itemize} | ||
|
||
\textbf{Output} | ||
|
||
$t$ lines each consisting of either "Yes" if the strings are anagrams, or "No" if they're not. | ||
|
||
\vspace{8pt} | ||
\hrule | ||
|
||
\textbf{Example} | ||
|
||
\begin{table}[h] | ||
\centering | ||
\begin{tabular}{|p{0.4\linewidth}|p{0.4\linewidth}|} | ||
\hline | ||
Input & Output \\ | ||
\hline | ||
3 \newline BABA ABBA \newline ORANGE CHERRY \newline MOUNTAINEERS ENUMERATIONS & | ||
\text{} \newline Yes \newline No \newline Yes \\ | ||
\hline | ||
\end{tabular} | ||
\end{table} | ||
|
||
Note that we have one output line for each of the test cases. | ||
|
||
Feel free to give the problem a try yourself! | ||
However, the main goal of this is for you to understand the submission system, so I've given some example solutions on the next page, and ways to submit them. | ||
These are given for Python and Java, to show the differences. | ||
|
||
Once you feel comfortable, let's move onto the first real problem! | ||
|
||
\newpage | ||
|
||
\textbf{Solutions and Submission} | ||
|
||
\lstset{language=python} | ||
\begin{lstlisting} | ||
#!/usr/bin/env python | ||
|
||
t = int(input()) # Get number of test cases | ||
|
||
for _ in range(t): | ||
# Get the two words | ||
w1, w2 = input().split() | ||
|
||
# Convert to sorted character arrays | ||
s1 = sorted(w1) | ||
s2 = sorted(w2) | ||
|
||
# Compare the arrays | ||
if s1 == s2: | ||
print("Yes") | ||
else: | ||
print("No") | ||
|
||
\end{lstlisting} | ||
|
||
\small | ||
\texttt{./ProgcompCli 0 sol.py} on Mac or Linux, with a shebang. \\ | ||
\texttt{.\textbackslash ProgcompCli.exe 0 python.exe -{}-executable-args sol.py} on Windows (remove \texttt{.exe} otherwise). | ||
|
||
\vspace{8pt} | ||
\hrule | ||
|
||
\lstset{language=java} | ||
\begin{lstlisting} | ||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class Solution { | ||
public static void main(String[] args) { | ||
// Allows us to read from stdin | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
// Get number of test cases | ||
int t = 0; | ||
try { | ||
t = Integer.parseInt(br.readLine()); | ||
} catch (IOException ex) {} | ||
|
||
String word1, word2; | ||
for (int i = 0; i < t; i++) { // Repeat for number of test cases | ||
// Get words | ||
try { | ||
String line = br.readLine(); | ||
String[] split = line.split(" "); | ||
word1 = split[0]; | ||
word2 = split[1]; | ||
} catch (IOException ex) { continue; } | ||
|
||
// Sort arrays | ||
char[] arr1 = word1.toCharArray(); | ||
Arrays.sort(arr1); | ||
char[] arr2 = word2.toCharArray(); | ||
Arrays.sort(arr2); | ||
|
||
// Compare arrays | ||
if (Arrays.equals(arr1, arr2)) { | ||
System.out.println("Yes"); | ||
} else { | ||
System.out.println("No"); | ||
} | ||
} | ||
} | ||
} | ||
\end{lstlisting} | ||
|
||
\texttt{.\textbackslash ProgcompCli.exe 0 java -{}-executable-args Solution} on Windows (remove \texttt{.exe} otherwise). | ||
\\ Make sure to compile it first with \texttt{javac}! | ||
|
||
\normalsize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python | ||
|
||
t = int(input()) # Get number of test cases | ||
|
||
for _ in range(t): | ||
# Get the two words | ||
w1, w2 = input().split() | ||
|
||
# Convert to sorted character arrays | ||
s1 = sorted(w1) | ||
s2 = sorted(w2) | ||
|
||
# Compare the arrays | ||
if s1 == s2: | ||
print("Yes") | ||
else: | ||
print("No") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
5 | ||
READ REED | ||
ZERO HERO | ||
PAID FEED | ||
WORDS SWORD | ||
REDDIT CRINGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import random | ||
|
||
i = 1 | ||
|
||
lines = [] | ||
for _ in range(30000): | ||
s = input().split()[0] | ||
if s.isascii() and s.isalpha(): | ||
lines.append(s.upper()) | ||
|
||
words = [w.upper() for w in lines] | ||
|
||
# print(len(lines)) | ||
|
||
print(10000) | ||
|
||
for k in range(4, 14): | ||
x = list(filter(lambda s: len(s) == k, words)) | ||
for _ in range(1000): | ||
w1 = random.choice(x) | ||
w2 = random.choice(x) | ||
print(w1, w2) |
Oops, something went wrong.