private int CalculateRowIndex(string rowInstruction) { var instructions = rowInstruction.ToList(); var index = 127; var range = new Range(0, 127); var seat = new Seat(); var currenRow = new CurrentRow(); currenRow.Start = 0; currenRow.End = 127; seat.RowRange = currenRow; instructions.ForEach(instr => { Console.WriteLine(instr); seat.RowRange = GetRowRange(instr, seat.RowRange); }); // If F => 0 - 63 // If B => 63 - 127 //for (int i = 0; i < instructions.Length; i++) //{ //} return(0); }
private CurrentRow GetRowRange(char instr, CurrentRow currentRow) { var result = seats.Length; var offset = result / 2; switch (instr) { case 'F': currentRow.Start = currentRow.End / 2; return(currentRow); case 'B': currentRow.End = currentRow.End / 2; return(currentRow); default: return(null); } }