Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- http://forums.scar-divi.com/other-scripts/2613-todays-coding-exercise-1-1-2014-a.html
- By Want3d
- }
- program WordPuzzleSolver;
- const
- DictionaryPath = 'C:\Users\James\Documents\SCAR Divi\English\wordsEn.txt';
- type
- TDecagonLetterWheel = record
- Letters: TStringArray;
- Points: TIntegerArray;
- end;
- var
- Wheels: array[0..7] of TDecagonLetterWheel;
- Dictionary: string;
- // I thought about putting the points in a seperate array, but then I figured
- // it would probably be faster to do direct memory reference
- procedure DeclareWheels; // Define Wheels with letters and points
- begin
- Wheels[0].Letters := ['O', 'Y', 'W', 'I', 'E', 'N', 'A', 'S', 'U', 'X'];
- Wheels[0].Points := [ 0, 4, 6, 0, 0, 2, 0, 2, 0, 6];
- Wheels[1].Letters := ['I', 'B', 'E', 'H', 'O', 'C', 'A', 'T', 'U', 'D'];
- Wheels[1].Points := [ 0, 2, 0, 4, 0, 2, 0, 2, 0, 4];
- Wheels[2].Letters := ['I', 'L', 'E', 'M', 'O', 'F', 'U', 'Z', 'A', 'N'];
- Wheels[2].Points := [ 0, 2, 0, 4, 0, 2, 0, 8, 0, 2];
- Wheels[3].Letters := ['E', 'D', 'O', 'H', 'U', 'S', 'I', 'R', 'A', 'P'];
- Wheels[3].Points := [ 0, 4, 0, 4, 0, 2, 0, 2, 0, 4];
- Wheels[4].Letters := ['E', 'N', 'K', 'A', 'F', 'B', 'O', 'L', 'I', 'R'];
- Wheels[4].Points := [ 0, 2, 8, 0, 2, 2, 0, 2, 0, 2];
- Wheels[5].Letters := ['T', 'Q', 'I', 'D', 'W', 'A', 'V', 'J', 'E', 'R'];
- Wheels[5].Points := [ 2, 8, 0, 4, 6, 0, 6, 6, 0, 2];
- Wheels[6].Letters := ['E', 'P', 'G', 'S', 'L', 'A', 'V', 'N', 'T', 'W'];
- Wheels[6].Points := [ 0, 4, 2, 2, 2, 0, 6, 2, 2, 6];
- Wheels[7].Letters := ['E', 'N', 'T', 'M', 'G', 'U', 'C', 'R', 'O', 'Y'];
- Wheels[7].Points := [ 0, 2, 2, 4, 2, 0, 2, 2, 0, 4];
- end;
- procedure LoadDictionary;
- var
- DictionaryFile: LongInt;
- FailedLoad: Boolean;
- begin
- DictionaryFile := OpenFile(DictionaryPath, False);
- FailedLoad := False;
- if (not (ReadFileString(DictionaryFile, Dictionary, FileSize(DictionaryFile)))) then
- begin
- WriteLn('Failed To Load Dictionary');
- FailedLoad := True;
- end;
- CloseFile(DictionaryFile);
- if (FailedLoad) then
- TerminateScript;
- end;
- function CheckWordOnToy(Word: string): Integer; // See if that word is possible to fit on toy and how many points its worth
- var
- StartingWheel: Integer;
- begin
- for StartingWheel := 0 to 7 do
- begin
- end;
- Result := 0;
- end;
- procedure MainLoop; // To avoid extra global variables
- var
- T: LongInt;
- begin
- T := GetSystemTime;
- LoadDictionary;
- WriteLn('Dictionary loaded (' + IntToStr(GetSystemTime - T) + ' ms)');
- T := GetSystemTime;
- DeclareWheels;
- WriteLn('Wheels declared (' + IntToStr(GetSystemTime - T) + ' ms)');
- WriteLn(Dictionary);
- end;
- begin
- MainLoop;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement