summaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-08-26 03:53:38 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-08-26 03:53:38 +0200
commit0162fa190cdf0a3b7b5ce27855b7b67fd26278aa (patch)
tree014e28862ad0f5953fa1d35d72cf1cf51d11b7e1 /go
parentaadbd64ad43803969502b9440a325dc8f09a50eb (diff)
Sovle house
Diffstat (limited to 'go')
-rw-r--r--go/house/house.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/go/house/house.go b/go/house/house.go
new file mode 100644
index 0000000..c3b353a
--- /dev/null
+++ b/go/house/house.go
@@ -0,0 +1,40 @@
+package house
+
+import "strings"
+
+func Embed(relPhrase, nounPhrase string) string {
+ return relPhrase + " " + nounPhrase
+}
+
+func Verse(subject string, relPhrases []string, nounPhrase string) string {
+ return subject + " " + strings.Join(append(relPhrases, nounPhrase), " ")
+}
+
+var items = [][]string{
+ {"lay in", "the house that Jack built."},
+ {"ate", "the malt"},
+ {"killed", "the rat"},
+ {"worried", "the cat"},
+ {"tossed", "the dog"},
+ {"milked", "the cow with the crumpled horn"},
+ {"kissed", "the maiden all forlorn"},
+ {"married", "the man all tattered and torn"},
+ {"woke", "the priest all shaven and shorn"},
+ {"kept", "the rooster that crowed in the morn"},
+ {"belonged to", "the farmer sowing his corn"},
+ {"", "the horse and the hound and the horn"},
+}
+
+func Song() string {
+ var s []string
+ for k, v := range items {
+ s = append(s, "This is "+v[1])
+ for i := k - 1; i >= 0; i-- {
+ s = append(s, "that "+strings.Join(items[i], " "))
+ }
+ if k != len(items)-1 {
+ s = append(s, "")
+ }
+ }
+ return strings.Join(s, "\n")
+}