name my functions to proper set theory

This commit is contained in:
David 2020-12-06 14:10:21 -05:00
parent 5a9e07c174
commit 708c4a53f9
1 changed files with 5 additions and 5 deletions

View File

@ -12,7 +12,7 @@ func main() {
partTwo()
}
func unique(s string) string {
func union(s string) string {
result := ""
for _, r := range s {
@ -24,7 +24,7 @@ func unique(s string) string {
return result
}
func union(s, q string) string {
func intersection(s, q string) string {
result := ""
for _, r := range s {
@ -56,13 +56,13 @@ func partOne() {
for scanner.Scan() {
line := scanner.Text()
if line == "" {
sum = sum + len(unique(currentForm))
sum = sum + len(union(currentForm))
currentForm = ""
} else {
currentForm = currentForm + line
}
}
sum = sum + len(unique(currentForm))
sum = sum + len(union(currentForm))
fmt.Println(sum)
}
@ -87,7 +87,7 @@ func partTwo() {
newgroup = false
} else {
if line != "" {
currentForm = union(currentForm, line)
currentForm = intersection(currentForm, line)
} else {
sum = sum + len(currentForm)
newgroup = true