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.16 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.15 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.14 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.13 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.12 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.11 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.10 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.9 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.8 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.7 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.6 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.5 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.4 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.3 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.2 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.1 tracks/go/exercises/twelve-days/example.go
trackler-2.2.1.0 tracks/go/exercises/twelve-days/example.go
trackler-2.2.0.6 tracks/go/exercises/twelve-days/example.go
trackler-2.2.0.5 tracks/go/exercises/twelve-days/example.go
trackler-2.2.0.4 tracks/go/exercises/twelve-days/example.go