Designing with Algorithms (A Mathematical Guide)