init
This commit is contained in:
commit
f7443bbab9
30 changed files with 271 additions and 0 deletions
26
dup/dup1.go
Normal file
26
dup/dup1.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Dup1 prints the text of each line that appears more than
|
||||
// once in the standard input, preceeded by its count.
|
||||
|
||||
package main
|
||||
|
||||
import(
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
counts := make(map[string]int)
|
||||
input := bufio.NewScanner(os.Stdin)
|
||||
|
||||
for input.Scan() {
|
||||
counts[input.Text()]++
|
||||
}
|
||||
//NOTE: ingnoring potential errors from input.Err()
|
||||
for line, n := range counts {
|
||||
if n > 1 {
|
||||
fmt.Printf("%d\t%s\n", n , line)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
0
dup/dup1.go~
Normal file
0
dup/dup1.go~
Normal file
Reference in a new issue