From 9f2106ed94b78befe868f5fc260115131071c3d5 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 18 Jul 2015 10:39:25 -0700 Subject: [PATCH] Advance rotor by `count` positions Default value of parameter is 1 --- Enigma/Rotor.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Enigma/Rotor.swift b/Enigma/Rotor.swift index 2516d76..d37a345 100644 --- a/Enigma/Rotor.swift +++ b/Enigma/Rotor.swift @@ -36,8 +36,8 @@ class Rotor { self.series = series } - func advance() { - position = position.successor() % Rotor.alphabet.count + func advance(count: Int = 1) { + position = (position + count) % Rotor.alphabet.count } func encode(c: Character) throws -> Character {