Further simplify code
This commit is contained in:
@@ -82,15 +82,16 @@ public:
|
||||
char direction = line[0];
|
||||
int amount = std::stoi(line.substr(1));
|
||||
|
||||
if (direction == 'L') {
|
||||
dial.TurnLeft(amount);
|
||||
switch (direction) {
|
||||
case 'L':
|
||||
dial.TurnLeft(amount);
|
||||
break;
|
||||
case 'R':
|
||||
dial.TurnRight(amount);
|
||||
break;
|
||||
default:
|
||||
assert(false && "Invalid direction");
|
||||
}
|
||||
else if (direction == 'R') {
|
||||
dial.TurnRight(amount);
|
||||
}
|
||||
else {
|
||||
assert(false && "Invalid direction");
|
||||
}
|
||||
|
||||
if (dial.GetPosition() == 0) {
|
||||
password++;
|
||||
@@ -108,14 +109,15 @@ public:
|
||||
char direction = line[0];
|
||||
int amount = std::stoi(line.substr(1));
|
||||
|
||||
if (direction == 'L') {
|
||||
clicksAtZero += dial.TurnLeft(amount);
|
||||
}
|
||||
else if (direction == 'R') {
|
||||
clicksAtZero += dial.TurnRight(amount);
|
||||
}
|
||||
else {
|
||||
assert(false && "Invalid direction");
|
||||
switch (direction) {
|
||||
case 'L':
|
||||
clicksAtZero += dial.TurnLeft(amount);
|
||||
break;
|
||||
case 'R':
|
||||
clicksAtZero += dial.TurnRight(amount);
|
||||
break;
|
||||
default:
|
||||
assert(false && "Invalid direction");
|
||||
}
|
||||
}
|
||||
return std::to_string(clicksAtZero);
|
||||
|
||||
Reference in New Issue
Block a user