# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1513049065 18000 # Node ID a991288f3d5578042687926f1cd8f9475b806688 # Parent 66707d1400b460b2f4bcf047528bbcd039f90285 day 11: simplify hexNorm diff --git a/2017/day11.d b/2017/day11.d --- a/2017/day11.d +++ b/2017/day11.d @@ -1,7 +1,7 @@ import std.array: array; import std.math: abs; import std.string: chomp, split; -import std.algorithm: min, map, cumulativeFold, maxElement; +import std.algorithm: max, map, cumulativeFold, maxElement; import std.stdio; immutable int[2][string] directions; @@ -21,9 +21,7 @@ if (x*y < 0) { return abs(x) + abs(y); } - x = abs(x); - y = abs(y); - return abs(x - y) + min(x, y); + return max(abs(x), abs(y)); } void main(string[] args) {