# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1513486046 18000 # Node ID f1f0220b5f7ccef9529a3a75a83fd06520fd1409 # Parent 8d1edc9efcb4b426a2c6b3a248ba6788161cd700 day 16: simply loop diff --git a/2017/day16.d b/2017/day16.d --- a/2017/day16.d +++ b/2017/day16.d @@ -29,13 +29,10 @@ } auto iteratePerm(string[] ops, string progs) { - string[] seenprogs = [progs]; - string result = progs; - while(true) { - result = ops.parseOps(result); - if(seenprogs.canFind(result)) { - break; - } + string[] seenprogs; + for(string result = progs; + !seenprogs.canFind(result); + result = ops.parseOps(result)) { seenprogs ~= result; } return seenprogs[1_000_000_000 % seenprogs.length];