Sha256: 9b9149abef2c8824ae73863085694e1f4b316539ebbe4f861fbca68a5eb71bea

Contents?: true

Size: 477 Bytes

Versions: 396

Compression:

Stored size: 477 Bytes

Contents

package counter

import "unicode"

// Incorrect implementation: wrongly counts lines.
type Impl1 struct {
	lines, characters, letters int
}

func (c *Impl1) AddString(s string) {
	for _, char := range s {
		if char == '\n' {
			c.lines++
		} else if unicode.IsLetter(char) {
			c.letters++
		}
		c.characters++
	}
}

func (c Impl1) Lines() int      { return c.lines }
func (c Impl1) Letters() int    { return c.letters }
func (c Impl1) Characters() int { return c.characters }

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.118 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.117 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.116 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.115 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.114 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.113 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.111 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.110 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.109 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.108 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.107 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.106 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.105 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.104 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.103 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.102 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.101 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.100 tracks/go/exercises/counter/impl1.go
trackler-2.2.1.99 tracks/go/exercises/counter/impl1.go