0

I want to work with loto combinaison but i have timeout . Is it Possible to go out for this timeout ? Not Loop Infinite !

public class Program { public static void main(String[] args) { int i1; i1 = 49; for (int i= i1; i>=6; i--) { for (int j=i-1; j>=5; j--) { for (int k=j-1; k>=4; k--) { for (int m=k-1; m>=3; m--) { for (int o=m-1; o>=2; o--) { for (int p=o-1; p>=1; p--) { System.out.println(String.valueOf(i) + " / " + String.valueOf(j) + " / " + String.valueOf(k) + " / " + String.valueOf(m) + " / " + String.valueOf(o) + " / " + String.valueOf(p)); } } } } } } } }

9th Sep 2020, 10:43 AM
Yannick Le Breton
Yannick Le Breton - avatar
5 Answers
+ 3
I am assuming you are referring to timeout on SoloLearn. First, check is there any infinite loop in your code. If there is none and SoloLearn still gives you timeout, you can try running the Java program locally on your computer.
9th Sep 2020, 11:56 AM
Heng Jun Xi
Heng Jun Xi - avatar
+ 2
If you want to get help here, please put your code in playground and post it here. Thanks!
9th Sep 2020, 12:47 PM
Lothar
Lothar - avatar
+ 2
Yannick Le Breton ,I Never did coding in java, but (hopefully) I can read and understand this code. public class Program { public static void main(String[] args) { int i1; i1 = 49; for (int i= i1; i>=6; i--) { for (int j=i-1; j>=5; j--) { ... At the end of the first for loop, Var i has a value of 5. In the second for loop you initialized j with i-1, which is j=5-1 j=4. The condition in the second loop says: j>= 5, which is false. So i suppose this is the start an infinite loop. Maybe someone who is familiar in java can give a statement to my assumption? Thanks! BTW Yannick Le Breton, as I have put some time and effort in this code, it would be nice if you could enlighten me what your code is going to achieve. Thanks again!
10th Sep 2020, 11:05 AM
Lothar
Lothar - avatar
+ 1
@Lother no infinite loop.. When it false, how can it run further? It stops there.. It requires (43*42*41*39*38*37) number of repeatations... So here its time out only....
10th Sep 2020, 9:04 PM
Jayakrishna 🇼🇳
0
Do you know how many time there the inner most loop runs... I think .. SoloLearn time out is less than 5secs only I think.. It may take more i guess.. So it definitely a time out... So reduse number of times loop should run is the only way... You have extra closing brackets, remove.. And BTW you don't need to convert to string, it extra unnecessary calculations, remove..
9th Sep 2020, 8:09 PM
Jayakrishna 🇼🇳