Programming

Sudoku Solver in Java

SudokuSolver

This is a Sudoku solver that uses arc consistency and domain splitting. Also able to tell if a board has no or many solutions.

Download SudokuSolver

Deterministic Linear Time k-Select Algorithm

Code

This is an implementation of linear time selection by Blum, Floyd, Pratt, Rivest, and Tarjon in Java.

Pseudocode:

BSelect(A,k):
    If |A| == 1 return A[1]
    p = GoodPivot(A)
    S = { A[i] | A[i] < p }
    L = { A[i] | A[i] > p }
    If |S| >= k return BSelect(S,k)
    else if |S| == k-1 return p
    else return BSelect(L, k-|S|-1)

GoodPivot(A):
    Divide A into n/5 groups of 5 elements each
    Find the median of each group
    Use BSelect to find the median, p, of the n/5 medians
    Return p

View implementation


Conway’s Game of Life in C++

gameoflife

A (rather crude) version of the Game of Life written in C++. You’ll need to compile it.

View the Source

Basic Compilation of a C++ Program

compile

If you are using Mac OSX or Linux, go to the folder where your cpp file is located in the terminal. On windows, you will need to install g++.

Assuming your source file is called main.app, and you want your output file to be called “hellos” then type the following:

g++ -o hellos main.cpp

To run it:

./hellos

Note: It is possible to compile the program without specifying the output file name but it will default to “a.out”:

g++ main.cpp

Additional compiler options can be found here.

From Java to C++: Similarities and Differences

After some fiddling with XCode and C++, I finally got it compiling my Hello World. To my pleasure, the syntax in C++ is somewhat similar with Java, but there are still many differences.

Read the rest of this entry »

Quizzicle: A Java Math Quiz Generator

quizzicle

Here is a quick Java application I whipped up. Quizzicle is a command line application that generates random math equations. You can choose an arithmetic operation, the number of questions, the number of digits in the question, and if negative numbers or zeros are allowed. Javadoc included.

quizzicle-optionsUpdate 1.1:

  • Adds a Timer
  • Adds Logging (writing to a file)
  • Various other minor features

I did not plan to release this one so you may see a few hacks.

Download Quizzicle 1.1

Installing the Eclipse IDE

eclipse-ganymede

This guide will show beginner programmers how to set up and install JDK and the Eclipse IDE. I will be installing JDK 6 Update 7 and Eclipse 3.4.0 Ganymede.

Read the rest of this entry »