[...] start at the given coordinates [...] and face North.
Then, follow the provided sequence: either turn left (L) or right (R) 90 degrees, then walk forward the given number of blocks [...]

Following simple, mechanical steps seemed like a fine introduction to programming for young people, so I signed in and requested the data for Part 1 of the puzzle.

Oh...

You see, while the examples Eric provides are quite simple, the actual input is over 150 steps and some of the distances are three-digit numbers.
So while this puzzle is perfect for a small programming challenge, it'd be too tedious to work through manually.

Unless...

What if we could solve the programming puzzle without any programming?

What if we could solve it with something familiar to non-developers?

What if we could solve it with a basic spreadsheet???

Hmmm...

Let's try!

We'll be using Google Sheets because it's free, easy to use, and convenient.
(But any decent spreadsheet will do.)
And we'll be working with the sample data (not the actual puzzle data) so as not to give too much away.
Keep reading to see all the steps - or follow along in a spreadsheet if you want to get your hands dirty.

Good, let's start with the sample data:

R5, L5, R5, R3 leaves you 12 blocks away.

To understand why and familiarize yourself with the puzzle, read about taxicab geometry and work through the steps on paper first.
It's important to realize that R and L steps do not necessarily alternate and that the direction at the end of each step depends on the direction at the beginning of the step.
However, given the state after N steps, the state after step N+1 is completely defined by that direction and distance.

Spreadsheets typically go "down", so let's set ours up like that by adding the steps to a Data column (leaving row 2 blank for reasons that will be clear later):

A

1

Data

2

3

R5

4

L5

5

R5

6

R3

Each step contains two pieces of information: the Direction to turn and the Distance to move.
Let's start by pulling them apart so we can deal with them separately.
The LEFT and RIGHT functions are our friends here (with a little help from LEN).
The Direction is simply the first character of the data, or =LEFT(A3, 1) (assuming we're looking at row 3, the first value).
And the Distance is just the rest of the string, or =RIGHT(A3, LEN(A3)-1).

Type those formulas into cells B3 and C3 and replicate the formulas down to row 6.
(Your spreadsheet program should automatically update the formulas for rows 4-6 to be relative to their respective cells.)
Done correctly, that gives the following:

A

B

C

1

Data

Direction

Distance

2

3

R5

R

5

4

L5

L

5

5

R5

R

5

6

R3

R

3

We'd like to turn the Direction letter into a number so we can do math on it - the IF function works nicely for that.
By using -1 to represent a left turn and 1 to represent a right turn, use the formula =IF(B3="L", -1, 1) to create a Rotation field for row 3 (and then replicate the formula down):

A

B

C

D

1

Data

Direction

Distance

Rotation

2

3

R5

R

5

1

4

L5

L

5

-1

5

R5

R

5

1

6

R3

R

3

1

Now let's use Rotation to create a Heading that tracks where the player is pointing after each move.
The four possible values are North, East, South, and West - it's convenient to use the numbers 0, 1, 2, and 3 respectively.
Because we're adding and subtracting numbers to determine the Heading, it's possible to get values outside that range (ex: 3 + 1 = 4).
Just like with a 12-hour clock (11am + 2 hours = 1pm), we'll use modular arithmetic to stay within the desired range.
The starting direction is North, so we'll seed an initial Heading by putting the value 0 in cell E2.
(See, I told you row 2 would be useful!)
After that, the MOD function can be used to figure out the new Heading by adding the Rotation to the current value: =MOD(E2 + D3, 4).
Replicating this formula down gives the following:

A

B

C

D

E

1

Data

Direction

Distance

Rotation

Heading

2

0

3

R5

R

5

1

1

4

L5

L

5

-1

0

5

R5

R

5

1

1

6

R3

R

3

1

2

Knowing a Heading and a Distance means we can track of the X and Y coordinates as the player moves around the city.
If the player is facing East and moves forward, the X coordinate will increase by that Distance; if facing West, it will decrease.
Similarly, a move facing North will increase the Y coordinate, while a move South will decrease it.
The CHOOSE function allows us to represent this quite easily.
The only catch is that CHOOSE indices are 1-based and our Heading values are 0-based, so we need to adjust for that by adding 1.
After seeding 0 values for the starting X and Y coordinates in row 2, we can update the X coordinate with =F2 + CHOOSE(E3+1, 0, C3, 0, -C3) and the Y coordinate with =G2 + CHOOSE(E3+1, C3, 0, -C3, 0).
Replicating those formulas down leads to:

A

B

C

D

E

F

G

1

Data

Direction

Distance

Rotation

Heading

X

Y

2

0

0

0

3

R5

R

5

1

1

5

0

4

L5

L

5

-1

0

5

5

5

R5

R

5

1

1

10

5

6

R3

R

3

1

2

10

2

Now all that's left to solve the puzzle is to compute the taxicab distance of each X/Y coordinate from the starting point.
Well, that's just the magnitude of the X coordinate added to the magnitude of the Y coordinate and that can be expressed using the ABS function: =ABS(F3) + ABS(G3).
Replicating that down gives the following, final, table and the answer to the sample puzzle:

A

B

C

D

E

F

G

H

1

Data

Direction

Distance

Rotation

Heading

X

Y

Taxicab Distance from Start

2

0

0

0

3

R5

R

5

1

1

5

0

5

4

L5

L

5

-1

0

5

5

10

5

R5

R

5

1

1

10

5

15

6

R3

R

3

1

2

10

2

12

Sure enough, the taxicab distance after the final move (cell H6) is 12 - just like the sample said it should be!
And we figured that out without writing any "code" at all - we simply came up with few small formulas to methodically break the problem down into little pieces we could solve with a spreadsheet.
That may not quite be coding (in the usual sense), but it sure is programming!

PS - Having definitively established that you are 1337 with a spreadsheet, you might be looking for other challenges...
Good news: Part 2 of the Advent of Code taxicab problem has been left as an exercise for the reader! :)

The lightweight, cross-platform Visual Studio Code editor recently gained support for extensions, third party packages that add or enhance capabilities of the tool.
Of particular interest to me are linters, syntax checkers that help avoid mistakes and maintain consistency when working with a language (either code or markup).
I've previously written about markdownlint, a Node.js linter for the Markdown markup language.
After looking at the VS Code API, it seemed straightforward to create a markdownlint extension for Code.
I did so and published markdownlint to the extension gallery where it can be installed via the command ext install markdownlint.
What's nice about editor integration for a linter is that feedback is immediate and interactive: mistakes are highlighted as they're made and it's easy to click a link for information about any rule violation.

If linting Markdown is something that interests you, please try the markdownlint extension for VS Code and share your feedback!

Inspired by Marco Arment's recent post about blocking advertisements on the web, I decided to explore the same idea.
However, while Marco focuses on the annoyance of advertisements, I am interested in the security benefits of removing them.
There have been numerous incidents of otherwise respectable websites compromising the security of their users due to the advertisements they include.
Searches for "web site hacked 'ad network'" on Google and Bing provide some examples; another is this XSS attack on Troy Hunt's site, which is interesting thanks to the detailed analysis Troy provides.
Popular sites of all kinds have been compromised in this way, and one might argue they should be treated as attackers because of the approach used to serve third-party ads.

Marco's article describes an in-browser solution for ad-blocking, but I prefer something that automatically protects all the machines on my network (at least, while they're using the network; see below).
So I set out looking for something that works at the network level and came across Pi-Hole, a DNS-based ad-blocker for the Raspberry Pi.
Aside from the fact that I don't own a Pi, this seemed like exactly what I wanted. ;)

Fortunately, there are no actual dependencies on Pi hardware, so I decided to create my own Pi-Hole on a server in the cloud - thus the name "Sky-Hole".
To do so, I opened the Microsoft Azure Portal, created a small virtual machine running Ubuntu Server 15.04, and configured it according to the manual instructions for Pi-Hole (with a few customizations outlined below).
Then I updated my wireless router to use Sky-Hole as the DNS server for my home network - and all my devices stopped showing advertisements!

Directions

I used a minimal set of steps to configure the Sky-Hole and list them below so they're easy to reproduce.
I made a couple of tweaks to the Pi-Hole process along the way and explain them in turn.

The addn-hosts option is meant to be optional, but I needed it because /etc/hosts was not updated by gravity.sh.
The host-record option was necessary to avoid a "sudo: unable to resolve host" error which showed up whenever I enabled dnsmasq.
(Though this may be an artifact of the default virtual machine configuration under Azure.)

Update 2015-08-30: host-record was similarly necessary on AWS, where the automatically-assigned host name was of the form ip-123-123-123-123.

Now, download the Pi-Hole script and run it to generate the list of domain names to block:

The last line is my own and replaces the virtual machine's IP address with an unusable 0.0.0.0 address when redirecting undesirable sites.
Because I'm not running a web server on the Sky-Hole, this seems like a more appropriate way to block unwanted domain names.
(Besides, hostname -I in Azure reports the virtual machine's internal address which is on a private network.)

Restart dnsmasq to apply the changes:

sudo service dnsmasq restart

Now, test things locally via ping, dig, nslookup (or similar) to verify that desirable domain names are returned as-is and undesirable ones are blocked by returning the 0.0.0.0 IP.
Assuming that's the case, update the virtual machine to accept incoming UDP traffic on port 53 (per the DNS specification) and test again from a different machine.
If everything is working as expected, configure your router to use the Sky-Hole's public IP address for DNS resolution.
This automatically applies to all devices on the local network and avoids the need to update each one manually.

Update 2015-08-30: You may also want to enable TCP traffic on port 53 (per RFC 5966).

Congratulations, you're done!

Notes

The nice thing about this approach is that it covers all the machines on your network.
However, it can only protect machines when they're connected to that network.
Taking a phone or tablet elsewhere or using cellular data exempts a device from this kind of protection.

So this may be an argument in favor of per-device ad-blocking - though perhaps as a strategy to be used in addition to (rather than instead of) a network-wide approach.

When creating the virtual machine, I used the Basic A1 size which would cost about $34.97 per month on Azure (though I don't plan to leave it running very long).

I tried the A0 size first (which would have cost $13.39 per month on Azure), but it ran out of memory building the domain list, seemingly due to this known issue.

As I note above, I chose not to configure a local web server on my Sky-Hole.
While doing so offers interesting benefits, it didn't seem compelling for the purposes of this experiment and I preferred to keep thing simple.
Should you choose to, directions are available in the Pi-Hole documentation.

If you end up using Pi-Hole like this (or on its own) please consider donating to the author, Jacob Salmela, to help support his work.

Conclusion

I'm only been running Sky-Hole for a couple of days, but the usability and performance improvements for some sites are quite noticeable.
More importantly, it seems to me the browsing experience is necessarily safer by virtue of removing not just a subset of traffic, but the subset which is most likely to contain unwanted content.

As an experiment and a learning experience, Sky-Hole has been a successful side-project.
I hope others find it interesting or thought-provoking and I welcome comments on improving or enhancing the approach!

Yesterday at its Build conference, Microsoft released the Visual Studio Code editor which is a lightweight, cross-platform tool for building web and cloud applications.
I've been using internal releases for a while and highly recommend trying it out!

One thing I didn't know about until yesterday was support for Tasks to automate common steps like build and testing.
As the documentation shows, there's already knowledge of common build frameworks, including gulp for Node.js and io.js.
But for simple Node projects I like to automate via npm's scripts because they're simple and make it easy to integrate with CI systems like Travis.
So I whipped up a simple tasks.json for Code that handles build, test, and lint for typical npm configurations.
I've included it below for anyone who's interested.

Note: Thanks to metadata, the build and test tasks are recognized as such by Code and easily run with the default hotkeys Ctrl+Shift+B and Ctrl+Shift+T.

Tree nodes are assumed to have a numeric value and references to their left and right nodes (both possibly null).

I used the name value (vs. data) because it is slightly more specific.

I decided on an iterative algorithm because it has two notable advantages over recursion:

In the worst case for a tree with N nodes, an iterative solution has bookkeeping for N/2 nodes (when starting to process the leaf nodes of a balanced tree assuming nodes were queued) whereas a recursive solution has bookkeeping for all N nodes (when processing the deepest node of a completely unbalanced tree).

Because there are two recursive calls, I don't thinktail recursion can be counted on to fix the worst-case behavior.

The memory used for bookkeeping by an iterative solution comes from the heap which is generally much larger than the thread stack.

To be fair, neither advantage is likely to be significant in practice - but they make good discussion points during an interview. :)

The iterative algorithm has a disadvantage:

Bookkeeping requires an additional object type (wrapper in the code above) which associates the relevant min and max bounds with pending node instances.

... unless you avoid the wrapper by augmenting the node elements themselves.

... which is quite easy in JavaScript thanks to its dynamic type system.

The code uses a stack (vs. a queue) because stacks tend to be simpler than queues - especially when implemented with an array.

I made use of the fact that comparing a number to undefined evaluates to false so I could avoid specifying explicit minimum/maximum values (as in the Wikipedia example) or making HasValue checks (as in James's example).

If you have a different approach or a suggestion to simplify this one, please share!

Count the number of ways to combine coins worth 100, 50, 25, 10, 5, and 1 cent for a total value of 100 cents

As Josh says, it's a fun challenge and I encourage you to stop reading now and solve it!

Seriously: Stop now. Spoilers ahead...

I took his advice and sat down with pen, paper, and a self-imposed 30 minute time limit.
I came up with the C# solution below just before time ran out.
As I note in the code, I forgot one line (though I caught it when typing up the solution).
Less embarrassingly, this implementation worked correctly the first time I ran it.
What's more, it's flexible with regard to the target amount and number/value of the coins (both of which are passed as parameters to the constructor).
For bonus points, it outputs all the combinations it finds along the way.

I've added some comments to the code to outline the general algorithm.
There are some opportunities to refactor for clarity and an implicit assumption values are passed in decreasing order, but otherwise I'm pretty happy with how it turned out.

If you take on the challenge and come up with something interesting, please leave a note - I'd love to see other approaches!

I've had blog since 2006.
It's called Delay's Blog and - for a time - was among the top most visited blogs on MSDN.
MSDN hosts its blogs on the Telligent platform and has a team of people whose job it is to keep things running.
This is a nice perk and that team makes it easy for Microsoft employees to reach a wide audience.
I had a good run and I appreciate all their efforts!

However, I'm something of a control freak and tinkerer and I've always thought it would be nice to own the whole content pipeline.
So I decided a number of months ago to migrate this blog to my own site instead.
Of course, there are a wealth of good blogging platforms I could have chosen, and lots that are based on the ASP.NET stack I use for the rest of my site.

But I didn't choose any of them - instead, I've written my own blogging platform based on the Node.js stack.
While I'll be the first to acknowledge there's an element of NIH going on [ :) ], there were other considerations:

Node.js presents a good learning opportunity for a .NET guy like myself

My current job is all about HTML/CSS/JavaScript, so Node.js is a great fit

The Node.js community is very active and NPM has a wealth of great packages

Though I like typing posts in HTML, I want to experiment with Markdown

By writing my own blog, I have complete control (evil laugh...)

Development happened in small bits and pieces over many weeks and bus rides; the result is the blog you're reading now.

For convenience, I've migrated all the existing content from MSDN so I can reference it in one place (here!).
For continuity, I've left the posts on MSDN, with comments disabled and a pointer to this site for new content.

As expected, developing my own blogging platform on a new framework was a great learning experience; I had a good time doing it and am happy to finally have complete control over my (blogging) destiny.

Go ahead and give it a try if you want a challenge! You can make your own puzzle out of paper cutouts or build something with interlocking cubes (which I can say from experience works quite well).

Aside: I'm not going to reveal where the original puzzle came from because I don't want to spoil it for anyone. But feel free to leave a comment if it looks familiar!

Now, maybe the puzzle's solution is/was obvious to you, but like I said, I was stuck. As it happens, I was in a stubborn mood and didn't want to admit defeat, so I decided to write a simple program to solve the puzzle for me!

I'd done this before (many years ago), and had a decent sense of what was involved; I managed to bang out the solution below pretty quickly. My goal was to solve the puzzle with minimal effort on my part - so the implementation favors simplicity over performance and there's a lot of room for improvement. Still, it finds the solution in about a second and that's more than quick enough for my purposes.:)

I've included the complete implementation below. The code should be fairly self-explanatory, so read on if you're interested in one way to solve something like this. Two things worth calling out are that this approach is guaranteed to find the solution with the fewest number of moves and it can handle arbitrarily-shaped pieces and boards - both of which flow pretty naturally from the underlying design.

There's not much more to say - except that you should feel free to reuse the code for your own purposes!