Пример #1
0
        public string Reduce(string input, Direction initialDirection)
        {
            var sb = new StringBuilder();
            var currentDirection = initialDirection;

            foreach (var c in input.ToUpperInvariant())
            {
                if (c == Constants.LeftChar)
                {
                    currentDirection = _directionsMapper.LeftOf(currentDirection);
                }
                if (c == Constants.RightChar)
                {
                    currentDirection = _directionsMapper.RightOf(currentDirection);
                }
                if (c == Constants.MoveChar)
                {
                    sb.Append(_directionsMapper.MapFromDirection(currentDirection));
                    sb.Append(Constants.MoveChar);
                }
            }
            return(sb.ToString());
        }
 public string Format(Piece target)
 {
     return($"{target.Position.X}{target.Position.Y}{_directionsMapper.MapFromDirection(target.Direction)}");
 }