Skip to content

Commit 2f87dea

Browse files
committed
Add "Leap Years" hole
Updates #3
1 parent 2f44c3f commit 2f87dea

File tree

4 files changed

+179
-27
lines changed

4 files changed

+179
-27
lines changed

db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ CREATE TYPE public.hole AS ENUM (
3232
'fibonacci',
3333
'fizz-buzz',
3434
'happy-numbers',
35+
'leap-years',
3536
'morse-decoder',
3637
'morse-encoder',
3738
'niven-numbers',

routes/answers.go

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,152 @@ Buzz`,
881881
190
882882
192
883883
193`,
884+
"leap-years": `1804
885+
1808
886+
1812
887+
1816
888+
1820
889+
1824
890+
1828
891+
1832
892+
1836
893+
1840
894+
1844
895+
1848
896+
1852
897+
1856
898+
1860
899+
1864
900+
1868
901+
1872
902+
1876
903+
1880
904+
1884
905+
1888
906+
1892
907+
1896
908+
1904
909+
1908
910+
1912
911+
1916
912+
1920
913+
1924
914+
1928
915+
1932
916+
1936
917+
1940
918+
1944
919+
1948
920+
1952
921+
1956
922+
1960
923+
1964
924+
1968
925+
1972
926+
1976
927+
1980
928+
1984
929+
1988
930+
1992
931+
1996
932+
2000
933+
2004
934+
2008
935+
2012
936+
2016
937+
2020
938+
2024
939+
2028
940+
2032
941+
2036
942+
2040
943+
2044
944+
2048
945+
2052
946+
2056
947+
2060
948+
2064
949+
2068
950+
2072
951+
2076
952+
2080
953+
2084
954+
2088
955+
2092
956+
2096
957+
2104
958+
2108
959+
2112
960+
2116
961+
2120
962+
2124
963+
2128
964+
2132
965+
2136
966+
2140
967+
2144
968+
2148
969+
2152
970+
2156
971+
2160
972+
2164
973+
2168
974+
2172
975+
2176
976+
2180
977+
2184
978+
2188
979+
2192
980+
2196
981+
2204
982+
2208
983+
2212
984+
2216
985+
2220
986+
2224
987+
2228
988+
2232
989+
2236
990+
2240
991+
2244
992+
2248
993+
2252
994+
2256
995+
2260
996+
2264
997+
2268
998+
2272
999+
2276
1000+
2280
1001+
2284
1002+
2288
1003+
2292
1004+
2296
1005+
2304
1006+
2308
1007+
2312
1008+
2316
1009+
2320
1010+
2324
1011+
2328
1012+
2332
1013+
2336
1014+
2340
1015+
2344
1016+
2348
1017+
2352
1018+
2356
1019+
2360
1020+
2364
1021+
2368
1022+
2372
1023+
2376
1024+
2380
1025+
2384
1026+
2388
1027+
2392
1028+
2396
1029+
2400`,
8841030
"niven-numbers": `1
8851031
2
8861032
3

routes/home.go

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -103,33 +103,34 @@ func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
103103
WHEN 'fibonacci' THEN 3
104104
WHEN 'fizz-buzz' THEN 4
105105
WHEN 'happy-numbers' THEN 5
106-
WHEN 'niven-numbers' THEN 6
107-
WHEN 'odious-numbers' THEN 7
108-
WHEN 'pascals-triangle' THEN 8
109-
WHEN 'pernicious-numbers' THEN 9
110-
WHEN 'prime-numbers' THEN 10
111-
WHEN 'quine' THEN 11
112-
WHEN '12-days-of-christmas' THEN 12
113-
WHEN '99-bottles-of-beer' THEN 13
114-
WHEN 'christmas-trees' THEN 14
115-
WHEN 'diamonds' THEN 15
116-
WHEN 'morse-decoder' THEN 16
117-
WHEN 'morse-encoder' THEN 17
118-
WHEN 'pangram-grep' THEN 18
119-
WHEN 'seven-segment' THEN 19
120-
WHEN 'sierpiński-triangle' THEN 20
121-
WHEN 'λ' THEN 21
122-
WHEN 'π' THEN 22
123-
WHEN 'φ' THEN 23
124-
WHEN '𝑒' THEN 24
125-
WHEN 'τ' THEN 25
126-
WHEN 'arabic-to-roman' THEN 26
127-
WHEN 'brainfuck' THEN 27
128-
WHEN 'poker' THEN 28
129-
WHEN 'roman-to-arabic' THEN 29
130-
WHEN 'rule-110' THEN 30
131-
WHEN 'spelling-numbers' THEN 31
132-
WHEN 'sudoku' THEN 32
106+
WHEN 'leap-years' THEN 6
107+
WHEN 'niven-numbers' THEN 7
108+
WHEN 'odious-numbers' THEN 8
109+
WHEN 'pascals-triangle' THEN 9
110+
WHEN 'pernicious-numbers' THEN 10
111+
WHEN 'prime-numbers' THEN 11
112+
WHEN 'quine' THEN 12
113+
WHEN '12-days-of-christmas' THEN 13
114+
WHEN '99-bottles-of-beer' THEN 14
115+
WHEN 'christmas-trees' THEN 15
116+
WHEN 'diamonds' THEN 16
117+
WHEN 'morse-decoder' THEN 17
118+
WHEN 'morse-encoder' THEN 18
119+
WHEN 'pangram-grep' THEN 19
120+
WHEN 'seven-segment' THEN 20
121+
WHEN 'sierpiński-triangle' THEN 21
122+
WHEN 'λ' THEN 22
123+
WHEN 'π' THEN 23
124+
WHEN 'φ' THEN 24
125+
WHEN '𝑒' THEN 25
126+
WHEN 'τ' THEN 26
127+
WHEN 'arabic-to-roman' THEN 27
128+
WHEN 'brainfuck' THEN 28
129+
WHEN 'poker' THEN 29
130+
WHEN 'roman-to-arabic' THEN 30
131+
WHEN 'rule-110' THEN 31
132+
WHEN 'spelling-numbers' THEN 32
133+
WHEN 'sudoku' THEN 33
133134
END, row_number`,
134135
userID,
135136
)

routes/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ A Partridge in a Pear Tree.</blockquote>`,
118118
"", "",
119119
"happy-numbers", "Happy Numbers", "Fast",
120120
"A happy number is defined by the following sequence: Starting with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are sad numbers.<p>For example, 19 is happy, as the associated sequence is:</p><dl><dd>1<sup>2</sup> + 9<sup>2</sup> = 82<dd>8<sup>2</sup> + 2<sup>2</sup> = 68<dd>6<sup>2</sup> + 8<sup>2</sup> = 100<dd>1<sup>2</sup> + 0<sup>2</sup> + 0<sup>2</sup> = 1.</dl><p>Print all the happy numbers from <b>1</b> to <b>200</b> inclusive, each on their own line.</p>",
121+
}, {
122+
"", "",
123+
"leap-years", "Leap Years", "Fast",
124+
"In the Gregorian calendar, a leap year is created by extending Februrary to 29 days in order to keep the calendar year synchronized with the astronomical year. These longer years occur in years which are multiples of <b>4</b> but not multiples of <b>400</b>.<p>Write a progream to print all the leap years between the year <b>1800</b> and <b>2400</b>.</p>",
121125
}, {
122126
"", "",
123127
"morse-decoder", "Morse Decoder", "Medium",

0 commit comments

Comments
 (0)