hi

So i'm doing this project for school but i'm quite literally at a standstill. Let me just briefly tell you what the puzzle is supposed to do, because honestly its really weird.

Its based off of that old game "Drive Ya' Nuts!" (which is a very appropriate name). Basically you have 7 hexagons, with each side being numbered 1 through 6 in any order. You have to assemble it so that each side is touching the side of another hex, with the condition being that the sides of the two hexagons must be of an identical number. Confused? I understand. Here is an image:

http://www.samstoybox.com/toypics/DriveYaNuts2.jpg

Notice the layout, and how the numbers of all the adjacent hexes are matching.

The algorithm is my problem; I cannot for love of all that is sacred, wrap my head around how im going to implement it. The way the program is implemented is that im using a circular linked list to represent each hex (a requirement); this way, i can rotate it very easily. Here is what is working in my program:

-The ability to make hexes

-print the hexes

-rotate the hexes

I know i have to use some sort of recursive method, because i need to be able to backtrack if my sequence of hexes are incorrect and start over. Also each hex can only be used once, so i need a way to somehow know which hexes have already been used. I tried adding all the hexes into an arraylist before passing them through a method; i dont know if thats helpful or not...

Code :

package project3; import java.util.ArrayList; import java.util.Iterator; //circular linked list class Hex { Node head; Hex() { head = null; } public void insert(int n) { Node temp = new Node(n); Node current = head; //if the list is empty, then the new node equal to head if(head == null) { head = temp; head.next = head; System.out.println("hit"); } else { //Starting from head, move through the list until you get to head again while(current.getNext() != head) { current = current.getNext(); } //set the last node's pointer to the new node current.setNext(temp); //set the pointer of the last node back to the first node temp.next = head; } } public Hex rotate() { Hex rotated = new Hex(); Node current = head; do { current = current.getNext(); rotated.insert(current.getElement()); } while(current != head); return rotated; } //Compare public boolean compareCenter(Hex h1, Hex h2) { Node current1 = h1.head; Node current2 = h2.head; Boolean match = false; while(match == false) { if(current1.getElement() == current2.getElement()) { match = true; } else { h2 = h2.rotate(); } } return true; } /*public boolean compareSides(Hex h1, Hex h2) { }*/ //Board public void Board(ArrayList<Hex> hexList, int[] use, int[] order) { } //Assemble public static void Assemble(ArrayList<Hex> hexList) //int[] use, int[]pos) { Iterator<Hex> itr = hexList.iterator(); while(itr.hasNext()) { System.out.println(itr.next()); } } //node class class Node { int element; Node next; Node() { } Node(int element) { this.element = element; next = null; } Node(int element, Node next) { this.element = element; this.next = next; } public int getElement() { return element; } public void setElement(int element) { this.element = element; } public Node getNext() { return next; } public void setNext(Node next) { this.next = next; } } public String toString() { Node current = head; String output = ""; for(int i = 0; i < 6; i++) { output += "[" + current.getElement() + "]"; current = current.getNext(); } return output; } } //MAIN public class Project3 { public static void main(String[] args) { Hex h1 = new Hex(); h1.insert(1); h1.insert(6); h1.insert(4); h1.insert(2); h1.insert(5); h1.insert(3); Hex h2 = new Hex(); h2.insert(1); h2.insert(6); h2.insert(5); h2.insert(4); h2.insert(3); h2.insert(2); Hex h3 = new Hex(); h3.insert(1); h3.insert(4); h3.insert(6); h3.insert(2); h3.insert(3); h3.insert(5); Hex h4 = new Hex(); h4.insert(1); h4.insert(6); h4.insert(5); h4.insert(3); h4.insert(2); h4.insert(4); Hex h5 = new Hex(); h5.insert(1); h5.insert(4); h5.insert(3); h5.insert(6); h5.insert(5); h5.insert(2); Hex h6 = new Hex(); h6.insert(1); h6.insert(2); h6.insert(3); h6.insert(4); h6.insert(6); h6.insert(6); Hex h7 = new Hex(); h7.insert(1); h7.insert(6); h7.insert(2); h7.insert(4); h7.insert(5); h7.insert(3); ArrayList<Hex> hexList = new ArrayList<Hex>(); hexList.add(h1); hexList.add(h2); hexList.add(h3); hexList.add(h4); hexList.add(h5); hexList.add(h6); hexList.add(h7); //System.out.println(hexList); Hex.Assemble(hexList); int[] useArray = new int[6]; int[] posArray = new int[6]; for(int i = 0; i < 6; i++) { useArray[i] = 0; posArray[i] = 0; } /*for(int i = 0; i < 6; i++) { System.out.print(useArray[i]); System.out.print(posArray[i]); }*/ //System.out.println(h1); /* h1 = h1.rotate(); System.out.println(h1); h1 = h1.rotate(); System.out.println(h1);*/ } }

Honestly, i would never ask such an broad and seemingly general question, but frankly im desperate at this point. I've spent this whole day just trying to make methods that will perform the operation but none of them have taken me far. I'm not asking for someone to program this for me, but i'm sure there are people out there with more experience who can at least guide me or even through out some ideas for me to try. (my face looks exactly like my icon right now)

Anyone? Thanks in advance