Skip to content

Instantly share code, notes, and snippets.

@lordvidex
Last active March 26, 2020 17:07
Show Gist options
  • Save lordvidex/ee7efd89b63f29aa9f2ded3cd1c1eac7 to your computer and use it in GitHub Desktop.
Save lordvidex/ee7efd89b63f29aa9f2ded3cd1c1eac7 to your computer and use it in GitHub Desktop.
Evans Owamoyo:: Day 0 track 1
import 'dart:io';
Map<String,int> band = const {
'black':0,
'brown':1,
'red':2,
'orange':3,
'yellow':4,
'green':5,
'blue':6,
'violet':7,
'grey':8,
'white':9,
};
int calculate(String color) {
return band[color.toLowerCase()];
}
void main() {
String input;
try{
input = stdin.readLineSync(); //If run on console
}catch(e){
//Color entered manually
input = 'Yellow';
}
print('Band code: ${calculate(input.toLowerCase())}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment