Tip: if you are printing the output, add the '\n' after every output.
I tried solving it in two ways:
1. Taking the numbers into char arrays:
The char array solution was difficult to code because I reversed each array, started to iterate until the array with min length, then traverse until the end of the longer array to get to the final answer. I made a number of mistakes here:
* Instead of iterating over revNum1, I iterated of num1
* The minLen was using the length of the larger array (mainly due to copy paste)
* I had to construct quite a few testcases to assure myself of the correctness
2. Taking the numbers as numbers:
This was simpler to code and I knew that I had the correct answer without crossing my fingers unlike the previous option. Keeping the implementation simpler assures you of the 'Accepted' state and you know that a 'WA' in this case means that something is wrong in the output format and not your code :-)
Solved yet another UVA problem: Wetlands of Florida. Feels good. One odd thing in this problem was handling the input. In the solution, I initially went with the recursive DFS which failed on my test case containing a 99x99 'W' wetlands map. I changed to follow one of the good implementations of Chefhack by msasha. Some implementations are so very user friendly than machine friendly.
Many thanks to the codechef CHEFHACK editorial to list this problem.
Email excerpt from the online judge: "Your submission with number 11309634 for the problem 469 - Wetlands of Florida has succeeded with verdict Accepted."
This link from CodeChef is the editorial for CHEFHACK. It had the link to another similar problem in UVA which is Seasonal War. I started to solve the problem and had just one thing that sounded unclear to me: "Cells with adjacent sides on common vertices, which contain binary
ones, comprise one war
eagle. A very large image of one war eagle might contain all ones." Looking at the sample cases it became clear. Coded the changes, created my own test cases and seeing that all was well, I submitted the solution. This is what the judge told: "Your submission with number 11293947 for the problem 352 - The Seasonal War has succeeded with verdict Accepted."
I was able to solve Different and Reverse binary in one attempt. Then, I started to code for Coastal length and found some interesting cases to solve. Need to find the right algorithm for this problem.