Sha256: 4b6bf57a1527c8e58a3fc28179e400de1efc91aea4c0f90290c3910037974f2f

Contents?: true

Size: 1.17 KB

Versions: 255

Compression:

Stored size: 1.17 KB

Contents

package twelve

import (
	"fmt"
)

const testVersion = 1

var verse = map[string]string{
	"first":    "a Partridge in a Pear Tree.",
	"twelfth":  "twelve Drummers Drumming",
	"eleventh": "eleven Pipers Piping",
	"tenth":    "ten Lords-a-Leaping",
	"ninth":    "nine Ladies Dancing",
	"eighth":   "eight Maids-a-Milking",
	"seventh":  "seven Swans-a-Swimming",
	"sixth":    "six Geese-a-Laying",
	"fifth":    "five Gold Rings",
	"fourth":   "four Calling Birds",
	"third":    "three French Hens",
	"second":   "two Turtle Doves",
}

var wording = map[int]string{
	1:  "first",
	2:  "second",
	3:  "third",
	4:  "fourth",
	5:  "fifth",
	6:  "sixth",
	7:  "seventh",
	8:  "eighth",
	9:  "ninth",
	10: "tenth",
	11: "eleventh",
	12: "twelfth",
}

func Verse(i int) string {
	var gifts = ""
	for from := i; from > 0; from-- {
		if i != 1 && from == 1 {
			gifts = fmt.Sprintf("%s, and %s", gifts, verse[wording[from]])
		} else {
			gifts = fmt.Sprintf("%s, %s", gifts, verse[wording[from]])
		}
	}
	return fmt.Sprintf("On the %s day of Christmas my true love gave to me%s", wording[i], gifts)
}

func Song() string {
	var song = ""
	for i := 1; i <= 12; i++ {
		song += Verse(i) + "\n"
	}
	return song
}

Version data entries

255 entries across 255 versions & 1 rubygems

Version Path
trackler-2.2.1.56 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.55 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.54 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.53 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.52 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.51 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.50 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.49 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.48 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.47 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.46 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.45 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.44 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.43 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.42 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.41 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.40 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.39 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.38 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.37 tracks/go/exercises/twelve-days/example.go