Skip to content

Instantly share code, notes, and snippets.

@BNSby
Last active December 12, 2019 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BNSby/15dc8c79c759bb9ac29b24b276e2b999 to your computer and use it in GitHub Desktop.
Save BNSby/15dc8c79c759bb9ac29b24b276e2b999 to your computer and use it in GitHub Desktop.
Изучаем Dart 2019 / ДЗ по функциям
void main() {
List<String> data = ["dart", "abc", "good luck"];
print(wordValue(data));
}
List<int> wordValue(List<String> array) {
List<String> alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
List<int> arr = [];
for (var word in array) {
int i = 0;
word
.split('')
.where((char) => char != ' ')
.toList()
.forEach((char) => i += (alphabet.indexOf(char) + 1));
arr.add((array.indexOf(word) + 1) * i);
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment