Skip to content

Commit

Permalink
Add the "12-days-of-christmas" hole
Browse files Browse the repository at this point in the history
Updates #3
  • Loading branch information
JRaspass committed Dec 8, 2017
1 parent dadfe67 commit 079513e
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 22 deletions.
4 changes: 4 additions & 0 deletions assets/common.css
@@ -1,5 +1,9 @@
/* include codemirror.css */

blockquote {
white-space: pre;
}

body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
font-size: 16px;
Expand Down
113 changes: 113 additions & 0 deletions routes/answers.go
@@ -1,6 +1,119 @@
package routes

var answers = map[string]string{
"12-days-of-christmas": `On the First day of Christmas
My true love sent to me
A Partridge in a Pear Tree.
On the Second day of Christmas
My true love sent to me
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Third day of Christmas
My true love sent to me
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Fourth day of Christmas
My true love sent to me
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Fifth day of Christmas
My true love sent to me
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Sixth day of Christmas
My true love sent to me
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Seventh day of Christmas
My true love sent to me
Seven Swans-a-Swimming,
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Eighth day of Christmas
My true love sent to me
Eight Maids-a-Milking,
Seven Swans-a-Swimming,
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Ninth day of Christmas
My true love sent to me
Nine Ladies Dancing,
Eight Maids-a-Milking,
Seven Swans-a-Swimming,
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Tenth day of Christmas
My true love sent to me
Ten Lords-a-Leaping,
Nine Ladies Dancing,
Eight Maids-a-Milking,
Seven Swans-a-Swimming,
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Eleventh day of Christmas
My true love sent to me
Eleven Pipers Piping,
Ten Lords-a-Leaping,
Nine Ladies Dancing,
Eight Maids-a-Milking,
Seven Swans-a-Swimming,
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.
On the Twelfth day of Christmas
My true love sent to me
Twelve Drummers Drumming,
Eleven Pipers Piping,
Ten Lords-a-Leaping,
Nine Ladies Dancing,
Eight Maids-a-Milking,
Seven Swans-a-Swimming,
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.`,
"99-bottles-of-beer": `99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
Expand Down
20 changes: 20 additions & 0 deletions routes/hole.go
Expand Up @@ -8,6 +8,26 @@ import (
)

var preambles = map[string]string{
"12-days-of-christmas": `<h1>12 Days of Christmas</h1><p>Print the lyrics to the song <b>The 12 Days of Christmas</b>:</p><blockquote>On the first day of Christmas
My true love sent to me
A Partridge in a Pear Tree.
On the twelfth day of Christmas
My true love sent to me
Twelve Drummers Drumming,
Eleven Pipers Piping,
Ten Lords-a-Leaping,
Nine Ladies Dancing,
Eight Maids-a-Milking,
Seven Swans-a-Swimming,
Six Geese-a-Laying,
Five Gold Rings,
Four Calling Birds,
Three French Hens,
Two Turtle Doves, and
A Partridge in a Pear Tree.</blockquote>`,
"99-bottles-of-beer": `<h1>99 Bottles of Beer</h1><p>Print the lyrics to the song 99 Bottles of Beer.</p>`,
"arabic-to-roman": `<h1>Arabic to Roman</h1><p>For each arabic numeral argument print the same number in roman numerals.</p>`,
"christmas-trees": `<h1>Christmas Trees</h1><p>Print a size ascending range of Christmas trees using asterisks, ranging from size <b>3</b> to size <b>9</b>, each tree separated by a blank line.<p>A size <b>3</b> tree should look like this, with a single centered asterisk for the trunk:<pre> *
Expand Down
47 changes: 25 additions & 22 deletions routes/home.go
Expand Up @@ -53,28 +53,29 @@ func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
WHERE row_number < 6
OR user_id = $1
ORDER BY CASE hole
WHEN 'emirp-numbers' THEN 0
WHEN 'evil-numbers' THEN 1
WHEN 'fibonacci' THEN 2
WHEN 'fizz-buzz' THEN 3
WHEN 'happy-numbers' THEN 4
WHEN 'odious-numbers' THEN 5
WHEN 'pascals-triangle' THEN 6
WHEN 'pernicious-numbers' THEN 7
WHEN 'prime-numbers' THEN 8
WHEN 'quine' THEN 9
WHEN '99-bottles-of-beer' THEN 10
WHEN 'christmas-trees' THEN 11
WHEN 'pangram-grep' THEN 12
WHEN 'seven-segment' THEN 13
WHEN 'sierpiński-triangle' THEN 14
WHEN 'π' THEN 15
WHEN 'φ' THEN 16
WHEN '𝑒' THEN 17
WHEN 'τ' THEN 18
WHEN 'arabic-to-roman' THEN 19
WHEN 'roman-to-arabic' THEN 20
WHEN 'spelling-numbers' THEN 21
WHEN 'emirp-numbers' THEN 0
WHEN 'evil-numbers' THEN 1
WHEN 'fibonacci' THEN 2
WHEN 'fizz-buzz' THEN 3
WHEN 'happy-numbers' THEN 4
WHEN 'odious-numbers' THEN 5
WHEN 'pascals-triangle' THEN 6
WHEN 'pernicious-numbers' THEN 7
WHEN 'prime-numbers' THEN 8
WHEN 'quine' THEN 9
WHEN '12-days-of-christmas' THEN 10
WHEN '99-bottles-of-beer' THEN 11
WHEN 'christmas-trees' THEN 12
WHEN 'pangram-grep' THEN 13
WHEN 'seven-segment' THEN 14
WHEN 'sierpiński-triangle' THEN 15
WHEN 'π' THEN 16
WHEN 'φ' THEN 17
WHEN '𝑒' THEN 18
WHEN 'τ' THEN 19
WHEN 'arabic-to-roman' THEN 20
WHEN 'roman-to-arabic' THEN 21
WHEN 'spelling-numbers' THEN 22
END, row_number`,
printHeader(w, r, 200),
)
Expand Down Expand Up @@ -130,6 +131,8 @@ func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
w.Write([]byte(`<div class=`))

switch hole {
case "12-days-of-christmas":
w.Write([]byte(`Medium><a href=12-days-of-christmas>12 Days of Christmas`))
case "99-bottles-of-beer":
w.Write([]byte(`Medium><a href=99-bottles-of-beer>99 Bottles of Beer`))
case "arabic-to-roman":
Expand Down
1 change: 1 addition & 0 deletions routes/scores.go
Expand Up @@ -10,6 +10,7 @@ import (

var holes = [][]string{
{"all", "All Holes"},
{"12-days-of-christmas", "12 Days of Christmas"},
{"99-bottles-of-beer", "99 Bottles of Beer"},
{"arabic-to-roman", "Arabic to Roman"},
{"christmas-trees", "Christmas Trees"},
Expand Down

0 comments on commit 079513e

Please sign in to comment.