Common Core Math Vs Old Math In PHP

Love it or hate it, Facebook brings out the passion in people. People get unfriended and feelings get hurt. There’s no better way to experience it than to post an opinionated political viewpoint. Still, politics are far from the only fuel for these fires. Recently, I’ve seen heated discussions about Common Core Math, a relatively newer way to approach learning math principles. Some of the concepts seem, on the surface, to be a big, crazy departure from the concepts many of us learned as children and that’s what I’ve seen most of the noise about. In some instances, friends share an image from an angry parent whose child’s math solution was marked incorrect because the common core methods were not applied. In other cases, frustration is voiced because it appears that the new methods are actually worse than the old ones. Whatever side you’re on, be sure to open your mind to learning new things and making your own mind up.

I’m still on the fence, so as a software engineer, I decided to throw ones and zeros at the problem and see what stuck. In this case, I decided that the problem I wanted to solve would be to determine which method might be faster for subtracting numbers. The “old way”, as seen on the left in the image below, involves lining up your numbers and borrowing from the next digit to the left as you subtract each digit on the bottom from the one on the top. The new way involves essentially rounding up the number you’re subtracting until it matches the number you’re subtracting from and adding all the numbers you had to use to round up in order to get to the difference. The simplest explanation I saw for this was 9 minutes into this video, in which the teacher describes the process of counting change back to a customer at a cash register.

ccmath

To solve my problem, I used PHP to try to mimic the process we go through as humans to subtract one number from another. I programmed functions for the old and new ways to solve a subtraction problem and added code to time each and loop lots of times to create a more visible comparison. The Commmon Core math in PHP code is on GitHub for anyone who would like to try it out or improve it and below are some example results.

1,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 0.0071358680725098 seconds
Total time for the new way : 0.01004958152771 seconds

100,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 0.71134495735168 seconds
Total time for the new way : 0.97455978393555 seconds

1,000,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 6.9777636528015 seconds
Total time for the new way : 9.8461444377899 seconds

100 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 0.00092959403991699 seconds
Total time for the new way : 0.0014877319335938 seconds

100,000 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 1.0502970218658 seconds
Total time for the new way : 1.6906788349152 seconds

1,000,000 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 22.028552055359 seconds
Total time for the new way : 34.783274650574 seconds

It’s worth noting that computers and the human brain work in very different ways. This experiment is not intended to prove anything either way, nor is it intended as scientific data in the slightest. It’s merely an experiment on the process and I welcome discussion and open-minded debate in the comments.

How To Black Out Your Site In Three Easy Steps

Earlier this week, thousands of sites, including JoeTech.com, blocked or hid their content as a symbolic gesture to protest the impending SOPA/PIPA legislation that threatened the integrity of free-flowing information on the Internet. While some sites displayed a pop-up message allowing users to move on to content by clicking a button and Google simply changed their logo to appear censored, sites like Wikipedia and Joe Tech completely blocked all content from users to truly emphasize the impact such legislation could cause. An example is seen below. This post will show you how we did it in just a few very easy steps.

sopadark

Black Out Your Site Like Wikipedia

This site and Wikipedia both used a pretty harmless method to block our content for the protest. The method we used involved simply covering up the normal content with a layer of HTML that hides it and shows something else in its place. To accomplish this in an elegant way, you will need an image and/or content to display, the HTML shown below, and a small change to your site’s CSS. Here’s how it’s done:

1. Create your image and content. In my case, I made a couple very simple changes to a large version of my logo image to make it more protest-y.

2. Add the overlay code. In your site’s template (or your theme’s footer.php in WordPress), copy the code below and paste it right above the /body tag. Modify it as indicated to include your own image or message.


<div style="position:absolute;left:0px;top:0px;
width:100%;height:100%;
background:url(/images/darken.png);text-align:center;">
<!-- Add your image and message below this line -->
<img src="/images/sopa.png" />
<!-- Add your image and message above this line -->
</div>

Here’s the background and content images I used.

3. Stop the scroll. Update your site’s CSS file to stop the original content from being larger than the new overlay content. This may not always be necessary, but will be pretty obvious when it is. Just add the following code anywhere to the bottom of the CSS:


body{overflow:hidden;}

That’s it! Follow the three steps above and you’ll have your protest/maintenance/special message up in no time on every page on the site.