File tree 2 files changed +29
-1
lines changed
main/java/com/thealgorithms/dynamicprogramming
test/java/com/thealgorithms/dynamicprogramming
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 6
6
public class EggDropping {
7
7
8
8
// min trials with n eggs and m floors
9
- private static int minTrials (int n , int m ) {
9
+ public static int minTrials (int n , int m ) {
10
10
int [][] eggFloor = new int [n + 1 ][m + 1 ];
11
11
int result , x ;
12
12
Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .dynamicprogramming ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+
5
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
6
+
7
+ public class EggDroppingTest {
8
+
9
+ @ Test
10
+ void hasMultipleEggSingleFloor (){
11
+ assertEquals (1 ,EggDropping .minTrials (3 ,1 ));
12
+ }
13
+
14
+ @ Test
15
+ void hasSingleEggSingleFloor (){
16
+ assertEquals (1 ,EggDropping .minTrials (1 ,1 ));
17
+ }
18
+
19
+ @ Test
20
+ void hasSingleEggMultipleFloor (){
21
+ assertEquals (3 ,EggDropping .minTrials (1 ,3 ));
22
+ }
23
+
24
+ @ Test
25
+ void hasMultipleEggMultipleFloor (){
26
+ assertEquals (7 ,EggDropping .minTrials (100 ,101 ));
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments