Rogue_Leader
BAN USERYour variable names aren't meaningful. Meaningful variable names make code more readable.
- Rogue_Leader February 03, 2012The question doesn't specify that.
- Rogue_Leader February 03, 2012"all the numbers between 1 and 100, except for one number that has been removed"
Sort the array then Iterate through, subtracting each element from the previous element, testing the difference. When the difference == 2, return the current minuend-1
This works for arrays of n size.
There are probably more elegant ways to do it, but the problem states a 99-element array which is so small that it renders performance considerations negligible.
I don't think 1. and 2. are handle tests - they belong in the Cup test suite.
Will the handle stay on when the cup is full of water? Sugar? Milk?
I addition, I'd perform usability tests: When the cup is full of hot water, can it be carried by the handle without burning the hand? Can it be carried easily if there are other cups to carry?
Identification of tests which are candidates for automation is a fine art and a dark science. The tests must be ones which are repeatedly required in order to justify the time and expenditure on development of manual tests, and they must have clear inputs and outputs. Unit tests are a good example, but also, for instance, functional tests on an e-commerce website that relate to calculation of price, or are conditional on the display of a predictable, clearly-identified page element. Given these parameters, the decision of whether to include tests for automation is a budgetary, time-related one.
Conversely, look and feel tests, most changes to the UI and cross-platform tests are not usually good candidates for automation.
Here's the implementation in Ruby (and why I love Ruby ):)
- Rogue_Leader February 03, 2012