Coding
Example Question:
  • Make assumptions
  • If they tell you are taking input from STDIN, start by just taking input from a string.
  • Write example cases as comments, or part of the code execution. This gives discussion points.
  • Explain assumptions about validity of input
  • Create an assert function, which takes in the expected result given an input. See PHP or JS
1
input = "a b c d e";
2
3
main(input) {
4
...
5
}
6
7
assert(expected, input) {
8
console.log(input);
9
actual = main(input);
10
result = expected === actual;
11
console.log(result);
12
if (!result) {
13
console.log(actual);
14
console.log(expected);
15
}
16
}
17
18
// Case 1
19
assert(expected, input);
20
21
// Case 2
22
assert(expected2, input2);
23
24
// Case 3
25
assert(expected3, input3);
Copied!

Copy link
Contents