Last active
December 12, 2019 22:37
-
-
Save BNSby/15dc8c79c759bb9ac29b24b276e2b999 to your computer and use it in GitHub Desktop.
Изучаем Dart 2019 / ДЗ по функциям
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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