Skip to content

Instantly share code, notes, and snippets.

@Hawaiideveloper
Last active May 5, 2020 19:33
Show Gist options
  • Save Hawaiideveloper/54043940de14acd48b15dffba3c3a0a6 to your computer and use it in GitHub Desktop.
Save Hawaiideveloper/54043940de14acd48b15dffba3c3a0a6 to your computer and use it in GitHub Desktop.
Sum of two elements in a queue that equal 9
import java.util.ArrayList;
class solution {
public static void main(String[] args) {
int repository_numbers = 3;
// int sumValues = 0;
ArrayList<Integer> number_set = new ArrayList<Integer>(repository_numbers);
// use add method to add elements into the list
number_set.add(2);
number_set.add(7);
number_set.add(11);
number_set.add(15);
// prints all the elements available in list
//for (Integer number : number_set) {
// I need to add the first element of the string to the next element of the string
//for(repository_numbers++; repository_numbers <number_set.size();repository_numbers++){
//This adds the number plus its next index
// System.out.println("The number set is Corey");
//for (int i = 0; i < number_set.size(); i++){
//System.out.println(number_set.get(i));
//}
// This gives you a running total of sum values
// int sumValues = (number);
// System.out.println("the sumValues is " + sumValues++ ) ;
// System.out.println ("the number set position" + number_set.get(0));
// System.out.println ("the number set position" + number_set.get(1));
// System.out.println ("the number set position" + number_set.get(2));
// System.out.println ("the number set position" + number_set.get(3));
//sets the combinations
// Prints out the combinations that equl 9 only of all number added to the previous one
//Print out first element plus the next element in one line then add them together
int combination_A = number_set.get(0) + number_set.get(1);
System.out.println("the combination of combo A: " + (number_set.get(0) + " + " + (number_set.get(1))));
System.out.println("is:" + combination_A);
// int combination_B = number_set.get(0) + number_set.get(2);
// System.out.println("the combination of combo B:" + (number_set.get(0) + " + " +( number_set.get(2))));
// System.out.println("is:" + combination_B);
// int combination_C = number_set.get(0) + number_set.get(3);
// System.out.println("the combination of combo C:" + (number_set.get(0) + " + " +( number_set.get(3))));
// System.out.println("is:" + combination_C);
// int combination_D = number_set.get(1) + number_set.get(2);
//System.out.println("the combination of combo D:" + (number_set.get(1) + " + " +( number_set.get(2))));
//System.out.println("is:" + combination_D);
// int combination_E = number_set.get(1) + number_set.get(3);
//System.out.println("the combination of combo E:" + (number_set.get(1) + " + " +( number_set.get(3))));
// System.out.println("is:" + combination_E);
// int combination_F = number_set.get(2) + number_set.get(3);
// System.out.println("the combination of combo F:" + (number_set.get(2) + " + " +( number_set.get(3))));
// System.out.println("is:" + combination_F);
int combination_G = number_set.get(2) - number_set.get(0);
System.out.println("the combination of combo G:" + (number_set.get(2) + " - " +( number_set.get(0))));
System.out.println("is:" + combination_G);
// System.out.println("the manual number is" + combination_B);
// System.out.println("the manual number is" + combination_D);
// System.out.println("the manual number is" + combination_E);
// System.out.println("the manual number is" + combination_F);
}
// Printing elements one by one
//for (int i = 0; i<number_set.size(); i++)
//System.out.print(number_set.get(i));
// Prints out the combinations of all number added to the previous one
//Print out first element plus the next element in one line add them together
}
//}
// define what equals 9 (logic)
// each time the number 9 shows up keep it
// each time any other number happens throw it away
// return the sets of numbers that equal 9
// let me know which combination works to get a nine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment