webdevRefinery Forum: Scramble with Friends Solver - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

User is online ianonavy 

  • Group: Members
  • Posts: 329
  • Joined: 14-April 10
  • Expertise:HTML,CSS,Java,Javascript,Python

Posted 05 February 2012 - 04:57 PM (#1)

Scramble with Friends Solver


I finished it! If anyone cares to optimize it, here it is:

Minified code:
Spoiler


Full commented code:
Spoiler


Input goes as follows: "scte hral lanb yema" where each space indicates the next line.

It uses
dictionary.txt
(
d
in the minified code). You can download it from that link.

Yes, it's cheating, but it was fun to make. :) I used a prefix tree (tier) built on a dictionary file that was made available by Zynga, and used Depth-First Search to expand to each neighbor after checking the string built so far against the prefix tree. Works pretty fast. :) It's better than my original solution of expanding all nodes and checking each combination against the dictionary.
if (this.post.isHelpful()) {
    reputation++;
} else {
    response.write(constructiveCriticism);
}
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1180
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 05 February 2012 - 05:21 PM (#2)

What, tired of getting your butt kicked :P
"1st plane could've been an accident, 2nd plane was an attack, 3rd plane was an act of war" - George W. Bush
"Poli meaing many, tics meaning blood-sucking butt lumps" - Anonymous
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is online ianonavy 

  • Group: Members
  • Posts: 329
  • Joined: 14-April 10
  • Expertise:HTML,CSS,Java,Javascript,Python

Posted 05 February 2012 - 06:17 PM (#3)

There's absolutely no time between setting up this script and being able to play, so it's not practical for the game itself. xD
if (this.post.isHelpful()) {
    reputation++;
} else {
    response.write(constructiveCriticism);
}
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1180
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 05 February 2012 - 07:10 PM (#4)

View Postianonavy, on 05 February 2012 - 06:17 PM, said:

There's absolutely no time between setting up this script and being able to play, so it's not practical for the game itself. xD

You do know that you can pause the game, right?
"1st plane could've been an accident, 2nd plane was an attack, 3rd plane was an act of war" - George W. Bush
"Poli meaing many, tics meaning blood-sucking butt lumps" - Anonymous
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is online Hyde 

  • Totally Ubermensch
  • Group: Members
  • Posts: 1272
  • Joined: 08-March 10
  • Expertise:HTML,CSS,PHP

Posted 05 February 2012 - 08:06 PM (#5)

Wow! That dictionary.txt is really nice. Thanks for the link.
Hyde | HTML | CSS | PHP & SQL | Basic JavaScript | Objective-C
0


User is online ianonavy 

  • Group: Members
  • Posts: 329
  • Joined: 14-April 10
  • Expertise:HTML,CSS,Java,Javascript,Python

Posted 05 February 2012 - 08:13 PM (#6)

View PostHyde, on 05 February 2012 - 08:06 PM, said:

Wow! That dictionary.txt is really nice. Thanks for the link.

If you're on a Unix-based operating system, you should be able to find a more thorough list of English words in
/usr/share/dict/words
. I used that particular file because it was free of apostrophes and capital letters, and it is the exact file that Zynga uses for its dictionary.
if (this.post.isHelpful()) {
    reputation++;
} else {
    response.write(constructiveCriticism);
}
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services