Skip to content

Commit 8de7b8c

Browse files
authored
Merge branch 'code-differently:main' into DavidSmith-Lesson10-Loader.ts
2 parents 7b2605b + 3e8f77b commit 8de7b8c

File tree

26 files changed

+6953
-1
lines changed

26 files changed

+6953
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Check Lesson 10 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_11/arrays_java/**"
8+
- "lesson_11/arrays_ts/**"
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
26+
- name: Use Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20.x'
30+
31+
- name: Build Lesson 11 with Java
32+
working-directory: ./lesson_11/arrays_java
33+
run: ./gradlew check
34+
35+
- name: Build Lesson 11 with Node.js
36+
working-directory: ./lesson_11/arrays_ts
37+
run: |
38+
npm ci
39+
npm run check

.github/workflows/check_push.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
- "lesson_07/conditionals/**"
1212
- "lesson_09/types/**"
1313
- "lesson_10/libraries/**"
14+
- "lesson_11/arrays_java/**"
15+
- "lesson_11/arrays_ts/**"
1416

1517
jobs:
1618
build:
@@ -82,4 +84,12 @@ jobs:
8284
npm ci
8385
npm run compile
8486
87+
- name: Build Lesson 11 with Java
88+
working-directory: ./lesson_11/arrays_java
89+
run: ./gradlew assemble
8590

91+
- name: Build Lesson 11 with Node.js
92+
working-directory: ./lesson_11/arrays_ts
93+
run: |
94+
npm ci
95+
npm run compile

lesson_11/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ Please review the following resources before lecture:
99

1010
## Homework
1111

12-
TODO(anthonydmays): Add details
12+
- [ ] Complete methods in [Lesson11.java](./arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java) and submit PR.
13+
- [ ] Do pre-work for [lesson 12](/lesson_12/).
14+
15+
### Extra credit
16+
17+
- [ ] Complete TypeScript version of methods in [Lesson11.ts](./arrays_ts/src/lesson11.ts) and submit PR.

lesson_11/arrays_java/.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

lesson_11/arrays_java/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
plugins {
2+
// Apply the application plugin to add support for building a CLI application in Java.
3+
application
4+
eclipse
5+
id("com.diffplug.spotless") version "6.25.0"
6+
id("org.springframework.boot") version "3.2.2"
7+
id("com.adarshr.test-logger") version "4.0.0"
8+
}
9+
10+
apply(plugin = "io.spring.dependency-management")
11+
12+
repositories {
13+
// Use Maven Central for resolving dependencies.
14+
mavenCentral()
15+
}
16+
17+
dependencies {
18+
// Use JUnit Jupiter for testing.
19+
testImplementation("com.codedifferently.instructional:instructional-lib")
20+
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
21+
testImplementation("org.springframework.boot:spring-boot-starter-test")
22+
testImplementation("org.assertj:assertj-core:3.25.1")
23+
testImplementation("at.favre.lib:bcrypt:0.10.2")
24+
25+
// This dependency is used by the application.
26+
implementation("com.codedifferently.instructional:instructional-lib")
27+
implementation("com.google.guava:guava:31.1-jre")
28+
implementation("com.google.code.gson:gson:2.10.1")
29+
implementation("org.projectlombok:lombok:1.18.30")
30+
implementation("org.springframework.boot:spring-boot-starter")
31+
}
32+
33+
application {
34+
// Define the main class for the application.
35+
mainClass.set("com.codedifferently.lesson11.Lesson11")
36+
}
37+
38+
tasks.named<Test>("test") {
39+
// Use JUnit Platform for unit tests.
40+
useJUnitPlatform()
41+
}
42+
43+
44+
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
45+
46+
format("misc", {
47+
// define the files to apply `misc` to
48+
target("*.gradle", ".gitattributes", ".gitignore")
49+
50+
// define the steps to apply to those files
51+
trimTrailingWhitespace()
52+
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
53+
endWithNewline()
54+
})
55+
56+
java {
57+
// don't need to set target, it is inferred from java
58+
59+
// apply a specific flavor of google-java-format
60+
googleJavaFormat()
61+
// fix formatting of type annotations
62+
formatAnnotations()
63+
}
64+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson11;
2+
3+
import java.util.List;
4+
5+
public class Lesson11 {
6+
7+
/**
8+
* Provide the solution to LeetCode 1929 here:
9+
* https://leetcode.com/problems/concatenation-of-array
10+
*/
11+
public int[] getConcatenation(int[] nums) {
12+
return null;
13+
}
14+
15+
/**
16+
* Provide the solution to LeetCode 2942 here:
17+
* https://leetcode.com/problems/find-words-containing-character/
18+
*/
19+
public List<Integer> findWordsContaining(String[] words, char x) {
20+
return null;
21+
}
22+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.codedifferently.lesson11;
2+
3+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
import java.util.Arrays;
7+
import java.util.List;
8+
import org.junit.jupiter.api.Test;
9+
10+
class Lesson11Test {
11+
12+
@Test
13+
public void testGetConcatenation() {
14+
Lesson11 solution = new Lesson11();
15+
16+
// Test case 1
17+
int[] nums1 = {1, 2, 1};
18+
int[] expected1 = {1, 2, 1, 1, 2, 1};
19+
int[] result1 = solution.getConcatenation(nums1);
20+
assertArrayEquals(expected1, result1);
21+
22+
// Test case 2
23+
int[] nums2 = {1, 3, 2, 1};
24+
int[] expected2 = {1, 3, 2, 1, 1, 3, 2, 1};
25+
int[] result2 = solution.getConcatenation(nums2);
26+
assertArrayEquals(expected2, result2);
27+
28+
// Test case 3
29+
int[] nums3 = {};
30+
int[] expected3 = {};
31+
int[] result3 = solution.getConcatenation(nums3);
32+
assertArrayEquals(expected3, result3);
33+
34+
// Test case 4
35+
int[] nums4 = {5};
36+
int[] expected4 = {5, 5};
37+
int[] result4 = solution.getConcatenation(nums4);
38+
assertArrayEquals(expected4, result4);
39+
40+
// Test case 5
41+
int[] nums5 = {0, 0, 0};
42+
int[] expected5 = {0, 0, 0, 0, 0, 0};
43+
int[] result5 = solution.getConcatenation(nums5);
44+
assertArrayEquals(expected5, result5);
45+
}
46+
47+
@Test
48+
public void testWordsContainingChar() {
49+
Lesson11 solution = new Lesson11();
50+
51+
// Test case 1
52+
char ch1 = 'a';
53+
String[] words1 = {"apple", "banana", "cherry", "date"};
54+
List<Integer> expected1 = Arrays.asList(0, 1, 3);
55+
List<Integer> result1 = solution.findWordsContaining(words1, ch1);
56+
assertEquals(expected1, result1);
57+
58+
// Test case 2
59+
char ch2 = 'z';
60+
String[] words2 = {"apple", "banana", "cherry", "date"};
61+
List<Integer> expected2 = Arrays.asList();
62+
List<Integer> result2 = solution.findWordsContaining(words2, ch2);
63+
assertEquals(expected2, result2);
64+
65+
// Test case 3
66+
char ch3 = 'e';
67+
String[] words3 = {"apple", "banana", "cherry", "date"};
68+
List<Integer> expected3 = Arrays.asList(0, 2, 3);
69+
List<Integer> result3 = solution.findWordsContaining(words3, ch3);
70+
assertEquals(expected3, result3);
71+
72+
// Test case 4
73+
char ch4 = 'a';
74+
String[] words4 = {"", " ", "banana"};
75+
List<Integer> expected4 = Arrays.asList(2);
76+
List<Integer> result4 = solution.findWordsContaining(words4, ch4);
77+
assertEquals(expected4, result4);
78+
}
79+
}
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)