<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.7.3">Jekyll</generator><link href="https://danielfrentzel.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://danielfrentzel.github.io/" rel="alternate" type="text/html" /><updated>2018-08-07T18:51:08+00:00</updated><id>https://danielfrentzel.github.io/</id><title type="html">Daniel Frentzel</title><subtitle>Portfolio</subtitle><entry><title type="html">Hand build 20x10 LED display with Tetris</title><link href="https://danielfrentzel.github.io/blog6/" rel="alternate" type="text/html" title="Hand build 20x10 LED display with Tetris" /><published>2018-08-02T00:00:00+00:00</published><updated>2018-08-02T00:00:00+00:00</updated><id>https://danielfrentzel.github.io/blog6</id><content type="html" xml:base="https://danielfrentzel.github.io/blog6/">&lt;p&gt;As part of an embedded systems class, we were instructed to create a project powered by an Arduino or Raspberry Pi, using various electrical components, to display competence in the class material. A classmate, Brendan, and I decided to create a display using individual LEDs with the goal to implement a game of Tetris. In order to power the classical 20x10 Tetris display, we needed a way to wire and control 200 LEDs with less than 30 general-purpose input/output, GPIO, pins on the Raspberry Pi. Little did we know that the final project would employ 4 breadboards and 350 hand cut wires.&lt;/p&gt;

&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://danielfrentzel.github.io/static/display1.jpg&quot;&gt;
    &lt;img src=&quot;https://danielfrentzel.github.io/static/display1.jpg&quot; alt=&quot;display1&quot; /&gt; 
&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Project Design&lt;/h2&gt;
&lt;p&gt;After discussing ideas, we realized that by connecting LEDs across the rows and LEDs down the columns together, that a coordinate-like system could be achieved. Since LEDs need a voltage differential to flow, by supplying 0v to column, x, and 5v to row, y, the LED at coordinate x, y can be illuminated. This method works great as long as only a single LED is illuminated at a time. A list of LEDs that need to be illuminated will be iterated through, flashing every LED on, then off, to appear as multiple LEDs are on at the same time. This idea alone requires only 30 GPIO pins, but that number still needs to be reduced.&lt;/p&gt;

&lt;h3&gt;Demultiplexers&lt;/h3&gt;
&lt;p&gt;Our professor, Dr. Andy Keck, introduced the idea of multiplexer chips. Demultiplexers can be used to take n, number of inputs, to power 2&lt;sup&gt;n&lt;/sup&gt; output chips. Using demultiplexers allows us to use 5 GPIO pins to control the 20 rows and 4 pins to account for the 10 columns. Due to our particular situation, we chose to use 5 pins to control the columns to prevent the first led from defaulting to the on position while keeping zero based indexing in the software. Ultimately, this reduced the number of required GPIO pins from 30 to a very manageable 10.&lt;/p&gt;

&lt;h3&gt;Getting It Done&lt;/h3&gt;
&lt;p&gt;As it turns out, 5 to 32 pin demultiplexers are not readily available, but a 2 to 4 used with three 3 to 8 demultiplexers can be used together to achieve 32 output pins. This works by using the highest two binary inputs to supply the 2 to 4 chip to enable a single 3 to 8 chip, while the lowest three binary inputs supply input to every 3 to 8 chip. Below, on the left, is a diagram of how to columns are controlled with one 2 to 4 chip and two 3 to 8 chips. The same logic is used for the rows. It is worth mentioning that our demultiplexers send low to the selected output pin and high to the rest. While this is ideal for controlling the columns, it means that the demultiplexer outputs going to the 3 to 8 chips and to the rows need to be inverted. While we didn’t have inverters on hand, we were able to make them using transistors. This can be seen in the top right quadrant of the project, inverting the voltage from the demultiplexers to the rows, and above the 2 to 4 chip at the bottom of the third breadboard. It is also worth noting that our 2 to 4 chip is actually two 2 to 4 chips in one, so it’s output is wired, through inverters, to the enable pins on the 3 to 8 chips for both the rows and columns.&lt;/p&gt;

&lt;div class=&quot;row&quot;&gt;
    &lt;a target=&quot;_blank&quot; href=&quot;https://danielfrentzel.github.io/static/selector_columns.png&quot;&gt;
        &lt;img src=&quot;https://danielfrentzel.github.io/static/selector_columns_crop.png&quot; alt=&quot;display_diag&quot; width=&quot;440&quot; /&gt;
    &lt;/a&gt;
    &lt;a target=&quot;_blank&quot; href=&quot;https://danielfrentzel.github.io/static/display_diag.png&quot;&gt;
        &lt;img src=&quot;https://danielfrentzel.github.io/static/display_diag_crop.png&quot; alt=&quot;display_diag&quot; width=&quot;250&quot; /&gt;
    &lt;/a&gt;
&lt;/div&gt;

&lt;h3&gt;LED Wiring&lt;/h3&gt;
&lt;p&gt;In order to connect the rows and columns in series, a lot of individual wires needed to be cut. Luckily, we were able to plug in 2x3 grids of LEDs to share appropriate power and grounds. Wires were then cut to jump each grid, connecting the whole display, detailed in the wiring diagram above on the right. The forest of wires responsible for this is hidden underneath the LEDs.&lt;/p&gt;

&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://danielfrentzel.github.io/static/display2.jpg&quot;&gt;
    &lt;img src=&quot;https://danielfrentzel.github.io/static/display2.jpg&quot; alt=&quot;display2&quot; /&gt; 
&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;p&gt;The library, driver.py, is responsible for communication between the Raspberry Pi and the display board. It’s responsible for setting up the GPIO pins, changing the illumination state of LEDs, and cleaning up the GPIO ports. The game, tetris.py, is responsible for running the Tetris game, responding to the buttons, and telling driver.py which LEDs to illuminate.&lt;/p&gt;

&lt;p&gt;Here is Brendan playing Tetris, with the controller, and the rest of the project assembled.
&lt;a target=&quot;_blank&quot; href=&quot;https://danielfrentzel.github.io/static/display_tetris.jpg&quot;&gt;
    &lt;img src=&quot;https://danielfrentzel.github.io/static/display_tetris.jpg&quot; alt=&quot;display_tetris&quot; /&gt; 
&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Closing Thoughts&lt;/h2&gt;
&lt;p&gt;Although this project involved a lot more time and effort than we had expected, it was an extremely rewarding and fun project that I will never forget. We joked about this being our prototype, as we thought about improvements like building the demultiplexers ourselves. With that being said, I believe we were close to the limits with this project. We noticed a small amount of ghosting, stray LEDs faintly being lit, on the display, which we believe were caused by the hand built inverters. Also, when the display starts to fill up, the flashing of the LEDs becomes noticeable to the viewer. Of course this project could have been accomplished with a custom circuit board, LED strips or even a LCD display, but we fancied the idea of building everything that we could, embracing the retro design and spending countless hours sticking over 1300 wires into breadboards.&lt;/p&gt;

&lt;p&gt;Thanks for checking out our project!&lt;/p&gt;

&lt;h2&gt;Project Links&lt;/h2&gt;
&lt;p&gt;Check out the &lt;a href=&quot;https://github.com/MystiriodisLykos/Ercinee&quot; target=&quot;_blank&quot;&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">As part of an embedded systems class, we were instructed to create a project powered by an Arduino or Raspberry Pi, using various electrical components, to display competence in the class material. A classmate, Brendan, and I decided to create a display using individual LEDs with the goal to implement a game of Tetris. In order to power the classical 20x10 Tetris display, we needed a way to wire and control 200 LEDs with less than 30 general-purpose input/output, GPIO, pins on the Raspberry Pi. Little did we know that the final project would employ 4 breadboards and 350 hand cut wires.</summary></entry><entry><title type="html">Boids Flocking Simulation</title><link href="https://danielfrentzel.github.io/blog4/" rel="alternate" type="text/html" title="Boids Flocking Simulation" /><published>2018-07-11T00:00:00+00:00</published><updated>2018-07-11T00:00:00+00:00</updated><id>https://danielfrentzel.github.io/blog4</id><content type="html" xml:base="https://danielfrentzel.github.io/blog4/">&lt;p&gt;This project consists of independent bodies, boids, acting on certain characteristics to simulate the nature of a flying flock of birds. A world is created and boids are given three desires to fly based on Craig W. Reynolds paper, “Flocks, Herds, and Schools: A Distributed Behavior Model.”&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Collision Avoidance: The desire to avoid collisions with nearby boids&lt;/li&gt;
  &lt;li&gt;Velocity Matching: The desire to fly at the same speed as nearby boids&lt;/li&gt;
  &lt;li&gt;Flock Centering: The desire to stay towards the center of the flock&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The desires are accomplished with object oriented programming, creating objects for boids, flocks, and behaviors. Each boid belongs to a flock that knows every boid within the flock and computes a distance matrix between the boids of the flock. Although boids could do this on their own, it is more efficient for the flock to calculate this each tick. Boids are also given a behavior that uses algorithms to tell the boid where to move based on its three desires. A point class is used for 3-D coordinates to hold locations and vectors. The point class overrides operators so point objects can be added, scaled, etc. and contains functions to calculate distance, magnitude and to normalize vectors. Each tick, the flock is told to update, telling every boid to move, which asks its behavior where to move and moves the boid, and then flock updates the distance between all the boids.&lt;/p&gt;

&lt;h2&gt;Realistic Animation:&lt;/h2&gt;
&lt;p&gt;Parameters are used to weigh the importance of all three desires of the boids. After trial and error, parameters were found to create a decent flying simulation of a flock of birds.&lt;/p&gt;
&lt;video width=&quot;720&quot; height=&quot;405&quot; controls=&quot;&quot;&gt;
  &lt;source src=&quot;../static/boid_goodex.mp4&quot; type=&quot;video/mp4&quot; /&gt;
Your browser does not support the video tag.
&lt;/video&gt;

&lt;h2&gt;Unrealistic Animation:&lt;/h2&gt;
&lt;p&gt;The following is an example of an animation where the parameter on the flock centering is too high. Notice that the boids lose their sense of direction and all repeatedly fly towards the center.&lt;/p&gt;
&lt;video width=&quot;720&quot; height=&quot;405&quot; controls=&quot;&quot;&gt;
  &lt;source src=&quot;../static/boid_badex.mp4&quot; type=&quot;video/mp4&quot; /&gt;
Your browser does not support the video tag.
&lt;/video&gt;

&lt;h2&gt;Other&lt;/h2&gt;
&lt;p&gt;While this was part of a group project, I was not involved in the development on the world, graphics, or GUI anymore than to make sure flock objects were being initialized and called correctly. The goal for this project was to create object avoidance and multiple behavior algorithms before running out of time.&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href=&quot;https://github.com/WSCU/boids&quot; target=&quot;_blank&quot;&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">This project consists of independent bodies, boids, acting on certain characteristics to simulate the nature of a flying flock of birds. A world is created and boids are given three desires to fly based on Craig W. Reynolds paper, “Flocks, Herds, and Schools: A Distributed Behavior Model.”</summary></entry><entry><title type="html">Song Year Prediction on the Million Song Dataset</title><link href="https://danielfrentzel.github.io/blog2/" rel="alternate" type="text/html" title="Song Year Prediction on the Million Song Dataset" /><published>2018-07-01T00:00:00+00:00</published><updated>2018-07-01T00:00:00+00:00</updated><id>https://danielfrentzel.github.io/blog2</id><content type="html" xml:base="https://danielfrentzel.github.io/blog2/">&lt;p&gt;The sound of music has changed throughout the past century and continues
to change. The Million Song Dataset collects song features from popular
contemporary songs ranging from 1922 to 2010. By using the sound characteristics of songs, this project applies linear regression models, namely ordinary
least squares and ridge regression, to the segments pitches and segments timbre
features found in the dataset. These features are used to build a model matrix
of predictors and to predict song release years using residual sum of squares
and leave-one-out cross-validation.&lt;/p&gt;

&lt;h2&gt;Technologies&lt;/h2&gt;
&lt;p&gt;The project is programmed in Python using various libraries. NumPy is used to store data in narrays, compute covariance matrices for song data and for general computing. Pandas is used to create data frame structures for analysis, which are pickled as fast, serialized files that can easily be reloaded. Scikit-learn does the heavy lifting by supplying the machine learning models while Matplotlib graphs the results.&lt;/p&gt;

&lt;h2&gt;Song Year Predictions&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://danielfrentzel.github.io/static/hist.png&quot; alt=&quot;histogram&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The correct year is predicted for songs more often than any other year. The model is able to predict 75% of songs within a decade and 45% of songs within 5 years of their actual release year. The histogram is skewed right, representing more over predictions by the model. If the model is trusted, these over predictions contain songs that are futuristic. Further work can be done to analyze futuristic song patterns to shed light on future music trends and the characteristics that make future throwback songs.&lt;/p&gt;

&lt;h2&gt;Project Links&lt;/h2&gt;
&lt;p&gt;View my full research &lt;a href=&quot;../static/MLSSpaper.pdf&quot; target=&quot;_blank&quot;&gt;paper&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&quot;https://github.com/danielfrentzel/song-year-predictions-msd&quot; target=&quot;_blank&quot;&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">The sound of music has changed throughout the past century and continues to change. The Million Song Dataset collects song features from popular contemporary songs ranging from 1922 to 2010. By using the sound characteristics of songs, this project applies linear regression models, namely ordinary least squares and ridge regression, to the segments pitches and segments timbre features found in the dataset. These features are used to build a model matrix of predictors and to predict song release years using residual sum of squares and leave-one-out cross-validation.</summary></entry><entry><title type="html">Dynamic Virtual Tour of Crested Butte</title><link href="https://danielfrentzel.github.io/blog5/" rel="alternate" type="text/html" title="Dynamic Virtual Tour of Crested Butte" /><published>2018-06-14T00:00:00+00:00</published><updated>2018-06-14T00:00:00+00:00</updated><id>https://danielfrentzel.github.io/blog5</id><content type="html" xml:base="https://danielfrentzel.github.io/blog5/">&lt;p&gt;This project consists of a Flask website running off of an Sqlite server. The tour consists of pins on a map to mark locations and pictures that are uploaded corresponding to the pin. Pins have already been placed on the tour so users can visit and interact with the &lt;a href=&quot;http://danielfrentzel.pythonanywhere.com/&quot; target=&quot;_blank&quot;&gt;website&lt;/a&gt;. Everything is stored in a database and dynamically loaded so users can add their locations and pictures to the virtual tour.&lt;/p&gt;

&lt;p&gt;Information on how to use the website and understand the underlying technologies can be found in the documentation link below.&lt;/p&gt;

&lt;h2&gt;Project Links&lt;/h2&gt;
&lt;p&gt;Visit the &lt;a href=&quot;http://danielfrentzel.pythonanywhere.com/&quot; target=&quot;_blank&quot;&gt;full website&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://danielfrentzel.github.io/2017-VT-CS350/&quot; target=&quot;_blank&quot;&gt;Documentation&lt;/a&gt; for using the website&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&quot;https://github.com/danielfrentzel/2017-VT-CS350&quot; target=&quot;_blank&quot;&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">This project consists of a Flask website running off of an Sqlite server. The tour consists of pins on a map to mark locations and pictures that are uploaded corresponding to the pin. Pins have already been placed on the tour so users can visit and interact with the website. Everything is stored in a database and dynamically loaded so users can add their locations and pictures to the virtual tour.</summary></entry><entry><title type="html">StartPy Game Object Library</title><link href="https://danielfrentzel.github.io/blog3/" rel="alternate" type="text/html" title="StartPy Game Object Library" /><published>2018-04-23T00:00:00+00:00</published><updated>2018-04-23T00:00:00+00:00</updated><id>https://danielfrentzel.github.io/blog3</id><content type="html" xml:base="https://danielfrentzel.github.io/blog3/">&lt;p&gt;For this project I was asked to maintain a pygame library for a fun, introductory class to game programming. The objective of the StartPy library is to create an easy to use interface for first time programmers to create simple games such as pong. I was responsible for developing, maintaining, and testing compound objects (multiple objects being added together as one object), labels, buttons, backgrounds and more, mostly dealing with the GObj.py file.&lt;/p&gt;

&lt;p&gt;An example of a basic demonstration using various game objects is shown below. The code is basic and straight-forward to read, as intended by the StaryPy library. A video is also shown of the script being run.&lt;/p&gt;

&lt;h2&gt;Example Code&lt;/h2&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;StartPy&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;cir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Circle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BLUE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'img.jpg'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;350&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;btn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Click to start'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GRAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BLACK&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;135&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;lab&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BLACK&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Demo is running...'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;btn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sendToBack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;waitForClick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;btn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;cir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pause&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collides&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;comp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cir&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;comp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setVisible&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;comp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;pause&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;comp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;run&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;lab&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Demo is completed!'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2&gt;Running the Example Code&lt;/h2&gt;
&lt;video controls=&quot;&quot;&gt;
  &lt;source src=&quot;../static/startpy_demo.mp4&quot; type=&quot;video/mp4&quot; /&gt;
Your browser does not support the video tag.
&lt;/video&gt;

&lt;p&gt;Check out the &lt;a href=&quot;https://github.com/danielfrentzel/startpy-object-library&quot; target=&quot;_blank&quot;&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">For this project I was asked to maintain a pygame library for a fun, introductory class to game programming. The objective of the StartPy library is to create an easy to use interface for first time programmers to create simple games such as pong. I was responsible for developing, maintaining, and testing compound objects (multiple objects being added together as one object), labels, buttons, backgrounds and more, mostly dealing with the GObj.py file.</summary></entry><entry><title type="html">Sum of Even Fibinici Terms</title><link href="https://danielfrentzel.github.io/blog1/" rel="alternate" type="text/html" title="Sum of Even Fibinici Terms" /><published>2017-12-22T00:00:00+00:00</published><updated>2017-12-22T00:00:00+00:00</updated><id>https://danielfrentzel.github.io/blog1</id><content type="html" xml:base="https://danielfrentzel.github.io/blog1/">&lt;p&gt;The Fibinici sequence is renowned for its golden ratio that is found throughout our world. It starts with the first two terms as 1 and is formed with each subsequent term being the sum of the two previous terms (1, 1, 2, 3, 5, 8, 13,…). Suppose one wanted to know the sum of every even term less than 4 million. While the solution is straight forward, a little cleverness can be used to improve efficiency.&lt;/p&gt;

&lt;p&gt;Since the first two terms of the sequence are given, we can start the sequence as a list and build the rest of the terms less than 4 million&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# add the next term, the sum of the previous two terms&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;At this point our list, &lt;code class=&quot;highlighter-rouge&quot;&gt;f&lt;/code&gt;, holds all the Fibinici terms less than 4 million. Finding the sum of the even terms is easy enough. A comprehension can be used to get the even terms and the built in &lt;code class=&quot;highlighter-rouge&quot;&gt;sum&lt;/code&gt; operator can sum the list&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;term&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;term&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;term&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;We have answered the question, but do we really need to append each term and hold onto the entire sequence? After all, we are just summing the even terms.&lt;/p&gt;

&lt;p&gt;Let’s try to do this on the fly by only holding two values, starting with our initial list. When we compute the next term, we will update the held values so that the second value is the current term and the first value is our previous term. The two terms in our list always tell us how to compute the next term in the Fibinici sequence. You can think of the two held values as your view of the whole sequence, through a window only two terms wide. Every update to our held values, shifts our view, once, down the sequence.&lt;/p&gt;

&lt;p&gt;Notice, since we aren’t holding the entire sequence, we can’t use the &lt;code class=&quot;highlighter-rouge&quot;&gt;sum&lt;/code&gt; operator. Instead, the sum is held in &lt;code class=&quot;highlighter-rouge&quot;&gt;sum2&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sum2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;# update the held values&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;sum2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Notice the subtlety in python’s ability to return multiple values. Since &lt;code class=&quot;highlighter-rouge&quot;&gt;f[0]&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;f[1]&lt;/code&gt; are both computed before being assigned, there is no need for a place holder variable.&lt;/p&gt;

&lt;p&gt;Admittetly, the computational difference in this example is negliable, but as the size of the list grows, avoiding the append operator becomes more important.&lt;/p&gt;</content><author><name></name></author><summary type="html">The Fibinici sequence is renowned for its golden ratio that is found throughout our world. It starts with the first two terms as 1 and is formed with each subsequent term being the sum of the two previous terms (1, 1, 2, 3, 5, 8, 13,…). Suppose one wanted to know the sum of every even term less than 4 million. While the solution is straight forward, a little cleverness can be used to improve efficiency.</summary></entry></feed>