catScore function
It returns the number of
commands that are not paint
commands
Returns: The score of the cat.
Implementation
int catScore({
List<String> commands = const <String>[],
bool visible = false,
int interface = 0,
}) {
if (commands.isEmpty) {
return 0;
}
if (commands.first == "None") {
commands.removeAt(0);
}
if (commands.isEmpty) {
return 0;
}
int score = 0;
score += visible ? 0 : 1;
score += interface;
int partScore = 0;
for (final String s in commands) {
int lineScore = 0;
final List<String> tokenized = splitCommand(s.toLowerCase());
switch (tokenized.first) {
case "paint":
lineScore = tokenized.length == 2 ? 4 : 5;
break;
case "fill_empty":
lineScore = 5;
break;
case "copy":
lineScore = 6;
break;
case "mirror":
lineScore = 6;
break;
default:
continue;
}
partScore = lineScore > partScore ? lineScore : partScore;
}
return score + partScore;
}