mirror of
https://github.com/Xevion/contest.git
synced 2025-12-15 02:11:23 -06:00
refactor UIL packet
This commit is contained in:
450
uil/uil-practice-armstrong/test-1/EXPLANATIOn.md
Normal file
450
uil/uil-practice-armstrong/test-1/EXPLANATIOn.md
Normal file
@@ -0,0 +1,450 @@
|
||||
# UIL Eligibility Packet
|
||||
|
||||
Question 1-26 are done in full. From then on, only harder problems will be explained at much lighter levels to save time while completing this 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.
|
||||
|
||||
```java
|
||||
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`).
|
||||
|
||||
```java
|
||||
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.
|
||||
|
||||
```java
|
||||
!(!(!(...)))
|
||||
!true || !false && !false
|
||||
false || true && true
|
||||
true && true
|
||||
true
|
||||
!(!(!(true)))
|
||||
!(!(false))
|
||||
!(true)
|
||||
false
|
||||
```
|
||||
|
||||
## Question 8
|
||||
|
||||
This one actually tricked me because I'm really dumb and can't read; they are `if`s and `else if`s to look for here.
|
||||
|
||||
It's pretty easy modulus, I got `ABE`.
|
||||
|
||||
## Question 9
|
||||
|
||||
Solve from left to right, (P)(E)(MD)(AS).
|
||||
|
||||
Tip: You can solve in sections with the parentheses above, as multiplication/division can be done in any order together without changing the result. It helps a little bit with cutting down the manual solving time, if you ask me.
|
||||
|
||||
```java
|
||||
3 + 5 / 2 + 2.0
|
||||
3 + 2 + 2.0
|
||||
5 + 2.0
|
||||
7.0
|
||||
```
|
||||
|
||||
## Question 10
|
||||
|
||||
Just a little bit of math and tracking of a changing array.
|
||||
|
||||
```java
|
||||
r[3] = 19;
|
||||
r[1] = r[3] * 2 = 38;
|
||||
r[4] = r[1] / 2 = 19;
|
||||
r[2] = r[4 % 3 = 1] / 3 = 38 / 3 = 12;
|
||||
```
|
||||
```java
|
||||
r = [0, 38, 12, 19, 19]
|
||||
```
|
||||
|
||||
## Question 11
|
||||
|
||||
`Math.ceil` on a number already at it's ceiling/floor does nothing.
|
||||
|
||||
```java
|
||||
2.15 -> 2.0 -> 2.0
|
||||
```
|
||||
|
||||
## Question 12
|
||||
|
||||
This one has a incredibly interesting output, and I believe the answer is incorrect, or something has changed to make this incorrect over time.
|
||||
|
||||
Let's split it up into sections to make the problem simpler.
|
||||
|
||||
### Regex
|
||||
|
||||
`\\.*+` may seem abstract and strange at first, but it's really just an amalgamation of escape sequences and the PCRE Regex Engine (Javascript based Regex engines are more common, PCRE is server side and thus is not commonly seen with it's set of PCRE specific features).
|
||||
|
||||
`\\` is simply a escape sequence for the backslash in **Java**. This will catch most as you might move to the mindset that we're working in Regex, but we're in fact sending a String to a regex engine before it gets processes, and thus we must escape for **Java** before Regex.
|
||||
|
||||
`\\.` leads to a escape sequence for a dot `.` in Regex. Note: this is not the metacharacter, this is the escaped period/dot.
|
||||
|
||||
`\\.*` matches 0 or more escaped periods.
|
||||
|
||||
`\\.*+` adds a reluctant quantifier, specific to the PCRE Regex Engine. This caught me, as I had never seen the reluctant quantifier like this before.
|
||||
|
||||
If you want a tutorial on how reluctant vs other quantifiers, see [this Stack Overflow answer](https://stackoverflow.com/a/5319978/6912830), it's perfect and is very easy to understand.
|
||||
|
||||
So what does this in total match? *Zero or more periods*, of course.
|
||||
|
||||
### Solving the split
|
||||
|
||||
`a...b..c.d.efg...h` is our string. Let's see how our regex, `zero or more periods`, actually works in practice.
|
||||
|
||||
First, the `a` is seen and nothing is found, but it matches the idea of `zero or more periods`, so it progresses on to the second character, the `.`. Between this and the next sequence, a split is added, so the current array looks like this: `["a",]`...
|
||||
|
||||
Here, it begins matching the 2nd to 4th characters, a line of 3 dots. All 3 are deleted and replaced with a empty string to designate a split. Our array looks like `["a", "",]` now.
|
||||
|
||||
The basic idea of how this regex ends up working and how it would react almost always should take form now. You could come up with a rule to work off of so that the rest of the array is easier, split by every character, but add a empty space where dots are.
|
||||
|
||||
Be careful and make sure that
|
||||
|
||||
The rest of the array ends up being `[a, , b, , c, , d, , e, f, g, , h]`.
|
||||
|
||||
## Question 13
|
||||
|
||||
This question is dependent on `pre-increment` and `post-increment` operator knowledge.
|
||||
|
||||
### Unary Increment and Decrement Operators
|
||||
|
||||
What I'm talking about is the `unary operators`, `++` and `--`.
|
||||
|
||||
"Post" vs "Pre" is shown by the position of the operator before or after the variable it's modifying.
|
||||
|
||||
Pre-increment `++x`
|
||||
|
||||
Post-increment `y--`
|
||||
|
||||
Post-decrement `--this.halogen.id`
|
||||
|
||||
Pre-increment `dragon.level++`
|
||||
|
||||
### Evaluation
|
||||
|
||||
Let's evaluate the equation we're presented with.
|
||||
|
||||
```java
|
||||
int x = 3;
|
||||
int y = 4;
|
||||
println(++x + ++y + y++)
|
||||
```
|
||||
|
||||
The evaluating engine (or whatever) sees a 4 with the pre-increment operator, x is incremented to 4, and returns a 4. Then, y is incremented to 5, and the operator returns a 5.
|
||||
|
||||
So far, we've got `4 + 5 + y++`.
|
||||
|
||||
Finally, y is returned as it is currently (5) and then incremented.
|
||||
|
||||
The final equation looks like `4 + 5 + 5 = 14`.
|
||||
|
||||
`x = 4 and y = 6` in the end.
|
||||
|
||||
## Question 14
|
||||
|
||||
This question is based on how you can instantiate different data types.
|
||||
|
||||
You should remember that the `char` data type is really a integer that maps to a specific character, and thus, you can use a integer to instantiate it. The first line passes.
|
||||
|
||||
The second line is a short. Shorts are essentially integers, but 16 bit, and thus their maximum value is smaller by a very large portion. Their set notation is `[-32,768, 32,768]` inclusive.
|
||||
|
||||
The answer from here on out would be `line two`, but let's look at the rest, too.
|
||||
|
||||
The third line is a integer, which has a much larger range, and `33,000` comes no where near it's maximum. This line is okay.
|
||||
|
||||
The fourth line is alright, casting a integer to a float is totally okay, but there is a big caveat: the variable name being used to instantiate has *already been used in the previous line*.
|
||||
|
||||
This causes a second compiler error, so, one could rule 3 lines here could cause the problem, requiring at least two lines to be changed or removed to cease errors from occurring.
|
||||
|
||||
## Question 15
|
||||
|
||||
This question is to test your knowledge on ArrayLists and how they work.
|
||||
|
||||
Do notice here that the name actually almost looks like it's `1st` and not `lst`. The font is slightly ambiguous in meaning, one could say.
|
||||
|
||||
Let's see how the ArrayList is slowly changed over time.
|
||||
|
||||
```java
|
||||
List<String> lst = new ArrayList<>();
|
||||
> List<String>([])
|
||||
lst.add("Bob");
|
||||
=> List<String>(["Bob"])
|
||||
lst.add(1, "Ralph");
|
||||
=> List<String>(["Bob", "Ralph"])
|
||||
lst.add(0, "Sue");
|
||||
=> List<String>(["Sue", "Bob", "Ralph"])
|
||||
lst.set(1, "Debbie");
|
||||
=> List<String>(["Sue", "Debbie", "Ralph"])
|
||||
out.println(lst.get(lst.size()-1));
|
||||
%> out.println(lst.get(3 - 1))
|
||||
%> out.println(lst.get(2))
|
||||
=> "Ralph"
|
||||
```
|
||||
|
||||
`ArrayList.add(type value)` appends the value specified to the end of the array.
|
||||
|
||||
`ArrayList.add(int index, type value)` inserts the value specified at the position in front of the specified index. It moves the specified index forward and puts the value before it.
|
||||
|
||||
`ArrayList.set(int index, type value)` sets the value at the index specified to the value specified.
|
||||
|
||||
## Question 16
|
||||
|
||||
This question concerns the left shift operator, which is very easy to understand, but hard to evaluate on paper.
|
||||
|
||||
The value given is `1234`, and we shift it left `6` times.
|
||||
|
||||
The binary representation of `1234` is `10011010010`, so, to left shift it, we simply add 6 zeroes to the end. Now, we just convert it from it's new binary representation, `10011010010000000`, to base 10.
|
||||
|
||||
It's final base 10 repsentation is 78976.
|
||||
|
||||
|
||||
## Question 17
|
||||
|
||||
First parameter is the number, second is the base.
|
||||
|
||||
Remember for 123<sub>4</sub>, 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...
|
||||
|
||||
```java
|
||||
n(n/4) - 256(64) - 64(16) - 16(4) - 4(1).
|
||||
```
|
||||
|
||||
So to build 123 <sub>4</sub>, `123 - 64 - 48 - 8 - 3 = 0`.
|
||||
|
||||
And to build 234 <sub>5</sub>, `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.
|
||||
|
||||
```java
|
||||
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:
|
||||
|
||||
```java
|
||||
jgu6oaouih23_6@
|
||||
d9hi@
|
||||
i_3@
|
||||
f@
|
||||
```
|
||||
|
||||
but not these
|
||||
|
||||
```java
|
||||
@
|
||||
^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`) This also does not allow second-level, or any multi-level domains such as `.co.uk`.
|
||||
|
||||
---
|
||||
|
||||
To solve the problem, let's just see which which matches.
|
||||
|
||||
```java
|
||||
>>> bob@example.com
|
||||
Matches!
|
||||
```
|
||||
```java
|
||||
>>> bob@example.co.uk
|
||||
Does not match!
|
||||
".co.uk" does not match "\.[a-z]{2, 3}" which allows only 1 period.
|
||||
```
|
||||
```java
|
||||
>>> ralph@coding.guru
|
||||
Does not match!
|
||||
Domain extensions may only be 2-3 characters long: "\.[a-z]{2, 3}".
|
||||
```
|
||||
```java
|
||||
>>> sue.smith@company.com
|
||||
Does not match!
|
||||
"sue.smith" does not match "\w{1,}", no periods are allowed in the username.
|
||||
```
|
||||
```java
|
||||
>>> donaldgoose@dizney.com
|
||||
Matches!
|
||||
```
|
||||
|
||||
## Question 26
|
||||
|
||||
This is a rather long problem, so let's split it up into parts.
|
||||
|
||||
### 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 is how comparables "compare", and it returns a integer value to representation how it should be placed in the array. The array is sorted in descending order when `Collections.sort` is called on it.
|
||||
|
||||
The integer it returns is calculated based on the length first: if the two Strings have the same length, it returns the result of the two strings `compareTo` method, but if they're not the same length, it returns the difference in length of the two Strings.
|
||||
6
uil/uil-practice-armstrong/test-1/java/.idea/misc.xml
generated
Normal file
6
uil/uil-practice-armstrong/test-1/java/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
uil/uil-practice-armstrong/test-1/java/.idea/modules.xml
generated
Normal file
8
uil/uil-practice-armstrong/test-1/java/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/java.iml" filepath="$PROJECT_DIR$/java.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
uil/uil-practice-armstrong/test-1/java/.idea/vcs.xml
generated
Normal file
6
uil/uil-practice-armstrong/test-1/java/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
243
uil/uil-practice-armstrong/test-1/java/.idea/workspace.xml
generated
Normal file
243
uil/uil-practice-armstrong/test-1/java/.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,243 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="5ee3d13c-335f-4b45-baa5-1d7b6e58ccd6" name="Default Changelist" comment="" />
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FUSProjectUsageTrigger">
|
||||
<session id="1158414669">
|
||||
<usages-collector id="statistics.lifecycle.project">
|
||||
<counts>
|
||||
<entry key="project.closed" value="2" />
|
||||
<entry key="project.open.time.0" value="1" />
|
||||
<entry key="project.open.time.2" value="1" />
|
||||
<entry key="project.opened" value="2" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.open">
|
||||
<counts>
|
||||
<entry key="java" value="1" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.open">
|
||||
<counts>
|
||||
<entry key="JAVA" value="1" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.edit">
|
||||
<counts>
|
||||
<entry key="java" value="53" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.edit">
|
||||
<counts>
|
||||
<entry key="JAVA" value="53" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
</session>
|
||||
<session id="-2041611852">
|
||||
<usages-collector id="statistics.lifecycle.project">
|
||||
<counts>
|
||||
<entry key="project.closed" value="1" />
|
||||
<entry key="project.open.time.0" value="1" />
|
||||
<entry key="project.opened" value="1" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.edit">
|
||||
<counts>
|
||||
<entry key="java" value="461" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.edit">
|
||||
<counts>
|
||||
<entry key="JAVA" value="461" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
</session>
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/question26.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="425">
|
||||
<caret line="27" column="20" selection-start-line="27" selection-start-column="20" selection-end-line="27" selection-end-column="20" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#435#436#0" expanded="true" />
|
||||
<element signature="e#466#467#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../.." />
|
||||
</component>
|
||||
<component name="GradleLocalSettings">
|
||||
<option name="projectSyncType">
|
||||
<map>
|
||||
<entry key="A:/Programming/Modding/Minecraft/EnderStorage" value="PREVIEW" />
|
||||
<entry key="A:/Programming/Modding/Minecraft/Fabric/fabric-example-mod" value="PREVIEW" />
|
||||
<entry key="A:/Programming/Modding/Minecraft/HelloWorldMod" value="PREVIEW" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/src/question26.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="-8" />
|
||||
<option name="y" value="-8" />
|
||||
<option name="width" value="1936" />
|
||||
<option name="height" value="1066" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="java" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="java" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1568697422732" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="question26" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="question26" />
|
||||
<module name="java" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Application.question26" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="5ee3d13c-335f-4b45-baa5-1d7b6e58ccd6" name="Default Changelist" comment="" />
|
||||
<created>1568588446129</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1568588446129</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.1881663" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info id="Image Layers" order="2" />
|
||||
<window_info id="Designer" order="3" />
|
||||
<window_info id="UI Designer" order="4" />
|
||||
<window_info id="Capture Tool" order="5" />
|
||||
<window_info id="Favorites" order="6" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.2306867" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="bottom" id="Terminal" order="7" />
|
||||
<window_info anchor="bottom" id="Event Log" order="8" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Version Control" order="9" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Messages" order="10" weight="0.32939914" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
<window_info anchor="right" id="Palette" order="3" />
|
||||
<window_info anchor="right" id="Capture Analysis" order="4" />
|
||||
<window_info anchor="right" id="Theme Preview" order="5" />
|
||||
<window_info anchor="right" id="Palette	" order="6" />
|
||||
<window_info anchor="right" id="Maven Projects" order="7" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/src/question26.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="425">
|
||||
<caret line="27" column="20" selection-start-line="27" selection-start-column="20" selection-end-line="27" selection-end-column="20" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#435#436#0" expanded="true" />
|
||||
<element signature="e#466#467#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>11</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
||||
11
uil/uil-practice-armstrong/test-1/java/java.iml
Normal file
11
uil/uil-practice-armstrong/test-1/java/java.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Binary file not shown.
Binary file not shown.
46
uil/uil-practice-armstrong/test-1/java/src/question26.java
Normal file
46
uil/uil-practice-armstrong/test-1/java/src/question26.java
Normal file
@@ -0,0 +1,46 @@
|
||||
import static java.lang.System.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class X implements Comparable<X> {
|
||||
String str;
|
||||
X(String str) {
|
||||
this.str = str;
|
||||
}
|
||||
public int compareTo(X other) {
|
||||
return str.length() == other.str.length()
|
||||
? str.compareTo(other.str)
|
||||
: other.str.length() - str.length();
|
||||
}
|
||||
public String toString() {
|
||||
return this.str;
|
||||
}
|
||||
public int[] getValues() {
|
||||
int[] values = new int[this.str.length()];
|
||||
for(int i = 0; i < this.str.length(); i++) {
|
||||
values[i] = (int) this.str.charAt(i);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
public int getSum() {
|
||||
int sum = 0;
|
||||
for(int val : this.getValues()) {
|
||||
sum += val;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
||||
class question26 {
|
||||
public static void main(String[] args) {
|
||||
List<X> w = new ArrayList<>();
|
||||
String str = "Hi this is the right answer";
|
||||
for(String sub : str.split("\\s"))
|
||||
w.add(new X(sub));
|
||||
Collections.sort(w);
|
||||
out.println(w);
|
||||
out.println(Arrays.toString(new X("Hello").getValues()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user