Created
December 3, 2013 11:49
-
-
Save shadeglare/7767899 to your computer and use it in GitHub Desktop.
for PHP-man
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace TrainSelector | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var seatToCoupes = new Dictionary<Int32, Int32>(); | |
var mainCoupeSize = 4; | |
var leftCoupeSize = 2; | |
var coupeCount = 9; | |
var totalMainSeatsOffset = coupeCount * mainCoupeSize; | |
for (var currentCoupe = 1; currentCoupe <= coupeCount; currentCoupe++) | |
{ | |
for (var offsetMainSeatNumber = 1; offsetMainSeatNumber <= mainCoupeSize; offsetMainSeatNumber++) | |
{ | |
var currentMainSeatNumber = (currentCoupe - 1) * mainCoupeSize + offsetMainSeatNumber; | |
seatToCoupes.Add(currentMainSeatNumber, currentCoupe); | |
} | |
for (var offsetLeftSeatNumber = 1; offsetLeftSeatNumber <= leftCoupeSize; offsetLeftSeatNumber++) | |
{ | |
var currentLeftSeatNumber = (coupeCount - currentCoupe) * leftCoupeSize + offsetLeftSeatNumber + totalMainSeatsOffset; | |
seatToCoupes.Add(currentLeftSeatNumber, currentCoupe); | |
} | |
} | |
Console.WriteLine(seatToCoupes[54]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment