Friday, May 18, 2018

Tuesday, May 1, 2018

Ok Google, talk to Code Tutor!

Code Tutor is still under active development as of this post. Contributions are welcome!

Version 2 of Code Tutor is on the Google Assistant! Just say "Ok Google, talk to Code Tutor".

You can get the Google Assistant on your mobile device:

I'm still improving it. That's why I'm open-sourcing it so we can help it improve faster together. You can also learn from the code to more quickly build your own voice app: https://github.com/hchiam/code-tutor BTW: Can you find all the hidden features? :)


Monday, March 5, 2018

Synthesis of Programming Problem Solving Strategies:

AEIOU

What?

For context: skim/fast-forward through these:

Thing is, when you're already trying to solve a tough problem, you can't mentally keep track of too many steps. But you also don't want to lose out on important considerations. And add on top of that how easy it is to forget* the steps when they're so abstract. Some steps even seem to overlap. 

I like summaries, so I've been playing with a few ideas to optimize for compactness. Some steps can be grouped into larger conceptual chunks. I've tried posting visual mnemonics in my room (think pictionary and infographics), but I found a simpler way to keep a mental checklist.

I came up with:

  • A
  • E
  • I
  • O
  • U

Which stand for:

  • Assumptions
  • Examples
  • Ideas
  • Optimizations
  • Unit tests

Or if you like things in threes:

  • Examples (which you should ask for to clarify assumptions)
  • Ideas (of different possible solutions, and choosing one)
  • Optimizations (which should be done with testing to evaluate your idea(s))
And then you'd just remember the "EIEIO" farmer song.

*Of course, with practice, you don't really need to memorize the steps. You should be internalizing the concepts behind the steps so they become habits of thought. But having a portable checklist (i.e. a mental/paperless way to remember) is helpful for practicing to set up the habits in the first place.

Thursday, February 8, 2018

LUI 4 Update

Lui's back.

Suggestions? Wake-up-words? The voice assistant side-project got upgraded.


"Computer what can you do"

To talk to Lui, start by saying "computer", and then your request. For example: "computer what can you do", or "computer play number guessing game".



"Computer stop/start listening"

You can talk to Lui completely hands-free in Chrome. If you want the voice assistant to stop responding to everything you say, just tell it: "computer stop listening".


"Computer let's program"

One of the newest features is you can get Lui to find code for you. This may come in handy with the feature of programming with your voice (which is still in development). Just say "computer let's program" to see a suggested next action.
 


Links:

Live demo: https://codepen.io/hchiam/full/WOLOJG/

Feedback: https://goo.gl/forms/Nwf8TXvOW2vE2OHA3
 
Release notes: https://github.com/hchiam/language-user-interface/releases

Lui's premier blog post: https://hchiam.blogspot.ca/2017/08/lui.html


_____________________
<This blog post was automatically posted at 12 noon on February 8th, 2018.>
_____________________

Thursday, February 1, 2018

sourcefetch-server: An Interface to Find Code for You*

Live demo*: 


*Please don't blindly copy code. Making use of code you find on Google still requires critical thinking. This interface could be helpful for remembering syntax. But it was made with a bigger project in mind that I've been working on (news coming soon). 
 
_____________________
<This blog post was automatically posted at 12 noon on February 1st, 2018.>
_____________________

Sunday, November 12, 2017

Monday, October 30, 2017

Mentally Finding Roots and Squares (or at least get pretty close)

 🔲 🌿 𝓷

How do you find the square of a number? What if that number has a decimal place?
What is b^2? 

Answer: make use of what you already know.  

Here's the equation:

b^2 = a^2 + Δ * Σ

That's a little cryptic. Here's that equation again:

destination^2 = origin^2 + difference * sum
Note: difference = (destination - origin). Going up should have a positive difference.  

Or this:

 dest^2 = orig^2 + (dest - orig)(dest + orig)

Or, for visual simplicity:

b^2 = a^2 + (b - a)(b + a)
Think: "to get from a to b". 

In other words: 

To get the square of a number (b^2, like 3.5^2 = ?), you can make use of a square that you already know (a^2, like 3^2 = 9), and just add the difference times the sum of the destination and the origin. Bonus: numbers with .5's and .1's are especially easy and can be used to get numbers with .6's. 

Example: 3.5^2 = ?

Well, with our equation we can make use of 3^2:
3.5^2 = 3^2 + (3.5-3)(3.5+3)
3.5^2 = 9 + (0.5)(3 x 2 + 0.5) 
3.5^2 = 9 + half of (6 + 0.5) 
3.5^2 = 9 + 3 + 0.25 

So: 3.5^2 = 12.25

We got 3.5^2 by using what we already know (3^2 = 9) and then did some calculations using relatively smaller numbers and mental shortcuts. 

Ok, but why do this?

The point was to practice problem-solving. The explicit goal was to answer a practice programming question: How do you implement or "manually" compute the square root of any number? There are multiple solutions, but one solution involves:
  1. ) An initial educated guess (pick smaller than the number, e.g. sqrt(17) should be smaller than 17, so maybe pick 4), 
  2. ) checking if that guess^2 is above/below the number (e.g. 4^2 is below 17), 
  3. ) adjusting using an efficient search of numbers below/above that number (binary search for O(logN) time), and 
  4. ) repeating steps 2 and 3 until you get an exact answer or you settle with a close-enough answer.
Our shortcut equations give us a way to mentally do step 2, especially when steps 3 and 4 give us a number with a decimal place as we get closer and closer answers.

Proof for the curious: 

Use algebra.

b^2 = a^2 + (b - a)(b + a)
b^2 = a^2 + (b^2 + ab - ab - a^2), using distributive property
b^2 = a^2 + b^2 - a^2, cancelling out 
b^2 = b^2
Proven.

But that doesn't really show how the equation was found. Thing is, the equation is basically the answer. So how do you find the equation?

How the equation (i.e. answer) was found:

Discovery. This is where the real problem solving is. Find patterns in the squares of numbers, and patterns in the differences between destination and origin. Hence the equations at the beginning of this post involving destination, origin, difference, and sum. 

In general, make use of what you already know (like simpler squares, or ones you already calculated) and build on those things to get closer to a solution. Go with what you know. Discover patterns. Problem solve. If you just need a quick answer, you can use a calculator or computer assistant. But if you want to practice solving problems, make the most of the mental toolbox you already have, and grow from there.

_________________________

LINKS TO OTHER STUFF: 

Favourites
Programming
Original Art
Games