diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2022-02-17 20:49:00 +0100 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2022-02-17 20:49:00 +0100 |
| commit | 6397d4bd302e33f07e9c632d9119780643cf8374 (patch) | |
| tree | 3764f7a97c33c7a7dce70a51d2a58605eea5fca3 | |
| parent | 6a933e40878b068e5b069f94c3ae685f3d8769b7 (diff) | |
| download | perlweeklychallenge-club-6397d4bd302e33f07e9c632d9119780643cf8374.tar.gz perlweeklychallenge-club-6397d4bd302e33f07e9c632d9119780643cf8374.tar.bz2 perlweeklychallenge-club-6397d4bd302e33f07e9c632d9119780643cf8374.zip | |
Challenge 152 Task 1 Java
| -rw-r--r-- | challenge-152/lubos-kolouch/java/ch-1.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/challenge-152/lubos-kolouch/java/ch-1.java b/challenge-152/lubos-kolouch/java/ch-1.java new file mode 100644 index 0000000000..46bda99f11 --- /dev/null +++ b/challenge-152/lubos-kolouch/java/ch-1.java @@ -0,0 +1,36 @@ +class MinPathFinder { + + static int get_min_count(int[][] in_arr) { + int min_sum = 0; + + int i; + for (i = 0; i < in_arr.length; i++) { + int min = in_arr[i][0]; + + int j; + for (j = 0; j < in_arr[i].length; j++) { + if (in_arr[i][j] < min) { + min = in_arr[i][j]; + } + } + + min_sum += min; + } + return min_sum; + } + + public static void main(String[] args) { + + int[][] my_list = {{1}, {5, 3}, {2, 3, 4}, {7, 1, 0, 2}, {6, 4, 5, 2, 8}}; + + if (get_min_count(my_list) != 8) { + System.out.println("Failed test 1"); + } + + int[][] my_list2 = {{5}, {2, 3}, {4, 1, 5}, {0, 1, 2, 3}, {7, 2, 4, 1, 9}}; + + if (get_min_count(my_list2) != 9) { + System.out.println("Failed test 2"); + } + } +} |
