当前位置: 首页>>代码示例>>C++>>正文


C++ Sudoku::set方法代码示例

本文整理汇总了C++中Sudoku::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Sudoku::set方法的具体用法?C++ Sudoku::set怎么用?C++ Sudoku::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sudoku的用法示例。


在下文中一共展示了Sudoku::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: block_groups

void block_groups(Sudoku &sudoku, int group_size, int row_block, int col_block)
{
    HammingWeightIterator subset_iter(group_size);
    int digit_subset;

    // for each set of n numbers S = {k1, k2, ... kn}:
    while ((digit_subset = subset_iter.next()) != -1)
    {
        // C(k) == set of columns containing k
        // C(S) == union of C(k) over k in S
        int blocks_containing = blockcells_containing_any(sudoku, row_block, col_block, digit_subset);

        // if size(C(S)) == n
        if (num_ones(blocks_containing) == group_size)
        {
            // remove all other possibilities from columns in C(S)
            SetBitIndexIterator block_iter(blocks_containing);
            auto end = SetBitIndexIterator::end();

            for (; block_iter != end; ++block_iter)
            {
                int row, col;
                blockunmask(mask(*block_iter), row, col);
                row += row_block * 3;
                col += col_block * 3;
                int prev = sudoku(row, col);
                sudoku.set(row, col, prev & digit_subset);
            }
        }
    }
}
开发者ID:jpreiss,项目名称:bitdoku,代码行数:31,代码来源:groups.cpp

示例2: row_groups

void row_groups(Sudoku &sudoku, int group_size, int row)
{
    HammingWeightIterator subset_iter(group_size);
    int digit_subset;

    // for each set of n numbers S = {k1, k2, ... kn}:
    while ((digit_subset = subset_iter.next()) != -1)
    {
        // C(k) == set of columns containing k
        // C(S) == union of C(k) over k in S
        int cols_containing = columns_containing_any(sudoku, row, digit_subset);

        // if size(C(S)) == n
        if (num_ones(cols_containing) == group_size)
        {
            // remove all other possibilities from columns in C(S)
            SetBitIndexIterator col_iter(cols_containing);
            auto end = SetBitIndexIterator::end();

            for (; col_iter != end; ++col_iter)
            {
                int prev = sudoku(row, *col_iter);
                sudoku.set(row, *col_iter, prev & digit_subset);
            }
        }
    }
}
开发者ID:jpreiss,项目名称:bitdoku,代码行数:27,代码来源:groups.cpp

示例3: box_row_eliminate

void box_row_eliminate(Sudoku &sudoku, int row, int box, int eliminate_mask)
{
	for (int col = box * 3; col < (box + 1) * 3; ++col)
	{
		int cell = sudoku(row, col);
		int newcell = subtract(cell, eliminate_mask);
		sudoku.set(row, col, newcell);
	}
}
开发者ID:jpreiss,项目名称:bitdoku,代码行数:9,代码来源:rowbox.cpp

示例4: solve

  static bool solve(Sudoku & s) {
    init_algorithm(s);
	bool valid = r_solve(filter_sudoku);
	if(valid) {
        size_t i =0;
        for(std::vector<int>& f : filter_sudoku) {
            if(f.size()!=1)
                std::cout<< "No solution found!";
            s.set(f.front(), i/table_width,  i%table_width); // Kordináták fel vannak cserélve!! HAHA :D
            ++i;
        }
    }
    return valid;
  }
开发者ID:iszekeres-so,项目名称:parallel-force,代码行数:14,代码来源:filter_solver.hpp

示例5: only_in_row

void only_in_row(Sudoku &sudoku, int row)
{
	int cols_who_contain[9];
	sudoku.digit_to_column_map(row, cols_who_contain);

	for (int num = 0; num < 9; ++num)
	{
		int cols = cols_who_contain[num];
		if (1 == num_ones(cols))
		{
			int col = unmask(cols);
			sudoku.set(row, col, mask(num));
		}
	}
}
开发者ID:jpreiss,项目名称:bitdoku,代码行数:15,代码来源:singles.cpp

示例6: only_in_block

void only_in_block(Sudoku &sudoku, int row_block, int col_block)
{
	int friends_who_contain[9] = { 0 };

	sudoku.digit_to_block_map(row_block, col_block, friends_who_contain);

	int row_base = row_block * 3;
	int col_base = col_block * 3;

	for (int num = 0; num < 9; ++num)
	{
		int friends = friends_who_contain[num];
		if (1 == num_ones(friends))
		{
			int row, col;
			blockunmask(friends, row, col);
			if (sudoku(row_base + row, col_base + col) != mask(num))
			{
				sudoku.set(row_base + row, col_base + col, mask(num));
			}
		}
	}
}
开发者ID:jpreiss,项目名称:bitdoku,代码行数:23,代码来源:singles.cpp


注:本文中的Sudoku::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。