Monday, November 24, 2014

Changes 11/21/14

Ruby:

  • Installed Ruby on Rails to my Ubuntu VM


EIMACS:

  • Read more about selection sort

Thursday, November 20, 2014

Changes 11/20/14

Web design:

Wednesday, November 19, 2014

Changes 11/19/14

Java:

Website:

Tuesday, November 18, 2014

Changes 11/18/14

EIMACS:

  • Took EIMACS test 18, which was on binary and sequential sorts
  • I'm finding that the tests put a lot of focus on being able to work through these obscure, pointless algorithms for no clear reason other than to jump through their hoop to get the answer.
  • For example:
  • What is the value returned by the line newsearch( new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 9 )?
  •   public static int newsearch( int[] a, int t ) 
      { 
        int n = (a.length - 1) / 2; 
        int k = 0; 
        while ( true ) 
        { 
          for ( int j = 0 ; j < a.length ; j += n ) 
          { 
            k++; 
            if ( t == a[ j ] ) 
            { 
              return k; 
            } 
          } 
          n--; 
        } 
      }
  • And my approach for solving it:
  • What does this even do?  Why would you ever want to do this??  They make these complex algorithms for no reason!  The only thing they are testing is my patience by making me work through each iteration, not my knowledge of searches.

Monday, November 17, 2014

Changes 11/17/14

I didn't like this:
public boolean equals( Object o )
  {
    return compareTo( (Item)o ) == 0;
  }
Strictly speaking, by overriding the equals method in this way we are violating the general contract for equals, which is required never to throw an exception. The usual way to avoid this uses theinstanceof operator (which is not part of the Advanced Placement Java subset):
  public boolean equals( Object o )
  {
    return ( o instanceof Item ) &&
             ( compareTo( (Item)o ) == 0 );
  }

EIMACS:

  • I don't like this because you would never, ever want to use the first implementation of equals.  Even though they make a note of this, it shows that the philosophy for their curriculum is out of touch with reality.
  • Since the AB exam is no longer a thing, eimacs really needs to update their curriculum to stop focusing on the Collegeboard's curriculum.  Operators like instanceof are important in Java, and acting like they don't exist is just plain stupid.  I wish they would just teach instanceof once so they don't have to make a special case every time instanceof is necessary for solving a problem.

  • Learned more about binary search, and wrote my own, which was kind of tough because I knew roughly what it should look like but forgot what the midpoint should be set to on each iteration.
  • I had mid = (high - low) / 2, when it should actually be low + (high - low) / 2, or (high + low) / 2
  • Learned that a binary search runs in O( log2n )

Changes Weekend 11/14 to 11/16

Java:

  • Fixed the problems I was having with getting different counts in different Pythagorean Triples algorithms run on the same data set.  What I realized was that the non-hash algorithms would count a Pythagorean Triple for each valid C value if there was more than one, while the hashed algorithm would not.  For example, in the set {3,4,5,5}, the O(n3) algorithms would find 2 triples in this set, while the hashed algorithm would find one.  To remedy this, I set the O(n3) algorithms to break once a C value had been found.
  • Created a program that tests the average run times for various implementations of the Pythagorean Triples program with n=1000
  • Timings:
    Strategy UMD solution: 115 ms.
    Strategy UMD solution with Math.pow: 984 ms.
    Strategy UMD solution with pre-squared array: 78 ms.
    Strategy pre-squared with hash: 6 ms.
  • The accuracy of this measurement could probably be improved if I had used something more accurate than System.currentTimeMillis(), but as it is it illustrates how much faster using a hash is than any other implementation.

Web Design:

  • I made a website over the weekend: tommywiseau.github.io
  • It's a tribute to the movie The Room, written and directed by Tommy Wiseau
  • It's essentially like a soundboard, but for videos.  Left clicking one of the video buttons will play the video, and right clicking will toggle looping on the video.
  • If you click Tommy Wiseau's face in the top left, it plays a recording of one of the many times Tommy Wiseau laughs awkwardly.
  • If you don't like hearing bad words, make sure to click the "toggle NSFW" button!
  • Additionally, if you want to be taken on a magical cinematic experience, press the "Play all" button.

Friday, November 14, 2014

Changes 11/14/14

UMD Programming Contest / Java:

  • At NSF Kevin and I started working on a way to benchmark the efficiency of the various algorithms used to find Pythagorean triples.
  • We are testing UMD's base solution, their solution with Math.pow used to square the arrays, their solution with a pre-squared array, and Kevin's solution with a pre-squared array and hash.
  • The program runs, but Kevin's solution finds a different number of triples than the other three strategies.  For example: count 1619 did not equal lastCount 1454 for strategy: pre-squared with hash
  • I'm not sure the best way to go about debugging this, I'll work on it on Monday.