Category Archives: computer science

Triangle Spaghetto?

So, this is an interesting question to think about…

If you were to break a piece of spaghetti randomly twice, to yield three smaller pieces, what are the chances that your three pieces would form a triangle?

spaghetto_poll.PNG

I encourage you to take some time to think about this before reading my solution.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

I had a little intuition based on the triangle inequality, which says that for any pair of sides of a triangle, their sum must be greater than the third side: a+b>c.

After making that guess, I actually tried to prove this to myself geometrically before moving to try a simulation via computer program, so I guess I’m still a mathematician at heart even though my current teaching load is all computer science courses! ūüôā

tri_spaghetto

The outer triangle, AEF, is the probability space for the spaghetto we’re talking about, assuming (without loss of generality) that the original spaghetto has length 1. The x-axis represents our (random) choice for the first break, which could be any number between 0 and 1 with equal/uniform probability.¬† Let’s call the random number chosen x*. The y-axis then represents our (random) choice for the second break, which is now constrained with an upper bound of 1-x*, based on however long our first broken piece was (thus the hypotenuse of the right triangle, y=1-x). Only two breaks (or, equivalently, random numbers) are needed, 0‚ȧx*‚ȧ1, and 0‚ȧy*‚ȧ1-x*, since the third piece is completely determined by the first two, as 1-x*-y*.

Within our probability space, the bluish-green region in the lower right is out-of-bounds for trianglehood, since an initial break of my first piece x*>0.5 would mean that I’m left with a piece less than 0.5 which still needs to be broken into two, and that means those two pieces could never sum to more than my first piece (the triangle inequality). The magenta region near the top is similarly off-limits, even if my initial break is small enough, if my second break yields a y*>0.5, the first and third pieces could never sum to more than the second. Finally, the yellow region near the bottom represents non-triangles where both the first and second breaks are two short, yielding a combined sum less than 0.5, and therefore a third/final piece greater than 0.5 which would dominate the first two and thus not allow triangularity to flourish from our three pieces of spaghetti.

So the only triangularly-valid region is the center, which is 1/4 the total area of our probability space.

After becoming certain of this answer, I did mock up a quick random number generator function in Python:

py_spaghetto

While this was indeed closer to 0.25 than any other option in the initial poll, the fact that I ran 10,000,000 trials and got consistently less than 0.2 (and not closer to 0.25) does worry me that I coded one of the assumptions wrong. I’m still 99% certain that 0.25 is the correct answer. But if anyone spots a program error, or a logic error, please let me know!

Advertisements

Leave a comment

Filed under computer science, math

PI DAY 2018!

Happy pi day!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Pi Day as a holiday is 30 years old this year¬†(unless someone had been celebrating quietly on 3/14’s before Larry Shaw publicly founded Pi Day at the San Francisco Exploratorium in 1988)!

While last year was a pi day snow day for us, this year the snow has mostly missed us in Maryland, while Boston area folks have had several huge storms in a row, and some of them do have a pi day snow day today!

The day was off to a good start this morning with a beautiful pi day sunrise:

I was up early to buy some pies, as per usual, when I stumbled across a pi-day pie sale! While I’ve seen photos of these before on social media, this is the first time I’ve actually come across one in person on a pi day myself!

 

I made my chalkboard a little busier than usual, including a few extra pi facts:

I also wore a new pi tie today (some years I’ve worn pi t-shirts). You can’t tell from the photo, but the image/pattern is made up of pi’s digits!

My first period AP CS A (Java / object-oriented programming class, with juniors and seniors) is the only class I did a pi-focused lesson with this year. In my other classes, we took a ten-minute pi and pie break, and talked about pi facts while eating, then back to our regularly-scheduled lesson. But in AP CS A, we coded an infinite series for pi in Java. We used the Leibniz formula, relatively easy to understand and code: 1/1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11 + 1/13 – …

This actually converges fairly slowly, compared to other infinite series for pi. Here are the results after ten terms, with the terms included on the left, and the running summation on the right of each line:

Here we are after 1000 iterations, just the sums:

And after a million terms, we’re getting pi accurate to five digits:

A million terms took a few minutes to run, so we didn’t dare try ten million, for fear we would break our ancient computers! Nor did we try to break the record of 22 trillion digits of pi, which would need many many times more terms if we were to use this series ūüôā

Also today, in other news, a nationwide walkout against gun violence, which students at my school participated in as well. And I took two students on a field trip; the students had built a custom-engineered bicycle for a kid with a disability last month during National Engineering Week, and today we got to deliver the bike to the kid and his mother. So that was pretty cool.

Anyway, that’s how my day went, hope your pi day was similarly awesome!

Here’s my round-up of a few Pi Links:

And a few really creative pi-related photos, found via Twitter (linked to their sources):

Leave a comment

Filed under computer science, math, teaching

CS Ed Week, Part 2

To continue with my post from 12/4, a few more emails for Computer Science Education Week 2017!

Thu 12/7: Hour of Code week almost over!

Hi Patterson peeps,

Just a reminder that we are nearing the end of Computer Science Education Week. I hope you have all had the chance to try out one of the awesome lessons yourself and with your classes (or have plans to do so today or tomorrow!).

 

I leave you with this:

Fri 12/8: Last push РHour of Code!

As Computer Science Education Week draws to a close this weekend, let me leave you with three resources, two facts, and one reminder:

Resources:

  1. A new video from code.org in which basketball star Stephen Curry talks about coding and persistence
  2. A video produced last year, called¬†“Computer Science is Changing Everything”, that really hits home that CS is found in every field, from agriculture to medicine to dance
  3. If you’re not able to do a whole hour of code, check out this¬†five-minutes-of-code¬†¬†activity¬†in which you can design your own snowflake and holiday card (with thanks to Mr. Callahan)

Facts:

  1. CS Education Week was founded in honor of Admiral Grace Hopper, one of the pioneers of computer science, whose birthday is tomorrow 12/9 (if alive, she would be 111 years old tomorrow, which is sort-of a binary age!)
  2. Coding is for everyone, in the same way writing is for everyone, a way “to organize, express, and share ideas in new ways, in a new medium” (okay, maybe that’s an opinion and not a fact, but seriously, check out¬†this interview with Mitch Resnick¬†from MIT, it may change the way you think about coding).
Reminder:
  1. Don’t forget to send me student names and have your students who do the Hour of Code¬†complete the survey!
 snow
Happy holidays, and happy coding!
Nick Yates

Finally, here’s a photo of my colleagues and I encouraging everyone to “Code Like a Girl”:

CodeLikeAGirl2.PNG

Leave a comment

Filed under computer science, teaching

Computer Science Education Week 2017

Hi all, it’s CS Education Week! Am forming a blog post of the emails I send out to my school to encourage participation in the Hour of Code. Will update this post (or maybe a new one) as I email more.

 

Thu 11/30 (before CS Ed Week):

Greetings Patterson Family!

Next week is Computer Science Education Week, and we have celebrated this each of the last several years at Patterson by having students do an Hour of Code! Please check out https://hourofcode.com/us and consider picking one day next week to teach coding in each of your classes.

 

hourofcode.com
The Hour of Code is a global movement reaching tens of millions of students in 180+ countries. Anyone, anywhere can organize an Hour of Code event.

 

There are a variety of activities, including ones that can be done on computer workstations, ones that can be done on students’ call phones / mobile devices, and ones that are “unplugged” using cups or printable manipulatives etc. Depending on your classroom dynamic, you could also work together as a whole class to complete coding exercises on your teacher computer / projector screen. Or, if you’re feeling ambitious, you could try to come up with your own lesson that relates coding to your content area, and teaches problem-solving or algorithmic thinking (e.g. peanut butter and jelly making as clear communication, necessary for ELA/writing classes and also for writing computer code that breaks a process down into multiple steps and communicates them clearly to the computer to run).

 

FYI – for our ESOL population, many (though not all) of the computer-based coding activities have instructions in multiple languages that can be adjusted at the bottom of the screen.

Please let me know if you plan to do an activity, or if you want to chat about different possibilities. For computer access, I can offer my room for second period (all days next week) or fifth period (except Monday). There may also be laptop carts available on a first-come first-serve basis that you can follow the usual process to reserve. Additionally, I am interested in tracking which activities are used, as well as student names for certificates.
Happy coding!
Nick Yates
Mon 12/4 AM: The Hour of Code is here!

Greetings Patterson Family!

CS Education Week is here, and with it the Hour of Code!

Please consider teaching a coding lesson in one of your classes this week, so that we can help our students become creators of technology rather than merely consumers of technology.

Here are some intro videos to the HoC: https://hourofcode.com/us/promote/resources#videos (YouTube + download link in case YT is blocked)

Among the¬†activities, there seem to be two new ones for this year¬†that I’ve noticed near the top: Minecraft (three versions, one from each of the past two years, plus a new tutorial for this year) and Google Design-Your-Own-Logo-with-Scratch.

You can also sort the activities by the technology you plan to use (computers, student mobile devices, or unplugged Рno devices), AND nicely by content area (e.g. if you teach Science and want to teach a cross-curricular science+coding lesson):

code_options

 

Please let me know if I can help in any way, whether by consulting with you on which lesson might best fit your class, or having you bring your class down to my room, etc.

HAPPY CODING!

Best,

Nick Yates and the Academy of Engineering and Technology Team

Mon 12/4 PM: Google Doodle today celebrates 50 years of kids coding!

Hey Patterson people,

The Logo programming language, designed for kids with a turtle that moved around and could draw pictures, was invented 50 years ago! Today’s Google Doodle celebrated that fact. In case you missed it, and want to try it out,¬†here’s a link that will still work after today is over:¬†https://www.google.com/doodles/celebrating-50-years-of-kids-coding¬†.¬†It is a cool symbol-based (no words, so should work for students of any language!) HoC-style activity within a Google Doodle, with a rabbit trying to eat some carrots. Check it out!

 

Celebrating 50 years of Kids Coding #GoogleDoodle
Also, if you’re interested, there is an actual¬†Hour of Code activity¬†based on that original turtle (updated to the Python language), which can be found at¬†https://hourofcode.com/codehsturtle
Happy CS Education Week!

NY

Tue 12/5: Hour of Code subject recommendations

If you haven’t started the Hour of Code yet because you don’t have access to a classroom set of computers and aren’t sure what coding has to do with your curriculum, here are my recommendations for unplugged subject-specific activities!

  • Science –¬†Rock Paper Scissors,¬†with connections to biological population modeling¬†(unplugged activity plus presentation on teacher screen)
  • Social Studies – History of Codes and Ciphers (one lesson, plenty more material as well e.g.¬†wikipedia)
  • Art –¬†Algorithmic Doodles¬†(fractals & algorithms)
  • Math –¬†Hexahexaflexagons¬†(geometry, discrete math w/ directed graphs and finite state machines)
  • English / Language Arts –¬†Magical Book Magic¬†(computational thinking and patterns with words)

If any English teachers do have access to a set of computers, the Automatic Homework Excuse Generator looks pretty cool too!

Happy coding,

Nick Yates & the AOET Team

1 Comment

Filed under computer science, teaching

Number Systems

Binary and hexadecimal today in AP CSP:

binary.jpg

hex.jpg

When I was in elementary school, I was fascinated with number systems. I know I read about some different number systems used by different cultures through history in a book of number history my parents had, and was also inspired by some discussion of binary / ternary / base-4 in The Math Curse. I asked my mom to explain them, and she did.

Somehow (I forget the source, if it was a news article or an “interesting fact” in some book), I got really into the Inupiaq number system, both the symbols and the base-20 place value system for writing them. I remember writing the date in the upper right-hand corners of my papers using Inupiaq numerals each day in Mrs. McCarthy’s 4th grade class (or was it 6th grade? — she was my teacher both those years).

Always lots of fun teaching number systems! One of my favorite topics. ūüôā

#day16 #apcsp #teach180 #180blog

Leave a comment

Filed under computer science, math, teaching

Planning In Code

One of the skills I work with students on in many of my classes is how to plan to code, in a helpful and efficient way. This is true certainly in my computer science classes but also in my Principles of Engineering (POE) and Computer Integrated Manufacturing (CIM) classes as well. Pseudocode, flow charts, process flow diagrams, are all structures and formats I have used before with students, with varying degrees of success.

This year, with Advanced Placement Computer Science A (AP CSA), I definitely plan to use several of the UML diagram formats with Java coding. Certainly class diagrams (like this one I posted last week) fit very well with an object-oriented language like Java. The course I took this summer on the Software Development Process, and especially our group project there, helped me understand several of the UML formats in a deeper way; I can definitely see myself using the Use Case and perhaps Sequence diagrams as well.

Anyway, today I worked with my AP CSA students to develop a few less-formal diagrams on the board: We did some mind mapping together as we brainstormed attributes or variables with values that would apply to weather (for a weather app):

weatherAttributes.jpg

And then we did the beginning of a decision tree:

weatherConditionals.PNG

My engineering students are using a planning table on paper to plan out their G&M-codes they will use to control the CNC milling machine to carve out their initials.

And my AP CS Principles students haven’t gotten deep enough into code yet to use a planning template. We have done some coding using Python as a calculator and to draw pictures (turtle library), and to play interactively against the “intelligent paper”. But most of our time so far has been discussing computing innovations, their impact on society, and working on a research presentation.

After school today, I had students stay for CyberPatriot practice, and it was also the first day of Interactive Mural Lab, led by some folks from MICA, which will help coach some students to creative a computer-programmed, electronics-infused, creative mural on a wall of our school! I’m super-excited to watch their progress over the course of this year, both to see how the mural turns out, and to see what skills and techniques students will learn as a part of this project.

Phew – I’m exhausted just writing about all that! ūüôā¬† Have a good evening.

#day15 #180blog #teach180

Leave a comment

Filed under computer science, teaching

Team meetings

One of the things we’ve tried to do over the years is to meet as an engineering department once a week, every Friday. There are so many things to discuss and work on, from field trips, to after-school clubs, to purchasing equipment & materials, to recruiting students into the pathway. Some years that has not been possible, if we don’t have the same planning period, so we would just grab a few minutes here and there (perhaps after the school day was over). Other years we kept it less formal, since my colleagues and I would constantly be having meetings and working together every day.

This year, we brought back the tradition, stronger than ever:

team_mtg

Five of us, from engineering, computer science, and entrepreneurship, on the Academy of Engineering and Technology (AOET) team. Go team!

Another thing that has kept us strong over the years is support from teachers at other schools (unlike a math department, nine-strong at a school the size of Patterson, most engineering schools only have 1-2 engineering teachers at each school) and from industry and higher education. We meet once a month with our Program Advisory Committee (PAC), which supports and advises the seven Baltimore City high schools with PLTW Engineering programs. We had our first PAC meeting of the new school year yesterday (Monday) afternoon at OpenWorks. This year, one of our main foci is going to be pipeline development, including strengthening connections with middle schools and with colleges/universities.

Later this week, on Thursday, Code in the Schools will host our first monthly Professional Learning Community (PLC) meeting with Baltimore City computer science teachers.

[Days 9-10 #180blog]

Leave a comment

Filed under computer science, engineering