First commit
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>SudokuSolver</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.myfirstapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="19" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.example.SudokuSolver.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.example.SudokuSolver.DisplayMessageActivity"
|
||||
android:label="@string/title_activity_display_message"
|
||||
android:parentActivityName="com.example.SudokuSolver.MainActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.myfirstapp.MainActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.myfirstapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="19" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.example.SudokuSolver.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.example.SudokuSolver.DisplayMessageActivity"
|
||||
android:label="@string/title_activity_display_message"
|
||||
android:parentActivityName="com.example.SudokuSolver.MainActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.myfirstapp.MainActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
# cache for current jar dependency. DO NOT EDIT.
|
||||
# format is <lastModified> <length> <SHA-1> <path>
|
||||
# Encoding is UTF-8
|
||||
@@ -0,0 +1,6 @@
|
||||
/** Automatically generated file. DO NOT MODIFY */
|
||||
package com.example.myfirstapp;
|
||||
|
||||
public final class BuildConfig {
|
||||
public final static boolean DEBUG = true;
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package com.example.myfirstapp;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class dimen {
|
||||
/** Default screen margins, per the Android Design guidelines.
|
||||
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
|
||||
|
||||
*/
|
||||
public static final int activity_horizontal_margin=0x7f040000;
|
||||
public static final int activity_vertical_margin=0x7f040001;
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int cell_shape=0x7f020000;
|
||||
public static final int ic_launcher=0x7f020001;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int LinearLayout1=0x7f080000;
|
||||
public static final int TextView_1=0x7f08000e;
|
||||
public static final int TextView_10=0x7f080011;
|
||||
public static final int TextView_11=0x7f080012;
|
||||
public static final int TextView_12=0x7f080013;
|
||||
public static final int TextView_13=0x7f08001a;
|
||||
public static final int TextView_14=0x7f08001b;
|
||||
public static final int TextView_15=0x7f08001c;
|
||||
public static final int TextView_16=0x7f080023;
|
||||
public static final int TextView_17=0x7f080024;
|
||||
public static final int TextView_18=0x7f080025;
|
||||
public static final int TextView_19=0x7f080014;
|
||||
public static final int TextView_2=0x7f08000f;
|
||||
public static final int TextView_20=0x7f080015;
|
||||
public static final int TextView_21=0x7f080016;
|
||||
public static final int TextView_22=0x7f08001d;
|
||||
public static final int TextView_23=0x7f08001e;
|
||||
public static final int TextView_24=0x7f08001f;
|
||||
public static final int TextView_25=0x7f080026;
|
||||
public static final int TextView_26=0x7f080027;
|
||||
public static final int TextView_27=0x7f080028;
|
||||
public static final int TextView_28=0x7f080029;
|
||||
public static final int TextView_29=0x7f08002a;
|
||||
public static final int TextView_3=0x7f080010;
|
||||
public static final int TextView_30=0x7f08002b;
|
||||
public static final int TextView_31=0x7f080032;
|
||||
public static final int TextView_32=0x7f080033;
|
||||
public static final int TextView_33=0x7f080034;
|
||||
public static final int TextView_34=0x7f08003b;
|
||||
public static final int TextView_35=0x7f08003c;
|
||||
public static final int TextView_36=0x7f08003d;
|
||||
public static final int TextView_37=0x7f08002c;
|
||||
public static final int TextView_38=0x7f08002d;
|
||||
public static final int TextView_39=0x7f08002e;
|
||||
public static final int TextView_4=0x7f080017;
|
||||
public static final int TextView_40=0x7f080035;
|
||||
public static final int TextView_41=0x7f080036;
|
||||
public static final int TextView_42=0x7f080037;
|
||||
public static final int TextView_43=0x7f08003e;
|
||||
public static final int TextView_44=0x7f08003f;
|
||||
public static final int TextView_45=0x7f080040;
|
||||
public static final int TextView_46=0x7f08002f;
|
||||
public static final int TextView_47=0x7f080030;
|
||||
public static final int TextView_48=0x7f080031;
|
||||
public static final int TextView_49=0x7f080038;
|
||||
public static final int TextView_5=0x7f080018;
|
||||
public static final int TextView_50=0x7f080039;
|
||||
public static final int TextView_51=0x7f08003a;
|
||||
public static final int TextView_52=0x7f080041;
|
||||
public static final int TextView_53=0x7f080042;
|
||||
public static final int TextView_54=0x7f080043;
|
||||
public static final int TextView_55=0x7f080044;
|
||||
public static final int TextView_56=0x7f080045;
|
||||
public static final int TextView_57=0x7f080046;
|
||||
public static final int TextView_58=0x7f08004d;
|
||||
public static final int TextView_59=0x7f08004e;
|
||||
public static final int TextView_6=0x7f080019;
|
||||
public static final int TextView_60=0x7f08004f;
|
||||
public static final int TextView_61=0x7f080056;
|
||||
public static final int TextView_62=0x7f080057;
|
||||
public static final int TextView_63=0x7f080058;
|
||||
public static final int TextView_64=0x7f080047;
|
||||
public static final int TextView_65=0x7f080048;
|
||||
public static final int TextView_66=0x7f080049;
|
||||
public static final int TextView_67=0x7f080050;
|
||||
public static final int TextView_68=0x7f080051;
|
||||
public static final int TextView_69=0x7f080052;
|
||||
public static final int TextView_7=0x7f080020;
|
||||
public static final int TextView_70=0x7f080059;
|
||||
public static final int TextView_71=0x7f08005a;
|
||||
public static final int TextView_72=0x7f08005b;
|
||||
public static final int TextView_73=0x7f08004a;
|
||||
public static final int TextView_74=0x7f08004b;
|
||||
public static final int TextView_75=0x7f08004c;
|
||||
public static final int TextView_76=0x7f080053;
|
||||
public static final int TextView_77=0x7f080054;
|
||||
public static final int TextView_78=0x7f080055;
|
||||
public static final int TextView_79=0x7f08005c;
|
||||
public static final int TextView_8=0x7f080021;
|
||||
public static final int TextView_80=0x7f08005d;
|
||||
public static final int TextView_81=0x7f08005e;
|
||||
public static final int TextView_9=0x7f080022;
|
||||
public static final int action_settings=0x7f08005f;
|
||||
public static final int button0=0x7f08000c;
|
||||
public static final int button1=0x7f080003;
|
||||
public static final int button2=0x7f080004;
|
||||
public static final int button3=0x7f080005;
|
||||
public static final int button4=0x7f080006;
|
||||
public static final int button5=0x7f080007;
|
||||
public static final int button6=0x7f080008;
|
||||
public static final int button7=0x7f080009;
|
||||
public static final int button8=0x7f08000a;
|
||||
public static final int button9=0x7f08000b;
|
||||
public static final int fragment1=0x7f080001;
|
||||
public static final int tableRow1=0x7f08000d;
|
||||
public static final int tableRow2=0x7f080002;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int activity_main=0x7f030000;
|
||||
public static final int sudokugrid=0x7f030001;
|
||||
public static final int sudokugridlarge=0x7f030002;
|
||||
}
|
||||
public static final class menu {
|
||||
public static final int display_message=0x7f070000;
|
||||
public static final int main=0x7f070001;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int Hint=0x7f050003;
|
||||
public static final int action_settings=0x7f050001;
|
||||
public static final int app_name=0x7f050000;
|
||||
public static final int title_activity_display_message=0x7f050002;
|
||||
}
|
||||
public static final class style {
|
||||
/**
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
|
||||
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
|
||||
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
|
||||
API 11 theme customizations can go here.
|
||||
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
|
||||
API 14 theme customizations can go here.
|
||||
*/
|
||||
public static final int AppBaseTheme=0x7f060000;
|
||||
/** Application theme.
|
||||
All customizations that are NOT specific to a particular API-level can go here.
|
||||
*/
|
||||
public static final int AppTheme=0x7f060001;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -0,0 +1,14 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-19
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape= "rectangle" >
|
||||
<solid android:color="#ff9"/>
|
||||
<stroke android:width="1dp" android:color="#000"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,181 @@
|
||||
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/LinearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".MainActivity" >
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment1"
|
||||
android:name="com.example.SudokuSolver.SudokuGrid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.6" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="1"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="2"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="3"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="4"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="5"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="6"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="7"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="8"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="9"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="0"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="Send" >
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="Clear"
|
||||
android:text="Clear"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="Send"
|
||||
android:text="Send"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,181 @@
|
||||
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/LinearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".MainActivity" >
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment1"
|
||||
android:name="com.example.SudokuSolver.SudokuGridlarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.6" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="1"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="2"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="3"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="4"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="5"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="6"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="7"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="8"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="9"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="0"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="Send" >
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="Clear"
|
||||
android:text="Clear"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="Send"
|
||||
android:text="Send"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,148 @@
|
||||
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/LinearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".MainActivity" >
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment1"
|
||||
android:name="com.example.SudokuSolver.SudokuGridlarge"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.6" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="1"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="2"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="3"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="4"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="5"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="6"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="7"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="8"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="9"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="0"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="Clear"
|
||||
android:text="Clear"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="Send"
|
||||
android:text="Send"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,150 @@
|
||||
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/LinearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".MainActivity" >
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment1"
|
||||
android:name="com.example.SudokuSolver.SudokuGrid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.6" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3" >
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="1"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="2"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="3"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="4"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="5"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:onClick="SetInput"
|
||||
android:text="6"
|
||||
android:textAlignment="center" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="7"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="8"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="9"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="SetInput"
|
||||
android:text="0"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="Clear"
|
||||
android:text="Clear"
|
||||
android:textAlignment="center"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:onClick="Send"
|
||||
android:text="Send"
|
||||
android:textAlignment="center"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
|
||||
</menu>
|
||||
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
|
||||
</menu>
|
||||
@@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw600dp devices (e.g. 7" tablets) here.
|
||||
-->
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">128dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
|
||||
<!-- API 11 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,12 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Sudoku Solver</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="title_activity_display_message">My Message</string>
|
||||
<string name="Hint">0</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,20 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
-->
|
||||
</style>
|
||||
|
||||
<!-- Application theme. -->
|
||||
<style name="AppTheme" parent="AppBaseTheme">
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,532 @@
|
||||
package com.example.SudokuSolver;
|
||||
import com.example.myfirstapp.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
private static final String KEY_TEXT_VALUE = "1";
|
||||
|
||||
private TextView textView;
|
||||
|
||||
private int[][] mTijdelijkResultaat;
|
||||
private int[][] mImportUitInterface;
|
||||
|
||||
private boolean IsItLegal(int iX, int iY, int i)
|
||||
{
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
if (mImportUitInterface[x][iY] == i)
|
||||
if (x != iX)
|
||||
return false;
|
||||
if (mTijdelijkResultaat[x][iY] == i)
|
||||
if (x != iX)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int y = 0; y < 9; y++)
|
||||
{
|
||||
if (mImportUitInterface[iX][y] == i)
|
||||
if (y != iY)
|
||||
return false;
|
||||
if (mTijdelijkResultaat[iX][y] == i)
|
||||
if (y != iY)
|
||||
return false;
|
||||
}
|
||||
|
||||
//T// /get cells sector.
|
||||
int tX, tY;
|
||||
tX = (iX / 3) * 3;
|
||||
tY = (iY / 3) * 3;
|
||||
|
||||
// check cells sector.
|
||||
for (int x = tX; x < (tX + 3); x++)
|
||||
{
|
||||
for (int y = tY; y < (tY + 3); y++)
|
||||
{
|
||||
if (mImportUitInterface[x][y] == i)
|
||||
if (x != iX)
|
||||
if (y != iY)
|
||||
return false;
|
||||
if (mTijdelijkResultaat[x][y] == i)
|
||||
if (x != iX)
|
||||
if (y != iY)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int GetNextPos(int iX, int iY)
|
||||
{
|
||||
if (mImportUitInterface[iX][iY] != 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
while (mTijdelijkResultaat[iX][iY] < 9)
|
||||
{
|
||||
mTijdelijkResultaat[iX][iY] += 1;
|
||||
if (IsItLegal(iX, iY, mTijdelijkResultaat[iX][iY]))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
mTijdelijkResultaat[iX][iY] = 0;
|
||||
return -1; // No More Possibilities.
|
||||
}
|
||||
|
||||
private boolean GetSolution()
|
||||
{
|
||||
/*
|
||||
* berekeningen hier.
|
||||
* */
|
||||
int error = 0;
|
||||
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
for (int y = 0; y < 9; y++)
|
||||
{
|
||||
int temp = GetNextPos(x, y);
|
||||
if (temp == -1)
|
||||
{
|
||||
error = 1;
|
||||
}
|
||||
else if (temp == 1)
|
||||
{
|
||||
error = 0;
|
||||
}
|
||||
|
||||
if (error == 1)
|
||||
{
|
||||
if (y > 0)
|
||||
{
|
||||
y -= 2;
|
||||
}
|
||||
else if (y == 0 && x > 0)
|
||||
{
|
||||
x--;
|
||||
y = 7;
|
||||
}
|
||||
else if ((x == 0) && (y == 0))
|
||||
{
|
||||
/*
|
||||
* Not valid.
|
||||
* */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//first solution.
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean InputValid()
|
||||
{
|
||||
/*
|
||||
* check if input is valide
|
||||
* */
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
for (int y = 0; y < 9; y++)
|
||||
{
|
||||
if (mImportUitInterface[x][y] != 0)
|
||||
{
|
||||
if (!IsItLegal(x, y, mImportUitInterface[x][y]))
|
||||
{
|
||||
/*
|
||||
* not valid.
|
||||
* */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
if (savedInstanceState != null)
|
||||
{
|
||||
ArrayList<String> list = savedInstanceState.getStringArrayList(KEY_TEXT_VALUE);
|
||||
|
||||
((TextView)findViewById(R.id.TextView_1)).setText(list.get(0));
|
||||
((TextView)findViewById(R.id.TextView_2)).setText(list.get(1));
|
||||
((TextView)findViewById(R.id.TextView_3)).setText(list.get(2));
|
||||
((TextView)findViewById(R.id.TextView_4)).setText(list.get(3));
|
||||
((TextView)findViewById(R.id.TextView_5)).setText(list.get(4));
|
||||
((TextView)findViewById(R.id.TextView_6)).setText(list.get(5));
|
||||
((TextView)findViewById(R.id.TextView_7)).setText(list.get(6));
|
||||
((TextView)findViewById(R.id.TextView_8)).setText(list.get(7));
|
||||
((TextView)findViewById(R.id.TextView_9)).setText(list.get(8));
|
||||
((TextView)findViewById(R.id.TextView_10)).setText(list.get(9));
|
||||
((TextView)findViewById(R.id.TextView_11)).setText(list.get(10));
|
||||
((TextView)findViewById(R.id.TextView_12)).setText(list.get(11));
|
||||
((TextView)findViewById(R.id.TextView_13)).setText(list.get(12));
|
||||
((TextView)findViewById(R.id.TextView_14)).setText(list.get(13));
|
||||
((TextView)findViewById(R.id.TextView_15)).setText(list.get(14));
|
||||
((TextView)findViewById(R.id.TextView_16)).setText(list.get(15));
|
||||
((TextView)findViewById(R.id.TextView_17)).setText(list.get(16));
|
||||
((TextView)findViewById(R.id.TextView_18)).setText(list.get(17));
|
||||
((TextView)findViewById(R.id.TextView_19)).setText(list.get(18));
|
||||
((TextView)findViewById(R.id.TextView_20)).setText(list.get(19));
|
||||
((TextView)findViewById(R.id.TextView_21)).setText(list.get(20));
|
||||
((TextView)findViewById(R.id.TextView_22)).setText(list.get(21));
|
||||
((TextView)findViewById(R.id.TextView_23)).setText(list.get(22));
|
||||
((TextView)findViewById(R.id.TextView_24)).setText(list.get(23));
|
||||
((TextView)findViewById(R.id.TextView_25)).setText(list.get(24));
|
||||
((TextView)findViewById(R.id.TextView_26)).setText(list.get(25));
|
||||
((TextView)findViewById(R.id.TextView_27)).setText(list.get(26));
|
||||
((TextView)findViewById(R.id.TextView_28)).setText(list.get(27));
|
||||
((TextView)findViewById(R.id.TextView_29)).setText(list.get(28));
|
||||
((TextView)findViewById(R.id.TextView_30)).setText(list.get(29));
|
||||
((TextView)findViewById(R.id.TextView_31)).setText(list.get(30));
|
||||
((TextView)findViewById(R.id.TextView_32)).setText(list.get(31));
|
||||
((TextView)findViewById(R.id.TextView_33)).setText(list.get(32));
|
||||
((TextView)findViewById(R.id.TextView_34)).setText(list.get(33));
|
||||
((TextView)findViewById(R.id.TextView_35)).setText(list.get(34));
|
||||
((TextView)findViewById(R.id.TextView_36)).setText(list.get(35));
|
||||
((TextView)findViewById(R.id.TextView_37)).setText(list.get(36));
|
||||
((TextView)findViewById(R.id.TextView_38)).setText(list.get(37));
|
||||
((TextView)findViewById(R.id.TextView_39)).setText(list.get(38));
|
||||
((TextView)findViewById(R.id.TextView_40)).setText(list.get(39));
|
||||
((TextView)findViewById(R.id.TextView_41)).setText(list.get(40));
|
||||
((TextView)findViewById(R.id.TextView_42)).setText(list.get(41));
|
||||
((TextView)findViewById(R.id.TextView_43)).setText(list.get(42));
|
||||
((TextView)findViewById(R.id.TextView_44)).setText(list.get(43));
|
||||
((TextView)findViewById(R.id.TextView_45)).setText(list.get(44));
|
||||
((TextView)findViewById(R.id.TextView_46)).setText(list.get(45));
|
||||
((TextView)findViewById(R.id.TextView_47)).setText(list.get(46));
|
||||
((TextView)findViewById(R.id.TextView_48)).setText(list.get(47));
|
||||
((TextView)findViewById(R.id.TextView_49)).setText(list.get(48));
|
||||
((TextView)findViewById(R.id.TextView_50)).setText(list.get(49));
|
||||
((TextView)findViewById(R.id.TextView_51)).setText(list.get(50));
|
||||
((TextView)findViewById(R.id.TextView_52)).setText(list.get(51));
|
||||
((TextView)findViewById(R.id.TextView_53)).setText(list.get(52));
|
||||
((TextView)findViewById(R.id.TextView_54)).setText(list.get(53));
|
||||
((TextView)findViewById(R.id.TextView_55)).setText(list.get(54));
|
||||
((TextView)findViewById(R.id.TextView_56)).setText(list.get(55));
|
||||
((TextView)findViewById(R.id.TextView_57)).setText(list.get(56));
|
||||
((TextView)findViewById(R.id.TextView_58)).setText(list.get(57));
|
||||
((TextView)findViewById(R.id.TextView_59)).setText(list.get(58));
|
||||
((TextView)findViewById(R.id.TextView_60)).setText(list.get(59));
|
||||
((TextView)findViewById(R.id.TextView_61)).setText(list.get(60));
|
||||
((TextView)findViewById(R.id.TextView_62)).setText(list.get(61));
|
||||
((TextView)findViewById(R.id.TextView_63)).setText(list.get(62));
|
||||
((TextView)findViewById(R.id.TextView_64)).setText(list.get(63));
|
||||
((TextView)findViewById(R.id.TextView_65)).setText(list.get(64));
|
||||
((TextView)findViewById(R.id.TextView_66)).setText(list.get(65));
|
||||
((TextView)findViewById(R.id.TextView_67)).setText(list.get(66));
|
||||
((TextView)findViewById(R.id.TextView_68)).setText(list.get(67));
|
||||
((TextView)findViewById(R.id.TextView_69)).setText(list.get(68));
|
||||
((TextView)findViewById(R.id.TextView_70)).setText(list.get(69));
|
||||
((TextView)findViewById(R.id.TextView_71)).setText(list.get(70));
|
||||
((TextView)findViewById(R.id.TextView_72)).setText(list.get(71));
|
||||
((TextView)findViewById(R.id.TextView_73)).setText(list.get(72));
|
||||
((TextView)findViewById(R.id.TextView_74)).setText(list.get(73));
|
||||
((TextView)findViewById(R.id.TextView_75)).setText(list.get(74));
|
||||
((TextView)findViewById(R.id.TextView_76)).setText(list.get(75));
|
||||
((TextView)findViewById(R.id.TextView_77)).setText(list.get(76));
|
||||
((TextView)findViewById(R.id.TextView_78)).setText(list.get(77));
|
||||
((TextView)findViewById(R.id.TextView_79)).setText(list.get(78));
|
||||
((TextView)findViewById(R.id.TextView_80)).setText(list.get(79));
|
||||
((TextView)findViewById(R.id.TextView_81)).setText(list.get(80));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState (Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putStringArrayList(KEY_TEXT_VALUE, GetGridData());
|
||||
}
|
||||
|
||||
protected ArrayList<String> GetGridData()
|
||||
{
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(((TextView)findViewById(R.id.TextView_1)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_2)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_3)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_4)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_5)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_6)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_7)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_8)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_9)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_10)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_11)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_12)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_13)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_14)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_15)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_16)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_17)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_18)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_19)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_20)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_21)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_22)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_23)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_24)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_25)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_26)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_27)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_28)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_29)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_30)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_31)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_32)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_33)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_34)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_35)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_36)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_37)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_38)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_39)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_40)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_41)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_42)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_43)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_44)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_45)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_46)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_47)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_48)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_49)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_50)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_51)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_52)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_53)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_54)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_55)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_56)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_57)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_58)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_59)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_60)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_61)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_62)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_63)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_64)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_65)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_66)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_67)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_68)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_69)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_70)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_71)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_72)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_73)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_74)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_75)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_76)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_77)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_78)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_79)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_80)).getText().toString());
|
||||
list.add(((TextView)findViewById(R.id.TextView_81)).getText().toString());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
protected void SetGridData(ArrayList<String> list)
|
||||
{
|
||||
((TextView)findViewById(R.id.TextView_1)).setText(list.get(0));
|
||||
((TextView)findViewById(R.id.TextView_2)).setText(list.get(1));
|
||||
((TextView)findViewById(R.id.TextView_3)).setText(list.get(2));
|
||||
((TextView)findViewById(R.id.TextView_4)).setText(list.get(3));
|
||||
((TextView)findViewById(R.id.TextView_5)).setText(list.get(4));
|
||||
((TextView)findViewById(R.id.TextView_6)).setText(list.get(5));
|
||||
((TextView)findViewById(R.id.TextView_7)).setText(list.get(6));
|
||||
((TextView)findViewById(R.id.TextView_8)).setText(list.get(7));
|
||||
((TextView)findViewById(R.id.TextView_9)).setText(list.get(8));
|
||||
((TextView)findViewById(R.id.TextView_10)).setText(list.get(9));
|
||||
((TextView)findViewById(R.id.TextView_11)).setText(list.get(10));
|
||||
((TextView)findViewById(R.id.TextView_12)).setText(list.get(11));
|
||||
((TextView)findViewById(R.id.TextView_13)).setText(list.get(12));
|
||||
((TextView)findViewById(R.id.TextView_14)).setText(list.get(13));
|
||||
((TextView)findViewById(R.id.TextView_15)).setText(list.get(14));
|
||||
((TextView)findViewById(R.id.TextView_16)).setText(list.get(15));
|
||||
((TextView)findViewById(R.id.TextView_17)).setText(list.get(16));
|
||||
((TextView)findViewById(R.id.TextView_18)).setText(list.get(17));
|
||||
((TextView)findViewById(R.id.TextView_19)).setText(list.get(18));
|
||||
((TextView)findViewById(R.id.TextView_20)).setText(list.get(19));
|
||||
((TextView)findViewById(R.id.TextView_21)).setText(list.get(20));
|
||||
((TextView)findViewById(R.id.TextView_22)).setText(list.get(21));
|
||||
((TextView)findViewById(R.id.TextView_23)).setText(list.get(22));
|
||||
((TextView)findViewById(R.id.TextView_24)).setText(list.get(23));
|
||||
((TextView)findViewById(R.id.TextView_25)).setText(list.get(24));
|
||||
((TextView)findViewById(R.id.TextView_26)).setText(list.get(25));
|
||||
((TextView)findViewById(R.id.TextView_27)).setText(list.get(26));
|
||||
((TextView)findViewById(R.id.TextView_28)).setText(list.get(27));
|
||||
((TextView)findViewById(R.id.TextView_29)).setText(list.get(28));
|
||||
((TextView)findViewById(R.id.TextView_30)).setText(list.get(29));
|
||||
((TextView)findViewById(R.id.TextView_31)).setText(list.get(30));
|
||||
((TextView)findViewById(R.id.TextView_32)).setText(list.get(31));
|
||||
((TextView)findViewById(R.id.TextView_33)).setText(list.get(32));
|
||||
((TextView)findViewById(R.id.TextView_34)).setText(list.get(33));
|
||||
((TextView)findViewById(R.id.TextView_35)).setText(list.get(34));
|
||||
((TextView)findViewById(R.id.TextView_36)).setText(list.get(35));
|
||||
((TextView)findViewById(R.id.TextView_37)).setText(list.get(36));
|
||||
((TextView)findViewById(R.id.TextView_38)).setText(list.get(37));
|
||||
((TextView)findViewById(R.id.TextView_39)).setText(list.get(38));
|
||||
((TextView)findViewById(R.id.TextView_40)).setText(list.get(39));
|
||||
((TextView)findViewById(R.id.TextView_41)).setText(list.get(40));
|
||||
((TextView)findViewById(R.id.TextView_42)).setText(list.get(41));
|
||||
((TextView)findViewById(R.id.TextView_43)).setText(list.get(42));
|
||||
((TextView)findViewById(R.id.TextView_44)).setText(list.get(43));
|
||||
((TextView)findViewById(R.id.TextView_45)).setText(list.get(44));
|
||||
((TextView)findViewById(R.id.TextView_46)).setText(list.get(45));
|
||||
((TextView)findViewById(R.id.TextView_47)).setText(list.get(46));
|
||||
((TextView)findViewById(R.id.TextView_48)).setText(list.get(47));
|
||||
((TextView)findViewById(R.id.TextView_49)).setText(list.get(48));
|
||||
((TextView)findViewById(R.id.TextView_50)).setText(list.get(49));
|
||||
((TextView)findViewById(R.id.TextView_51)).setText(list.get(50));
|
||||
((TextView)findViewById(R.id.TextView_52)).setText(list.get(51));
|
||||
((TextView)findViewById(R.id.TextView_53)).setText(list.get(52));
|
||||
((TextView)findViewById(R.id.TextView_54)).setText(list.get(53));
|
||||
((TextView)findViewById(R.id.TextView_55)).setText(list.get(54));
|
||||
((TextView)findViewById(R.id.TextView_56)).setText(list.get(55));
|
||||
((TextView)findViewById(R.id.TextView_57)).setText(list.get(56));
|
||||
((TextView)findViewById(R.id.TextView_58)).setText(list.get(57));
|
||||
((TextView)findViewById(R.id.TextView_59)).setText(list.get(58));
|
||||
((TextView)findViewById(R.id.TextView_60)).setText(list.get(59));
|
||||
((TextView)findViewById(R.id.TextView_61)).setText(list.get(60));
|
||||
((TextView)findViewById(R.id.TextView_62)).setText(list.get(61));
|
||||
((TextView)findViewById(R.id.TextView_63)).setText(list.get(62));
|
||||
((TextView)findViewById(R.id.TextView_64)).setText(list.get(63));
|
||||
((TextView)findViewById(R.id.TextView_65)).setText(list.get(64));
|
||||
((TextView)findViewById(R.id.TextView_66)).setText(list.get(65));
|
||||
((TextView)findViewById(R.id.TextView_67)).setText(list.get(66));
|
||||
((TextView)findViewById(R.id.TextView_68)).setText(list.get(67));
|
||||
((TextView)findViewById(R.id.TextView_69)).setText(list.get(68));
|
||||
((TextView)findViewById(R.id.TextView_70)).setText(list.get(69));
|
||||
((TextView)findViewById(R.id.TextView_71)).setText(list.get(70));
|
||||
((TextView)findViewById(R.id.TextView_72)).setText(list.get(71));
|
||||
((TextView)findViewById(R.id.TextView_73)).setText(list.get(72));
|
||||
((TextView)findViewById(R.id.TextView_74)).setText(list.get(73));
|
||||
((TextView)findViewById(R.id.TextView_75)).setText(list.get(74));
|
||||
((TextView)findViewById(R.id.TextView_76)).setText(list.get(75));
|
||||
((TextView)findViewById(R.id.TextView_77)).setText(list.get(76));
|
||||
((TextView)findViewById(R.id.TextView_78)).setText(list.get(77));
|
||||
((TextView)findViewById(R.id.TextView_79)).setText(list.get(78));
|
||||
((TextView)findViewById(R.id.TextView_80)).setText(list.get(79));
|
||||
((TextView)findViewById(R.id.TextView_81)).setText(list.get(80));
|
||||
}
|
||||
|
||||
public void Clear(View v)
|
||||
{
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (int i=0; i<81; i++)
|
||||
list.add("0");
|
||||
SetGridData(list);
|
||||
}
|
||||
|
||||
public void Send(View v)
|
||||
{
|
||||
mTijdelijkResultaat = new int[9][];
|
||||
for (int y = 0; y < 9; y++)
|
||||
{
|
||||
mTijdelijkResultaat[y] = new int[9];
|
||||
}
|
||||
|
||||
mImportUitInterface = new int[9][];
|
||||
for (int y = 0; y < 9; y++)
|
||||
{
|
||||
mImportUitInterface[y] = new int[9];
|
||||
}
|
||||
|
||||
ArrayList<String> grid = GetGridData();
|
||||
for (int x=0;x<9;x++)
|
||||
for (int y=0;y<9;y++)
|
||||
mImportUitInterface[x][y] = Integer.parseInt(grid.get((x*9)+y));
|
||||
|
||||
if (InputValid())
|
||||
{
|
||||
Toast.makeText(this, "Your Sudoku is inValid.", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetSolution())
|
||||
{
|
||||
Toast.makeText(this, "No valid solution found.", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x=0;x<9;x++)
|
||||
for (int y=0;y<9;y++)
|
||||
grid.set((x*9)+y, Integer.valueOf( mTijdelijkResultaat[x][y]==0?mImportUitInterface[x][y]:mTijdelijkResultaat[x][y] ).toString() );
|
||||
|
||||
SetGridData(grid);
|
||||
|
||||
Toast.makeText(this, "Solution found.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetFocus(View v)
|
||||
{
|
||||
if ( textView != null )
|
||||
textView.setTextColor(Color.BLACK);
|
||||
|
||||
textView=(TextView)v;
|
||||
textView.setTextColor(Color.RED);
|
||||
}
|
||||
|
||||
public void SetInput(View v)
|
||||
{
|
||||
if ( textView != null )
|
||||
{
|
||||
switch (v.getId()) {
|
||||
case (R.id.button1):
|
||||
textView.setText("1");
|
||||
break;
|
||||
case (R.id.button2):
|
||||
textView.setText("2");
|
||||
break;
|
||||
case (R.id.button3):
|
||||
textView.setText("3");
|
||||
break;
|
||||
case (R.id.button4):
|
||||
textView.setText("4");
|
||||
break;
|
||||
case (R.id.button5):
|
||||
textView.setText("5");
|
||||
break;
|
||||
case (R.id.button6):
|
||||
textView.setText("6");
|
||||
break;
|
||||
case (R.id.button7):
|
||||
textView.setText("7");
|
||||
break;
|
||||
case (R.id.button8):
|
||||
textView.setText("8");
|
||||
break;
|
||||
case (R.id.button9):
|
||||
textView.setText("9");
|
||||
break;
|
||||
case (R.id.button0):
|
||||
textView.setText("0");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.example.SudokuSolver;
|
||||
|
||||
import com.example.myfirstapp.R;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class SudokuGrid extends Fragment
|
||||
{
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.sudokugrid, container, false);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.example.SudokuSolver;
|
||||
|
||||
import com.example.myfirstapp.R;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class SudokuGridlarge extends Fragment
|
||||
{
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.sudokugridlarge, container, false);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
//LinkedListSudoku LLS[];
|
||||
|
||||
/*protected class LinkedListSudoku
|
||||
{
|
||||
//Total list.
|
||||
LinkedListSudoku previouse = null;
|
||||
LinkedListSudoku next = null;
|
||||
|
||||
//Row
|
||||
LinkedListSudoku left = null;
|
||||
LinkedListSudoku right = null;
|
||||
|
||||
//Column
|
||||
LinkedListSudoku top = null;
|
||||
LinkedListSudoku bottom = null;
|
||||
|
||||
//Box
|
||||
LinkedListSudoku boxPreviouse = null;
|
||||
LinkedListSudoku boxNext = null;
|
||||
|
||||
//Value
|
||||
Integer value = null;
|
||||
Integer calculatedValue = null;
|
||||
|
||||
LinkedListSudoku(int iValue)
|
||||
{
|
||||
value = Integer.valueOf(iValue);
|
||||
}
|
||||
|
||||
public String GetValue()
|
||||
{
|
||||
return (value!=Integer.valueOf(0)?value:calculatedValue!=null?calculatedValue:Integer.valueOf(0)).toString();
|
||||
}
|
||||
|
||||
public boolean IsInput()
|
||||
{
|
||||
return value==0?false:true;
|
||||
}
|
||||
|
||||
private boolean HasDuplicates(Integer[] arrayList)
|
||||
{
|
||||
ArrayList<Integer> vals = new ArrayList<Integer>();
|
||||
boolean returnValue = false;
|
||||
for(int i=0; i<arrayList.length; i++)
|
||||
{
|
||||
if(vals.contains(arrayList[i]))
|
||||
{
|
||||
returnValue = true;
|
||||
break;
|
||||
}
|
||||
if (arrayList[i] != 0)
|
||||
vals.add(arrayList[i]);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public LinkedListSudoku GetLeft()
|
||||
{
|
||||
if (this.left == null)
|
||||
return this;
|
||||
else
|
||||
return left.GetLeft();
|
||||
}
|
||||
public LinkedListSudoku GetTop()
|
||||
{
|
||||
if (this.top == null)
|
||||
return this;
|
||||
else
|
||||
return top.GetTop();
|
||||
}
|
||||
public LinkedListSudoku GetFirstBox()
|
||||
{
|
||||
if (this.boxPreviouse == null)
|
||||
return this;
|
||||
else
|
||||
return boxPreviouse.GetFirstBox();
|
||||
}
|
||||
|
||||
//returns false if valid
|
||||
public boolean CheckRow()
|
||||
{
|
||||
LinkedListSudoku begin = this.GetLeft();
|
||||
|
||||
LinkedListSudoku next;
|
||||
Integer[] temp = new Integer[9];
|
||||
int i = 0;
|
||||
next = begin;
|
||||
|
||||
do{
|
||||
temp[i] = next.value;
|
||||
i++;
|
||||
next = next.right;
|
||||
}while(next != null);
|
||||
|
||||
return HasDuplicates(temp);
|
||||
}
|
||||
public boolean CheckColumn()
|
||||
{
|
||||
LinkedListSudoku begin = this.GetTop();
|
||||
|
||||
LinkedListSudoku next;
|
||||
Integer[] temp = new Integer[9];
|
||||
int i = 0;
|
||||
next = begin;
|
||||
|
||||
do{
|
||||
temp[i] = next.value;
|
||||
i++;
|
||||
next = next.bottom;
|
||||
}while(next != null);
|
||||
|
||||
return HasDuplicates(temp);
|
||||
}
|
||||
|
||||
//returns false if valid.
|
||||
public boolean CheckBox()
|
||||
{
|
||||
LinkedListSudoku begin = this.GetFirstBox();
|
||||
|
||||
LinkedListSudoku next;
|
||||
Integer[] temp = new Integer[9];
|
||||
int i = 0;
|
||||
next = begin;
|
||||
|
||||
do{
|
||||
temp[i] = next.value;
|
||||
i++;
|
||||
next = next.boxNext;
|
||||
}while(next != null);
|
||||
|
||||
return HasDuplicates(temp);
|
||||
}
|
||||
|
||||
//returns false if found valid number.
|
||||
public boolean GetValidNummer()
|
||||
{
|
||||
if (!this.IsInput())
|
||||
{
|
||||
//Pre-Check if grid is valid.
|
||||
if (!this.CheckRow())
|
||||
{
|
||||
if (!this.CheckColumn())
|
||||
{
|
||||
if (!this.CheckBox())
|
||||
{
|
||||
//valid.
|
||||
HashSet<Integer> vals = new HashSet<Integer>();
|
||||
for (int i=1; i<=9; i++) vals.add(i);
|
||||
|
||||
//remove row
|
||||
LinkedListSudoku begin = this.GetLeft();
|
||||
LinkedListSudoku next;
|
||||
next = begin;
|
||||
|
||||
do{
|
||||
vals.remove(next.value);
|
||||
vals.remove(next.calculatedValue);
|
||||
next = next.right;
|
||||
}while(next != null);
|
||||
|
||||
//remove column
|
||||
begin = this.GetTop();
|
||||
next = begin;
|
||||
|
||||
do{
|
||||
vals.remove(next.value);
|
||||
vals.remove(next.calculatedValue);
|
||||
next = next.bottom;
|
||||
}while(next != null);
|
||||
|
||||
//remove box
|
||||
begin = this.GetFirstBox();
|
||||
next = begin;
|
||||
|
||||
do{
|
||||
vals.remove(next.value);
|
||||
vals.remove(next.calculatedValue);
|
||||
next = next.boxNext;
|
||||
}while(next != null);
|
||||
|
||||
//remove last value
|
||||
if (this.calculatedValue != null)
|
||||
for (int i=1; i<=this.calculatedValue; i++)
|
||||
vals.remove(i);
|
||||
|
||||
//return value
|
||||
if (!vals.isEmpty())
|
||||
{
|
||||
this.calculatedValue = vals.iterator().next();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.calculatedValue = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else // is input
|
||||
return false;
|
||||
|
||||
//not valid
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
//returns false if grid is valid
|
||||
/*protected boolean CheckGridForValidation(LinkedListSudoku iLLS[])
|
||||
{
|
||||
//check grid for errors
|
||||
for (int i=0;i<9;i++)
|
||||
{
|
||||
if ( iLLS[i*10].CheckRow() )
|
||||
return true;
|
||||
if ( iLLS[i*10].CheckColumn() )
|
||||
return true;
|
||||
if ( iLLS[6].CheckBox() )
|
||||
return true;
|
||||
}
|
||||
for (int i=0; i<81; i+=27)
|
||||
{
|
||||
for (int x=0; x<9; x+=3)
|
||||
{
|
||||
if ( iLLS[i+x].CheckBox() )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
/*public void Send(View v)
|
||||
{
|
||||
AssembleLL();
|
||||
|
||||
Toast.makeText(this, CheckGridForValidation(LLS)?"Your Sudoku is Invalid.":"Your Sudoku is Valid.", Toast.LENGTH_LONG).show();
|
||||
|
||||
for (int i=0;i<81;i++)
|
||||
{
|
||||
if (LLS[i].GetValidNummer())
|
||||
{
|
||||
if (i==0)
|
||||
{
|
||||
if (LLS[i].IsInput())
|
||||
break;
|
||||
break;
|
||||
}
|
||||
i-=2;
|
||||
}
|
||||
}
|
||||
|
||||
SetGridData(GetListOfLL());
|
||||
}*/
|
||||
|
||||
/*protected void AssembleLL()
|
||||
{
|
||||
ArrayList<String> list = GetGridData();
|
||||
|
||||
LLS = new LinkedListSudoku[81];
|
||||
|
||||
LLS[0] = new LinkedListSudoku(Integer.parseInt(list.get(0)));
|
||||
|
||||
//list
|
||||
for (int i=1; i<81; i++)
|
||||
{
|
||||
LLS[i] = new LinkedListSudoku(Integer.parseInt(list.get(i)));
|
||||
LLS[i-1].next = LLS[i];
|
||||
LLS[i].previouse = LLS[i-1];
|
||||
}
|
||||
|
||||
//rows
|
||||
for (int r=0;r<9;r++)
|
||||
{
|
||||
for (int i=(r*9)+1;i<(r*9)+9;i++)
|
||||
{
|
||||
LLS[i-1].right = LLS[i];
|
||||
LLS[i].left = LLS[i-1];
|
||||
}
|
||||
}
|
||||
|
||||
//columns
|
||||
for (int c=0;c<9;c++)
|
||||
{
|
||||
for (int i=1;i<9;i++)
|
||||
{
|
||||
LLS[c+((i-1)*9)].bottom = LLS[c+(i*9)];
|
||||
LLS[c+(i*9)].top = LLS[c+((i-1)*9)];
|
||||
}
|
||||
}
|
||||
|
||||
//boxes
|
||||
LinkedListSudoku temp = null;
|
||||
for (int e=0; e<81; e+=27)
|
||||
{
|
||||
temp = null;
|
||||
for (int i=e+0; i<e+27; i+=9)
|
||||
{
|
||||
for (int x=0;x<3;x++)
|
||||
{
|
||||
if (temp != null)
|
||||
{
|
||||
temp.boxNext = LLS[i+x];
|
||||
LLS[i+x].boxPreviouse = temp;
|
||||
}
|
||||
temp = LLS[i+x];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int e=0; e<81; e+=27)
|
||||
{
|
||||
temp = null;
|
||||
for (int i=e+0; i<e+27; i+=9)
|
||||
{
|
||||
for (int x=3;x<6;x++)
|
||||
{
|
||||
if (temp != null)
|
||||
{
|
||||
temp.boxNext = LLS[i+x];
|
||||
LLS[i+x].boxPreviouse = temp;
|
||||
}
|
||||
temp = LLS[i+x];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int e=0; e<81; e+=27)
|
||||
{
|
||||
temp = null;
|
||||
for (int i=e+0; i<e+27; i+=9)
|
||||
{
|
||||
for (int x=6;x<9;x++)
|
||||
{
|
||||
if (temp != null)
|
||||
{
|
||||
temp.boxNext = LLS[i+x];
|
||||
LLS[i+x].boxPreviouse = temp;
|
||||
}
|
||||
temp = LLS[i+x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/*protected ArrayList<String> GetListOfLL()
|
||||
{
|
||||
if (LLS != null)
|
||||
{
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
|
||||
for (int i=0;i<81;i++)
|
||||
{
|
||||
list.add(LLS[i].GetValue());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
return null;
|
||||
}*/
|
||||
Reference in New Issue
Block a user