Archive for the 'Misc' Category

h1

One mile South, one mile West, one mile North

Tuesday, July 22nd, 2014

This is another puzzle I found to be an interesting variation from the original that I have heard previously.

Basic puzzle: how many places are there on Earth (if any) that you can you walk one mile South, one mile West and one mile North and be back in your original position.

Answer A: 1 — right at the North pole, so you form a geodesic triangle.


“True” answer B: infinitely many – one mile above the the slice of earth that is one mile in circumference.

Scale is all wrong yada yada but the visual concept should be clear enough (I hope, and such is the intent).

h1

8, 9, 12 balls problem

Monday, July 21st, 2014

Lately I’ve been reading some common interview puzzle problems and came across the 8-ball problem. I’ve come across this problem before, along with some more complex variations. In particular, http://learntofish.wordpress.com/2008/11/30/solution-of-the-12-balls-problem/ already gives a very good explanation of the solution. My only complaint is that I found it a bit difficult to keep track of the numbering. Thus, this post is not much more than my personal rendition of the problem and solution, using colour rather than labels.

The most basic variation is that you are given 8 balls but one is heavier than the rest. You are asked to find the minimum number of times you would use a balancing scale such that you would definitely find the heavier one.

basic 8 balls problem

basic 8 balls problem

I think it helps when you know that the solution is two times and you get to work that out. Here’s a visual solution:

basic problem solution

Solution to basic problem

This is the same solution for 9 balls, one heavy — the only difference is the second weighing is always the bottom case. However, a more interesting variation is of the same practical scenario but this time you are not told whether the one ball is heavier or lighter, just that it is different.

One ball has a different weight

Less knowledge: one ball weighs differently

This time solution to this is three times — this is somewhat straightforward for the 8 or 9 balls case, as an extension to above. But for the 12 ball case, the reasoning is much more subtle.

Addendum: It has been almost a year since I’ve last visited this post, I might one day finish with the visual version of the 12 ball case, but for now, I’ll just have to leave published as is. The original link‘s explanation will have to do.

 

h1

Handy command line thingies

Monday, December 23rd, 2013

A compilation of handy commands I use when working remotely and/or on command line.

File sharing from remote server

I used to use scp a bunch for transferring files between my local machine and some server. However, I found that ssh file share is waaay handier.

Essentially, you define a local folder from which you mount a directory in a remote server by typing the following:

sshfs <username>@<servername.host.domain>: <name_of_local_folder>/

So, for example, here I’d use sshfs sammi@nonado.net: MyNonadoFiles/ in the location where my MyNonadoFiles/ folder is.

Search previous commands

Another handy shortcut I use a lot since learning to use the command line is reusing previous commands. Pressing the ‘up’ scrolling button is fine but if I’ve been typing a lot of cd here and there or running scripts repeatedly then it can take a while to find a specific command (such as the sshfs above) which I use seldomly but is super useful. Here’s a couple of shortcuts:

  • Ctrl-r + “what you’re searching for”
    • e.g. pressing Ctrl and r, and then ssh would find your most recent command that has ssh in it.
    • To look further back, keep pressing Ctrl+r
  • history -“number of lines”
    • e.g. history -100 returns your most recent 100 commands

 

h1

Upgrading Ubuntu

Tuesday, December 18th, 2012

“Error during update

A problem occurred during the update. This is usually some sort of network problem, please check your network connection and retry.”

I haven’t upgraded my Ubuntu distribution since Lucid Lynx (10.04) and didn’t want to do a fresh install to get the current Precise Pangolin (12.04). This requires upgrading Lucid one intermediate distro at a time to get to my final goal. But, since nearly all the intermediate distros have become unsupported in the meantime, this means the standard way of asking the Update Manager do this all for me was a moot point. After a bunch of googling and lots of waiting (I had to go 10.04 -> 10.10 -> 11.04 -> 11.10 -> 12.04) I finally got there, despite some errors along the way.

In short, the main trick was this:

1. First, download the “Alternate Install CD” for the distribution version you want. Then:

2. (i) You can either burn the ISO onto a CD and upgrade by booting from it

or

2. (ii) Type in the terminal (don’t literally copy + paste the italics!):

  • sudo mount -o loop /Location/Name_of_downloaded_distribution.iso /media/cdrom0
  • gksu “sh /cdrom/cdromupgrade”

Remember to choose the upgrade without getting updates from the internet or there will likely be errors because it can’t find the no longer supported distribution.

I also ran into other errors that wouldn’t allow me to update but I can’t remember the precise details so I won’t bother trying to  dig it up. Something along the lines of removing unsupported software did the trick, I think.

h1

Webcomics and other miscellany (to keep me sane)

Wednesday, May 9th, 2012

Some miscellaneous comics which summarise: