Added:
trunk/Facebook_puzzles/.classpath
trunk/Facebook_puzzles/.project
trunk/Facebook_puzzles/.settings/
trunk/Facebook_puzzles/.settings/org.eclipse.jdt.core.prefs
trunk/Facebook_puzzles/data/
trunk/Facebook_puzzles/data/5x5.txt
trunk/Facebook_puzzles/data/testMatrix.txt
trunk/Facebook_puzzles/docs/
trunk/Facebook_puzzles/src/
trunk/Facebook_puzzles/src/net/
trunk/Facebook_puzzles/src/net/ddaniels/
trunk/Facebook_puzzles/src/net/ddaniels/facebook/
trunk/Facebook_puzzles/src/net/ddaniels/facebook/puzzles/
trunk/Facebook_puzzles/src/net/ddaniels/facebook/puzzles/GridFlip.java
trunk/Facebook_puzzles/src/net/ddaniels/facebook/puzzles/Matrix.java
trunk/Facebook_puzzles/test/
trunk/Facebook_puzzles/test/net/
trunk/Facebook_puzzles/test/net/ddaniels/
trunk/Facebook_puzzles/test/net/ddaniels/facebook/
trunk/Facebook_puzzles/test/net/ddaniels/facebook/puzzles/
trunk/Facebook_puzzles/test/net/ddaniels/facebook/puzzles/TestGridFlip.java
Log:
Initial import.
Added: trunk/Facebook_puzzles/.classpath
==============================================================================
--- (empty file)
+++ trunk/Facebook_puzzles/.classpath Sun Feb 24 22:14:48 2008
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/Facebook_puzzles/.project
==============================================================================
--- (empty file)
+++ trunk/Facebook_puzzles/.project Sun Feb 24 22:14:48 2008
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Facebook_puzzles</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/Facebook_puzzles/.settings/org.eclipse.jdt.core.prefs
==============================================================================
--- (empty file)
+++ trunk/Facebook_puzzles/.settings/org.eclipse.jdt.core.prefs Sun Feb
24 22:14:48 2008
@@ -0,0 +1,12 @@
+#Fri Feb 22 19:54:42 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/Facebook_puzzles/data/5x5.txt
==============================================================================
--- (empty file)
+++ trunk/Facebook_puzzles/data/5x5.txt Sun Feb 24 22:14:48 2008
@@ -0,0 +1,5 @@
+ 3 1 -5 -3 4
+ 4 -5 -2 -3 -3
+ 6 -8 -2 -6 1
+ 3 4 1 -4 -8
+ 1 4 -2 7 -1
\ No newline at end of file
Added: trunk/Facebook_puzzles/data/testMatrix.txt
==============================================================================
--- (empty file)
+++ trunk/Facebook_puzzles/data/testMatrix.txt Sun Feb 24 22:14:48 2008
@@ -0,0 +1,27 @@
+ 33 30 10 -6 18 -7 -11 23 -6
+ 16 -19 9 -26 -8 -19 -8 -21 -14
+ 17 12 -14 31 -30 13 -13 19 16
+ -6 -11 1 17 -12 -4 -7 14 -21
+ 18 -31 34 -22 17 -19 20 24 6
+ 33 -18 17 -15 31 -5 3 27 -3
+ -18 -20 -18 31 6 4 -2 -12 24
+ 27 14 4 -29 -3 5 -29 8 -12
+ -15 -7 -23 23 -9 -8 6 8 -12
+ 33 -23 -19 -4 -8 -7 11 -12 31
+ -20 19 -15 -30 11 32 7 14 -5
+ -23 18 -32 -2 -31 -7 8 24 16
+ 32 -4 -10 -14 -6 -1 0 23 23
+ 25 0 -23 22 12 28 -27 15 4
+ -30 -13 -16 -3 -3 -32 -3 27 -31
+ 22 1 26 4 -2 -13 26 17 14
+ -9 -18 3 -20 -27 -32 -11 27 13
+ -17 33 -7 19 -32 13 -31 -2 -24
+ -31 27 -31 -29 15 2 29 -15 33
+ -18 -23 15 28 0 30 -4 12 -32
+ -3 34 27 -25 -18 26 1 34 26
+ -21 -31 -10 -13 -30 -17 -12 -26 31
+ 23 -31 -19 21 -17 -10 2 -23 23
+ -3 6 0 -3 -32 0 -10 -25 14
+ -19 9 14 -27 20 15 -5 -27 18
+ 11 -6 24 7 -17 26 20 -31 -25
+ -25 4 -16 30 33 23 -4 -4 23
\ No newline at end of file
Added: trunk/Facebook_puzzles/src/net/ddaniels/facebook/puzzles/GridFlip.java
==============================================================================
--- (empty file)
+++
trunk/Facebook_puzzles/src/net/ddaniels/facebook/puzzles/GridFlip.java
Sun Feb 24 22:14:48 2008
@@ -0,0 +1,5 @@
+package net.ddaniels.facebook.puzzles;
+
+public class GridFlip {
+
+}
Added: trunk/Facebook_puzzles/src/net/ddaniels/facebook/puzzles/Matrix.java
==============================================================================
--- (empty file)
+++
trunk/Facebook_puzzles/src/net/ddaniels/facebook/puzzles/Matrix.java
Sun Feb 24 22:14:48 2008
@@ -0,0 +1,90 @@
+package net.ddaniels.facebook.puzzles;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+public class Matrix {
+
+ private int[][] matrix;
+
+ public Matrix(int n, int m) {
+ //Construct a blank n x m matrix with blank entries
+ matrix = new int[n][m];
+ }
+ public int getColCount() {
+ //Number of column elements in the first row
+ return matrix[0].length;
+ }
+ public int getRowCount() {
+ //Number of row elements in the matrix
+ return matrix.length;
+ }
+ public int get(int row, int col) {
+ return matrix[row][col];
+ }
+ /**
+ * Sets the specified (row,col) entry to the value.
+ * @param row
+ * @param col
+ * @param val
+ */
+ public void set(int row, int col, int val) {
+ matrix[row][col] = val;
+ }
+
+ public String toString() {
+ StringBuffer buff = new StringBuffer();
+ for(int i=0; i<matrix.length; i++) {
+ for(int j=0; j<matrix[i].length; j++) {
+ buff.append(matrix[i][j] + " ");
+ }
+ buff.append("\n");
+ }
+ return buff.toString();
+ }
+
+ public static Matrix fromFile(String fileName) {
+ Matrix matrix = null;
+ int m;
+ int n;
+
+ ArrayList<String> fileContents = new ArrayList<String>();
+
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(fileName));
+ String str;
+ while ((str = in.readLine()) != null) {
+ // Don't count any blank lines
+ if(!str.trim().equals("")) {
+ fileContents.add(str);
+ }
+ }
+ in.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ StringTokenizer stokenizer = new StringTokenizer(fileContents.get(0));
+ //Number of rows
+ m = fileContents.size();
+ //Number of columns
+ n = stokenizer.countTokens();
+ matrix = new Matrix(m,n);
+ for(int i=0; i<fileContents.size(); i++) {
+ stokenizer = new StringTokenizer(fileContents.get(i));
+ int j = 0;
+ while(stokenizer.hasMoreTokens()) {
+ String token = stokenizer.nextToken();
+ int val = Integer.parseInt(token);
+ //Set the value for the row==i, column==j
+ matrix.set(i, j, val);
+ j++;
+ }
+ }
+
+ return matrix;
+ }
+}
Added: trunk/Facebook_puzzles/test/net/ddaniels/facebook/puzzles/TestGridFlip.java
==============================================================================
--- (empty file)
+++
trunk/Facebook_puzzles/test/net/ddaniels/facebook/puzzles/TestGridFlip.java
Sun Feb 24 22:14:48 2008
@@ -0,0 +1,31 @@
+package net.ddaniels.facebook.puzzles;
+
+import java.util.logging.Logger;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestGridFlip {
+
+ private Logger logger = Logger.getLogger(TestGridFlip.class.getName());
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testMatrixFromFile() {
+ Matrix m = Matrix.fromFile("data/testMatrix.txt");
+ logger.info("testMatrixFromFile output: (n x
m)==("+m.getRowCount()+" x "+m.getColCount()+")\n" + m.toString());
+ }
+
+ @Test
+ public void test5x5MatrixFromFile() {
+ Matrix m = Matrix.fromFile("data/5x5.txt");
+ logger.info("5x5 file output: (n x m)==("+m.getRowCount()+"
x "+m.getColCount()+")\n" + m.toString());
+ }
+}