Skip to content

Commit

Permalink
Task centerFile from lesson 7 are fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iksburg committed Nov 14, 2020
1 parent e19a602 commit aacc21a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/lesson7/task1/Files.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,11 @@ fun centerFile(inputName: String, outputName: String) {
val writer = File(outputName).bufferedWriter()
var maxLineLength = 0
var stringWithoutSpaces: String
val maxLineCenter: Int
for (line in File(inputName).readLines()) {
stringWithoutSpaces = line.trim()
if (stringWithoutSpaces.length > maxLineLength) maxLineLength = stringWithoutSpaces.length
}
maxLineCenter = when {
val maxLineCenter = when {
maxLineLength % 2 == 0 -> (maxLineLength - 1) / 2
else -> maxLineLength / 2
}
Expand Down

0 comments on commit aacc21a

Please sign in to comment.