Skip to content

Commit 922fb91

Browse files
committed
Add the "divisors" hole
Updates #3
1 parent d83fcf9 commit 922fb91

File tree

4 files changed

+128
-23
lines changed

4 files changed

+128
-23
lines changed

routes/answers.go

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,106 @@ Go to the store and buy some more, 99 bottles of beer on the wall.`,
468468
***************
469469
*****************
470470
*`,
471+
"divisors": `1
472+
1 2
473+
1 3
474+
1 2 4
475+
1 5
476+
1 2 3 6
477+
1 7
478+
1 2 4 8
479+
1 3 9
480+
1 2 5 10
481+
1 11
482+
1 2 3 4 6 12
483+
1 13
484+
1 2 7 14
485+
1 3 5 15
486+
1 2 4 8 16
487+
1 17
488+
1 2 3 6 9 18
489+
1 19
490+
1 2 4 5 10 20
491+
1 3 7 21
492+
1 2 11 22
493+
1 23
494+
1 2 3 4 6 8 12 24
495+
1 5 25
496+
1 2 13 26
497+
1 3 9 27
498+
1 2 4 7 14 28
499+
1 29
500+
1 2 3 5 6 10 15 30
501+
1 31
502+
1 2 4 8 16 32
503+
1 3 11 33
504+
1 2 17 34
505+
1 5 7 35
506+
1 2 3 4 6 9 12 18 36
507+
1 37
508+
1 2 19 38
509+
1 3 13 39
510+
1 2 4 5 8 10 20 40
511+
1 41
512+
1 2 3 6 7 14 21 42
513+
1 43
514+
1 2 4 11 22 44
515+
1 3 5 9 15 45
516+
1 2 23 46
517+
1 47
518+
1 2 3 4 6 8 12 16 24 48
519+
1 7 49
520+
1 2 5 10 25 50
521+
1 3 17 51
522+
1 2 4 13 26 52
523+
1 53
524+
1 2 3 6 9 18 27 54
525+
1 5 11 55
526+
1 2 4 7 8 14 28 56
527+
1 3 19 57
528+
1 2 29 58
529+
1 59
530+
1 2 3 4 5 6 10 12 15 20 30 60
531+
1 61
532+
1 2 31 62
533+
1 3 7 9 21 63
534+
1 2 4 8 16 32 64
535+
1 5 13 65
536+
1 2 3 6 11 22 33 66
537+
1 67
538+
1 2 4 17 34 68
539+
1 3 23 69
540+
1 2 5 7 10 14 35 70
541+
1 71
542+
1 2 3 4 6 8 9 12 18 24 36 72
543+
1 73
544+
1 2 37 74
545+
1 3 5 15 25 75
546+
1 2 4 19 38 76
547+
1 7 11 77
548+
1 2 3 6 13 26 39 78
549+
1 79
550+
1 2 4 5 8 10 16 20 40 80
551+
1 3 9 27 81
552+
1 2 41 82
553+
1 83
554+
1 2 3 4 6 7 12 14 21 28 42 84
555+
1 5 17 85
556+
1 2 43 86
557+
1 3 29 87
558+
1 2 4 8 11 22 44 88
559+
1 89
560+
1 2 3 5 6 9 10 15 18 30 45 90
561+
1 7 13 91
562+
1 2 4 23 46 92
563+
1 3 31 93
564+
1 2 47 94
565+
1 5 19 95
566+
1 2 3 4 6 8 12 16 24 32 48 96
567+
1 97
568+
1 2 7 14 49 98
569+
1 3 9 11 33 99
570+
1 2 4 5 10 20 25 50 100`,
471571
"emirp-numbers": `13
472572
17
473573
31

routes/hole.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ A Partridge in a Pear Tree.</blockquote>`,
4343
***************
4444
*****************
4545
*</pre>`,
46+
"divisors": `<h1>Divisors</h1><p>A number is a divisor of another number if it can divide into it with no remainder.<p>Print the positive divisors of each number from <b>1</b> to <b>100</b> inclusive, on their own line, with each divisor separated by a space.</p>`,
4647
"emirp-numbers": `<h1>Emirp Numbers</h1><p>An emirp (prime spelled backwards) is a prime number that results in a different prime when its decimal digits are reversed. For example both <b>13</b> and <b>31</b> are emirps.</p><p>Print all the emirp numbers from <b>1</b> to <b>1000</b> inclusive, each on their own line.</p>`,
4748
"evil-numbers": `<h1>Evil Numbers</h1><p>An evil number is a non-negative number that has an even number of 1s in its binary expansion.<p>Print all the evil numbers from <b>0</b> to <b>50</b> inclusive, each on their own line.<p>Numbers that are not evil are called <a href=odious-numbers>odious numbers</a>.</p>`,
4849
"fibonacci": `<h1>Fibonacci</h1><p>Print the first <b>31</b> Fibonacci numbers from <b>F<sub>0</sub> = 0</b> to <b>F<sub>30</sub> = 832040</b> (inclusive), each on a separate line.</p>`,

routes/home.go

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,30 @@ func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
5252
WHERE row_number < 6
5353
OR user_id = $1
5454
ORDER BY CASE hole
55-
WHEN 'emirp-numbers' THEN 0
56-
WHEN 'evil-numbers' THEN 1
57-
WHEN 'fibonacci' THEN 2
58-
WHEN 'fizz-buzz' THEN 3
59-
WHEN 'happy-numbers' THEN 4
60-
WHEN 'odious-numbers' THEN 5
61-
WHEN 'pascals-triangle' THEN 6
62-
WHEN 'pernicious-numbers' THEN 7
63-
WHEN 'prime-numbers' THEN 8
64-
WHEN 'quine' THEN 9
65-
WHEN '12-days-of-christmas' THEN 10
66-
WHEN '99-bottles-of-beer' THEN 11
67-
WHEN 'christmas-trees' THEN 12
68-
WHEN 'pangram-grep' THEN 13
69-
WHEN 'seven-segment' THEN 14
70-
WHEN 'sierpiński-triangle' THEN 15
71-
WHEN 'π' THEN 16
72-
WHEN 'φ' THEN 17
73-
WHEN '𝑒' THEN 18
74-
WHEN 'τ' THEN 19
75-
WHEN 'arabic-to-roman' THEN 20
76-
WHEN 'roman-to-arabic' THEN 21
77-
WHEN 'spelling-numbers' THEN 22
55+
WHEN 'divisors' THEN 0
56+
WHEN 'emirp-numbers' THEN 1
57+
WHEN 'evil-numbers' THEN 2
58+
WHEN 'fibonacci' THEN 3
59+
WHEN 'fizz-buzz' THEN 4
60+
WHEN 'happy-numbers' THEN 5
61+
WHEN 'odious-numbers' THEN 6
62+
WHEN 'pascals-triangle' THEN 7
63+
WHEN 'pernicious-numbers' THEN 8
64+
WHEN 'prime-numbers' THEN 9
65+
WHEN 'quine' THEN 10
66+
WHEN '12-days-of-christmas' THEN 11
67+
WHEN '99-bottles-of-beer' THEN 12
68+
WHEN 'christmas-trees' THEN 13
69+
WHEN 'pangram-grep' THEN 14
70+
WHEN 'seven-segment' THEN 15
71+
WHEN 'sierpiński-triangle' THEN 16
72+
WHEN 'π' THEN 17
73+
WHEN 'φ' THEN 18
74+
WHEN '𝑒' THEN 19
75+
WHEN 'τ' THEN 20
76+
WHEN 'arabic-to-roman' THEN 21
77+
WHEN 'roman-to-arabic' THEN 22
78+
WHEN 'spelling-numbers' THEN 23
7879
END, row_number`,
7980
printHeader(w, r, 200),
8081
)
@@ -138,6 +139,8 @@ func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
138139
w.Write([]byte(`Slow><a href=arabic-to-roman>Arabic to Roman`))
139140
case "christmas-trees":
140141
w.Write([]byte(`Medium><a href=christmas-trees>Christmas Trees`))
142+
case "divisors":
143+
w.Write([]byte(`Fast><a href=divisors>Divisors`))
141144
case "emirp-numbers":
142145
w.Write([]byte(`Fast><a href=emirp-numbers>Emirp Numbers`))
143146
case "evil-numbers":

routes/scores.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func scores(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
8989
{"99-bottles-of-beer", "99 Bottles of Beer"},
9090
{"arabic-to-roman", "Arabic to Roman"},
9191
{"christmas-trees", "Christmas Trees"},
92+
{"divisors", "Divisors"},
9293
{"emirp-numbers", "Emirp Numbers"},
9394
{"evil-numbers", "Evil Numbers"},
9495
{"fibonacci", "Fibonacci"},

0 commit comments

Comments
 (0)