Skip to content

Instantly share code, notes, and snippets.

codemonkey-uk / pfc5.cpp
Created Nov 6, 2014
Programming Fun Challenge 5: Polygon Packing (Winning Solution)
View pfc5.cpp
// pfc5.cpp v2 (c) T.Frogley 2002
// Programming Fun Challenge 5: Polygon Packing
// My solution does not provide an optimal packing,
// instead it produces a reasonable packing,
// and very good throughput, scaling very well,
// packing thousands of polys in sub-minute times,
// rather than hundreds in hours.
View gist:bc2a824c55fe16804818
-- A five digit number minus a four digit number equals 33333,
-- where the nine contributing digits are 1-9, each used only once.
import Data.List
slice start end = take (end - start + 1) . drop start
sliced :: String -> [Int]
sliced s = [read $ slice 0 4 s, read $ slice 5 9 s]
View gist:8edab3ae727314b0f886

Why you should never have to call super.Foo() in an Foo overload.

This is a classic example of poorly structured points of customisation.

For example, when you have:

class Base
  virtual void Foo();