r/PowerShell • u/mdowst • Sep 18 '19
Parenting Through PowerShell
My 8 year old decided to pretend to be sick so he would get sent home from school the other day. So after we finished all the work the teach gave us, I decided to make him some extra work. Since they are learning double digit addition I wrote a quick script that will generate a page with 25 problems on it. I kept printing him off new sheets until the end of the regular school day.
I thought I'd share it in case anyone else has a 2nd grader who likes to play hooky. https://www.dowst.dev/homework-double-digit-addition-without-carrying/
Does anyone else have any examples of parenting through PowerShell?
19
u/timsstuff Sep 18 '19
Not Powershell but back around 1998 or so when my step daughter was acting up in elementary school I wrote a quick Visual Basic GUI for to repeatedly type a sentence Bart Simpson chalkboard style. It would count the number of times she typed it correctly, make a noise when there were typos, I had an admin password to set the sentence and number of repetitions. It took an hour or two to put together but it was pretty cool. For me anyway, she hated it!
9
u/mdowst Sep 18 '19
I could have used something like that for his spelling words. Maybe if there is a next time. But I have a feeling like that won't be for a while. At one point yesterday he asked to go back to school.
2
u/dus0922 Sep 18 '19
I have a copy of a script I found on this subreddit I think that is something very similar to what you're describing as far as the spelling words I'll link it when I get home if I remember
3
u/insufficient_funds Sep 18 '19 edited Sep 18 '19
so I dropped your script into ISE and got a number of errors. Not sure if I copied it out wrong or what though... I think some formatting got screwey and is messing with it.
edit: i changed the $bodytop = @" to start the '.xl65' on a new line and that looks to have fixed it.
5
u/mdowst Sep 18 '19
Thanks for the heads up. Looks like the plugin I'm using didn't like the HTML code inside of the code block. I switched it to a standard code block without the fancy color coding, and it is working now.
3
u/tkecherson Sep 18 '19
There we go; I was trying to tweak what was there in the fancy plugin with my (extrememly rudimentary) knowledge of HTML/CSS and was failing miserably. Thanks for the edit!
2
u/theSysadminChannel Sep 19 '19
You should paste a screenshot so we can all see what it looks like. This is great!!
2
u/1RedOne Sep 19 '19
Cool idea! I love that syntax for building a string, so terse and easy to read
I want to see the finished product though!
2
u/mdowst Sep 19 '19
Here's the finished product. I sized it so it would print nicely on 8.5x11 paper.
1
18
u/kreeef Sep 18 '19
My favorite is when they keep asking the same question, this little script comes in handy
while ($true){
Read-Host "Ask dad a question"
Write-Host "No"
}17
u/Pooter_Guy Sep 18 '19 edited Sep 18 '19
$mercy = 0 Do{ Read-Host "Ask dad a question" Write-Host "No" -foregroundcolor 'Red' $mercy++ } Until ($mercy -eq 2) If ($mercy -eq 2) {remove-localuser -name 'Johnny'}3
4
u/Onkel_Wackelflugel Sep 18 '19
while ($true){
Read-Host"Ask dad a question""Go ask your mother."
Write-Host "No"
}10
u/Pooter_Guy Sep 18 '19
Do { $mistake = read-host "Ask dad a question" If (($mistake -like "hungry") -or ($mistake -like "thirsty")) { write-output 'Go ask your mother' } Else { write-output "Let me think about it." start-sleep 9999999 write-output "No." } } Until ($mistake -eq "nevermind")
7
u/ISureHateMyCat Sep 18 '19
I did a spelling test for my kindergartener and also a simple speak-what-you-typed script for my then-three-year-old. Once her brother taught her to type “fart” that’s all I ever heard from those computer speakers.
5
u/revbo__ Sep 18 '19
Set-Content $algebra -path $meIf only PowerShell was around in the 90s, 8th grade math would have been a cinch!
4
u/ihaxr Sep 18 '19
You could program on the fancy TI-80 graphing calculators. I wrote a program for each formula as we learned them in Algebra 2... Slope / Slope Intercept, quadratic equation, perfect squares, etc... constantly being prompted to enter each variable made me think of the formula and I ended up memorizing them, making the programs unnecessary (other than to make sure I got the right answer, since you had to show your work anyway).
2
u/drexhex Sep 19 '19
My teacher said I could use the programs on tests as long as I wrote it and could show my work, so I made the program output each step. It had the same effect of just making me learn the formulas because of the time spent coding.
1
u/graysky311 Sep 19 '19
Haha me too. I wrote a triangle solver program, one called sys2 and sys3 that solved systems of equations. Aced my Trig class and got thousands of downloads on ticalc.org.
5
u/S1neW4ve Sep 19 '19
I once wrote some code to make sure my son didn't spend to much time on the PC.
He could spend X hours of pc-time a week and I also provided a script to check how many time he had left.
Worked great, because he had control over how he 'd like use that time, some weeks he used al his time in 2 days, other weeks he had some time left.
Also great to see of your kid can find your script in the startup folder, figures out how to use taskkill, and if he can clean up the logfile to cover up his tracks :-)
4
u/ihaxr Sep 18 '19
I got bored and decided to tweak the script a bit more to make it more flexible on the problem count and group sizes so you can adjust the number of problems and the group size to configure a PROBLEM x GROUP array (and if it's not a perfect square, it still works)
function Get-SumsUnder100 {
$a = Get-Random -Minimum 10 -Maximum 50
$b = Get-Random -Minimum 10 -Maximum 90
if ($a + $b -gt 100) {
Get-SumsUnder100
} else { [PSCustomObject]@{"a" = $a; "b" = $b}
}
}
function GenerateProblems ([int]$count) {
$Results = 1..$count | ForEach-Object {
Get-SumsUnder100
}
$Results
}
$problems = GenerateProblems -count 25
$groupSize = 5
$html = {
"<style> td {text-align: right; font: 24px monospace; padding:0px 15px 50px 15px;} hr {border:1px solid black; display:block}</style><table>"
for( $i=0; $i -lt $problems.Count; $i+=$groupSize ) {
"<tr>"
foreach ($problem in ($problems[$i..($i+($groupSize-1))]) ) {
"<td>$($problem.a) <br/> + $($problem.b)<hr/></td>"
}
"</tr>"
}
"</table>"
}
$html.Invoke() | Out-File -Force -FilePath "output.html"4
u/ka-splam Sep 18 '19 edited Sep 18 '19
Off topic; I was trying to do this in APL, and I came up with the idea of generating all combinations of two digit number addition into a table, filtering the ones below 100, taking the (x, y) axis indices of those as the available choices of addition problems for the worksheet, then taking nine pairs at random:
(⊢⌷⍨(⊂9?⍴)) ⍸100>∘.+⍨9+⍳90e.g. these pairs.
61 1 23 55 35 33 11 21 1 48 52 3 5 30 47 29 15 52Formatting them was as difficult and frustrating again, but I ended up with a neat grid. Room for the answer, and an underline, left as an exercise for the reader, lol.
3 3 ⍴ {(⍪' +'),↑⍵}¨ (⊢⌷⍨(⊂9?⍴)) ⍸100>∘.+⍨9+⍳90 ┌────┬────┬────┐ │ 12│ 55│ 29│ │+ 22│+ 6│+ 14│ ├────┼────┼────┤ │ 6│ 47│ 10│ │+ 33│+ 29│+ 27│ ├────┼────┼────┤ │ 3│ 41│ 40│ │+ 33│+ 26│+ 20│ └────┴────┴────┘TryAPL.org link for
3 3 ⍴ {(⍪' +'),↑⍵}¨ (⊢⌷⍨(⊂9?⍴)) ⍸100>∘.+⍨9+⍳90yes this took ages. yes this generates 8,100 pairs to find 9 random ones just to avoid using a loop around an if/else.
2
u/Lee_Dailey [grin] Sep 19 '19
/lee wonders ... is ka-splam
insane,unsane,non-sane, orbarely won a sanity/insanity roll freaky? [grin]2
u/ka-splam Sep 19 '19 edited Sep 19 '19
Lol, I think I'm going mad spending so long trying to get this version working!
{(⍪' +'),⊃⍵}¨1↓{⍵,⍣(100>+/⊃p)⊢p←⊂9+? 89 89}⍣{6=≢⍺}⊢⍬ 16 60 56 18 29 + 72 + 26 + 30 + 68 + 64It's fun though, in a way, like Regex is fun!
If this is the first nine numbers:
⍳9 1 2 3 4 5 6 7 8 9Then this is the addition table of each one, with each one:
(⍳9) ∘.+ (⍳9) 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 11 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 13 6 7 8 9 10 11 12 13 14 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 14 15 16 9 10 11 12 13 14 15 16 17 10 11 12 13 14 15 16 17 18And this is a bitmap on that table, of all the places where 10> value shown by a 1 (true), and 0 (false):
10>(⍳9) ∘.+ (⍳9) 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0And this is the coordinates (x, y) indexes into the matrix, where the 1 values are:
⍸10>(⍳9) ∘.+ (⍳9) 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 2 1 2 2 2 3 2 4 2 5 2 6 2 7 3 1 3 2 3 3 3 4 3 5 3 6 4 1 4 2 4 3 4 4 4 5 5 1 5 2 5 3 5 4 6 1 6 2 6 3 7 1 7 2 8 1So those are all the pairs where the single digit addition would still be a single digit answer, no carrying. Smaller, simpler version.
Putting the same thing on both sides of a function can use
⍨to echo it to both sides so(⍳9) ∘.+ (⍳9)->∘.+⍨ (⍳9)and the parens don't do anything there, so they can go..Isn't there a certain regex-style novelty there?
1
u/Lee_Dailey [grin] Sep 19 '19
howdy ka-splam,
i've come to consider APL to be ... the equivalent of quantum mechanics. useful, interesting, bizarre, and a handy bit of evidence that really smart people tend to be more than slightly freaky ... [grin]
take care,
lee2
u/ka-splam Sep 19 '19
Haha, yes I'd agree with a lot of that. I'm just hoping that if I go close enough, some of their smarts' dust will rub off on me :P
1
u/Lee_Dailey [grin] Sep 19 '19
[grin]
2
u/ka-splam Sep 19 '19
It's not working yet; Adám from Dyalog came up with
9+91(⊢,-)¨?5⍴90to generate the pairs in about 3 minutes and 4 revisions, I've got a lonnggggg way to go. :D2
u/Lee_Dailey [grin] Sep 19 '19
howdy ka-splam,
i hope you are having fun with it. [grin] i do enjoy digging thru a problem ... but APL is like an especially cryptic page of egyptian hieroglyphs.
take care,
lee
4
u/AlphaSun5 Sep 21 '19
I have a 6 year old daughter who just started 1st grade. She hasn't been trying to play hooky, but she has been having a hard time with math. When I saw this I thought it was great but I needed to modify it a bit to scale down to a 1st grade level. But then I thought, maybe I can add some parameters and make it scale down OR up for different skill levels. What I ended up with is a version of this script that generates either addition, subtraction, or multiplication problems using either 1, 2, or 3 digit numbers with the ability to choose whether or not 'number carrying' is used for addition and subtraction. The updated version of the script is on Pastebin here: https://pastebin.com/aifJ2c07
I printed out a sheet for our daughter and after finishing it she asked--rather excitedly--for another one. It took her a few minutes to complete each page, but she treated it like a game and though it was cool that I could just make random math worksheets for her. So, a huge thanks, OP!
3
u/Beablebeable Sep 18 '19
I have a silly one that we use to randomly select scales for my kid to play on demand. Used it while prepping for an audition so she wouldn't get used to doing them in the same order every time.
3
3
4
2
u/nphowe Sep 18 '19
Son of OP bitterly spends 6 hours a day doing math and neglecting all other subjects. Son of OP grows up and becomes bastard STEM nerd. Son of OP subjects grandson of OP to 6 daily hours of math problems written in PowerShell Core 14.1.
2
u/ron___ Sep 18 '19
I did this in OpenOffice with various maths operations. For addition, one worksheet had one addend missing, the other had the sum missing. For subtraction, each worksheet omitted either the minuend, subtrahend, or difference. So on for multiplication and division. For division, I also made long hand problems.
2
u/Pippenz Sep 19 '19
Nice work.
My kids get so mad at me when i block one of their game sites via router.
Lawlz.
2
0
Sep 18 '19
[deleted]
9
u/mdowst Sep 18 '19
I know the day is coming that he will write the script to answer the questions I generate.
I never thought about the Read-Host to help tech him. I've tried showing him before, but he prefers to stick to Scratch Jr for now.
12
u/SSChicken Sep 18 '19
What did they do? My daughter's only 7, but Scratch has been a whole lot of fun for us to do. I imagine one day we'll get into Powershell, Python, C#, or C++ but for now Scratch does a really good job at introduction
138
u/Dev-is-Prod Sep 18 '19
Do children have an API you can interface with? This would be so much easier if so. Where do I log a change request?
On a serious note, this is brilliant.