Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 15:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Sudoku - Zulässigkeit

Discussion on Sudoku - Zulässigkeit within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
The_Dentist's Avatar
 
elite*gold: 13
Join Date: Nov 2014
Posts: 71
Received Thanks: 4
Sudoku - Zulässigkeit

Hallo,

Ich habe noch ein zweites Problem, diesmal geht es um einen Sudokolöser:

Meine Methode sieht derzeit wie folgt aus:

Code:
static boolean zulaessig(int[][] feld, int x, int y) {

int wert = feld[x][y];
		


		for(int i = 0; i < 9; i++){
			if(wert == feld[i][y]) return false;
		}	
		for(int j = 0; j < 9; j++){
			if(wert == feld[x][j]) return false;
		}

	

		return true;

	}
Jetzt habe ich das Problem, dass ich noch einmal 3*3 Feld durchgehen soll. Die Aufgabenstellung ist: Dies möglichst effizient zu programmieren, also laufe ich einmal die Spalte durch mit dem Wert und einmal die Zeile.

Leider funktioniert dies noch nicht wie es soll. Zudem weiß ich auch noch nicht genau wie ich das 3*3 kleine Feld durchgehe.

Kann mir dabei Jemand helfen?

Vielen Dank.

LG

The_Dentist
The_Dentist is offline  
Old 12/08/2014, 13:48   #2
 
Belur's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 3,441
Received Thanks: 1,473
Ich habs jetzt nicht compiliert und gestestet obs klappt aber so müsste das in etwa gehen:

PHP Code:
public static boolean checkBox(int xint yint val) {

        
int xTemp = (x/3)*3;
        
int yTemp = (y/3)*3;
        

        for (
int row xTemprow xTemp+3row++) {
            for (
int col yTempcol yTemp+3col++) {
                if (
Field[row][col] == val) {
                    return 
false;
                }
            }
        }
        return 
true;
    } 
Dein Problem mit den springenden Damen schon gelöst?
Belur is offline  
Reply


Similar Threads Similar Threads
Kleines Sudoku
11/26/2012 - Freebies - 33 Replies
Hallo hab ma ein kleines soduku für euch vorbereitet Es soll ÜBER ALL 15 RAUS KOMMEN Ihr Dürft nicht die 5 in die mitte machen. Zahlen . 1-2-3-4-5-6-7-8-9 Von Links - Rechts Von Oben - Unten und auch Quer z.B so 5+6+4 :15 x+x+x :15 x+x+x :15
Sudoku in Aion
07/16/2011 - Aion - 4 Replies
hej ihrs, aus langeweile hab ich die vergangenen tage mal ein kleines sudoku-plugin fuer Aion gebastelt. wenn euch also mal im spiel mal langweilig ist weil z.b. grad alle gegner tot sind und man warten muss bis sie wieder angelaufen kommen, koennt ihr euch nun mit einem kleinen sudoku spiel die zeit vertreiben^^ http://img685.imageshack.us/img685/9656/aion0004d nh.jpg wie koennt ihr auch spielen? ganz einfach: im anhang findet ihr in gepackter form 3 dateien. diese muesst ihr in...
Sudoku Rätsel bei meitn2
12/24/2009 - Metin2 - 6 Replies
CLOSE PLS ANTWORT HABE ICH SCHO BEKOMMEN



All times are GMT +1. The time now is 15:44.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.