Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Part1_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Part1_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Part1_4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Part2_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Part3_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

```text
PUT ANSWER TO #2 HERE
The blank object is mutable, because an immutable object is an object that once created, cannot be modified, but the point class's x and y points can be modified at any point.
```

```java
Expand Down Expand Up @@ -48,6 +49,7 @@ public class Puzzler {

```text
PUT ANSWER TO #5 HERE
findCenter returns a Point class, which provides 2 separate values and in this case, the method only takes one value to produce them. distance returns a double value by doing a simple math equation when provided with two values to produce it.
```

```java
Expand Down Expand Up @@ -88,13 +90,16 @@ Recall that aliases are two variables that refer to the same object.

```text
PUT ANSWER TO #2 HERE
(5, 8)
(5, 8)
```

3. At the end of main, are p1 and p2 aliased? Why or why not?
* Put your answer in the text block below

```text
PUT ANSWER TO #3 HERE
p1 and p2 are not aliased, even though they are both set to the value of findCenter(box1), box1 is grown before p2 is set, thus the value of their centers are different.
```

```java
Expand Down
16 changes: 16 additions & 0 deletions src/BigIntRewrite.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import java.math.BigInteger;

public class BigIntRewrite {
public static void main(String[] args) {
System.out.println(pow(1000,40));
}

public static BigInteger pow(int x, int n) {
if (n == 0) return BigInteger.valueOf(1);
// find x to the n/2 recursively
BigInteger t = pow(x, n / 2);
BigInteger xBig = BigInteger.valueOf(x);
// if n is even, the result is t squared
// if n is odd, the result is t squared times x
if (n % 2 == 0) {
return t.multiply(t);
} else {
return t.multiply(t.multiply(xBig));
}
}
}
10 changes: 10 additions & 0 deletions src/StringPlayground.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
public class StringPlayground {
public static void main(String[] args) {
System.out.println(parenthesisBalance("({3 * 7] * [2 / 2)", 0));
}

public static String parenthesisBalance(String s, int count) {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '(' || c == '[' || c == '{') { count++; }
else if (c == ')' || c == ']' || c == '}') { count--; }
}
return Integer.toString(count);
}
}