Skip to content

Commit 7b72ebc

Browse files
committed
Add the "niven-numbers" hole
Updates #3
1 parent d568705 commit 7b72ebc

File tree

4 files changed

+73
-37
lines changed

4 files changed

+73
-37
lines changed

db.sql

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
2828
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
2929

3030

31-
SET search_path = public, pg_catalog;
32-
3331
--
3432
-- Name: hole; Type: TYPE; Schema: public; Owner: jraspass
3533
--
3634

37-
CREATE TYPE hole AS ENUM (
35+
CREATE TYPE public.hole AS ENUM (
3836
'12-days-of-christmas',
3937
'99-bottles-of-beer',
4038
'arabic-to-roman',
@@ -48,6 +46,7 @@ CREATE TYPE hole AS ENUM (
4846
'happy-numbers',
4947
'morse-decoder',
5048
'morse-encoder',
49+
'niven-numbers',
5150
'odious-numbers',
5251
'pangram-grep',
5352
'pascals-triangle',
@@ -65,13 +64,13 @@ CREATE TYPE hole AS ENUM (
6564
);
6665

6766

68-
ALTER TYPE hole OWNER TO jraspass;
67+
ALTER TYPE public.hole OWNER TO jraspass;
6968

7069
--
7170
-- Name: lang; Type: TYPE; Schema: public; Owner: jraspass
7271
--
7372

74-
CREATE TYPE lang AS ENUM (
73+
CREATE TYPE public.lang AS ENUM (
7574
'bash',
7675
'javascript',
7776
'lisp',
@@ -84,7 +83,7 @@ CREATE TYPE lang AS ENUM (
8483
);
8584

8685

87-
ALTER TYPE lang OWNER TO jraspass;
86+
ALTER TYPE public.lang OWNER TO jraspass;
8887

8988
SET default_tablespace = '';
9089

@@ -94,58 +93,58 @@ SET default_with_oids = false;
9493
-- Name: solutions; Type: TABLE; Schema: public; Owner: jraspass
9594
--
9695

97-
CREATE TABLE solutions (
96+
CREATE TABLE public.solutions (
9897
submitted timestamp without time zone NOT NULL,
9998
user_id integer NOT NULL,
100-
hole hole NOT NULL,
101-
lang lang NOT NULL,
99+
hole public.hole NOT NULL,
100+
lang public.lang NOT NULL,
102101
code text NOT NULL,
103102
failing boolean DEFAULT false NOT NULL
104103
);
105104

106105

107-
ALTER TABLE solutions OWNER TO jraspass;
106+
ALTER TABLE public.solutions OWNER TO jraspass;
108107

109108
--
110109
-- Name: users; Type: TABLE; Schema: public; Owner: jraspass
111110
--
112111

113-
CREATE TABLE users (
112+
CREATE TABLE public.users (
114113
id integer NOT NULL,
115114
login text NOT NULL
116115
);
117116

118117

119-
ALTER TABLE users OWNER TO jraspass;
118+
ALTER TABLE public.users OWNER TO jraspass;
120119

121120
--
122121
-- Name: solutions solutions_pkey; Type: CONSTRAINT; Schema: public; Owner: jraspass
123122
--
124123

125-
ALTER TABLE ONLY solutions
124+
ALTER TABLE ONLY public.solutions
126125
ADD CONSTRAINT solutions_pkey PRIMARY KEY (user_id, hole, lang);
127126

128127

129128
--
130129
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: jraspass
131130
--
132131

133-
ALTER TABLE ONLY users
132+
ALTER TABLE ONLY public.users
134133
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
135134

136135

137136
--
138137
-- Name: TABLE solutions; Type: ACL; Schema: public; Owner: jraspass
139138
--
140139

141-
GRANT SELECT,INSERT,UPDATE ON TABLE solutions TO code_golf;
140+
GRANT SELECT,INSERT,UPDATE ON TABLE public.solutions TO code_golf;
142141

143142

144143
--
145144
-- Name: TABLE users; Type: ACL; Schema: public; Owner: jraspass
146145
--
147146

148-
GRANT SELECT,INSERT,UPDATE ON TABLE users TO code_golf;
147+
GRANT SELECT,INSERT,UPDATE ON TABLE public.users TO code_golf;
149148

150149

151150
--

routes/answers.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,39 @@ Buzz`,
792792
190
793793
192
794794
193`,
795+
"niven-numbers": `1
796+
2
797+
3
798+
4
799+
5
800+
6
801+
7
802+
8
803+
9
804+
10
805+
12
806+
18
807+
20
808+
21
809+
24
810+
27
811+
30
812+
36
813+
40
814+
42
815+
45
816+
48
817+
50
818+
54
819+
60
820+
63
821+
70
822+
72
823+
80
824+
81
825+
84
826+
90
827+
100`,
795828
"odious-numbers": `1
796829
2
797830
4

routes/home.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,28 @@ 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 'odious-numbers' THEN 6
107-
WHEN 'pascals-triangle' THEN 7
108-
WHEN 'pernicious-numbers' THEN 8
109-
WHEN 'prime-numbers' THEN 9
110-
WHEN 'quine' THEN 10
111-
WHEN '12-days-of-christmas' THEN 11
112-
WHEN '99-bottles-of-beer' THEN 12
113-
WHEN 'christmas-trees' THEN 13
114-
WHEN 'morse-decoder' THEN 14
115-
WHEN 'morse-encoder' THEN 15
116-
WHEN 'pangram-grep' THEN 16
117-
WHEN 'seven-segment' THEN 17
118-
WHEN 'sierpiński-triangle' THEN 18
119-
WHEN 'π' THEN 19
120-
WHEN 'φ' THEN 20
121-
WHEN '𝑒' THEN 21
122-
WHEN 'τ' THEN 22
123-
WHEN 'arabic-to-roman' THEN 23
124-
WHEN 'brainfuck' THEN 24
125-
WHEN 'roman-to-arabic' THEN 25
126-
WHEN 'spelling-numbers' THEN 26
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 'morse-decoder' THEN 15
116+
WHEN 'morse-encoder' THEN 16
117+
WHEN 'pangram-grep' THEN 17
118+
WHEN 'seven-segment' THEN 18
119+
WHEN 'sierpiński-triangle' THEN 19
120+
WHEN 'π' THEN 20
121+
WHEN 'φ' THEN 21
122+
WHEN '𝑒' THEN 22
123+
WHEN 'τ' THEN 23
124+
WHEN 'arabic-to-roman' THEN 24
125+
WHEN 'brainfuck' THEN 25
126+
WHEN 'roman-to-arabic' THEN 26
127+
WHEN 'spelling-numbers' THEN 27
127128
END, row_number`,
128129
userID,
129130
)

routes/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ A Partridge in a Pear Tree.</blockquote>`,
8888
}, {
8989
"morse-encoder", "Morse Encoder", "Medium",
9090
"Using ▄ (U+2584 Lower Half Block) to represent a dot, decode the argument into" + morseTable,
91+
}, {
92+
"niven-numbers", "Niven Numbers", "Fast",
93+
"A niven number is a non-negative number that is divisible by the sum of its digits.<p>Print all the niven numbers from <b>0</b> to <b>100</b> inclusive, each on their own line.</p>",
9194
}, {
9295
"odious-numbers", "Odious Numbers", "Fast",
9396
"An odious number is a non-negative number that has an odd number of 1s in its binary expansion.<p>Print all the odious numbers from <b>0</b> to <b>50</b> inclusive, each on their own line.<p>Numbers that are not odious are called <a href=evil-numbers>evil numbers</a>.</p>",

0 commit comments

Comments
 (0)