diff --git a/TODO.md b/TODO.md
index 892f99a..0bd88a5 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,6 +1,7 @@
- deploy
- now.sh, waiting for it to be purely front end
- purely front end except for mailing list
+- remove repeated exercises
- make text inputs big enough for MAX_DIGITS_PROBLEMS and MAX_DIGITS_BITS
- show a message on submit
- show warning when specifying invalid number of bits or problems
diff --git a/public/global.css b/public/global.css
index ec905f5..587b220 100644
--- a/public/global.css
+++ b/public/global.css
@@ -64,3 +64,30 @@ button:not(:disabled):active {
button:focus {
border-color: #666;
}
+.inputs {
+ text-align: right; width: 2em; border: none; outline: none;
+}
+
+
+.primary-button {
+ cursor: pointer;
+ border: none;
+ background-color: dodgerblue;
+ color: white
+}
+
+.button {
+ cursor: pointer;
+ background-color: white;
+}
+
+input[type=number]::-webkit-inner-spin-button,
+input[type=number]::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+
+input[type=number] {
+ -moz-appearance:textfield;
+}
+
diff --git a/src/App.svelte b/src/App.svelte
index 7089399..b4db6e8 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -1,9 +1,15 @@
Binary Quiz!
-
-
+ {#if ($activeQuiz)}
+
+
+ {:else}
+
+ {/if}
diff --git a/src/Inputs.svelte b/src/Inputs.svelte
deleted file mode 100644
index 573f8a2..0000000
--- a/src/Inputs.svelte
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
diff --git a/src/Quiz.svelte b/src/Quiz.svelte
deleted file mode 100644
index e69de29..0000000
diff --git a/src/components/Inputs.svelte b/src/components/Inputs.svelte
new file mode 100644
index 0000000..f83f1b6
--- /dev/null
+++ b/src/components/Inputs.svelte
@@ -0,0 +1,52 @@
+
+
+
diff --git a/src/components/Problem.svelte b/src/components/Problem.svelte
new file mode 100644
index 0000000..32160cc
--- /dev/null
+++ b/src/components/Problem.svelte
@@ -0,0 +1,54 @@
+
+
+{#if displaySummary}
+ Congratulations, you've completed {$num_problems} {$bits}-bit problems!
+
+{:else}
+
+{/if}
+
+
diff --git a/src/components/Quiz.svelte b/src/components/Quiz.svelte
new file mode 100644
index 0000000..3023eff
--- /dev/null
+++ b/src/components/Quiz.svelte
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/src/components/Tally.svelte b/src/components/Tally.svelte
new file mode 100644
index 0000000..f9aef8e
--- /dev/null
+++ b/src/components/Tally.svelte
@@ -0,0 +1,7 @@
+
+
+
+ {$tally}/{$num_problems}
+
diff --git a/src/config.js b/src/config.js
index 78ca859..fcd45ae 100644
--- a/src/config.js
+++ b/src/config.js
@@ -7,3 +7,7 @@ export const MAX_DIGITS_BITS = MAX_BITS.toString().length
export const DEFAULT_BITS = 8
export const DEFAULT_NUM_PROBLEMS = 20
+export const getMaxPermutations = (bits) => {
+ return Math.pow(2, bits)
+}
+
diff --git a/src/problems.js b/src/problems.js
new file mode 100644
index 0000000..bf8669e
--- /dev/null
+++ b/src/problems.js
@@ -0,0 +1,22 @@
+import {DEFAULT_BITS, DEFAULT_NUM_PROBLEMS} from "./config";
+
+export const generateProblems = (bits, num_problems) => {
+ let probs = []
+ let counter = 0
+ while (counter < (num_problems || DEFAULT_NUM_PROBLEMS)) {
+ let problem = generateProblem(bits || DEFAULT_BITS)
+ if (probs.includes(problem)) {
+ continue
+ }
+ probs.push(problem)
+ counter++
+ }
+ return probs
+}
+
+export const generateProblem = bits => Array.from(Array(bits)).map((_, i) => Math.random() >= .5 ? '1' : '0').join('')
+
+export const solveProblem = problem => parseInt(problem, 2)
+
+export const checkAnswer = (answer, problem) => solveProblem(problem) === answer
+
diff --git a/src/stores.js b/src/stores.js
index c4e1773..3883b7d 100644
--- a/src/stores.js
+++ b/src/stores.js
@@ -1,4 +1,19 @@
-import { writable } from 'svelte/store'
+import {derived, writable} from 'svelte/store'
+import {generateProblem} from "./problems"
+import {getMaxPermutations, MIN_BITS, MAX_BITS, MIN_PROBLEMS, MAX_PROBLEMS, DEFAULT_BITS, DEFAULT_NUM_PROBLEMS} from "./config"
export const bits = writable()
export const num_problems = writable()
+export const activeQuiz = writable(false)
+export const activeProblemIndex = writable(0)
+export const tally = writable(0)
+export const problems = writable([])
+
+export const valid = derived([bits, num_problems], ([$bits, $num_problems]) => (
+ ($bits || DEFAULT_BITS) <= MAX_BITS
+ && ($bits || DEFAULT_BITS) >= MIN_BITS
+ && ($num_problems || DEFAULT_NUM_PROBLEMS) >= MIN_PROBLEMS
+ && ($num_problems || DEFAULT_NUM_PROBLEMS) <= MAX_PROBLEMS
+ && ($num_problems || DEFAULT_NUM_PROBLEMS) <= getMaxPermutations($bits)
+))
+