Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. {
  2.  
  3. http://forums.scar-divi.com/other-scripts/2613-todays-coding-exercise-1-1-2014-a.html
  4.  
  5. By Want3d
  6. }
  7.  
  8. program WordPuzzleSolver;
  9.  
  10. const
  11. DictionaryPath = 'C:\Users\James\Documents\SCAR Divi\English\wordsEn.txt';
  12.  
  13. type
  14. TDecagonLetterWheel = record
  15. Letters: TStringArray;
  16. Points: TIntegerArray;
  17. end;
  18.  
  19. var
  20. Wheels: array[0..7] of TDecagonLetterWheel;
  21. Dictionary: string;
  22.  
  23. // I thought about putting the points in a seperate array, but then I figured
  24. // it would probably be faster to do direct memory reference
  25.  
  26. procedure DeclareWheels; // Define Wheels with letters and points
  27. begin
  28. Wheels[0].Letters := ['O', 'Y', 'W', 'I', 'E', 'N', 'A', 'S', 'U', 'X'];
  29. Wheels[0].Points := [ 0, 4, 6, 0, 0, 2, 0, 2, 0, 6];
  30. Wheels[1].Letters := ['I', 'B', 'E', 'H', 'O', 'C', 'A', 'T', 'U', 'D'];
  31. Wheels[1].Points := [ 0, 2, 0, 4, 0, 2, 0, 2, 0, 4];
  32. Wheels[2].Letters := ['I', 'L', 'E', 'M', 'O', 'F', 'U', 'Z', 'A', 'N'];
  33. Wheels[2].Points := [ 0, 2, 0, 4, 0, 2, 0, 8, 0, 2];
  34. Wheels[3].Letters := ['E', 'D', 'O', 'H', 'U', 'S', 'I', 'R', 'A', 'P'];
  35. Wheels[3].Points := [ 0, 4, 0, 4, 0, 2, 0, 2, 0, 4];
  36. Wheels[4].Letters := ['E', 'N', 'K', 'A', 'F', 'B', 'O', 'L', 'I', 'R'];
  37. Wheels[4].Points := [ 0, 2, 8, 0, 2, 2, 0, 2, 0, 2];
  38. Wheels[5].Letters := ['T', 'Q', 'I', 'D', 'W', 'A', 'V', 'J', 'E', 'R'];
  39. Wheels[5].Points := [ 2, 8, 0, 4, 6, 0, 6, 6, 0, 2];
  40. Wheels[6].Letters := ['E', 'P', 'G', 'S', 'L', 'A', 'V', 'N', 'T', 'W'];
  41. Wheels[6].Points := [ 0, 4, 2, 2, 2, 0, 6, 2, 2, 6];
  42. Wheels[7].Letters := ['E', 'N', 'T', 'M', 'G', 'U', 'C', 'R', 'O', 'Y'];
  43. Wheels[7].Points := [ 0, 2, 2, 4, 2, 0, 2, 2, 0, 4];
  44. end;
  45.  
  46. procedure LoadDictionary;
  47. var
  48. DictionaryFile: LongInt;
  49. FailedLoad: Boolean;
  50. begin
  51. DictionaryFile := OpenFile(DictionaryPath, False);
  52. FailedLoad := False;
  53. if (not (ReadFileString(DictionaryFile, Dictionary, FileSize(DictionaryFile)))) then
  54. begin
  55. WriteLn('Failed To Load Dictionary');
  56. FailedLoad := True;
  57. end;
  58. CloseFile(DictionaryFile);
  59. if (FailedLoad) then
  60. TerminateScript;
  61. end;
  62.  
  63. function CheckWordOnToy(Word: string): Integer; // See if that word is possible to fit on toy and how many points its worth
  64. var
  65. StartingWheel: Integer;
  66. begin
  67. for StartingWheel := 0 to 7 do
  68. begin
  69.  
  70. end;
  71. Result := 0;
  72. end;
  73.  
  74. procedure MainLoop; // To avoid extra global variables
  75. var
  76. T: LongInt;
  77. begin
  78. T := GetSystemTime;
  79. LoadDictionary;
  80. WriteLn('Dictionary loaded (' + IntToStr(GetSystemTime - T) + ' ms)');
  81. T := GetSystemTime;
  82. DeclareWheels;
  83. WriteLn('Wheels declared (' + IntToStr(GetSystemTime - T) + ' ms)');
  84. WriteLn(Dictionary);
  85. end;
  86.  
  87. begin
  88. MainLoop;
  89. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement