Skip to content

Commit

Permalink
jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
s50600822 committed Oct 2, 2023
1 parent ebd291e commit da86daf
Show file tree
Hide file tree
Showing 68 changed files with 25 additions and 16 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/interview_prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
Expand All @@ -41,13 +41,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'adopt'
java-version: 21
distribution: 'corretto'
- name: Build and test Java
run: |
cd interview_prep/algorithm/java17
cd interview_prep/algorithm/java
./mvnw test
3 changes: 3 additions & 0 deletions interview_prep/algorithm/java/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.debug.settings.onBuildFailureProceed": true
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ public static <T> Node<T> bfs(
while (!frontier.isEmpty()) {
Node<T> currentNode = frontier.poll();
T currentState = currentNode.state;
System.out.println("currentState: "+currentState);
if (goalTest.test(currentState)) {
return currentNode;
}
// check where we can go next and haven't explored
for (T child : successors.apply(currentState)) {
System.out.println("child " +child+", visited:" + explored);
if (explored.contains(child)) {
continue; // skip children we already explored
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class UndirectedGraphTest {
@Test
Expand All @@ -18,9 +19,8 @@ public void test1() {
"Seattle",
v -> v.equals("Chicago"),
g::neighbor);
List<String> path = Search.nodeToPath(bfsResult);
assertEquals(List.of("Seattle","Chicago"), path);

assertNotNull(bfsResult);
assertEquals(List.of("Seattle","Chicago"), Search.nodeToPath(bfsResult));
}

@Test
Expand All @@ -31,6 +31,7 @@ public void test2() {
"Seattle",
v -> v.equals("Riverside"),
g::neighbor);
assertNotNull(bfsResult);
List<String> path = Search.nodeToPath(bfsResult);
assertEquals("Seattle", path.get(0));
assertEquals("Riverside", path.get(path.size()-1));
Expand All @@ -45,9 +46,8 @@ public void test3() {
"Chicago",
v -> v.equals("Seattle"),
g::neighbor);
List<String> path = Search.nodeToPath(bfsResult);
assertEquals(List.of("Chicago","Seattle"), path);

assertNotNull(bfsResult);
assertEquals(List.of("Chicago","Seattle"), Search.nodeToPath(bfsResult));
}

@Test
Expand All @@ -59,7 +59,11 @@ public void test4() {
"Boston",
v -> v.equals("Miami"),
g::neighbor);

assertNotNull(bfsResult);
List<String> path = Search.nodeToPath(bfsResult);
assertEquals("Seattle", path.get(0));
assertEquals("Riverside", path.get(path.size()-1));
}

private UndirectedGraph<String> cities(){
Expand Down

0 comments on commit da86daf

Please sign in to comment.