aboutsummaryrefslogtreecommitdiff
path: root/challenge-152/lubos-kolouch/java/ch-1.java
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-02-18 10:40:32 +0000
committerGitHub <noreply@github.com>2022-02-18 10:40:32 +0000
commit8952297006cc07b7393cf13a78d24fb1cb7ff99d (patch)
tree95858365980f672a9486a45c8766c393256ab55a /challenge-152/lubos-kolouch/java/ch-1.java
parent3acd29f6195bfb005f78108c56423a018f2d44c4 (diff)
parentc4a63597ef2a392701b49be29f7615f0cad91cde (diff)
downloadperlweeklychallenge-club-8952297006cc07b7393cf13a78d24fb1cb7ff99d.tar.gz
perlweeklychallenge-club-8952297006cc07b7393cf13a78d24fb1cb7ff99d.tar.bz2
perlweeklychallenge-club-8952297006cc07b7393cf13a78d24fb1cb7ff99d.zip
Merge pull request #5668 from LubosKolouch/master
Challenge 152 LK Perl Python PHP Java
Diffstat (limited to 'challenge-152/lubos-kolouch/java/ch-1.java')
-rw-r--r--challenge-152/lubos-kolouch/java/ch-1.java36
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");
+ }
+ }
+}