2 Replies - 293 Views - Last Post: 26 October 2019 - 08:42 AM Rate Topic: -----

#1 crosswordhelp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-October 19

How can I optimize this code (Crossword Array) so that I don't hav

Posted 26 October 2019 - 01:37 AM

Code below. I can post more if needed, this is just the array list file.

I basically want an array where the puzzle is automatically generated from a list of however many words. Ideas?

public static crossword getCrossword1() {
		
		ArrayList<clue> cluesAcross = new ArrayList<clue>();
		ArrayList<clue> cluesDown = new ArrayList<clue>();

		cluesAcross.add(new clue(1, 1, 0, "Eager Involvement", "enthusiasm"));
		cluesAcross.add(new clue(8, 0, 2, "RAM memory that set aside as a specialized buffer storage", "CACHE"));
		cluesAcross.add(new clue(9, 6, 2, "Take as one's own", "adopt"));
		cluesAcross.add(new clue(10, 0, 4, "Ball game", "golf"));
		cluesAcross.add(new clue(12, 5, 4, "Guard", "sentry"));
		cluesAcross.add(new clue(14, 0, 6, "2D Array of Brightness Values", "BITMAP"));
		cluesAcross.add(new clue(17, 7, 6, "Fruit", "plum"));
		cluesAcross.add(new clue(21, 0, 8, "In addition", "extra"));
		cluesAcross.add(new clue(22, 6, 8, "Boundary", "limit"));
		cluesAcross.add(new clue(23, 0, 10, "Executives", "management"));

		cluesDown.add(new clue(2, 2, 0, "Pertaining to warships", "naval"));
		cluesDown.add(new clue(3, 4, 0, "Solid", "hard"));
		cluesDown.add(new clue(4, 6, 0, "Apportion", "share"));
		cluesDown.add(new clue(5, 8, 0, "Concerning", "about"));
		cluesDown.add(new clue(6, 10, 0, "Friendly", "matey"));
		cluesDown.add(new clue(7, 0, 1, "Boast", "brag"));
		cluesDown.add(new clue(11, 3, 4, "Enemy", "foe"));
		cluesDown.add(new clue(13, 7, 4, "Doze", "nap"));
		cluesDown.add(new clue(14, 0, 6, "Water vapour", "steam"));
		cluesDown.add(new clue(15, 2, 6, "Consumed", "eaten"));
		cluesDown.add(new clue(16, 4, 6, "Loud, resonant sound", "clang"));
		cluesDown.add(new clue(18, 8, 6, "Yellowish, citrus fruit", "lemon"));
		cluesDown.add(new clue(19, 10, 6, "Mongrel dog", "mutt"));
		cluesDown.add(new clue(20, 6, 7, "Shut with force", "slam"));

		return new crossword("EXAMPLE (COMP SCI VOCAB)", 24, cluesAcross, cluesDown);
		
	}

	public static crossword getCrossword2() {
		
		ArrayList<clue> cluesAcross = new ArrayList<clue>();
		ArrayList<clue> cluesDown = new ArrayList<clue>();

		cluesAcross.add(new clue(1, 1, 0, "Showy", "OSTENTATIOUS"));
		cluesAcross.add(new clue(9, 0, 2, "Carrying weapons", "ARMED"));
		cluesAcross.add(new clue(10, 6, 2, "Cocaine (anag)", "OCEANIC"));
		cluesAcross.add(new clue(11, 0, 4, "Dull continuous pain", "ACHE"));
		cluesAcross.add(new clue(12, 5, 4, "Under an obligation", "BEHOLDEN"));
		cluesAcross.add(new clue(14, 0, 6, "Cheap and showy", "TAWDRY"));
		cluesAcross.add(new clue(15, 7, 6, "Bewail", "LAMENT"));
		cluesAcross.add(new clue(18, 0, 8, "Contrary", "OPPOSITE"));
		cluesAcross.add(new clue(20, 9, 8, "Sign of things to come", "OMEN"));
		cluesAcross.add(new clue(22, 0, 10, "Impetuous person", "HOTHEAD"));
		cluesAcross.add(new clue(23, 8, 10, "Norwegian dramatist", "IBSEN"));
		cluesAcross.add(new clue(24, 0, 12, "Rebuff", "COLD-SHOULDER"));

		cluesDown.add(new clue(2, 2, 0, "One way or another", "SOMEHOW"));
		cluesDown.add(new clue(3, 4, 0, "Swirling current", "EDDY"));
		cluesDown.add(new clue(4, 6, 0, "Gardener's tool", "TROWEL"));
		cluesDown.add(new clue(5, 8, 0, "Sacred writings of Islam", "THE KORAN"));
		cluesDown.add(new clue(6, 10, 0, "Possessed", "OWNED"));
		cluesDown.add(new clue(7, 12, 0, "Best", "SECOND TO NONE"));
		cluesDown.add(new clue(8, 0, 1, "Disastrous", "CATASTROPHIC"));
		cluesDown.add(new clue(13, 4, 5, "European Commission HQ", "BRUSSELS"));
		cluesDown.add(new clue(16, 10, 6, "All together", "EN MASSE"));
		cluesDown.add(new clue(17, 6, 7, "Artist's workroom", "STUDIO"));
		cluesDown.add(new clue(19, 2, 8, "Part of a flower ", "PETAL"));
		cluesDown.add(new clue(21, 8, 9, "English philosopher and economist, d. 1873", "MILL"));

		return new crossword("Guardian 13,019", 13, cluesAcross, cluesDown);
		
	}


Is This A Good Question/Topic? 0
  • +

Replies To: How can I optimize this code (Crossword Array) so that I don't hav

#2 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 6,062
  • Joined: 25-December 13

Re: How can I optimize this code (Crossword Array) so that I don't hav

Posted 26 October 2019 - 05:06 AM

One change would be to create a file with the data that is read, parsed and used to create the puzzle, instead of hardcoding it in the program.
Was This Post Helpful? 0
  • +
  • -

#3 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3648
  • View blog
  • Posts: 16,768
  • Joined: 20-September 08

Re: How can I optimize this code (Crossword Array) so that I don't hav

Posted 26 October 2019 - 08:42 AM

Have a look at https://www.theguard...s/cryptic/27961 for inspiration. This is essentially a Java applet. You could even reverse engineer it
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1