Skip to main content

Posts

Diary

First day as a TA at Coding Dojo Worked up through the automated testing portion of the Django official tutorial Didn't have time to do any algorithms -- learned about a path-finding problem (2D array represents connections between nodes -- determine whether there is a path from A to B for arbitrary A and B) e.g. for nodes A, B, and C [ [0, 1, 0] , [0 , 0, 1], [0, 0, 0] ] First entry says A is connected to B, second that B is connected to C -- so there's a path from A to C. The connection relationship is not robust.  A can be connected to B without B being connected to A.  It must however in some sense give rise to another relationship that is at least transitive.  If A and B are connected, and B and C are connected, then I can get from A to C.  This does not mean, however, that I can get back from C to A. Initial thought was do something with recursion.  Too complicated.  And what if you have loops?  Now it seems you just need a way to trans...

How To Get More Out Of Tutorials

We all follow tutorials.  Coming up with an idea for a new app, including the scaffolding and the specific functionality, is hard.  Struggling through something on your own can be valuable and helps you internalize it, but you also risk "reinventing the wheel" if you fail to take advantage of the resources and experience available from those who have "done it before."  Tutorials help you work through an ambitious project step by step and "learn while doing."   But blindly copying someone else's code without knowing why you are doing what you are doing can severely limit your learning.  Use the following steps to get the best of both worlds -- a dedicated teacher who will guide you every step of the way through the app you want to make AND a system that will hold you responsible for what you learn and help you to internalize it so that you can generalize specific steps for future pet projects (or work assignments). 1. Pause The Tutorial Pause t...

Starting A New Project In Django

Purpose What follows are streamlined notes following Django's web app tutorial . Project Assuming that you have Python and Django installed and, if needed, are running the appropriate environment, you begin a project by navigating to the desired project directory and running the command django-admin startproject <project name here>  This creates a directory for your project with the basic file structure. App A Django app encapsulates some site function (e.g. registration). To create a Django app, run the following command in the directory where you want to implement it: python manage.py startapp <app name here> As of Django 2, it appears that the app is automatically registered with the setup (settings.py), saving time. Errata.   Above I stated that an app does not need to be "installed" in Django 2.  This is not correct.  To install an app (necessary for using app models), add <app name>.apps.<app name>Config (e.g. Example...

Implementing A Queue With An Array

I'm working on coding an array implementation of a queue in Java.  The implementation should have the following features: The array has a head  which marks the item least recently inserted. The array has a tail  which marks* the item most recently inserted. Enqueue() adds an item to the tail of the array. Dequeue() removes an item from the head of the array. The array will resize()  dynamically as it gets too small or too large. Size()  returns the size of the queue from head to tail. IsEmpty()  returns whether or not the queue contains anything at all. You start out by initializing an empty array.  It looks like this: [0]  null  (head / tail) So at the beginning, the head is set to zero.  I guess the tail can also be zero.  Then you enqueue. [0] "To" (head / tail) So the first time you try to enqueue, the head is null.  Fill the head.  Now you want the tail to move up.   H...

Diary

Morning: reviewed and implemented an example of a stack based on the linked list data-type.  Learned about inner classes in Java. Afternoon: spent time talking with and helping other students.  Began working on a React implementation of Minesweeper (it was only yesterday that I figured out how to actually play the game!) Evening: went to a talk on GraphQL. Article: make a list of all the technologies you know, organized by category, then cross out the ones you aren't interested in -- BUT those technologies become "R&D" -- the industry keeps working on them, even if you don't, and eventually the fruits of its labors redound (word choice?) to the technologies you are familiar with.  The next implementation of JavaScript will incorporate whatever is good in Elm, even if you never get a chance to study Elm.  (Everything is connected and at some level everything is the same -- same concepts, similar problems.  Similarities before differences.) Goals: We...

Working Through The Efficient Three Sum Algorithm

This morning I spent an hour or so working on recreating the Three Sum algorithm in Java (I know because, for the sake of motivation, I timed myself).  I wanted to recreate the solution suggested in the class I'm following: go through all the possible pairs in the array and select, from the remaining values, all elements that sum to zero when added together with the pairs[1] -- using binary search. That's the solution that takes you from O(n^3) to O(n^2 log n) -- if I'm getting the notation right.  Because binary search for N elements is a log N algorithm: if you look through N elements by dividing them into halves, you can do that at worst log N times.  (8 elements = 2 halves of 4 elements = 4 parts of 2 elements = 8 singletons, or 8 => 4 => 2 => 1 = 3 steps -- I guess, not including 8 itself = log 8). Again, I had a few problems: I forgot to put my midpoint value inside the loop (it was not being recalculated each time the high and low points changed). ...