Add day 6 solution.
This commit is contained in:
parent
b8cd01b914
commit
c8cc6d34ae
3 changed files with 84 additions and 18 deletions
21
2020/lib/util/strings.go
Normal file
21
2020/lib/util/strings.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package util
|
||||
|
||||
// Takes a slice of strings as from reading each line in a file.
|
||||
// Concatenates strings, creating new ones when blank lines are encountered
|
||||
// NB: adds a single space to the beginning of each concatenated line.
|
||||
func SplitOnBlankLine(input []string) []string {
|
||||
converted := []string{}
|
||||
|
||||
current := ""
|
||||
for _, line := range input {
|
||||
if line == "" {
|
||||
converted = append(converted, current)
|
||||
current = ""
|
||||
continue
|
||||
}
|
||||
|
||||
current += " " + line
|
||||
}
|
||||
|
||||
return converted
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue