Size6

Number Place Generator Version 2.0 -- Sample Programs

How to call Java API of Number Place Generator Version 2.0.

Size6

Let's write a Java program that makes a small Number Place.

  • the length of the problem is 6.
  • the board is fill with same rectangles :width is 3, height is 2.
  • the given hint is shown below.
  • calculate the difficulty point.

The following program is the answer. I don't think the detail explanation is necessary.

Size6.java

package jp.gr.puzzle.npv2.sample;

import java.util.ArrayList;
import jp.gr.puzzle.npv2.core.*;

public class Size6 {
        final static int numSize = 6;
        static int[] hint = {
                        0,0,0,1,0,0,
                        0,0,1,0,0,0,
                        0,1,0,0,0,1,
                        1,0,0,0,1,0,
                        0,0,0,1,0,0,
                        0,0,1,0,0,0             };
        
        private static int[] hidden = new int[numSize*numSize];
        static SolverMethod method = new SolverMethod();

        public static void main(String[] args) {
                System.out.println("Size6");

                int[] problem = null;
                ArrayList<Integer[]> blockarraylist = Utility.makeNormalBlock(numSize,
                                3, 2);

                BlockConstraint block = new BlockConstraint(blockarraylist, numSize);
                Generator generator = new Generator(numSize, hint, hidden, block);
                generator.setMethod(method);

                while ((problem = generator.generate()) == null)
                        ;
                int point = (int) Evaluator.evaluate(numSize, block, problem);
                System.out.println("point " + point);
                Utility.printGrid(problem, numSize);
        }
}

result

Size6
point 304
 0 0 0 3 0 0
 0 0 5 0 0 0
 0 6 0 0 0 5
 3 0 0 0 4 0
 0 0 0 2 0 0
 0 0 2 0 0 0

You can solve this problem without effort.

PUZZLE GeneRator JaPan
Copyright(C) 2007 Time Intermedia Corporation. All Rights Reserved.