Posts by n-Holmes (3)

This post is largely my thoughts on Andy G's Algorithms as Objects, specifically in relation to simulation algorithms. The original article makes a case for Transforming complicated algorithms into objects in order to deal with five code smells:

  • Code that is long or deeply nested
  • Section comments
  • Excessive closures
  • Single-purpose helper functions polluting the namespace
  • Lots of state being passed between functions
Read the full post...

Statement

Given a sequence of rectangular buildings viewed from your position, efficiently compute the combined skyline which you will see.

Each building in the input is given as a triple (left, width, height). The sequence of buildings is not necessarily sorted in any meaningful order.

The skyline returned should consist of pairs (left, height) and be returned in order sorted by left (low to high). The right side of each rectangular section can be omitted as it will be the same as the next section's left. The final section should look like (left, 0).

Read the full post...

1