1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package com.pact;
- import java.io.*;
- import java.util.HashSet;
- public class Main {
- public HashSet<Node> process(String in)
- throws IOException, BracketException
- {
- BufferedReader inB = new BufferedReader(new FileReader(in));
- String line;
- HashSet<Node> templates = null;
- while((line = inB.readLine()) != null){
- if(templates == null) {
- // Load first line into template
- templates = new HashSet();
- templates.add(new Node(null, line));
- continue;
- }
- HashSet<Node> allCombined = new HashSet();
- Node input = new Node(null, line);
- for (Node template : templates) {
- // Get all the ways we can combine input with template
- HashSet<Node> combined = template.reducedCombine(input);
- System.out.println("com: " + combined);
- allCombined.addAll(combined);
- }
- templates = allCombined;
- }
- inB.close();
- return templates;
- }
- public static void main(String[] args) {
- Main main = new Main();
- String inputFilename = "input.txt";
- HashSet<Node> result;
- try {
- result = main.process(inputFilename);
- System.out.println("----------------------------------------");
- System.out.println("----------------------------------------");
- for(Node node : result){
- System.out.println(node.getVenn());
- }
- } catch (IOException e){
- System.out.println("Status: Fail, write error\n" + e);
- }
- }
- }
|