Sudoku code

hi,
any one can send sudoku code in ABAP as it is very urgent plz send the screen file also
my mail id is [email protected]
please do me this favour as it is very essential for me
SUDOKU CODE

Check this link to get all details -
http://forum.codecall.net/database-database-programming/121-sudoku-can-solved-using-sql-take-look.html
Re: Just a wild idea
http://www.di-mgt.com.au/src/sudoku.bas.html
http://www.di-mgt.com.au/sudoku.html#source
Hope this helps.

Similar Messages

  • ABAP SUDOKU code

    Hi plzz can anybody plzz send me the ABAP SUDOKU code (executable) plzz its very urgent plzzzz..
    points will be rewarded ...

    Hello,
    Go to these: [https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2bsolution%2bto%2bmedium%2band%2blow%2bcomplex%2bsudoku%2bpuzzles] and [https://wiki.sdn.sap.com/wiki/display/Community/ABAP+Games] to get more games!
    Regards,

  • Sudoku code in ABAP

    Hi,
    every one
    plz send sudoku code in ABAP as it is very urgent
    my mail id is [email protected]
    send screen downloded files also

    Check this link to get all details -
    http://forum.codecall.net/database-database-programming/121-sudoku-can-solved-using-sql-take-look.html
    Re: Just a wild idea
    http://www.di-mgt.com.au/src/sudoku.bas.html
    http://www.di-mgt.com.au/sudoku.html#source

  • Solving the regions in sudoku code

    was able to solve the repetition of the rows and columns... but i am now having trouble solving for the regions... My professor prefers we do it in a single class with multiple methods... here is what I have..
    This is my main method:
    public class Test extends JApplet{
        int [][] entries = new int [9][9];
        boolean filled [][] = new boolean [9][9];
        public void paint(Graphics canvas) {
            // draws the puzzle board
            SudokuPuzzel(canvas);
            //     sets the initial values
            initialValues(canvas);
            // this adds the guess
            addGuess(canvas);
        private void initialValues(Graphics canvas) {
            int puzzleLength;
            // creates the list of numbers to be used in the array
            List numberList = new ArrayList(8);
            for (int i = 1; i<10; i++)
                numberList.add(new Integer(i));
            // this will set the initial values into the entries array
            for (int x = 0; x<9;x++)
                puzzleLength = x;
                Collections.shuffle(numberList);
                for (int y = 0; y<9; y++){
                    entries[x][y] = (Integer) numberList.get(y);
                // this will check for repeats in the columns
                    boolean validityColumn, validityRegion;
                do{
                    validityColumn = true;
                    validityRegion = true;
                    validityColumn = checkColumn(puzzleLength, x);
                    validityRegion = checkRegion(puzzleLength);
                    if (!validityColumn || !validityRegion){
                        for (x = 1; x<3; x++)
                            Collections.shuffle(numberList);
                            for (int i =0; i<9;i++)
                                entries[x] = (Integer) numberList.get(i);
    System.out.println("re-determine");
    }while(!validityColumn || !validityRegion);
    for (int z = 0; z<9; z++)
    String value;
    for(int w = 0; w<9; w++){
    value = Integer.toString(entries[z][w]);
    printValue(canvas, value, z, w);
    This is the method that checks if the numbers in the columns are duplicatedprivate boolean checkColumn(int puzzleLength, int x) {
    // this method receives the puzzle length and row
    // it then checks to see if any number repeats
    // in the previous rows. if so, the row is
    // shuffled and realigned
    for (int j = 0; j<= puzzleLength; j++){
    for (int i =0; i< 9; i++)
    and this checks the regions..private boolean checkRegion(int puzzleLength) {
    if (puzzleLength == 2)
    for (int i = 0; i<3; i++)
    for (int j = 0; j<3; j++)
    for (int k = 0; k <3; k++)
    for (int l = 0; l<3; l++)
    if ((i != k && k != l) && entries[i][j] == entries[k][l])
    return false;
    return true;
    I am getting an infinate loop and I don't understand where or why...

    onorinbejasus wrote:
    I am getting an infinate loop and I don't understand where or why... Debug your application by placing some System.out.println's in your code and printing out the variables. That way, you see how they change and you can then deduce why an infinite loop is occurring.
    Start by debugging in your do-while statement: that is the only place (from the code you posted) where it can go in an infinite loop.
    I also recommend you create some "helper methods" to make the checking of rows, columns and regions easier:
    boolean[] getRow(int rowNumber) {
      // For example, if the 'rowNumber' has the numbers 1, 2, 3 and 8 filled in, return the
      // following array: [true, true, true, false, false, false, false, true, false]
      // You can also choose to return the numbers [1, 2, 3, 8] of course, that;'s for you to
      // decide (the return type should be changed to int[] of course)
    boolean[] getColumn(int columnNumber) {
      // the same as in getRow(...) but then the column values are returned
    boolean[] getRegion(int regionNumber) {
    }Good luck.

  • Server setting preventing .jar from being read/executed?

    Hey guys,
    I'm not completely sure this is the correct place to be posting my question, but I have been unable to find a better place for it, so hopefully someone here might be able to help me out.
    Ok.
    I have a signed .jar applet, that runs locally and when hosted on a server on the LAN. It also works when the .jar is hosted on my webspace given by my ISP.
    However, I have a website hosted where, for some reason, the applet fails. Furthermore, it only fails when it is packaged in a .jar archive. When only using .class files it works fine, however because I need to use .jar files in order to sign them this is no longer sufficient. The exception given by the java console is :
    java.lang.ClassNotFoundException: UserInterface.class
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed:http://www.nickmoores.com/applet/sudoku/UserInterface/class.class
         at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 7 more
    Exception: java.lang.ClassNotFoundException: UserInterface.class
    When I set the trace level in the java console to 5, the first exception that appears is :
    java.io.FileNotFoundException: http://www.nickmoores.com/applet/sudoku/sudoku.jar
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at sun.plugin.PluginURLJarFileCallBack.downloadJAR(Unknown Source) .... etc etc etc
    To me, this indicates that it can't find the .jar. However all the web browsers I have tried manage to find the file at the URL given by the exception (ie http://www.nickmoores.com/applet/sudoku/sudoku.jar), so it is not a simple case of having misplaced the jar or giving the wrong path.
    I made a simple .html page with the following html code :
    <!DOCTYPE HTML PUBLIC
      "-//IETF//DTD HTML LEVEL 1//EN">
    <HTML>
      <HEAD>
        <TITLE>Blank HTML Level 1 Page</TITLE>
        <META HTTP-EQUIV="Content-Type"
              CONTENT="text/html; charset=utf-8">
      </HEAD>
      <BODY>
         <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" name="SudokuApplet"
                   width="393" height="327"
                   codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_5_0-windows-i586.cab#Version=1,5,0,0">
              <param name="codebase" value="/applet/sudoku/" />
              <param name="archive" value="sudoku.jar" />
              <param name="code" value="UserInterface.class" />
              <param name="type" value="application/x-java-applet" />
              <comment>
                   <embed name="SudokuAppletFF"
                           archive="sudoku.jar"
                           codebase="http://nickmoores.pwp.blueyonder.co.uk/applet/sudoku/"
                           code="UserInterface.class"
                           width="393"
                           height="327"
                           type="application/x-java-applet"
                           pluginspage="http://java.sun.com/j2se/1.5.0/download.html">
                        <noembed>No Java Support.</noembed>
                   </embed>
              </comment>
         </object>
      </BODY>
    </HTML>I placed this page at my ISP webspace, my local LAN server, and the hosted site where it doesn't work, and put the .jar in the appropriate location on each server.
    As expected, it works everywhere EXCEPT the hosted website. This convinced me that there is a problem on the hosted website that is somehow preventing the .jar archive from being read from object/embed html tags. This seems strange as it manages to read and load .class files fine.
    I have communicated several times with the people who are hosting my site, and they haven't been too helpful so far. I've had several replies along the lines of "Can you try it now? I think it should be working" and "Have you tried testing it on a local site?", so i'm not sure they really know what the issue is.
    So does anyone know what setting on the server would be preventing the .jar from being loaded?
    If anyone wants to see the problem for themselves, the problem occurs at http://www.nickmoores.com/blanktest.html , but it works at http://www.nickmoores.pwp.blueyonder.co.uk . As you will see from the page source, the code is exactly the same, so it must be a server setting causing the problem, right?
    Thanks guys!

    Try this:
    <!--[if !IE]> -->
    <object classid="java:**.class"
    type="application/x-java-applet"
    archive="**.jar"
    height="350" width="550" >
    <param name="code" value="***.class" />
    <!-- For Konqueror -->
    <param name="archive" value="***.jar" />
    <param name="persistState" value="false" />
    </object>
    <!--<![endif]-->
    <!--[if IE]>
    <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"
    height="350" width="550" >
    <param name="archive" value="***.jar" />
    <param name="code" value="***.class" />
    <param name="persistState" value="false" />
    </object>
    <!--<![endif]-->

  • Sudoku Newspaper codes

    Where do you find these codes at.

    Can't help you with the newspaper question, though I was thinking one had to manually imput the numbers so that one did not have to use pen and paper. Not much gain in my opinion, that is unless it gives you warning for mistakes as it does in the imbedded games. Personally I don't use that mode.
    To remove a number that you inputed just input the same number back into that box. I came across this on my own, not sure if there is another way to do it or not.

  • Error message when trying to access the free Sudoku game I downloaded from Blackberry Owners' Forum

    I downloaded the free Sudoku game from the Blackberry Owners' Lounge (at http://na.blackberry.com/eng/ownerslounge/downloads/games.jsp) to my PC and then used the Blackberry Desktop Manager to transfer it to my Blackberry Curve 8300.
    But, when I try to open it from my Curve, I get the following error message: Application terminated: Sudoku has been denied the "Interprocess Communication" permission".
    Any idea what I've done wrong and/or how to correct the problem?

    Hi and Welcome to the Community!
    With the hundreds of possibilities, it's a pity you didn't provide the actual error message that you are seeing. Please provide the complete and exact error message, including all punctuation.
    Thanks!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Sudoku help needed

    Complete newcomer to java!!
    I want to create a sudoku java game using a gui. How do i go about this?? Whats the best way to start??

    Check this site for core java code to solve sudoku:
    http://kulandai.blogspot.com/2006/10/sudoku-puzzle-java-source.html

  • Sudoku GUI

    Hey am trying to create a GUI for my Sudoku board.
    Here is how it currently looks: (See code below)
    There are two things I wanna change
    1. How do I center align the number so they are not stuck to the right edge as they are now?
    2. How do I add a bolder line around blocks/boxes(e.g. the 3*3 sections). Im sure these are pretty easy but havent been able to figure it out as of yet!
    Any help would be greatly appreciated.
    Code:
    package proj.sudoku.gui;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Cursor;
    import java.awt.Font;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.InputMethodEvent;
    import java.awt.event.InputMethodListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.SwingConstants;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.DefaultTableCellRenderer;
    import proj.sudoku.representation.Board;
    import proj.sudoku.representation.Square;
    import proj.sudoku.ui.Sudoku;
    public class SudokuGUI extends JFrame implements ActionListener{
    private JTextField unfilledSquaresTextField;
    private JTextArea messagesTextArea;
    private JTable boardTable;
    private Board board;
    private Sudoku sudoku = new Sudoku();
    private int noOfUnfilledSquares = 20;
    private static final long serialVersionUID = 1L;
    class BoardTableTableModel extends AbstractTableModel {
    public final String[] COLUMN_NAMES = { "Row 0", "Row 1", "Row 2", "Row 3", "Row 4", "Row 5", "Row 6", "Row 7", "Row 8"};
    public int getRowCount() {
    return 9;
    public int getColumnCount() {
    return COLUMN_NAMES.length;
    public String getColumnName(int columnIndex) {
    return COLUMN_NAMES[columnIndex];
    public Object getValueAt(int rowIndex, int columnIndex) {
    int squareValue = board.getSquare(rowIndex, columnIndex).getSquareValue();
    if(squareValue == 0){
    return null;
    }else{
    return new Integer(squareValue);
    public boolean isCellEditable(int row, int col){
    return true;
    public void setValueAt(Object value, int row, int col) {
    int intValue = ((Integer)value).intValue();
    if((intValue >= 0) && (intValue < 10)){
    Square square = board.getSquare(row, col);
    square.setSquareValue(((Integer)value).intValue());
    board.setSquare(square, row, col);
    fireTableCellUpdated(row, col);
    public Class getColumnClass(int c) {
    return Integer.class;
    * Create the frame
    public SudokuGUI(Board newBoard) {
    super();
    getContentPane().setBackground(new Color(128, 128, 255));
    board = newBoard;
    getContentPane().setLayout(new GridBagLayout());
    setTitle("Sudoku Sudokme");
    setBounds(100, 100, 607, 456);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new GridBagLayout());
    final GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.weighty = 0.5;
    gridBagConstraints.weightx = 1;
    getContentPane().add(tablePanel, gridBagConstraints);
    boardTable = new JTable();
    boardTable.setRowHeight(40); // TODO This line has been changed
    boardTable.setFont(new Font("", Font.PLAIN, 20));// TODO This line has been changed
    boardTable.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    boardTable.setRowSelectionAllowed(false);
    boardTable.setShowGrid(true);
    boardTable.setModel(new BoardTableTableModel());
    final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();
    gridBagConstraints_2.gridx = 0;
    gridBagConstraints_2.gridy = 0;
    gridBagConstraints_2.insets = new Insets(0, -265, 0, 0);// TODO This line has been changed
    //gridBagConstraints_2.insets = new Insets(5, -265, 5, 0);
    tablePanel.add(boardTable, gridBagConstraints_2);
    final JPanel messagesPanel = new JPanel();
    messagesPanel.setLayout(new GridBagLayout());
    final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
    gridBagConstraints_6.weighty = 0.3;
    gridBagConstraints_6.weightx = 1.0;
    gridBagConstraints_6.gridy = 1;
    gridBagConstraints_6.gridx = 0;
    getContentPane().add(messagesPanel, gridBagConstraints_6);
    messagesTextArea = new JTextArea();
    messagesTextArea.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    messagesPanel.add(messagesTextArea, new GridBagConstraints());
    messagesTextArea.setText(board.getMessage());
    messagesTextArea.setEditable(false);
    final JPanel generateButtonPanel = new JPanel();
    generateButtonPanel.setLayout(new GridBagLayout());
    final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints();
    gridBagConstraints_3.gridy = 2;
    gridBagConstraints_3.gridx = 0;
    getContentPane().add(generateButtonPanel, gridBagConstraints_3);
    final JButton generateEmptyBoardButton = new JButton();
    generateEmptyBoardButton.addActionListener(this);
    generateEmptyBoardButton.setText("Generate Empty Board");
    final GridBagConstraints gridBagConstraints_9 = new GridBagConstraints();
    gridBagConstraints_9.gridy = 0;
    gridBagConstraints_9.gridx = 0;
    generateButtonPanel.add(generateEmptyBoardButton, gridBagConstraints_9);
    final JButton generateBoardButton = new JButton();
    generateBoardButton.addActionListener(this);
    generateBoardButton.setText("Generate Board");
    final GridBagConstraints gridBagConstraints_10 = new GridBagConstraints();
    gridBagConstraints_10.gridx = 2;
    generateButtonPanel.add(generateBoardButton, gridBagConstraints_10);
    final JLabel unfilledSquaresLabel = new JLabel();
    unfilledSquaresLabel.setText("Unfilled Squares");
    final GridBagConstraints gridBagConstraints_11 = new GridBagConstraints();
    gridBagConstraints_11.gridy = 0;
    gridBagConstraints_11.gridx = 3;
    generateButtonPanel.add(unfilledSquaresLabel, gridBagConstraints_11);
    unfilledSquaresTextField = new JTextField();
    unfilledSquaresTextField.setFont(new Font("", Font.BOLD, 14));
    unfilledSquaresTextField.addActionListener(this);
    unfilledSquaresTextField.setText(new Integer(noOfUnfilledSquares).toString());
    unfilledSquaresTextField.setBackground(Color.WHITE);
    final GridBagConstraints gridBagConstraints_12 = new GridBagConstraints();
    gridBagConstraints_12.gridy = 0;
    gridBagConstraints_12.gridx = 4;
    unfilledSquaresLabel.setLabelFor(unfilledSquaresTextField);
    generateButtonPanel.add(unfilledSquaresTextField, gridBagConstraints_12);
    final JPanel solveButtonsPanel = new JPanel();
    solveButtonsPanel.setRequestFocusEnabled(false);
    solveButtonsPanel.setLayout(new GridBagLayout());
    final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();
    gridBagConstraints_1.weighty = 0.1;
    gridBagConstraints_1.weightx = 1;
    gridBagConstraints_1.gridy = 3;
    gridBagConstraints_1.gridx = 0;
    getContentPane().add(solveButtonsPanel, gridBagConstraints_1);
    final JButton heuristicsSolveButton = new JButton();
    heuristicsSolveButton.addActionListener(this);
    heuristicsSolveButton.setText("Heuristics Solve");
    final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints();
    gridBagConstraints_4.gridx = 0;
    solveButtonsPanel.add(heuristicsSolveButton, gridBagConstraints_4);
    final JButton bruteForceSolveButton = new JButton();
    bruteForceSolveButton.addActionListener(this);
    bruteForceSolveButton.setText("Brute Force Solve");
    final GridBagConstraints gridBagConstraints_7 = new GridBagConstraints();
    gridBagConstraints_7.gridx = 1;
    solveButtonsPanel.add(bruteForceSolveButton, gridBagConstraints_7);
    final JButton hybridSolveButton = new JButton();
    hybridSolveButton.addActionListener(this);
    hybridSolveButton.setText("Hybrid Solve");
    final GridBagConstraints gridBagConstraints_8 = new GridBagConstraints();
    gridBagConstraints_8.gridx = 2;
    solveButtonsPanel.add(hybridSolveButton, gridBagConstraints_8);
    final JPanel testButtonsPanel = new JPanel();
    testButtonsPanel.setLayout(new GridBagLayout());
    final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints();
    gridBagConstraints_5.weighty = 0.1;
    gridBagConstraints_5.weightx = 1.0;
    gridBagConstraints_5.gridy = 4;
    gridBagConstraints_5.gridx = 0;
    getContentPane().add(testButtonsPanel, gridBagConstraints_5);
    final JButton checkIfValidButton = new JButton();
    checkIfValidButton.addActionListener(this);
    checkIfValidButton.setText("Check If Valid");
    testButtonsPanel.add(checkIfValidButton, new GridBagConstraints());
    final JButton checkIfLegalButton = new JButton();
    checkIfLegalButton.addActionListener(this);
    checkIfLegalButton.setText("Check If Legal");
    testButtonsPanel.add(checkIfLegalButton, new GridBagConstraints());
    public static void main(String args[]) {
    try {
    SudokuGUI frame = new SudokuGUI(new Board());
    frame.setVisible(true);
    //frame.pack();
    } catch (Exception e) {
    e.printStackTrace();
    public void actionPerformed(ActionEvent arg0) {
    if(arg0.getSource().getClass().getName().equals("javax.swing.JTextField")){
    noOfUnfilledSquares = new Integer(((JTextField)arg0.getSource()).getText()).intValue();
    this.repaint();
    }else{
    try{
    board = sudoku.processGUICommands(board, arg0.getActionCommand(), noOfUnfilledSquares);
    messagesTextArea.setText(board.getMessage());
    this.repaint();
    }catch(Exception e){
    e.printStackTrace();
    }

    1) Use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags when posting code so the code is readable
    2) The code you posted isn't compileable or executable so we see exactly what you layout looks like
    3) If you have a Grid type layout, then I would think a GridLayout would be more appropriate to use then the GridBagLayout. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use Layout Managers for more information.
    How do I add a bolder line around blocks/boxes[url http://java.sun.com/docs/books/tutorial/uiswing/misc/border.htmlHow to Use Borders[/url]
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

  • Sudoku-Generator

    Does anybody know PL/SQL-code for generating Sudoku-puzzles?
    Cheers,
    Nuerni

    Thanks for above links. But all seem to be solvers not generators - it's obvious that making sudoku puzzles is more complex than solving.
    Another starting point would be migration from other code to PL/SQL...?! Any further ideas?

  • Sudoku test 26

    Came up with this sudoku game, thought I would share :-) Enjoy
    Form1's code:
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private gameNumbers As New List(Of Integer) From {5, 3, 0, 0, 7, 0, 0, 0, 0, 6, 0, 0, 1, 9, 5, 0, 0, 0, 0, 9, _
    8, 0, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 0, 0, 3, 4, 0, 0, 8, _
    0, 3, 0, 0, 1, 7, 0, 0, 0, 2, 0, 0, 0, 6, 0, 6, 0, 0, 0, 0, _
    2, 8, 0, 0, 0, 0, 4, 1, 9, 0, 0, 5, 0, 0, 0, 0, 8, 0, 0, 7, 9}
    Private sGame As New SudokuGame(Me, gameNumbers)
    Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
    Me.Invalidate()
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.DoubleBuffered = True
    End Sub
    End Class
    Sudoku game class
    Public Class SudokuGame
    Public Property cellHeight As Integer = 20
    Public Property cellWidth As Integer = 20
    Public Property canvas As Control
    Private center As New Point(200, 200)
    Private mouseisDown As Boolean = False
    Private numbers As New List(Of SudokuGame.NumberCell)
    Private numberCells As New List(Of SudokuGame.NumberCell)
    Private currentPT As Point = New Point(0, 0)
    Private dFont As New Font("segoe script", 12)
    Private mousex As Integer
    Private mousey As Integer
    Friend WithEvents EditTB As New RichTextBox With {.Parent = canvas, .BorderStyle = BorderStyle.None, .Visible = False, .Font = New Font("Consolas", 16), .MaxLength = 1, .Multiline = False, .ForeColor = Color.Red, .BackColor = Color.DarkGoldenrod}
    Private editingIndex As Integer = 0
    Public Function CanCommitChange(ByRef numbercells As List(Of NumberCell), ByRef numberCell As NumberCell) As Boolean
    Dim cellRegionEnum As SudokuRegion = GetCellRegionEnum(numberCell)
    Dim cellRegion As List(Of NumberCell) = Me.GetRegion(numbercells, cellRegionEnum)
    Dim cellColumn As List(Of NumberCell) = Me.GetColumn(numbercells, numberCell.X)
    Dim cellRow As List(Of NumberCell) = Me.GetRow(numbercells, numberCell.Y)
    For Each nC As NumberCell In cellRegion
    If nC.Value = numberCell.Value Then
    If numberCell.Value = 0 Then Continue For
    Return False
    End If
    Next
    For Each nC As NumberCell In cellColumn
    If nC.Value = numberCell.Value Then
    If numberCell.Value = 0 Then Continue For
    Return False
    End If
    Next
    For Each nC As NumberCell In cellRow
    If nC.Value = numberCell.Value Then
    If numberCell.Value = 0 Then Continue For
    Return False
    End If
    Next
    Return True
    End Function
    Function colString(col As List(Of NumberCell)) As String
    Dim s As String = String.Empty
    For Each n As NumberCell In col
    s = s & n.Value
    Next
    Return s
    End Function
    Public Function GetCellRegionEnum(numberCell As NumberCell) As SudokuRegion
    Dim result As String = String.Empty
    Dim tLregion As New List(Of Integer) From {0, 1, 2, 9, 10, 11, 18, 19, 20}
    Dim tCregion As New List(Of Integer) From {3, 4, 5, 12, 13, 14, 21, 22, 23}
    Dim tRregion As New List(Of Integer) From {6, 7, 8, 15, 16, 17, 24, 25, 26}
    Dim cLregion As New List(Of Integer) From {27, 28, 29, 36, 37, 38, 45, 46, 47}
    Dim cCregion As New List(Of Integer) From {30, 31, 32, 39, 40, 41, 48, 49, 50}
    Dim cRregion As New List(Of Integer) From {33, 34, 35, 42, 43, 44, 51, 52, 53}
    Dim bLregion As New List(Of Integer) From {54, 55, 56, 63, 64, 65, 72, 73, 74}
    Dim bCregion As New List(Of Integer) From {57, 58, 59, 66, 67, 68, 75, 76, 77}
    Dim bRregion As New List(Of Integer) From {60, 61, 62, 69, 70, 71, 78, 79, 80}
    Select Case True
    Case tLregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.TopLeft
    Case tCregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.TopCenter
    Case tRregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.TopRight
    Case cLregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.CenterLeft
    Case cCregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.CenterCenter
    Case cRregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.CenterRight
    Case bLregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.BottomLeft
    Case bCregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.BottomCenter
    Case bRregion.IndexOf(numberCell.ArrayIndex) > -1 : Return SudokuRegion.BottomRight
    End Select
    Return Nothing
    End Function
    Public Function GetColumn(numbercells As List(Of NumberCell), colNumber As Integer) As List(Of NumberCell)
    Dim results As New List(Of NumberCell)
    For i As Integer = colNumber To 80 Step 9
    results.Add(numbercells(i))
    Next
    Return results
    End Function
    Public Function GetRow(numbercells As List(Of NumberCell), rowNumber As Integer) As List(Of NumberCell)
    Dim start As Integer = rowNumber * 9
    Dim results As New List(Of NumberCell)
    For I As Integer = start To start + 8
    results.Add(numbercells(I))
    Next
    Return results
    End Function
    Public Function RegionToString(numbercells As List(Of NumberCell), sRegion As SudokuRegion) As String
    Dim region As List(Of NumberCell) = Me.GetRegion(numbercells, sRegion)
    Dim sb As New System.Text.StringBuilder
    For i As Integer = 1 To region.Count
    sb.Append(region(i - 1).Value.ToString)
    If i Mod 3 = 0 Then sb.Append(vbCrLf)
    Next
    Return sb.ToString
    End Function
    Private Function ZeroCount(s As String) As Integer
    Dim result As Integer
    For Each c As Char In s
    If c = "0"c Then result += 1
    Next
    Return result
    End Function
    Public Function GetRegion(numbercells As List(Of NumberCell), region As SudokuRegion) As List(Of NumberCell)
    Dim c As List(Of NumberCell) = numbercells
    Select Case region
    Case SudokuRegion.Top
    Case SudokuRegion.TopCenter : Return {c(3), c(4), c(5), c(12), c(13), c(14), c(21), c(22), c(23)}.ToList
    Case SudokuRegion.TopRight : Return {c(6), c(7), c(8), c(15), c(16), c(17), c(24), c(25), c(26)}.ToList
    Case SudokuRegion.Center
    Case SudokuRegion.CenterCenter : Return {c(30), c(31), c(32), c(39), c(40), c(41), c(48), c(49), c(50)}.ToList
    Case SudokuRegion.CenterRight : Return {c(33), c(34), c(35), c(42), c(43), c(44), c(51), c(52), c(53)}.ToList
    Case SudokuRegion.Bottom
    Case SudokuRegion.BottomCenter : Return {c(57), c(58), c(59), c(66), c(67), c(68), c(75), c(76), c(77)}.ToList
    Case SudokuRegion.BottomRight : Return {c(60), c(61), c(62), c(69), c(70), c(71), c(78), c(79), c(80)}.ToList
    End Select
    Return New List(Of NumberCell)
    End Function
    Public Enum SudokuRegion
    TopLeft
    TopCenter
    TopRight
    CenterLeft
    CenterCenter
    CenterRight
    BottomLeft
    BottomCenter
    BottomRight
    End Enum
    Public Function renderSudakoCard(g As Graphics, center As Point, frameSize As Size, backColor As Color, numbers As List(Of NumberCell), font As Font) As List(Of NumberCell)
    Dim results As New List(Of NumberCell)
    Dim boldEveryNLines As Integer = 3
    Dim BoldLines As Boolean = True
    Dim rowCount As Integer = 9
    Dim columnCount As Integer = 9
    g.Clear(backColor)
    Dim combo As String = "000000"
    If rowCount Mod 2 = 1 Then combo = combo & "1" Else combo = combo & "0"
    If columnCount Mod 2 = 1 Then combo = combo & "1" Else combo = combo & "0"
    If cellHeight Mod 2 = 1 Then cellHeight += 1
    If cellWidth Mod 2 = 1 Then cellWidth += 1
    Select Case Convert.ToInt32(combo, 2)
    Case 0
    Dim centerX As Integer = center.X
    Dim centerY As Integer = center.Y
    Dim topY As Integer = centerY - ((rowCount \ 2) * cellHeight)
    Dim bottomY As Integer = centerY + ((rowCount \ 2) * cellHeight)
    Dim leftX As Integer = centerX - ((columnCount \ 2) * cellWidth)
    Dim rightX As Integer = centerX + ((columnCount \ 2) * cellWidth)
    RenderBackGround(g, topY, bottomY, leftX, rightX)
    DrawLines(g, leftX, rightX, topY, bottomY, boldEveryNLines, BoldLines)
    results.AddRange(DrawNumbers(g, numbers, topY, leftX, font))
    Case 1
    Dim centerX As Integer = center.X
    Dim centerY As Integer = center.Y
    Dim topY As Integer = centerY - ((rowCount \ 2) * cellHeight)
    Dim bottomY As Integer = centerY + ((rowCount \ 2) * cellHeight)
    Dim remainderColumns As Integer = (columnCount - 1) \ 2
    Dim leftX As Integer = (centerX - (cellWidth \ 2)) - (remainderColumns * cellWidth)
    Dim rightX As Integer = (centerX + (cellWidth \ 2)) + (remainderColumns * cellWidth)
    RenderBackGround(g, topY, bottomY, leftX, rightX)
    DrawLines(g, leftX, rightX, topY, bottomY, boldEveryNLines, BoldLines)
    results.AddRange(DrawNumbers(g, numbers, topY, leftX, font))
    Case 2
    Dim centerX As Integer = center.X
    Dim centerY As Integer = center.Y
    Dim remainderRows As Integer = (rowCount - 1) \ 2
    Dim topY As Integer = (centerY - (cellHeight \ 2)) - (remainderRows * cellHeight)
    Dim bottomY As Integer = (centerY + (cellHeight \ 2)) + (remainderRows * cellHeight)
    Dim leftX As Integer = centerX - ((columnCount \ 2) * cellWidth)
    Dim rightX As Integer = centerX + ((columnCount \ 2) * cellWidth)
    RenderBackGround(g, topY, bottomY, leftX, rightX)
    DrawLines(g, leftX, rightX, topY, bottomY, boldEveryNLines, BoldLines)
    results.AddRange(DrawNumbers(g, numbers, topY, leftX, font))
    Case 3
    Dim centerX As Integer = center.X
    Dim centerY As Integer = center.Y
    Dim remainderRows As Integer = (rowCount - 1) \ 2
    Dim topY As Integer = (centerY - (cellHeight \ 2)) - (remainderRows * cellHeight)
    Dim bottomY As Integer = (centerY + (cellHeight \ 2)) + (remainderRows * cellHeight)
    Dim remainderColumns As Integer = (columnCount - 1) \ 2
    Dim leftX As Integer = (centerX - (cellWidth \ 2)) - (remainderColumns * cellWidth)
    Dim rightX As Integer = (centerX + (cellWidth \ 2)) + (remainderColumns * cellWidth)
    RenderBackGround(g, topY, bottomY, leftX, rightX)
    DrawLines(g, leftX, rightX, topY, bottomY, boldEveryNLines, BoldLines)
    results.AddRange(DrawNumbers(g, numbers, topY, leftX, font))
    End Select
    Return results
    End Function
    Private Sub RenderBackGround(g As Graphics, topY As Integer, bottomY As Integer, LeftX As Integer, RightX As Integer)
    Dim left As Integer = LeftX - 5
    Dim top As Integer = topY - 5
    Dim width As Integer = (RightX - left) + 5
    Dim height As Integer = (bottomY - top) + 5
    Dim backGround As New Rectangle(left, top, width, height)
    g.FillRectangle(Brushes.White, backGround)
    End Sub
    Public Function GetCellAt(arr As List(Of NumberCell), location As Point) As NumberCell
    Dim index As Integer = (location.Y * 9) + location.X
    Return arr(index)
    End Function
    Private Sub DrawLines(g As Graphics, leftX As Integer, rightX As Integer, topY As Integer, bottomY As Integer, boldEveryNLines As Integer, boldLines As Boolean)
    Dim cnt As Integer = 0
    Dim sudPen As New Pen(Brushes.OliveDrab, 2)
    For x As Integer = leftX To rightX Step cellWidth
    Dim p1 As New Point(x, topY)
    Dim p2 As New Point(x, bottomY)
    If cnt Mod boldEveryNLines = 0 AndAlso boldLines = True Then
    g.DrawLine(sudPen, p1, p2)
    Else
    g.DrawLine(Pens.Black, p1, p2)
    End If
    cnt += 1
    Next
    cnt = 0
    For y As Integer = topY To bottomY Step cellHeight
    Dim p1 As New Point(leftX, y)
    Dim p2 As New Point(rightX, y)
    If cnt Mod boldEveryNLines = 0 AndAlso boldLines = True Then
    g.DrawLine(sudPen, p1, p2)
    Else
    g.DrawLine(Pens.Black, p1, p2)
    End If
    cnt += 1
    Next
    End Sub
    Private Function DrawNumbers(g As Graphics, numbers As List(Of NumberCell), topY As Integer, leftX As Integer, font As Font) As List(Of NumberCell)
    Dim results As New List(Of NumberCell)
    Dim counter As Integer = 1
    Dim txtY As Integer = topY + (cellHeight \ 2)
    Dim locX As Integer = 0
    Dim locY As Integer = 0
    For I As Integer = 0 To numbers.Count - 1
    Dim n As Integer = numbers(I).Value
    Dim x As Integer = (leftX - (cellWidth \ 2)) + (cellWidth * counter)
    Dim nString As String = n.ToString
    Dim textSizeF As SizeF = g.MeasureString(nString, font)
    Dim textSize As Size = New Size(CInt(textSizeF.Width), CInt(textSizeF.Height))
    Dim nX As Integer = x - (textSize.Width \ 2)
    Dim nY As Integer = txtY - (textSize.Height \ 2)
    Dim cX As Integer = leftX + (cellWidth * counter) - cellWidth
    Dim cy As Integer = txtY - (cellHeight \ 2)
    Dim cR As New Rectangle(cX, cy, cellWidth, cellHeight)
    Dim nCell As New NumberCell(n, I)
    nCell.Locked = numbers(I).Locked
    nCell.Bounds = cR
    nCell.X = locX
    nCell.Y = locY
    results.Add(nCell)
    locX += 1
    counter += 1
    If counter Mod 10 = 0 Then
    txtY += cellHeight
    locY += 1
    locX = 0
    counter = 1
    End If
    If n = Nothing OrElse n = 0 Then Continue For
    If nCell.Locked = True Then
    g.DrawString(nString, font, Brushes.Black, New Point(nX, nY))
    Else
    g.DrawString(nString, New Font(font.FontFamily, font.Size, FontStyle.Bold), Brushes.Green, New Point(nX, nY))
    End If
    Next
    Return results
    End Function
    Public Class NumberCell
    Public Property Bounds As New Rectangle
    Public Property ArrayIndex As Integer
    Public Property Value As Integer
    Public Property Locked As Boolean = False
    Public Property X As Integer
    Public Property Y As Integer
    Sub New(value As Integer, ArrayIndex As Integer)
    Me.Value = value
    Me.ArrayIndex = ArrayIndex
    If value = 0 Then
    Me.Locked = False
    Else
    Me.Locked = True
    End If
    End Sub
    Public Function IntersectsWith(pt As Point) As Boolean
    Return Bounds.IntersectsWith(New Rectangle(pt, New Size(1, 1)))
    End Function
    Public Shadows Function ToString() As String
    Return String.Format("Value={0} ArrayIndex={1} {2} X={3} Y={4}", Me.Value, Me.ArrayIndex, Me.Bounds.ToString, Me.X, Me.Y)
    End Function
    End Class
    Sub AddHandlers()
    AddHandler canvas.MouseClick, AddressOf canvas_MouseClick
    AddHandler canvas.Paint, AddressOf canvas_Paint
    AddHandler canvas.MouseMove, AddressOf canvas_MouseMove
    AddHandler canvas.MouseUp, AddressOf canvas_MouseUp
    AddHandler canvas.MouseDown, AddressOf canvas_MouseDown
    End Sub
    Private Sub canvas_MouseClick(sender As Object, e As MouseEventArgs)
    If e.Button = Windows.Forms.MouseButtons.Right Then Exit Sub
    For Each n As SudokuGame.NumberCell In numberCells
    If n.IntersectsWith(currentPT) Then
    If Not n.Locked Then
    If n.Value > 0 Then
    EditTB.Text = n.Value.ToString
    Else
    EditTB.Text = ""
    End If
    EditTB.Visible = True
    EditTB.Width = n.Bounds.Width - 1
    EditTB.Height = n.Bounds.Height - 1
    EditTB.Left = n.Bounds.X + 1
    EditTB.Top = n.Bounds.Y + 1
    EditTB.Focus()
    EditTB.SelectionStart = 0
    EditTB.SelectionLength = EditTB.Text.Length
    editingIndex = n.ArrayIndex
    Else
    EditTB.Visible = False
    End If
    canvas.Invalidate()
    Exit For
    Else
    End If
    Next
    End Sub
    Private Sub canvas_Paint(sender As Object, e As PaintEventArgs)
    canvas.Text = "Sudoku v0.1 by Paul Ishak"
    numberCells = Me.renderSudakoCard(e.Graphics, center, canvas.ClientRectangle.Size, canvas.BackColor, numbers, dFont)
    e.Graphics.DrawString("Use the RIGHT mouse button to drag the sudoku grid.", New Font("segoe script", 12), Brushes.Black, New Point(5, 5))
    End Sub
    Sub CommitChange()
    If Not EditTB.Text = "" Then
    Try
    Dim tmp As SudokuGame.NumberCell = numberCells(editingIndex)
    Dim intValue As Integer = 0
    Integer.TryParse(EditTB.Text, intValue)
    If intValue > 9 Then intValue = 9
    Dim newCell As New SudokuGame.NumberCell(intValue, tmp.ArrayIndex)
    newCell.Bounds = tmp.Bounds
    newCell.Locked = tmp.Locked
    newCell.X = tmp.X
    newCell.Y = tmp.Y
    If Me.CanCommitChange(numberCells, newCell) Then
    numbers(editingIndex) = newCell
    numberCells(editingIndex) = newCell
    EditTB.Text = ""
    EditTB.Visible = False
    canvas.Invalidate()
    Else
    EditTB.Text = ""
    EditTB.Visible = False
    Beep()
    canvas.Invalidate()
    End If
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End If
    End Sub
    Public Function configureGame(gameNumbers As List(Of Integer)) As List(Of SudokuGame.NumberCell)
    Dim result As New List(Of SudokuGame.NumberCell)
    For I As Integer = 1 To 81
    result.Add(New SudokuGame.NumberCell(gameNumbers(I - 1), I - 1))
    Next
    Return result
    End Function
    Private Sub canvas_MouseMove(sender As Object, e As MouseEventArgs)
    Dim pt As Point = canvas.PointToClient(Control.MousePosition)
    currentPT = pt
    If mouseisDown Then
    center = pt
    canvas.Invalidate()
    Else
    End If
    End Sub
    Private Sub canvas_MouseUp(sender As Object, e As MouseEventArgs)
    mouseisDown = False
    End Sub
    Private Sub canvas_MouseDown(sender As Object, e As MouseEventArgs)
    If e.Button = Windows.Forms.MouseButtons.Right Then
    EditTB.Visible = False
    mouseisDown = True
    ElseIf e.Button = Windows.Forms.MouseButtons.Left Then
    End If
    End Sub
    Private Sub EditTB_KeyDown(sender As Object, e As KeyEventArgs) Handles EditTB.KeyDown
    Select Case True
    Case e.KeyCode = Keys.Enter
    End Select
    End Sub
    Private Sub EditTB_KeyUp(sender As Object, e As KeyEventArgs) Handles EditTB.KeyUp
    CommitChange()
    End Sub
    Sub New(canvas As Control, gameNumbers As List(Of Integer))
    Me.canvas = canvas
    EditTB.Parent = canvas
    AddHandlers()
    numbers = configureGame(gameNumbers)
    End Sub
    End Class
    “If you want something you've never had, you need to do something you've never done.”
    Don't forget to mark
    helpful posts and answers
    ! Answer an interesting question? Write a
    new article
    about it! My Articles
    *This post does not reflect the opinion of Microsoft, or its employees.

    Have you tried searching for the error message? A few min on google gives some useful advice.
    http://stackoverflow.com/questions/14527201/vhdl-assigning-default-values
    "All entity inputs must have either a signal driving them, or a default value specified in the entity declaration."

  • SUDOKU (résolutio​n avec LV)

    Résolution des Sudoku avec LV.
    Ce VI utilise un algorithme de réflexion associé à un algorithme de backtraking. (100% home made)
    Il agit comme nous le ferions nous mêmes, par déductions, éliminations, recoupements
    et ... retour arrière en cas de "cul de sac".
    Les Sudoku "faciles" utilisent peu le backtraking. (pas du tout pour certains)
    Plus un Sudoku est difficile, plus il possède de solutions différentes.
    Celui que j'ai placé en "valeur par défaut d'entrée" est un exemple de Sudoku très difficile.
    Une horreur à résoudre, pour reprendre les termes de certains (je l'ai trouvé sur le Net)
    Ce Sudoku possèdent 2756 solutions différentes.
    Ce VI trouve la 1ere solution en 23 ms ... et les 2756 en un peu plus de 9 sec (Q6600 - 2.6Ghz)
    Possibilités:
    input - votre sudoku à résoudre.
    trouver une solution (la 1ere)
    trouver toutes les solutions.
    Faire pause (une fois que vous avez appuyé sur Pause, le petit bouton blanc permet de visualiser les solutions une par une)
    Le VI principal est : SUDOKU.vi
    Pour le tester rapidement ... lancer le vi et run
    1) start : il vous trouve la 1ere solution
    2) basculer l'interrupteur sur "all solutions" ... start ... il trouvera les 2756 solutions.
    voilou.
    Sur ce coup là ... me suis encore bien amusé
    Résolu !
    Accéder à la solution.
    Pièces jointes :
    main = SUDOKU.vi.zip ‏194 KB

    Il y a une règle pour interdire les groupes non anglophone?
    1) mon dieu ... que cela est bien difficle d'exprimer quelque chose ... de simple et de simplement dit.
    Je comprends que ceux qui travaillent sous LabVIEW tout ou partie de la journée aient envie de faire autre chose une fois chez eux.
    2) Je comprends parfaitement également, Il s'agissait d'un simple constat. (voir point 1)
    https://decibel.ni.com/content/docs/DOC-6108
    J'ai trouvé ceci sur le Net ... joli morceau de code ! très jolie cette solution récursive ...
    Mais ... mon algo va 5 fois plus vite. Résolution de la 1ere solution : 138ms contre 27ms.
    Cet algo récursif utilise également le backtraking, mais devant une impasse, il essaye "simplement" le nombre suivant.
    De mon côté, je calcule les possibilités pour chaque cases et à chaque instant,
    et quand je reviens en arrière, je ne passe pas "simplement" au nombre suivant ... mais au nombre suivant "possible" !

  • Is it possible to create a java program which can find the answer to any sudoku

    This is may sound as a beginner question but thats because i am a beginner. i have just learned the java language and now i am reading essential classes on oracle tutorials.
    anyway is this possible ? i think it is and i have been trying to do it but havent been sucessful. and if it is possible is it supposed to be easy ?
    i have been trying to do it by making a 2d array of 8 arrays having 8 ints each which is basically a sudoku. and creating a 1d array called possiblity having nos from 1 to 9. then using decision making statements and loops to eliminate the possiblities of each box and repeating until the sudoku is complete
    also if you could provide some project ideas that would be really appreciated.
    (PS i am still an intermediate at best so please dont provide very difficult project ideas)

    f1b8d129-b881-44f7-a736-5eef31471720 wrote:
    This is may sound as a beginner question but thats because i am a beginner. i have just learned the java language and now i am reading essential classes on oracle tutorials.
    anyway is this possible ?
    Yes.
    i think it is and i have been trying to do it but havent been sucessful. and if it is possible is it supposed to be easy ?
    Maybe.
    It should be easy to do a "brute force attack" to find the solution meaning that you simply try each and every possibility.
    i have been trying to do it by making a 2d array of 8 arrays having 8 ints each which is basically a sudoku. and creating a 1d array called possiblity having nos from 1 to 9. then using decision making statements and loops to eliminate the possiblities of each box and repeating until the sudoku is complete
    shouldn't there be 9 sqares with 9 fields each?
    also if you could provide some project ideas that would be really appreciated.
    But an array of primitives (int?) will not do the trick. Somehow you have to remember wich positions are fixed. and which numbers are still availabe for the current sqare.
    At your level the most obvisual approach may be a second array holding this information.
    I'd prefer to build a cusom object representing a square and another custom object to represent a field within this square with two attributes: currentNumber and isFix.
    Based on this the Sqare object could have a method to create a new combination by shifting the numbers that are not fix.
    If you need further assistance please show the code you have and what problem(s) you have with it.
    bye
    TPD

  • Applet sudoku

    Hello, I was wondering if anyone can help me. I am designing a sudoku game for a project in uni and im struggling to use applets. The difficulty im having now is that i have paint drawing each small grid(as a colored area in the background), but I am using a for loop to create each individual jtextfield for input and within paint it causes issues. Is their a way I can create the painted background for the smaller grids and then add the jtextfields over this outside of paint?
    Also any links for good applet tutorials welcome,
    cheers in advance
    MM

    ok, im lost again:)
    This is the code i have to give you an idea what im attempting to do, is this the completely wrong way to do this?
    public class sudoku extends Applet {
            int row[];
            int column[];
            JTextField game[][];
            JTextField f;
            JTextField n;
            JButton start;
         public void init() {          
              game=new JTextField[9][9];
         public void paint(Graphics g)
              super.paint(g);
              g.setColor(new Color(185, 220, 250));
              g.fillRect(0,0,115,115);
              g.fillRect(235,0,115,115);
              g.fillRect(115,115,120,120);
              g.fillRect(0,235,115,115);
              g.fillRect(235,235,115,115);
              g.setColor(new Color(127, 203, 250));
              g.fillRect(115,0,120,115);
              g.fillRect(0,115,115,120);
              g.fillRect(235,115,115,120);
              g.fillRect(115,235,120,115);
              setLayout(null);
              int row=5;
              int col=5;
              int watcher=0;
              for(int i=0; i<game.length;i++)
                   for(int j=0; j<game.length; j++)
                        if(watcher==8)
                             game[i][j]=new JTextField(""+ Integer.toString(i) +""+ Integer.toString(j) +"");
                             game[i][j].setBounds(row,col,20,20);
                             add(game[i][j]);
                             row=5;
                             col=col+40;
                             watcher=0;
                             System.out.println(" watcher equal 9 "+watcher+" i="+i+" j="+j+" row="+row+" col="+col);
                        else
                             game[i][j]=new JTextField();
                             game[i][j].setBounds(row,col,20,20);
                             add(game[i][j]);
                             row=row+40;
                             watcher++;
                             //System.out.println(" watcher not equal 9 "+watcher+" i="+i+" j="+j+" row="+row+" col="+col);
                             //System.out.println("minigrid   =" +minigrid(i,j));
         start=new JButton("Start");
         start.setBounds(1,370,100,30);
         add(start);
         }Thanks again all!!!
    MM

  • Sudoku generator problems(Stack overflow)

    I've been having some troubles trying to implement a program that generates sudoku problems. It takes a complete puzzle and pulls out the first number and tries to solve it with any of the 8 other numbers and if it can't then that means removing that variable completely will still keep the uniqueness of the solution. Problem is, I'm getting some stack overflow errors while implementing this and I have no idea why. My code is as follows, where the method solve is a program I've already written that can solve any sudoku problem.
    public int[][] generate(int [][] board) throws java.io.IOException {
              int oldValue;
              int[][] tempBoard = new int[9][9];
              for (int x = 0; x < 9; x++) {
                   for (int y = 0; y < 9; y++) {
                        tempBoard[x][y] = board[x][y];
              for (int x = 0; x < 9; x++) {
                   for (int y = 0; y < 9; y++) {
                        oldValue = board[x][y];
                        for (int z = 1; z <= 9; z++) {
                             if (z != oldValue) {
                                  board[x][y] = z;
                                  tempBoard = solve(tempBoard);
                                  if (tempBoard != null) {
                                       board[x][y] = oldValue;
                                       break;
                                  else {
                                       tempBoard = new int[9][9];
                                       for (int a = 0; a < 9; a++) {
                                            for (int b = 0; b < 9; b++) {
                                                 tempBoard[a] = board[a][b];
                        board[x][y] = 0;
                        for (int c = 0; c < 9; c++) {
                             for (int d = 0; d < 9; d++) {
                                  tempBoard[c][d] = board[c][d];
              return board;

    I was in the middle of editing that when you posted that, sorry
    public int[][] generate(int [][] board) throws java.io.IOException {
              int oldValue;
              int[][] tempBoard = new int[9][9];
              for (int x = 0; x < 9; x++) {
                   for (int y = 0; y < 9; y++) {
                        tempBoard[x][y] = board[x][y];
              for (int x = 0; x < 9; x++) {
                   for (int y = 0; y < 9; y++) {
                        oldValue = board[x][y];
                        for (int z = 1; z <= 9; z++) {
                             if (z != oldValue) {
                                  board[x][y] = z;
                                  tempBoard = solve(tempBoard);
                                  if (tempBoard != null) {
                                       board[x][y] = oldValue;
                                       break;
                                  else {
                                       tempBoard = new int[9][9];
                                       for (int a = 0; a < 9; a++) {
                                            for (int b = 0; b < 9; b++) {
                                                 tempBoard[a] = board[a][b];
                        board[x][y] = 0;
                        for (int c = 0; c < 9; c++) {
                             for (int d = 0; d < 9; d++) {
                                  tempBoard[c][d] = board[c][d];
              return board;
    Edited by: rhett77 on Oct 19, 2007 10:23 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • How to change number of new messages

    Is there a way to change how iCloud shows the number of new messages from including the whole thread of messages? ie - it shows the number of all old messages in a thread when there's just one new message.

  • My Macbook pro suddenly running very slow

    I have a 13" mid 2012 Macbook pro running OS X Mavericks v 10.9.4. About two weeks ago it suddenly became very slow and unresponsive. Startup and shut down takes much longer than usual, file transfers are slow and apps are taking forever to launch. T

  • A problem using bdbxml

    I download and install the dbd xml 2.3.8,in windows xp ,I use the cmd.exe to run dbxml and create a container phone.dbxml,then put some xml document as the docs.but whne i use query it occur error: dbxml> query ' collection("phone.dbxml")/string()' s

  • Infinite loop during recovery of JE 4.1.10 database environment

    Hi there, We have a JE 4.1.10 database environment which is over 20GB in size. In order to improve performance we increased je.log.fileCacheSize so that we could cache all of the 10MB DB log file descriptors in memory and prevent JE from having to co

  • Splash Screen Security?

    With 1200 series IOS APs, is it possible / will it someday be possible to enable security that involves a splash screen presented to the user when they open an IE browser, where they enter a password to get authenticated and on the WLAN? I know it's