jmjatlanta's blog

By jmjatlanta, history, 2 months ago, In English

I am still working on questions with low ranking ( < 1200 ). My submissions are far from perfect. The primary defect now is thinking of edge cases. In an attempt to be efficient, I make sure the code makes sense and the example test case passes. But I fail to think of many obvious cases that fail. For instance:

We are trying to cover a rectangular area with square tiles that cannot be cut but can extend beyond the borders. The math is easy, but there are many edge cases you have to think about.

  • We will be multiplying. Can the size of the variable handle the new number?
  • What if one of the numbers is a 1?
  • Can any of the numbers be a zero?
  • What if the size of 1 tile is smaller than the area to be covered?

I must learn to think about all the different combinations of input. I must also learn to take time and walk through the code with such test cases, and assure the answer is correct.

Read more »

  • Vote: I like it
  • -2
  • Vote: I do not like it

By jmjatlanta, history, 3 months ago, In English
  • clang++ uses the main return value as the exit value. Always set it to 0. Doh!
  • Initialize variables (always a good habit). clang++ doesn't always do that for you. (Isn't that part of the standard? I guess not.)
  • Read the description carefully. Make sure you are doing what they are asking (position != score)
  • It is very possible that the example inputs pass, but the logic is wrong. Make sure your results are the answer to what is being asked. Just because the results are as expected does not mean you are done (What are the chances? Better than you think!).

Most of those items are obvious, but these are the things that make the scores non-competitive. And fixing them are easier said than done. I attempt to complete the task rapidly instead of accurately, and that is a mistake. I will continue with the 800's until I improve in those areas.

Read more »

  • Vote: I like it
  • +13
  • Vote: I do not like it