Skip to content

Commit 08dc545

Browse files
committed
Code Stuff
1 parent 32ee94d commit 08dc545

2 files changed

Lines changed: 124 additions & 21 deletions

File tree

src/SUMMARY.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,6 @@ enshittification state machine example (Acquire -> Make good for business bad fo
261261
- [Drawing Isosceles Triangles](./loops_ii/drawing_isosceles_triangles.md)
262262
- [Challenges](./loops_ii/challenges.md)
263263

264-
# Projects
265-
266-
- [ASCII Art Generator](./projects/ascii_art.md)
267-
268264
# Code Structure
269265

270266
- [Methods](./methods.md)
@@ -294,8 +290,27 @@ enshittification state machine example (Acquire -> Make good for business bad fo
294290
- [Unreachable Statements](./return_values/unreachable_statements.md)
295291
- [Challenges](./return_values/challenges.md)
296292

293+
297294
# Data Types III
298295

296+
- [Multi-Dimensional Arrays](./multi_dimensional_arrays.md)
297+
- [Declaration](./multi_dimensional_arrays/declaration.md)
298+
- [Array Initializers](./multi_dimensional_arrays/array_initializers.md)
299+
- [Initialization with new](./multi_dimensional_arrays/initialization_with_new.md)
300+
- [Access Individual Elements](./multi_dimensional_arrays/access_individual_elements.md)
301+
- [Set Individual Elements](./multi_dimensional_arrays/set_individual_elements.md)
302+
- [Initialization with Size](./multi_dimensional_arrays/initialize_with_size.md)
303+
- [Default Values](./multi_dimensional_arrays/default_values.md)
304+
- [Populate Values](./multi_dimensional_arrays/populate_values.md)
305+
- [Ragged Arrays](./multi_dimensional_arrays/ragged_arrays.md)
306+
- [Challenges](./multi_dimensional_arrays/challenges.md)
307+
308+
# Projects
309+
310+
- [ASCII Art Generator](./projects/ascii_art.md)
311+
312+
# Data Types IV
313+
299314
- [null](./null.md)
300315
- [Null as Absence](./null/null_as_absence.md)
301316
- [Null as Unknown](./null/null_as_unknown.md)
@@ -353,7 +368,7 @@ enshittification state machine example (Acquire -> Make good for business bad fo
353368
- [Point of Sale System](./projects/point_of_sale_system.md)
354369

355370

356-
# Data Types IV
371+
# Data Types V
357372

358373
- [Enums](./enums.md)
359374
- [Declaration](./enums/declaration.md)
@@ -562,7 +577,7 @@ enshittification state machine example (Acquire -> Make good for business bad fo
562577
- [Reverse Domain Name Notation](./packages/reverse_domain_name_notation.md)
563578
- [Challenges](./packages/challenges.md)
564579

565-
# Data Types IV
580+
# Data Types VI
566581

567582
- [Records](./records.md)
568583
- [Declaration](./records/declaration.md)
@@ -640,7 +655,7 @@ enshittification state machine example (Acquire -> Make good for business bad fo
640655
- [Subtypes](./interfaces/subtypes.md)
641656
- [Multiple Implementations](./interfaces/multiple_implementations.md)
642657
- [Challenges](./interfaces/challenges.md)
643-
# Data Types V
658+
# Data Types VII
644659

645660
<!-- Note: Put a joke about the "A train leaves chicago at ..." problems.
646661
Make them do one. -->
@@ -730,7 +745,7 @@ Make them do one. -->
730745
- [Information Hiding](./encapsulation/information_hiding.md)
731746

732747

733-
# Data Types VI
748+
# Data Types VIII
734749

735750
- [Collections](./collections.md)
736751
- [List](./collections/list.md)
@@ -743,18 +758,6 @@ Make them do one. -->
743758
- [Challenges](./collections/challenges.md)
744759

745760

746-
- [Multi-Dimensional Arrays](./multi_dimensional_arrays.md)
747-
- [Declaration](./multi_dimensional_arrays/declaration.md)
748-
- [Array Initializers](./multi_dimensional_arrays/array_initializers.md)
749-
- [Initialization with new](./multi_dimensional_arrays/initialization_with_new.md)
750-
- [Access Individual Elements](./multi_dimensional_arrays/access_individual_elements.md)
751-
- [Set Individual Elements](./multi_dimensional_arrays/set_individual_elements.md)
752-
- [Initialization with Size](./multi_dimensional_arrays/initialize_with_size.md)
753-
- [Default Values](./multi_dimensional_arrays/default_values.md)
754-
- [Populate Values](./multi_dimensional_arrays/populate_values.md)
755-
- [Ragged Arrays](./multi_dimensional_arrays/ragged_arrays.md)
756-
- [Challenges](./multi_dimensional_arrays/challenges.md)
757-
758761
# Metaprogramming
759762

760763
- [Reflection](./reflection.md)
@@ -812,7 +815,7 @@ Make them do one. -->
812815
- [Final Classes](./class_extension/final_classes.md)
813816

814817

815-
# Data Types VII
818+
# Data Types IX
816819

817820
- [Niche Numerics](./niche_numerics.md)
818821
- [byte](./niche_numerics/byte.md)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,101 @@
11
# Challenges
2+
3+
Remember the rules for this are
4+
5+
- Try to use only the information given up to this point in this book.
6+
- Try not to give up until you've given it a solid attempt
7+
8+
9+
10+
11+
## Challenge 1.
12+
13+
Initialize 10x10 2D array of `int`s by size.
14+
Print every element of this new 2D array.
15+
16+
Will any elements of the outermost array be `null`?
17+
Write down your guess before making the program.
18+
19+
```java,editable
20+
void main() {
21+
int[][] xs = /* CODE HERE */
22+
// CODE HERE
23+
}
24+
```
25+
26+
## Challenge 2.
27+
28+
Print out every character in the 2D array of `char`s. After each
29+
row print a new line.
30+
31+
```java,editable
32+
void main() {
33+
char[][] picture = new char[][] {
34+
new char[] { ' ', ' ', ' ', ' ' },
35+
new char[] { ' ', '*', '*', ' ' }
36+
new char[] { '\\', ' ', ' ', '/' }
37+
new char[] { ' ', '-', '-', ' ' }
38+
};
39+
40+
// CODE HERE
41+
}
42+
```
43+
44+
## Challenge 3.
45+
46+
"Draw" a smiley face on the "canvas" provided by a 5x5 2D `char` array.
47+
48+
Use similar code as the previous challenge to print it out.
49+
50+
```java,editable
51+
void main() {
52+
final char[][] picture = new char[5][5];
53+
54+
// CODE HERE
55+
}
56+
```
57+
58+
59+
60+
## Challenge 3.
61+
62+
Write a method named `winner`. It should take in a 2-dimensional
63+
array of `String`s where each character is either `X`, `O`, or an empty string.
64+
This 2D array represents a [game of Tic-Tac-Toe](https://en.wikipedia.org/wiki/Tic-tac-toe).
65+
66+
If there is a winner of the Tic-Tac-Toe game, it should return `X` or `O` depending on who the winner is.
67+
It should return `null` if nobody won or the game is a tie.
68+
69+
```java
70+
String winner(String[][] ticTacToe) {
71+
// CODE HERE
72+
}
73+
74+
void main() {
75+
var winnerA = winner(new String[][] {
76+
new String[] { "X", "X", "" },
77+
new String[] { "O", "", "" },
78+
new String[] { "O", "", "" }
79+
});
80+
81+
IO.println(winnerA);
82+
83+
var winnerB = winner(new String[][] {
84+
new String[] { "X", "X", "X" },
85+
new String[] { "O", "O", "X" },
86+
new String[] { "O", "", "O" }
87+
});
88+
89+
IO.println(winnerB);
90+
91+
var winnerC = winner(new Character[][] {
92+
new Character[] { "O", "X", "O" },
93+
new Character[] { "O", "O", "X" },
94+
new Character[] { "O", "X", "O" }
95+
});
96+
97+
IO.println(winnerC);
98+
}
99+
```
100+
101+

0 commit comments

Comments
 (0)