Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I turn my code so that it finds all possible combinations of numbers
    primarykey
    data
    text
    <p>This is the code I have writen so far in order to find the unique combinations of the integers. I recieve the number of the total integers and the length of the teams that will be created and I want to use the recursion in order to find all combinations</p> <pre><code>import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class PartA { public static void main(String[] args) { Scanner sizeInput= new Scanner(System.in); ArrayList&lt;Integer&gt; teams= new ArrayList&lt;Integer&gt;(); int groupSize=0; int teamSize=0; System.out.println("Type the size you wish the main group to be: "); groupSize= sizeInput.nextInt(); System.out.println(" The group will be of size : "+groupSize); System.out.println("Type the size the team will have: "); teamSize= sizeInput.nextInt(); System.out.println(" The team will be of size : "+teamSize); ArrayList&lt;Integer&gt; mainGroup= new ArrayList&lt;Integer&gt;(); for(Integer i=0;i&lt;groupSize;i++){ mainGroup.add(i); int loopTimes=mainGroup.size(); int count=0; showTeams(mainGroup,teams,loopTimes,count,teamSize,groupSize); } } public static Integer showTeams(ArrayList&lt;Integer&gt;mainGroup, ArrayList&lt;Integer&gt;teams,int loopTimes,int count, int teamSize,int groupSize) { int e=0; int i=0,o; //int count=0; //int loop=U.length(); while(count&lt;=2){ for(i=0; i&lt;loopTimes-1 ; i++){ o=i+count; e=mainGroup.get(i)+mainGroup.get(o+1); System.out.println(e); } count++; loopTimes--; System.out.println(count + " " + loopTimes); if(count&gt;loopTimes) { System.out.println("Solution Found"); return e; } else { System.out.println("Recursion Call"); showTeams(mainGroup,teams,loopTimes,count,teamSize,groupSize); } } return e; } } </code></pre> <p>All I want is to print the unique combinations for the integers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload