Skip to content

Commit 9f3d87d

Browse files
committed
Automated update from private repo
1 parent 8c43663 commit 9f3d87d

24 files changed

Lines changed: 3227 additions & 408 deletions

scripts/strip_private_info.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,17 @@ def strip_solutions_from_xml_files(directory):
4848
root_element = tree.getroot()
4949

5050
# Find all 'exercise' elements in the document
51-
exercises = root_element.findall(".//exercise")
51+
# Or 'task' elements within an 'exercise' elemetn
52+
exercises = root_element.findall(".//exercise | .//exercise//task")
5253

5354
for exercise in exercises:
54-
# Find all 'solution' elements within the current 'exercise'
55-
solutions = exercise.findall("solution")
56-
57-
# Remove each found 'solution' element
58-
for solution in solutions:
59-
exercise.remove(solution)
60-
modified = True
61-
62-
answers = exercise.findall("answers")
63-
# Remove 'answers' elements if they exist
64-
for answer in answers:
65-
exercise.remove(answer)
66-
modified = True
55+
# Find all 'solution' elements or 'answer' elements
56+
# within the current 'exercise' or 'task'
57+
for node in exercise.findall('.//answer | .//solution'):
58+
parent = node.getparent()
59+
if parent is not None:
60+
parent.remove(node)
61+
modified = True
6762

6863
# Write the modified XML back to the file
6964
# The 'short_empty_elements' is a nice-to-have for cleaner XML

source/activities/wkst-eqrel-counting.ptx

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?xml version='1.0' encoding='UTF-8'?>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Contributed by Mitch Keller -->
23
<worksheet>
34
<title>Equivalence Relations and Counting</title>
45
<page>
@@ -10,7 +11,40 @@
1011
</p>
1112
</statement>
1213

13-
</exercise>
14+
<solution component="w2s">
15+
<p>
16+
Since <m>R</m> is an equivalence relation, the relation is reflexive, so every element is related to itself. Since we are told <m>aRd</m>, this means by symmetry that <m>d R a</m>. Similarly, <m>cRb</m> because <m>bRc</m> and <m>dRe</m> because <m>eRd</m>. By transitivity, we have that <m>aRe</m> and <m>e R a</m>. To make writing the elements of <m>R</m> easier to see, here is the equivalence relation as a diagram:
17+
</p>
18+
<image width="50%">
19+
<shortdescription>An equivalence relation as a digraph</shortdescription>
20+
<prefigure xmlns="https://prefigure.org" label="2025-Worksheet-12-Ex-7">
21+
<diagram dimensions="(200,200)" margins="5">
22+
<definition>N=5</definition>
23+
<definition>f(t)=(cos(2*pi*t/N), sin(2*pi*t/N))</definition>
24+
<coordinates bbox="(-1.75,-1.75,1.75,1.75)">
25+
<network directed="yes" scale="0.8"
26+
node-fill="#ffffff" node-stroke="black"
27+
seed="1" labels="yes" loop-scale="(0.5,0.5)"
28+
tactile-node-size="40" node-size="10" >
29+
<node at="1" p="f(0)" edges="[1,4,5]" loop-orientation="0"><m>a</m></node>
30+
<node at="2" p="f(1)" edges="[2,3]" loop-orientation="0"><m>b</m></node>
31+
<node at="3" p="f(2)" edges="[3,2]"><m>c</m></node>
32+
<node at="4" p="f(3)" edges="[1,4,5]"><m>d</m></node>
33+
<node at="5" p="f(4)" edges="[1,4,5]" loop-orientation="270"><m>e</m></node>
34+
</network>
35+
</coordinates>
36+
</diagram>
37+
</prefigure>
38+
</image>
39+
<p>
40+
From this, we can more readily see that the relation will be
41+
<md>
42+
<mrow>R = \{ \amp(a,a), (d,d), (e,e), (a,d), (d,a), (a,e), (e,a) , </mrow>
43+
<mrow>\amp (d,e), (e,d), (b,b), (c,c), (b,c), (c,b) \}</mrow>
44+
</md>.
45+
</p>
46+
</solution>
47+
</exercise>
1448

1549
<exercise>
1650
<introduction>
@@ -138,7 +172,27 @@
138172
Describe the partition of <m>\Z</m> resulting from the equivalence relation <m>\equiv \pmod{4}</m>.
139173
</p>
140174
</statement>
141-
</exercise>
175+
<solution component="w2s">
176+
<p>
177+
The way congruence modulo <m>4</m> partitions <m>\Z</m> is based on the remainder after division. So, there are four equivalence classes:
178+
<md>
179+
<mrow>
180+
[0] \amp = \{ x \in \Z : x \equiv 0 \pmod 4\} = \{ \ldots,-8, -4, 0, 4, 8, 12, \ldots \},
181+
</mrow>
182+
<mrow>
183+
[1] \amp = \{ x \in \Z : x \equiv 1 \pmod 4\} = \{ \ldots,-7, -3, 1,5, 9, 13, \ldots \},
184+
</mrow>
185+
<mrow>
186+
[2] \amp = \{ x \in \Z : x \equiv 2 \pmod 4\} = \{ \ldots,-6,-2,2,6,10,14 \ldots \},
187+
</mrow>
188+
<intertext>and</intertext>
189+
<mrow>
190+
[3] \amp = \{ x \in \Z : x \equiv 3 \pmod 4\} = \{ \ldots,-5,-1,3,7,11,15, \ldots \}.
191+
</mrow>
192+
</md>
193+
</p>
194+
</solution>
195+
</exercise>
142196
<exercise workspace="0.25in">
143197
<introduction>
144198
<p>
@@ -229,7 +283,12 @@
229283
</p>
230284
</statement>
231285

232-
</exercise>
286+
<solution component="w2s">
287+
<p>
288+
One possibility is <m>f(x) = \lceil \frac{x}{3} \rceil</m>. This is a <m>3</m>-to-<m>1</m> correspondence because for <m>j \in \{1, 2, \ldots, 10\}</m>, the numbers that will get mapped to <m>j</m> under <m>f</m> will be <m>3j</m>, <m>3j-1</m>, and <m>3j-2</m> (which are all elements of <m>\{1,2,\cdots,30\}</m>).
289+
</p>
290+
</solution>
291+
</exercise>
233292

234293
<exercise workspace="0.65in">
235294
<statement>
@@ -238,7 +297,12 @@
238297
</p>
239298
</statement>
240299

241-
</exercise>
300+
<solution component="w2s">
301+
<p>
302+
There are <m>3</m> choices for the first character in the string, and <m>2</m> choices for the second character. For the third, since we cannot have two consecutive characters be the same, we therefore have <m>2</m> choices. Similarly, there are <m>2</m> choices for the fourth, etc. Hence, there are <m>3 \cdot 2^9</m> strings of length <m>10</m> in which no two consecutive characters are the same.
303+
</p>
304+
</solution>
305+
</exercise>
242306

243307

244308

@@ -250,7 +314,12 @@
250314
</p>
251315
</statement>
252316

253-
</exercise>
317+
<solution component="w2s">
318+
<p>
319+
There are <m>2</m> choices for the leader at the front. Then, there are <m>10!</m> choices made for the ten girl scouts in the middle. Finally, there is one choice for the leader at the back of the line. Hence there are <m>2 \cdot 10!</m> ways to line up the entire troop.
320+
</p>
321+
</solution>
322+
</exercise>
254323

255324
<exercise workspace="0.75in">
256325
<introduction>
@@ -341,4 +410,4 @@
341410

342411

343412
</page>
344-
</worksheet>
413+
</worksheet>

0 commit comments

Comments
 (0)