diff --git a/src/lesson8/task1/Files.kt b/src/lesson8/task1/Files.kt index d7c454e43..6d4f2e9cf 100644 --- a/src/lesson8/task1/Files.kt +++ b/src/lesson8/task1/Files.kt @@ -54,7 +54,13 @@ fun alignFile(inputName: String, lineLength: Int, outputName: String) { * */ fun countSubstrings(inputName: String, substrings: List): Map { - TODO() + val text = File(inputName).readText().toLowerCase() + val substrs = mutableMapOf() + for (substring in substrings) { + val count = (text.length - text.replace(substring.toLowerCase(), "").length) / substring.length + substrs.put(substring, count) + } + return substrs } @@ -64,6 +70,7 @@ fun countSubstrings(inputName: String, substrings: List): Map