yea not really, as you can see I have already made it so it can find the size and searchfor functions, the problem is when reading into puzzle line I'm dragging those in as well.
This is driving me crazy...
To make this even more complicated,
if the input file should give me a size, then a puzzle, then another size, puzzle and search, the first puzzle needs to be disregarded and appropriate error message.
Even if I add some check like, if string[0]==s, and string[1]==i || string[1]==e, and string[2]==z || string[2]==a, and string[3]==e || string[3]==r, and string[4]=='=' || string[4]==c, and string[5]==h, and string[6]==f, and string[7]==o, and string[8]==r, and string[9]=='='
boolean variables can check if I have gotSize, and gotWord, and gotPuzzle. The thing I'm not entirely sure is how do I check, or know once I have reached the end of puzzle input. How/When do I set gotPuzzle?
this would be so much easier if I could put the find into a conditional:
1 2 3 4 5 6 7
|
if (line[0]=='#'||line=="")
...
else if (line.find("size=")
...
else if (line.find("searchfor=")
...
else // line is puzzle line...
|
I have boundries for the size, so maybe I need to add a counter for the puzzle line to only process n lines. But that still brings me back to my previous problem how to distinguish between size=, searchfor= and a puzzle line.
edit: keep in mind the word "size" or "search" may also be used a keyword search so just looking for those it maybe that I completely disregard huge chunks of the puzzle.