public string Spin(ReadOnlySpan <char> input, string baseLine) { var target = new Dance(baseLine); if (input.Length > 0) { target.Spin(input.Slice(1)); } else { target.Spin(input); } return(target.Result()); }
private void DanceSingle(Dance dance, string[] moves) { foreach (string move in moves) { switch (move[0]) { case 's': { dance.Spin(int.Parse(move.Substring(1))); break; } case 'x': { string[] p = move.Substring(1).Split("/"); dance.Exchange(int.Parse(p[0]), int.Parse(p[1])); break; } case 'p': { string[] p = move.Substring(1).Split("/"); dance.Partner(p[0][0], p[1][0]); break; } } } }