Skip to content

Commit

Permalink
Added decomposition of two digit numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinK84 committed Dec 7, 2023
1 parent 3eb3a65 commit 91e90ca
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 6 deletions.
1 change: 1 addition & 0 deletions make_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
site = Site.make_site(
contexts=[
('plus_over_10.html', {'solution': False}),
('number_deconstruction_two_digits.html', {'solution': False}),
('index.html', {'solution': True}),
],
outpath='docs'
Expand Down
25 changes: 25 additions & 0 deletions templates/_number_deconstruction_two_digits.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- templates/_number_deconstruction_two_digits.html -->
<table class="with_header" style="border:0px">
<tr>
<td style="padding-bottom:0px">Z</td>
<td> </td>
<td style="padding-bottom:0px">E</td>
<td> </td>
<td></td>
</tr>
<tr>
{% if solution %}
<td><div class="box"><script>document.write(a[ids[{{idx}}]].toString()[0]+'0');</script></div></td>
{% else %}
<td><div class="box">&nbsp;&nbsp;</div></td>
{% endif %}
<td> + </td>
{% if solution %}
<td><div class="box"><script>document.write("&nbsp;" + a[ids[{{idx}}]].toString()[1]);</script></div></td>
{% else %}
<td><div class="box">&nbsp;&nbsp;</div></td>
{% endif %}
<td> = </td>
<td><script>document.write(a[ids[{{idx}}]]);</script></td>
</tr>
</table>
18 changes: 13 additions & 5 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<!-- templates/index.html -->
<link rel="stylesheet" href="css/style.css">

<script>
const a = [5];
const b = [8];
var ids = [0]
</script>
{% set idx = 0 %}

<table style="margin-left:auto; margin-right:auto;">
<script>
var a = [5];
var b = [8];
var ids = [0]
</script>
<tr>
<td>{% include '_plus_over_10.html' %}</td>
<td style="vertical-align: top;"><a href="plus_over_10.html">Addition above 10 with intermediate step</a></td>
</tr>

<script>
a = [68];
</script>
<tr>
<td>{% include '_number_deconstruction_two_digits.html' %}</td>
<td style="vertical-align: top;"><a href="number_deconstruction_two_digits.html">Decomposition of two digit numbers</a></td>
</tr>
</table>
135 changes: 135 additions & 0 deletions templates/number_deconstruction_two_digits.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!-- templates/plus_over_10.html -->
<link rel="stylesheet" href="css/style.css">

<script>
var a = [];
for (var ida = 10; ida <= 99; ida++) {
a.push(ida);
}
var ids = [];
let i = 0;
while (i < a.length) {
ids.push(i);
i++;
}
ids = shuffle(ids);


function shuffle(array) {
let currentIndex = array.length, randomIndex;

// While there remain elements to shuffle.
while (currentIndex > 0) {

// Pick a remaining element.
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;

// And swap it with the current element.
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
}

return array;
}
</script>
<table style="margin-left:auto; margin-right:auto;">
<tr>
{% set solution = True %}
{% set idx = 0 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set solution = False %}
{% set idx = 1 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 2 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 3 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 4 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 5 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 6 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 7 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 8 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 9 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 10 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 11 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 12 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 13 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 14 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 15 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 16 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 17 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 18 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 19 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 20 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 21 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 22 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 23 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 24 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 25 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 26 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 27 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 28 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 29 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 30 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 31 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 32 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
<tr>
{% set idx = 33 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 34 %}
<td style="padding-right: 1.7em; padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
{% set idx = 35 %}
<td style="padding-bottom: 0.5em;">{% include '_number_deconstruction_two_digits.html' %} </td>
</tr>
</table>
2 changes: 1 addition & 1 deletion templates/plus_over_10.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<script>
const a = [2,3,3, 4,4,4, 5,5,5,5, 6,6,6,6,6, 7,7,7,7,7,7, 8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9];
const b = [9,9,8, 9,8,7, 9,8,7,6, 9,8,7,6,5, 9,8,7,6,5,4, 9,8,7,6,5,4,3, 9,8,7,6,5,4,3,2];
var ids = []
var ids = [];
let i = 0;
while (i < a.length) {
ids.push(i);
Expand Down

0 comments on commit 91e90ca

Please sign in to comment.