Thursday, March 28, 2013

Surviving Customer Support

This article is going to be another rant.

I'm trying to get my hands on an install of MS Office 2013 (well, I really only need PowerPoint to do my presentations, and Word to occasionally read files sent by people who don't know better).  Since I'm an honest individual, I decide to do the unthinkable and actually pay for Microsoft software.  However, I'm also a student, so I'm looking for a way to pay the least amount possible and still keep a clear conscience.  It appears the best option is the University 365 deal that's exclusive to full-time students. The catch: they have to verify you're a student before you can purchase or even download anything. This is where the fun begins.

You get three options for verification: through your school, an ISIC card, or manually typing a verification code into a text box. The first option sounds like the best, except it doesn't work: you get redirected to your school (in my case, Hokkaido University), you enter a username and password, and... get redirected to the start page. One option down, two to go. No, scratch that, I don't have an ISIC card. Well, that pretty much leaves one option -- get in touch with support and ask for a verification code. Sounds easy, huh?

Actually, it isn't. Go to the MS store and search for a way to contact their support team. Bonus question: try to find a way that doesn't involve picking up a telephone. Go on, I'll wait.

Back already?  Did you find an email?  Let me know if you did, cause I didn't.  As a consolation prize, I found a chat option...  that I can't use right now because it's outside of US business hours.  Seriously?  Is it really that hard to foresee that not everyone is going to be in the same time zone as the US?  It's almost as if Microsoft haven't heard of this wonderful thing called "eemail", which allows people across the globe to communicate without having to arrange a mutually convenient time.

Alright, let's try a different angle: let's go through the local Japanese MS site.  Maybe they have a workable support option.  Here's their product lineup.  I'll save you the time of having to click through to it:

Now, it's starting to get ridiculous.  Let's find the Microsoft Store in Japan through Google.  Thankfully, that site doesn't die with a server error.  But hey, remember that thing you wanted to buy half an hour ago...  yeah, Microsoft University 365?  It's not there!

I'm a patient and persistent guy.  Let's try googling around for "Microsoft University 365".  Here's the first hit from Google, and it looks really promising.  There's no link for purchasing information, but there is a "learn more" link.  Let's click on that.

Patience...  running...  out...

Microsoft, here I am, practically begging you to take my money so I can start using your software, and you still can't manage to keep my business.  Maybe I'll just have to go and pirate it like the rest of the world does.  I value my conscience, but I also value my time and sanity, and they are both taking a huge hit by having to deal with your online store.  If you insist on copying Apple and dressing up your staff to look like a bunch of clowns, then perhaps you should also look at copying Apple and making it easy for people to actually buy your products.

Sunday, March 24, 2013

Coding Practice: Binary Search

If you were given a full deck of cards and asked for search for a card (say, the Queen of Hearts), how would you do it? You could go about it several ways: start searching from the top of the deck, bottom of the deck, pick cards randomly... In the worst case, you'd have to shuffle through the entire deck (a whopping 52 cards) before reaching your goal. If I asked you to do this many times, and you were patient enough to oblige, you'd quickly grow tired of shuffling through the entire deck and look for ways to make your ordeal less monotonic. You'd put the cards in an order, using your favorite sorting algorithm (for example, merge-sort), using the value and suit of each card as the key.

Once the deck is sorted, then searching through becomes simpler.  There are several ways to perform the search.  One of the simplest to explain is the binary search, where you pick a card from the middle of the deck (dividing it into lower and upper halves), and compare it to the value you're searching.  If you got lucky and it's the card you want, then you're all done.  If the card you want is less than the card you just picked, then you look at the lower half.  Otherwise, you look at the upper half.

What's the computational complexity of this search?  At each step, you effectively halve the number of cards you have to look at next: 52, 26, 13, 6, 3, 1.   The number of search steps is thus $\log_2 52$, or approximately 6 steps.  The overall complexity is thus $\log N$, where $N$ is the number of elements to search.

The coding problem this time was to implement a binary search algorithm that searches a sorted array.  It works mostly like what I described above, with the exception of how it handles elements with the same value.  When the array contains more than one element of the same value (e.g. a messed-up deck with 2 Queens of Hearts), then the algorithm searches for the first occurrence of the element.

Here is a JavaScript demo (butt-ugly, but does what it's supposed to). The "<<" and ">>" arrows to move to the previous and next search steps, respectively. At each step, the blue, orange and red numbers represent the first, middle and end of the search, respectively. A green element indicates the search has reached its goal and has terminated.

Saturday, March 16, 2013

Counting Large Numbers in Japanese: a PITA

In Japan, the units people use to represent large numbers such as currency differ significantly to the "rest of the world".  Most people are used to decimal units that increase in powers of 3: thousands ($10^3$), millions ($10^6$), billions ($10^9$), trillions ($10^{12}$).  This system, known as the short scale, is also consistent with how numbers are written: as triplets, with a separator (such as a space, comma or otherwise).  Hundreds are a bit of an exception to this pattern.

In Japan, they also have hundreds, but beyond that, the units increase in powers of 4: ten thousand ($10^4$), 100 million ($10^8$), trillion ($10^{12}$).  Unsurprisingly, they have names for these units, too: man (万), oku (憶), and chou (兆), respectively.  They also have thousands ($10^3$), but that's kind of an exception.  They also have the infamous hyaku-man (百万), the hundred ten-thousands.  You may know that as a million.  Despite this "power of four" rule, the Japanese still write numbers as triplets, except using their own units: for example, car prices are often written as 123,000万円 (or 12.3億円, depending on the psychological trick the car dealership believes in).  For a non-Japanese person, that's 1,230,000,000 or 1.23 billion yen.  Simple, right?  All you need to do is mentally add a couple of zeros, shift the commas across, regroup the zeros...

Wrong.  I mess this up all the time, like when I'm reading the news or shopping around for my next BMW.  It happens frequently enough to be frustrating, but not frequently enough to learn my lesson. So, behold: I give you the "The Decimator": a JavaScript that converts Japanese numbers to our familiar decimal notation.