Skip to main content

Posts

Showing posts from May, 2012

Words formed by selecting one letter from each set (set combinations)

//Input 1,2   3,4,5  6  -1  each set is entered line-by-line //-1 is the end of input //output will be 136,146,156,236,246,256 import java.io.*; import java.util.*; import java.lang.String; import java.util.StringTokenizer; public class Possibilities {     public static void main(String[] args) throws IOException {         String s;         ArrayList<String> a1 = new ArrayList<String>();         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));         s = br.readLine();         if (!s.equals("-1"))             a1 = generatePossibilities(s);         System.out.println(a1);     }     public static ArrayList<String> generatePossibilities(String s)             throws IOException     {         ArrayList<String> a1 = new ArrayList<String>();         ArrayList<String> a2 = new ArrayList<String>();         ArrayList<String> a3 = new ArrayList<String>();         Buffered