Beispiel #1
0
    static void Main()
    {
        char[]           delimeters = { ' ', ',' };
        Tuple <int, int> size       = read_grid_size(delimeters);
        int rows = size.Item1;
        int cols = size.Item2;

        Grid grid = GridFactory.create_grid(rows, cols);

        Tuple <int, int, int> position_generations = read_position_and_generations(delimeters, rows, cols);
        int row_index   = position_generations.Item1;
        int col_index   = position_generations.Item2;
        int generations = position_generations.Item3;

        Func <int, bool> red_rule   = (int count) => { return(count == 3 || count == 6); };
        Func <int, bool> green_rule = (int count) => { return(count != 2 && count != 3 && count != 6); };

        Generator gen = new Generator(red_rule, green_rule);

        int count = get_count(gen, grid, row_index, col_index, generations);

        Console.WriteLine(count);
    }