Beat My Code is a competition hosted on this web site where programmers have to solve a problem in a specified language in an allotted amount of time. Once the competition is completed, the competitor with the fastest-running code that correctly solves the problem is announced and awarded. Do you think you have what it takes to beat my code?
Discussion boards for Beat My Code are available in the web site's forum.
Beat My Code Problem 1 has begun!
Here's everything that you will need to start things off. If you have any additional questions, contact me .
Are you ready? Set. Go!
Beat My Code Problem 1
"Scrabble Cheater v2.0"
BMC Problem 1 is finally here! I thought I'd start things out fairly easy with a simple extension of one of the projects I have posted in my Projects section, "Scrabble Cheater." This is a pretty open-ended problem; I've only put a few restrictions on how you can solve it. Good luck!
Note: my old solution to the Scrabble Cheater problem may not be the best! I was still a rookie programmer back then... ;-]
Description
You love Scrabble. The only thing you love more than Scrabble? Beating your friends at Scrabble. Being a brilliant programmer, you decide to put your knowledge of the C language to use to design a program that will calculate the highest scoring word(s) possible given the tiles that you currently have and the tiles that are currently on the board.
There will be one word already on the board directly in the center. You must create a word based off of the 7 tiles available to you and the word already on the board. For example, if the word already on the board is DOG, the word you create must contain either a D, O, or G (only one) somewhere in the word. To make this problem a little easier, I will not require you to take Doubles and Triples into consideration. Every space on the board is worth the normal number of points.
Goal
Calculate the highest-scoring Scrabble word(s) in the shortest amount of time possible without crashing or running out of memory.
Scrabble Point Values
A = 1, B = 3, C = 3, D = 2, E = 1, F = 4, G = 2, H = 4, I = 1,
J = 8, K = 5, L = 1, M = 3, N = 1, O = 1, P = 3, Q = 10, R = 1,
S = 1, T = 1, U = 1, V = 4, W = 4, X = 8, Y = 4, Z = 10
Input Files
In order to avoid allowing human error to slow the programs down, the program will use text files entirely for input. The program will use two text files:
dictionary.dict
This file contains all of the words that will be used in the Scrabble Cheater program. It is a very large dictionary file with all of the words capitalized.
1) The first line in the file contains a number n representing the number of words in the file.
2) For the next n lines in the file, the dictionary words will be listed line-by-line in alphabetical order.
Hint: Make sure that the words in the dictionary are valid Scrabble words (no spaces & punctuation).
Example dictionary.dict:
3
HELLO
PROGRAM
WORLD
board.in
This file contains the case(s) that the program will calculate the highest-scoring word(s) for.
1) The first line will contain a number m representing the number of cases there are.
2) The next line will contain a string representing the word that is already on the board for the current case.
3) The next line will contain a 7-letter string representing the tile configuration for the current case.
4) Repeat steps 2-3 (m-1) times
You may assume that all input from this file will be valid.
Example board.in:
2 (number of cases)
COMPUTER (word on board, case 1)
ABCDEFG (tile configuration, case 1)
LOG (word on board, case 2)
QWERTYA (tile configuration, case 2)
Output
For each case, print out the following:
1) The case number
2) The word already on the board
3) The tile configuration
4) The highest-scoring word(s) with point value(s)
Example output:
Case #1
Word: COMPUTER
Tiles: ABCDEFG
Highest-scoring word(s):
Highest-scoring word #1 (x points)
Highest-scoring word #2 (x points)
Case #2
Word: LOG
Tiles: QWERTYA
Highest-scoring word(s):
Highest-scoring word (x points)
Restrictions
At the beginning of your source code, comment it with the following:
/*
Name:
Email address:
Forum name:
Program title: "Scrabble Cheater v2.0"
Date submitted:
*/
1) You may only use the C programming language (NOT C++).
2) The program must compile under cygwin.
3) The program must run on a machine with 2 gigs of RAM.
4) Use white space and comment your code properly.
Other than that, just use standard programming procedures. Don't just put print statements that give the correct answer; I will be using different test cases.
Submitting
When your program is ready to be tested and timed, email the file(s) to me . If that link does not work for you, contact me on the forum and I will provide contact information for you. If your program does not compile or it crashes and there is still time left before the competition is over, I will email you back informing you of this and allow you to resubmit your solution.