Terminal Transcript @ Sep 19, 2012 9:57:02 PM

terminal++@$ ls
bin lib programming projects sdcard sum.java system tmp
terminal++@$ cd programming/
terminal++@$ ls
8Queens aandb matrixRotate90Deg replaceSpace vpnConnection.sh
Book Solutions hello recursive trie
terminal++@$ cd re
recursive/ replaceSpace/
terminal++@$ cd recursive/
terminal++@$ ls
SumSet.class SumSet.jar SumSet.java builder.sh log.txt run.sh
terminal++@$ cat SumSet.java
import java.util.ArrayList;
import java.util.Arrays;

class SumSet {
static void sum_up_recursive(ArrayList<Integer> numbers, int target, ArrayList<Integer> partial)
int s = 0;
for (int x: partial)
s += x;
if (s == target)
if (s >= target)
for(int i=0;i<numbers.size();i++)
ArrayList<Integer> remaining = new ArrayList<Integer>();
int n = numbers.get(i);
for (int j=i+1; j<numbers.size();j++)
ArrayList<Integer> partial_rec = new ArrayList<Integer>(partial);
static void sum_up(ArrayList<Integer> numbers, int target)
sum_up_recursive(numbers,target,new ArrayList<Integer>());
public static void main(String args[])
Integer[] numbers = {3,9,8,4,5,7,10,12, 14, 13, 18};
int target = 21;
sum_up(new ArrayList<Integer>(Arrays.asList(numbers)),target);


This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s