Moderatori: Anthony47, Triumph Of Steel, archimede
012504870040000000750016423504108730020050040003409500480005017000000000235701690
=Sudoku(A1)
' use integer;@A=split//,<>;sub R{for$i(0..80){next if$A[$i];my%t=map{$_/9
' ==$i/9||$_%9==$i%9||$_/27==$i/27&&$_%9/3==$i%9/3?$A[$_]:0=>1}0..80;R($A[
' $i]=$_)for grep{!$t{$_}}1..9;return$A[$i]=0}die@A}R
Private Function Sudoku(A As String) As String
Dim t(10) As Integer
Dim i As Integer, j As Integer
For i = 0 To 80
If Mid(A, i + 1, 1) = "0" Then
For j = 0 To 9
t(j) = 0
Next
For j = 0 To 80
t(IIf(Int(j / 9) = Int(i / 9) Or Int(j Mod 9) = Int(i Mod 9) Or Int(j / 27) = Int(i / 27) And Int(j Mod 9 / 3) = Int(i Mod 9 / 3), Asc(Mid(A, j + 1, 1)) - 48, 0)) = 1
Next
For j = 1 To 9
If t(j) = 0 Then
If i = 0 Then
A = Trim(Str(j)) & Right(A, 80)
ElseIf i = 80 Then
A = Left(A, 80) & Trim(Str(j))
Else
A = Left(A, i) & Trim(Str(j)) & Right(A, 80 - i)
End If
Call Sudoku(A)
End If
Next
If i = 0 Then
A = "0" & Right(A, 80)
ElseIf i = 80 Then
A = Left(A, 80) & "0"
Else
A = Left(A, i) & "0" & Right(A, 80 - i)
End If
Exit Function
End If
Next
Sudoku = A
End Function
' use integer;@A=split//,<>;sub R{for$i(0..80){next if$A[$i];my%t=map{$_/9
' ==$i/9||$_%9==$i%9||$_/27==$i/27&&$_%9/3==$i%9/3?$A[$_]:0=>1}0..80;R($A[
' $i]=$_)for grep{!$t{$_}}1..9;return$A[$i]=0}die@A}R
Dim i As Integer
Private Function Sudoku(A As String) As String
Dim t(10) As Integer
Dim j As Integer
For i = 0 To 80
If Mid(A, i + 1, 1) = "0" Then
For j = 0 To 9
t(j) = 0
Next
For j = 0 To 80
t(IIf(Int(j / 9) = Int(i / 9) Or Int(j Mod 9) = Int(i Mod 9) Or Int(j / 27) = Int(i / 27) And Int(j Mod 9 / 3) = Int(i Mod 9 / 3), Asc(Mid(A, j + 1, 1)) - 48, 0)) = 1
Next
For j = 1 To 9
If t(j) = 0 Then
If i = 0 Then
A = Trim(Str(j)) & Right(A, 80)
ElseIf i = 80 Then
A = Left(A, 80) & Trim(Str(j))
Else
A = Left(A, i) & Trim(Str(j)) & Right(A, 80 - i)
End If
Call Sudoku(A)
End If
Next
If i = 0 Then
A = "0" & Right(A, 80)
ElseIf i = 80 Then
A = Left(A, 80) & "0"
Else
A = Left(A, i) & "0" & Right(A, 80 - i)
End If
Exit Function
End If
Next
Sudoku = A
MsgBox A
End Function
' use integer;@A=split//,<>;sub R{for$i(0..80){next if$A[$i];my%t=map{$_/9
' ==$i/9||$_%9==$i%9||$_/27==$i/27&&$_%9/3==$i%9/3?$A[$_]:0=>1}0..80;R($A[
' $i]=$_)for grep{!$t{$_}}1..9;return$A[$i]=0}die@A}R
Dim Soluzione As String
Private Function Sudoku(A As String) As String
Dim t(10) As Integer
Dim i As Integer, j As Integer
For i = 0 To 80
If Mid(A, i + 1, 1) = "0" Then
For j = 0 To 9
t(j) = 0
Next
For j = 0 To 80
t(IIf(Int(j / 9) = Int(i / 9) Or Int(j Mod 9) = Int(i Mod 9) Or Int(j / 27) = Int(i / 27) And Int((j Mod 9) / 3) = Int((i Mod 9) / 3), Asc(Mid(A, j + 1, 1)) - 48, 0)) = 1
Next
For j = 1 To 9
If t(j) = 0 Then
If i = 0 Then
A = Trim(Str(j)) & Right(A, 80)
ElseIf i = 80 Then
A = Left(A, 80) & Trim(Str(j))
Else
A = Left(A, i) & Trim(Str(j)) & Right(A, 80 - i)
End If
If Soluzione = "" Then
A = Sudoku(A)
End If
End If
Next
If i = 0 Then
A = "0" & Right(A, 80)
ElseIf i = 80 Then
A = Left(A, 80) & "0"
Else
A = Left(A, i) & "0" & Right(A, 80 - i)
End If
If Soluzione = "" Then
Sudoku = A
Else
Sudoku = Soluzione
End If
Exit Function
End If
Next
Soluzione = A
End Function
using System;
/*
use integer;@A=split//,<>;sub R{for$i(0..80){next if$A[$i];my%t=map{$_/9
==$i/9||$_%9==$i%9||$_/27==$i/27&&$_%9/3==$i%9/3?$A[$_]:0=>1}0..80;R($A[
$i]=$_)for grep{!$t{$_}}1..9;return$A[$i]=0}die@A}R
*/
namespace Sudoku
{
class MainClass
{
static char[] A = new char[80];
static void R()
{
int[] t = new int[10];
int i,j;
for (i=0; i<81; i++)
{
if (A[i] == '0')
{
for (j=0; j<10; j++)
t[j]=0;
for (j=0; j<81; j++)
{
t[
j / 9 == i / 9
|| j % 9 == i % 9
|| j / 27 == i / 27 && j % 9 / 3 == i % 9 / 3
? A[j] - 48
: 0] = 1;
}
for (j=1; j<10; j++)
{
if (t[j]==0)
{
A[i] = (char)(48 + j);
R();
}
}
A[i] = '0';
return;
}
}
Console.WriteLine(A);
}
public static void Main(string[] args)
{
A = Console.ReadLine().ToCharArray();
R();
}
}
}
#include <stdio.h>
Per compilare il codice, se usi il compilatore Microsoft Visual C++, va bene così com'è, altrimenti se usi un compilatore C, devi togliere le prime 4 righe ed il codice inizierebbe con l'istruzione:
- Codice: Seleziona tutto
#include <stdio.h>
/*
use integer;@A=split//,<>;sub R{for$i(0..80){next if$A[$i];my%t=map{$_/9
==$i/9||$_%9==$i%9||$_/27==$i/27&&$_%9/3==$i%9/3?$A[$_]:0=>1}0..80;R($A[
$i]=$_)for grep{!$t{$_}}1..9;return$A[$i]=0}die@A}R
*/
public class Sudoku {
static char[] A = new char[80];
static void R()
{
int[] t = new int[10];
int i,j;
for (i=0; i<81; i++)
{
if (A[i] == '0')
{
for (j=0; j<10; j++)
t[j]=0;
for (j=0; j<81; j++)
{
t[
j / 9 == i / 9
|| j % 9 == i % 9
|| j / 27 == i / 27 && j % 9 / 3 == i % 9 / 3
? A[j] - 48
: 0] = 1;
}
for (j=1; j<10; j++)
{
if (t[j]==0)
{
A[i] = (char)(48 + j);
R();
}
}
A[i] = '0';
return;
}
}
System.out.println(A);
}
public static void main(String[] args) {
A=args[0].toCharArray();
R();
}
}
Composizione Di Numeri Per Killer Sudoku Autore: ikwae |
Forum: Applicazioni Office Windows Risposte: 14 |
Come Creare un'applet java di un orologio analogico da inse Autore: Maury170419 |
Forum: Applicazioni Office Windows Risposte: 7 |
Visitano il forum: Nessuno e 13 ospiti