/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package codejam.common;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Lance Chen
 */
public class CodeHelper {

    private static String FILE_ROOT = "D:/workspace/googlecodejam/meta";

    public static List<List<String>> loadInputsExcludes(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        int index = 0;
        for (String line : lines) {
            if (index == 0) {
                index++;
                continue;
            }
            if (index % 2 == 1) {
                index++;
                continue;
            }
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
            index++;
        }
        return result;
    }

    public static List<List<String>> loadInputs(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        for (String line : lines) {
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
        }
        return result;
    }

    public static List<String> loadInputLines(String fileName) {
        return FileUtil.readLines(FILE_ROOT + fileName);
    }

    public static void writeOutputs(String fileName, List<String> lines) {
        FileUtil.writeLines(FILE_ROOT + fileName, lines);
    }
}

package hk.polyu.cslhu.codejam.thread;

import hk.polyu.cslhu.codejam.lib.ResultCollector;
import hk.polyu.cslhu.codejam.solution.Solution;

import java.util.List;

import org.apache.log4j.Logger;

public abstract class JamThread implements Runnable {
	public static Logger logger = Logger.getLogger(JamThread.class);

	private ResultCollector resultCollector;
	private int indexOfList;
	private List<List<String>> testCaseList;
	private Solution solution;
	
	/**
	 * Return the solution
	 * 
	 * @return Solution
	 */
	public Solution getSolution() {
		return solution;
	}

	/**
	 * Set the solution used for test cases
	 * 
	 * @param solution Solution
	 */
	public void setSolution(Solution solution) {
		this.solution = solution;
	}

	/**
	 * Return the result collector
	 * 
	 * @return ResultCollector
	 */
	public ResultCollector getResultCollector() {
		return resultCollector;
	}

	/**
	 * Set the result collector
	 * 
	 * @param resultCollector ResultCollector
	 */
	public void setResultCollector(ResultCollector resultCollector) {
		this.resultCollector = resultCollector;
	}
	
	/**
	 * Return the index of list
	 *  
	 * @return int The index of list
	 */
	public int getIndexOfList() {
		return indexOfList;
	}

	/**
	 * Set the index of list
	 * 
	 * @param indexOfList int The index of list
	 */
	public void setIndexOfList(int indexOfList) {
		this.indexOfList = indexOfList;
	}

	/**
	 * Set the list of test cases
	 * 
	 * @param testCaseList List<LIst<String>>
	 */
	public void setTestCaseList(List<List<String>> testCaseList) {
		this.testCaseList = testCaseList;
		logger.debug("Total " + testCaseList.size() + " test cases have been added");
	}
	
	/**
	 * Get the list of test cases
	 * 
	 * @return List<List<String>> The list of test cases
	 */
	public List<List<String>> getTestCaseList() {
		return this.testCaseList;
	}
	
	public abstract void run();
}
