diff --git a/icpc/2018 ICPC East Central North America Regional Contest/D/input b/icpc/2018 ICPC East Central North America Regional Contest/C/input
similarity index 100%
rename from icpc/2018 ICPC East Central North America Regional Contest/D/input
rename to icpc/2018 ICPC East Central North America Regional Contest/C/input
diff --git a/icpc/2018 ICPC East Central North America Regional Contest/C/main.py b/icpc/2018 ICPC East Central North America Regional Contest/C/main.py
new file mode 100644
index 0000000..daa9643
--- /dev/null
+++ b/icpc/2018 ICPC East Central North America Regional Contest/C/main.py
@@ -0,0 +1,65 @@
+import os, sys
+
+mappings = {
+ '@' : ['at'],
+ '&' : ['and'],
+ '1' : ['one', 'won'],
+ '2' : ['to', 'too', 'two'],
+ '4' : ['for', 'four'],
+ 'b' : ['bea', 'be', 'bee'],
+ 'c' : ['sea', 'see'],
+ 'i' : ['eye'],
+ 'o' : ['oh', 'owe'],
+ 'r' : ['are'],
+ 'u' : ['you'],
+ 'y' : ['why']
+}
+
+# gets the largest and smallest possible subs
+minSub = min([min(list(map(len, vals))) for vals in mappings.values()])
+maxSub = max([max(list(map(len, vals))) for vals in mappings.values()])
+
+# Gets the token ('are' -> 'r') for a sub, case sensitive
+def getToken(sub):
+ for key in mappings.keys():
+ if sub in mappings[key]:
+ return key
+
+def processWord(word):
+ processed = [False] * len(word)
+ # For every character in the word
+ index = 0
+ while index < len(word):
+ possible = []
+ for length in range(minSub, maxSub + 1):
+ if index + length > len(word):
+ continue
+ sub = word[index:index + length]
+ token = getToken(sub.lower())
+ if token:
+ # Sometimes mulitple tokens can appear for the same one, we just select the one that is longest
+ possible.append((token, len(sub), sub))
+ # A token replacement has been found at this index
+ if possible:
+ # Find the best one, based on the sub
+ select = max(possible, key=lambda item : item[1])
+ # print(index, select, word[index:index + select[1]])
+ word = word[:index] + (select[0].title() if select[2].istitle() else select[0]) + word[index + select[1]:]
+ # word[index:index + select[1]] = select[0]
+ index += len(select[0])
+ else:
+ index += 1
+ return word
+
+# Process a single line
+def processLine(line):
+ return ' '.join([processWord(word) for word in line.split(' ')])
+
+# Drive Code
+def main():
+ path = os.path.join(sys.path[0], 'input')
+ data = open(path, 'r').read().split('\n')[1:]
+ print('\n'.join(map(processLine, data)))
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/icpc/2018 ICPC East Central North America Regional Contest/D/inputs/1 b/icpc/2018 ICPC East Central North America Regional Contest/D/inputs/1
new file mode 100644
index 0000000..fa7280a
--- /dev/null
+++ b/icpc/2018 ICPC East Central North America Regional Contest/D/inputs/1
@@ -0,0 +1,6 @@
+5
+H 2 0:13
+A 2 0:19
+H 1 0:52
+H 1 0:52
+A 3 1:08
\ No newline at end of file
diff --git a/icpc/2018 ICPC East Central North America Regional Contest/D/inputs/2 b/icpc/2018 ICPC East Central North America Regional Contest/D/inputs/2
new file mode 100644
index 0000000..165a430
--- /dev/null
+++ b/icpc/2018 ICPC East Central North America Regional Contest/D/inputs/2
@@ -0,0 +1,2 @@
+1
+H 1 16:00
\ No newline at end of file
diff --git a/icpc/2018 ICPC East Central North America Regional Contest/D/main.py b/icpc/2018 ICPC East Central North America Regional Contest/D/main.py
index daa9643..34beb36 100644
--- a/icpc/2018 ICPC East Central North America Regional Contest/D/main.py
+++ b/icpc/2018 ICPC East Central North America Regional Contest/D/main.py
@@ -1,65 +1,41 @@
-import os, sys
+import datetime, re, os, sys
-mappings = {
- '@' : ['at'],
- '&' : ['and'],
- '1' : ['one', 'won'],
- '2' : ['to', 'too', 'two'],
- '4' : ['for', 'four'],
- 'b' : ['bea', 'be', 'bee'],
- 'c' : ['sea', 'see'],
- 'i' : ['eye'],
- 'o' : ['oh', 'owe'],
- 'r' : ['are'],
- 'u' : ['you'],
- 'y' : ['why']
-}
+pattern = r'([HA]) (\d) (\d+):(\d+)'
+mmsspattern = '%M:%S'
-# gets the largest and smallest possible subs
-minSub = min([min(list(map(len, vals))) for vals in mappings.values()])
-maxSub = max([max(list(map(len, vals))) for vals in mappings.values()])
+# Process the input for a single niput
+def process(rawinput):
+ def getBest():
+ return max(score.items(), key=lambda x:x[1])[0]
+ score = {'H' : 0, 'A' : 0}
+ leads = {'H' : 0, 'A' : 0}
+ rawinput = '\n'.join(rawinput.split('\n')[1:])
+ events = re.finditer(pattern, rawinput)
+ curLead = ''
+ lastTime = datetime.datetime(1990, 1, 1, 0, 0, 0)
+ gameEnd = datetime.datetime(1990, 1, 1, 1, 30)
+ for event in events:
+ # Create the formatted timecode, add the score
+ timecode = '{}:{}'.format(event.group(3).zfill(2), event.group(4).zfill(2))
+ curtime = datetime.datetime.strptime(timecode, mmsspattern)
+ score[event.group(1)] += int(event.group(2))
+ # Get the team in the lead and if it's different
+ best = getBest()
+ leads[best] += int((curtime - lastTime).seconds)
+ lastTime = curtime
+# if gameEnd > lastTime:
+ # leads[best] += (gameEnd - lastTime).seconds
+ return '{} {} {}'.format(getBest(), leads['H'], leads['A'])
-# Gets the token ('are' -> 'r') for a sub, case sensitive
-def getToken(sub):
- for key in mappings.keys():
- if sub in mappings[key]:
- return key
-
-def processWord(word):
- processed = [False] * len(word)
- # For every character in the word
- index = 0
- while index < len(word):
- possible = []
- for length in range(minSub, maxSub + 1):
- if index + length > len(word):
- continue
- sub = word[index:index + length]
- token = getToken(sub.lower())
- if token:
- # Sometimes mulitple tokens can appear for the same one, we just select the one that is longest
- possible.append((token, len(sub), sub))
- # A token replacement has been found at this index
- if possible:
- # Find the best one, based on the sub
- select = max(possible, key=lambda item : item[1])
- # print(index, select, word[index:index + select[1]])
- word = word[:index] + (select[0].title() if select[2].istitle() else select[0]) + word[index + select[1]:]
- # word[index:index + select[1]] = select[0]
- index += len(select[0])
- else:
- index += 1
- return word
-
-# Process a single line
-def processLine(line):
- return ' '.join([processWord(word) for word in line.split(' ')])
-
-# Drive Code
+# Driver code
def main():
- path = os.path.join(sys.path[0], 'input')
- data = open(path, 'r').read().split('\n')[1:]
- print('\n'.join(map(processLine, data)))
+ # Read inputs
+ inputs = [os.path.join(sys.path[0], 'inputs', x) for x in
+ os.listdir(os.path.join(sys.path[0], 'inputs'))]
+ inputs = [open(path).read() for path in inputs]
+ for rawinput in inputs:
+ print(process(rawinput))
+ print('-'*19)
if __name__ == "__main__":
main()
\ No newline at end of file
diff --git a/icpc/2018 ICPC East Central North America Regional Contest/F/main.py b/icpc/2018 ICPC East Central North America Regional Contest/F/main.py
index 2e244fd..4321eb9 100644
--- a/icpc/2018 ICPC East Central North America Regional Contest/F/main.py
+++ b/icpc/2018 ICPC East Central North America Regional Contest/F/main.py
@@ -4,25 +4,41 @@ def process(item):
# Constants and initial values
stocks, (n, m) = item[1], item[0]
peaks, valleys = [], []
- possiblePeaks, possibleValleys = range(n, len(stocks) - n), range(m, len(stocks) - m)
# Check all possible peaks
- for index in possiblePeaks:
- isPeak = True
+ for index in range(len(stocks)):
+ isPeak, isValley = True, True
+ # Peak Checking
for i in range(1, n + 1):
- if not stocks[index - i] < stocks[index] or not stocks[index] > stocks[index + i]:
- isPeak = False
- if isPeak:
- peaks.append(index)
- print(peaks)
- # Check all possible valleys
- for index in possibleValleys:
- isValley = True
+ # If we're no the first index
+ if index - i >= 0:
+ # If position behind us is lower
+ if not stocks[index] > stocks[index - i]:
+ isPeak = False
+ break
+ # If we're not the final index
+ if index + i < len(stocks):
+ # and position in front of us is lower
+ if not stocks[index] > stocks[index + i]:
+ isPeak = False
+ break
+ # Valley checking
for i in range(1, m + 1):
- if not stocks[index - i] > stocks[index] or not stocks[index] < stocks[index + i]:
- isValley = False
- if isValley:
- valleys.append(index)
- print(valleys)
+ # If we're not the first index
+ if index - i >= 0:
+ # if position behind us is higher
+ if not stocks[index] < stocks[index - i]:
+ isValley = False
+ break
+ # If we're not the final index
+ if index + i < len(stocks):
+ # and position in front of us is higher
+ if not stocks[index] < stocks[index + i]:
+ isValley = False
+ break
+ if isPeak: peaks.append(index)
+ if isValley: valleys.append(index)
+ print(f'n{n}, m{m}')
+ print('{0}{1}\n{0}{2}'.format('-> ', peaks, valleys))
return len(peaks), len(valleys)
# Driver code for all inputs in folder
diff --git a/icpc/2018 ICPC East Central North America Regional Contest/README.MD b/icpc/2018 ICPC East Central North America Regional Contest/README.MD
index e9c5add..2fc034a 100644
--- a/icpc/2018 ICPC East Central North America Regional Contest/README.MD
+++ b/icpc/2018 ICPC East Central North America Regional Contest/README.MD
@@ -8,6 +8,14 @@ Most of these problems seem modestly easy, if I'm being honest.
## Progress
-#1 : Unsovled
+#A : **Solved**
-#2 : **Solved**
\ No newline at end of file
+#B : **Solved**
+
+#C : Unsolved
+
+#D : **Solved**
+
+#E : **Solved**
+
+#F : **Solved**
\ No newline at end of file
diff --git a/uil/October 2013 Set/1/java/.idea/misc.xml b/uil/October 2013 Set/1/java/.idea/misc.xml
new file mode 100644
index 0000000..4c1c37a
--- /dev/null
+++ b/uil/October 2013 Set/1/java/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uil/October 2013 Set/1/java/.idea/modules.xml b/uil/October 2013 Set/1/java/.idea/modules.xml
new file mode 100644
index 0000000..7a3904f
--- /dev/null
+++ b/uil/October 2013 Set/1/java/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uil/October 2013 Set/1/java/.idea/workspace.xml b/uil/October 2013 Set/1/java/.idea/workspace.xml
new file mode 100644
index 0000000..9fb398a
--- /dev/null
+++ b/uil/October 2013 Set/1/java/.idea/workspace.xml
@@ -0,0 +1,311 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uil/October 2013 Set/3/java/3.iml b/uil/October 2013 Set/3/java/3.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/uil/October 2013 Set/3/java/3.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uil/October 2013 Set/3/java/src/problem3.java b/uil/October 2013 Set/3/java/src/problem3.java
new file mode 100644
index 0000000..9307636
--- /dev/null
+++ b/uil/October 2013 Set/3/java/src/problem3.java
@@ -0,0 +1,19 @@
+import static java.lang.System.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Scanner;
+
+public class problem3 {
+ public static void main(String[] args ) throws FileNotFoundException {
+ // Constants
+ File input = new File("input1.dat");
+ Scanner read = new Scanner(input);
+ int lines = read.nextInt();
+ read.nextLine();
+
+ // Driver Code
+ for (int i = 0; i < lines; i++)
+ out.println(read.nextLine().length() <= 140 ? "tweet" : "not a tweet");
+ }
+
+}
\ No newline at end of file
diff --git a/uil/UIL.md b/uil/UIL.md
new file mode 100644
index 0000000..c82138e
--- /dev/null
+++ b/uil/UIL.md
@@ -0,0 +1,254 @@
+# UIL Eligibility Packet
+
+## Question 1
+
+This can be guessed on pretty easily by analyzing the magnitudes of the powers. Every number here is within a mildly close range of eachother, and the highest numbers have some of the *lowest* powers, so we can assume that the one with the highest power will be the largest when evaluated.
+
+# Question 2
+
+This is simple String and Integer addition.
+
+`3 + 4 + "Hi" + 3 + 4 = "7Hi34"`
+
+**Remember:** Left to right, Integer + String converts to String, no kind of math involved once integer is converted to String.
+
+## Question 3
+
+Super simple math.
+`3 + (7 + 3) = 13`
+
+## Question 4
+
+This one deals with integer division.
+
+```
+27 / 2 = 13
+13 / 2 = 6
+6 / 2 = 3
+3 / 2 = 1
+! 1 / 2 = 0
+Output: 27
+```
+
+Program flow should be analyzed carefully at the start and end as the output will include the first, then it will divide, and then the block ends and revaluates the expression `x > 0`.
+
+This means that the output will contain the first but not the last phase of the `x` variable.
+
+## Question 5
+
+This is another one of those painstaking problems where you have to verify the method without knowing it's purpose: making it a thousand times harder to trust your calculated answer.
+
+The for loop operates on every index in the String up the center, which ends up being `5` (`10 / 2 = 5`).
+
+For each index in the String being operated upon, the String `t` has the index being accessed and the last index in the String `s` added (always `e`).
+
+```
+0 => He
+1 => oe
+2 => we
+3 => de
+4 => ye
+```
+
+The final output for this problem is `Heoewedeye`.
+
+## Question 6
+
+This one requires prior knowledge of `Arrays.fill`.
+
+**Spoiler:** It's super easy.
+
+`Arrays.fill(array, start, stop, val)` simply places the value in the array specified from start to stop (left only inclusive).
+
+Since the specified range is `[2, 3)`, only one 4 is placed at index 2.
+
+The final array looks like `[0, 0, 4, 0, 0]`
+
+## Question 7
+
+This is just pretty awful parantheses aside from the initial solving.
+
+```
+!(!(!(...)))
+ !true || !false && !false
+ false || true && true
+ true && true
+ true
+!(!(!(true)))
+!(!(false))
+!(true)
+
+```
+
+## Question 8
+## Question 9
+## Question 10
+## Question 11
+## Question 12
+## Question 13
+## Question 14
+## Question 15
+## Question 16
+## Question 17
+
+First parameter is the number, second is the base.
+
+Remember for 1234, the maximum values for each digit in order from left-to-right (ending on the right), with the number it's used to build (right * 4 = left) would be...
+
+```
+n(n/4) - 256(64) - 64(16) - 16(4) - 4(1).
+```
+
+So to build 123 4, `123 - 64 - 48 - 8 - 3 = 0`.
+
+And to build 234 5, `234 - 125 - 100 - 5 - 4`.
+
+## Question 18
+
+Notice that the for loops loop over usually, but use `mat.length` instead of `mat.length-1`. Major mistake which results in a `OutOfBoundsException` to be raised.
+
+## Question 19 - 21
+
+Class A has a couple of interesting operators and distinctions that make it a difficult problem to diagnose.
+
+The constructor starts off by setting `int n` equal to itself after using the (pre) increment operator.
+
+Class A starts by instantiating a `protected int` primitive and then, while inside the constructor, uses the pre-increment operator.
+
+Additionally, since this is a class, all objects in `class scope` are given a `default value`, which is different to `local scope`.
+
+In the end, `n` in the `A` class will always equal 1.
+
+### Question 19
+
+*Thanks Mr. Smith for explaining this one better so I could properly understand it.*
+
+Question 19 makes the user create a new `B` object of type `A`, which is an important distinction as if it was instantiated as type `B`, `getN` would still be accessible - however as type `A`, it is not.
+
+At compile time, it is evaluated for
+
+### Question 20
+
+The pre-increment operator and being in class scope means that `n` will be equal to 1. `toString()` returns `n` in `String` type.
+
+### Question 21
+
+Class `B` is similar to the `A` class, and ends up using the `super()` operator. After `this.n` is equal to 1 as usual, `int n` (local constructor scope) is added to `this.n`.
+
+It is important to understand local/class scope, the `+=` assignment operator, and how `toString()` works.
+
+## Question 22 - 23
+
+Another complicated setup, but at least it's based on the same output.
+
+`String.lastIndexOf("#")` will return the index of the last `#` in the 21 character long `s` String. This index is `19`.
+
+The `fTwo` method takes two parameters and essentially combines to substrings of everything but that one `#` at index 19.
+
+The most complicated part of this is that `fOne` and `fTwo` return eachother recursively.
+
+Check the final else-statement (the first to run if you check based on the first initial input).
+
+It returns (recursively) the output of `fOne(fTwo(s, s.lastIndexOf("#")))`, which could go on recursively forever, but with careful analysis you'll see this does not happen.
+
+If the first `#` in a String is the last one, then it'll return the String like that.
+
+If the String's length is even, then it will recursively return `fOne(fTwo(s, s.indexOf("#")))`.
+
+Otherwise, it will recursively return `fOne(fTwo(s, s.lastIndexOf("#")))`, as mentioned above.
+
+### Question 22
+
+Let's diagnose the output for real and see what is really going on.
+
+```
+1 => H#i#t#h#i#s#i#s#f#u#n
+2 => H#i#t#h#i#s#i#s#f#un
+3 => Hi#t#h#i#s#i#s#f#un
+4 => Hi#t#h#i#s#i#s#fun
+5 => Hit#h#i#s#i#s#fun
+6 => Hit#h#i#s#i#sfun
+7 => Hit#h#i#s#isfun
+8 => Hith#i#s#isfun
+9 => Hith#i#sisfun
+10 => Hithi#sisfun
+```
+
+On the tenth iteration, the String is finally left with only a single `#`.
+
+The final string output is equal to `Hithi#sisfun`.
+
+### Question 23
+
+This one is rather easy as well, but it requires the output of `22` to continue, as well as a bit of knowledge of Regex.
+
+The Regex pattern `[aeiou]` simply matches against any one vowel in a row. `String.split` is also pretty simply, creating a String array made out of the string that is broken into pieces based on the matching regex pattern.
+
+To solve this, all we have to do is identify vowels in `Hithi#sisfun` and mark them out.
+
+`H[i]th[i]#s[i]sf[u]n`, with brackets around the sections that will be deleted and used to split apart the String.
+
+The final String array that is returned will be `["H", "th", "#s", "sf", "n"]`.
+
+## Question 24
+
+Pretty easy; from left to right `3 + 4 = 7`, and then it's converted to a String, so you add 7, 3 and 7 to make `7737`.
+
+## Question 25
+
+This is a rather simple regex pattern, but they all look like insane spaghetti initially. We should note, that since this isn't shown in Java, escaping is done using a single `\` instead of `\\`!
+
+To better explain, see the code below.
+
+```java
+"hello.world".split("\\.")
+```
+
+The regex pattern in text that is universally understood would be seen as `\.`, which matches against a single period (dot), and not a *escaped backslash* and a `.` metacharacter.
+
+This is minor, but I believe it should be properly explained.
+
+---
+
+To start understanding the pattern, we should break it apart.
+
+`^\w{1,}@\w{1,}\.[a-z]{2,3}$`
+
+`^` is a anchor, showing the start of the String. This is reciprocated at the end with a `$` ending anchor.
+
+`\w{1,}` matches against any `word` character (alphanumeric or underscore, essentially alphabet, digits or a underscore, case insensitive). It matches against 1 or more, but at least 1. This portion of the pattern is equal to `\w+`.
+
+`@` matches a single `@` character. We should take a moment to note that the sections before and this match these these kinds of emails:
+
+```
+jgu6oaouih23_6@
+d9hi@
+i_3@
+f@
+```
+
+but not these
+
+```
+@
+^35a@
+ @
+```
+
+(must match 1 character minimum, no special characters other than underscore, no whitespace)
+
+`\w{1,}\.` matches the same word character in a sequence at minimum 1 character long, and then a dot character (`\.`, not the metacharacter `.`).
+
+`[a-z]{2, 3}$` matches a sequence of lowercase letters with a length of 2 or 3. The `$` denotes the ending anchor as specified earlier.
+
+So in summary, the regex pattern matches a sequence of word characters, a `@` symbol, another sequence of word characters, a period, and then 2-3 lowercase letters. This is quite obviously a generate specification for an email (which allows underscores). The 2-3 lowercase letters only allows two or three letter domain extensions (`.com`, `.gov`, `.me` but not `.photography`, `.online`)
+
+## Question 26
+
+This is a rather long problem, so let's split it up into the patrs.
+
+### Class X
+
+Class X is a implementation of the Comparable Interface, and is essentially a method for comparing Strings when sorted. Focus on the `compareTo` method.
+
+The `compareTo` method
\ No newline at end of file