Dogeku 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +39 -0
- data/app/Historique/Action.rb +29 -0
- data/app/Historique/ChangerCase.rb +44 -0
- data/app/Historique/HistoriqueAction.rb +114 -0
- data/app/components/CaseDessin.rb +325 -0
- data/app/components/GrilleDessin.rb +235 -0
- data/app/components/Header.rb +194 -0
- data/app/config/app.yml +0 -0
- data/app/config/database.yml +2 -0
- data/app/controller/ApprentissageControleur.rb +75 -0
- data/app/controller/ChargerControleur.rb +41 -0
- data/app/controller/JeuLibreControleur.rb +244 -0
- data/app/controller/MenuControleur.rb +57 -0
- data/app/controller/NiveauControleur.rb +54 -0
- data/app/controller/NouvellePartieControleur.rb +34 -0
- data/app/controller/PrincipaleControleur.rb +30 -0
- data/app/controller/PseudoControleur.rb +95 -0
- data/app/controller/ReglagesControleur.rb +86 -0
- data/app/controller/ReglesControleur.rb +34 -0
- data/app/controller/ScoresControleur.rb +42 -0
- data/app/controller/StatistiquesControleur.rb +64 -0
- data/app/core/Conf.rb +26 -0
- data/app/core/Controller.rb +180 -0
- data/app/core/Core.rb +186 -0
- data/app/core/Model.rb +159 -0
- data/app/core/View.rb +56 -0
- data/app/db/main.sqlite3 +0 -0
- data/app/model/Configuration.rb +180 -0
- data/app/model/Grille.rb +180 -0
- data/app/model/Jeu.rb +74 -0
- data/app/model/Score.rb +100 -0
- data/app/model/Utilisateur.rb +113 -0
- data/app/utils/DSubset.rb +98 -0
- data/app/utils/Generateur.rb +171 -0
- data/app/utils/HPTriple.rb +75 -0
- data/app/utils/Peche.rb +46 -0
- data/app/utils/SCandidate.rb +86 -0
- data/app/utils/SCell.rb +73 -0
- data/app/utils/Technique.rb +202 -0
- data/app/utils/TechniqueUsine.rb +25 -0
- data/app/utils/XWing.rb +203 -0
- data/app/view/Fenetre.rb +424 -0
- data/app/view/FenetreApprentissage.rb +272 -0
- data/app/view/FenetreCharger.rb +31 -0
- data/app/view/FenetreJeuLibre.rb +468 -0
- data/app/view/FenetreMenu.rb +198 -0
- data/app/view/FenetreNiveau.rb +105 -0
- data/app/view/FenetreNouvellePartie.rb +92 -0
- data/app/view/FenetrePrincipale.rb +45 -0
- data/app/view/FenetrePseudo.rb +115 -0
- data/app/view/FenetreReglages.rb +209 -0
- data/app/view/FenetreRegles.rb +111 -0
- data/app/view/FenetreScores.rb +120 -0
- data/app/view/FenetreStatistiques.rb +134 -0
- data/assets/css/style.css +69 -0
- data/assets/img/eraser.png +0 -0
- data/assets/img/fond.jpg +0 -0
- data/assets/img/iconApp.png +0 -0
- data/assets/img/logoS.jpeg +0 -0
- data/assets/img/sudokuIntro.jpg +0 -0
- data/assets/img/user.png +0 -0
- data/bin/dogeku +19 -0
- data/doc/Action.html +309 -0
- data/doc/ApprentissageControleur.html +568 -0
- data/doc/CaseDessin.html +2405 -0
- data/doc/ChangerCase.html +405 -0
- data/doc/ChargerControleur.html +342 -0
- data/doc/Conf.html +378 -0
- data/doc/Configuration.html +1115 -0
- data/doc/Controller.html +1008 -0
- data/doc/Core.html +1191 -0
- data/doc/DSubset.html +647 -0
- data/doc/Fenetre.html +2631 -0
- data/doc/FenetreApprentissage.html +1175 -0
- data/doc/FenetreCharger.html +343 -0
- data/doc/FenetreJeuLibre.html +1859 -0
- data/doc/FenetreMenu.html +900 -0
- data/doc/FenetreNiveau.html +626 -0
- data/doc/FenetreNouvellePartie.html +602 -0
- data/doc/FenetrePrincipale.html +371 -0
- data/doc/FenetrePseudo.html +695 -0
- data/doc/FenetreReglages.html +946 -0
- data/doc/FenetreRegles.html +636 -0
- data/doc/FenetreScores.html +650 -0
- data/doc/FenetreStatistiques.html +672 -0
- data/doc/Generateur.html +1015 -0
- data/doc/Grille.html +1348 -0
- data/doc/GrilleDessin.html +1281 -0
- data/doc/HPTriple.html +593 -0
- data/doc/Header.html +1253 -0
- data/doc/HistoriqueAction.html +792 -0
- data/doc/Jeu.html +923 -0
- data/doc/JeuLibreControleur.html +1445 -0
- data/doc/MenuControleur.html +522 -0
- data/doc/Model.html +996 -0
- data/doc/NiveauControleur.html +451 -0
- data/doc/NouvellePartieControleur.html +330 -0
- data/doc/Peche.html +396 -0
- data/doc/PrincipaleControleur.html +320 -0
- data/doc/PseudoControleur.html +695 -0
- data/doc/ReglagesControleur.html +747 -0
- data/doc/ReglesControleur.html +330 -0
- data/doc/SCandidate.html +617 -0
- data/doc/SCell.html +587 -0
- data/doc/Score.html +926 -0
- data/doc/ScoresControleur.html +346 -0
- data/doc/StatistiquesControleur.html +390 -0
- data/doc/Technique.html +543 -0
- data/doc/TechniqueUsine.html +252 -0
- data/doc/Utilisateur.html +806 -0
- data/doc/View.html +844 -0
- data/doc/XWing.html +1031 -0
- data/doc/_index.html +478 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +492 -0
- data/doc/file.README.html +141 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +141 -0
- data/doc/js/app.js +243 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +2523 -0
- data/doc/top-level-namespace.html +112 -0
- data/test/Generateur/grilleCorrecte.rb +198 -0
- data/test/Model/scoreCorrecte.rb +55 -0
- data/test/Model/utilisateurCorrecte.rb +68 -0
- data/test/test_helper.rb +2 -0
- data/test/unitTest.rb +72 -0
- metadata +187 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
|
|
2
|
+
##
|
|
3
|
+
## Technique Disjoint Subset.
|
|
4
|
+
##
|
|
5
|
+
class DSubset < Technique
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
## Constructeur de la classe DSubset
|
|
9
|
+
##
|
|
10
|
+
## @return Une instance de la classe DSubset
|
|
11
|
+
##
|
|
12
|
+
def DSubset.creer()
|
|
13
|
+
new()
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
## Recherche une solution pour la technique utilisée
|
|
18
|
+
##
|
|
19
|
+
## @param grille La grille
|
|
20
|
+
##
|
|
21
|
+
## @return Les informations pour aider l'utilisateur, ou nul si la méthode ne trouve rien
|
|
22
|
+
##
|
|
23
|
+
def solution(grille)
|
|
24
|
+
grilleIndice = indice(grille)
|
|
25
|
+
|
|
26
|
+
res = Array.new()
|
|
27
|
+
[0,1,2,3,4,5,6,7,8].each { |x|
|
|
28
|
+
col = colonne(grilleIndice,x)
|
|
29
|
+
col.each_with_index{ |c,y|
|
|
30
|
+
i = 0
|
|
31
|
+
c.each_value{|v| if v == true then i+=1 end }
|
|
32
|
+
if i>1 then
|
|
33
|
+
res << [x,y]
|
|
34
|
+
col[(y+1)..(-1)].each_with_index{ |cBis,yBis|
|
|
35
|
+
if cBis.eql?(c) then res << [x,y+yBis+1] end
|
|
36
|
+
}
|
|
37
|
+
if res.length == i then
|
|
38
|
+
return res
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
res = Array.new()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[0,1,2,3,4,5,6,7,8].each { |y|
|
|
46
|
+
lig = ligne(grilleIndice,y)
|
|
47
|
+
lig.each_with_index{ |c,x|
|
|
48
|
+
i = 0
|
|
49
|
+
c.each_value{|v| if v == true then i+=1 end }
|
|
50
|
+
if i>1 then
|
|
51
|
+
res << [x,y]
|
|
52
|
+
lig[(x+1)..(-1)].each_with_index{|cBis,xBis|
|
|
53
|
+
if cBis.eql?(c) then res << [x+xBis+1,y] end
|
|
54
|
+
}
|
|
55
|
+
if res.length == i then
|
|
56
|
+
return res
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
res = Array.new()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return nil
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
## Retourne le nombre d'étape pour faire la technique
|
|
68
|
+
##
|
|
69
|
+
## @return Le nombre d'étape(s)
|
|
70
|
+
##
|
|
71
|
+
def combienEtape()
|
|
72
|
+
return 4
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
## Retourne les étapes pour faire la technique
|
|
77
|
+
##
|
|
78
|
+
## @param n Le numéro de la technique
|
|
79
|
+
##
|
|
80
|
+
## @return Un text expliquant l'étape sinon
|
|
81
|
+
##
|
|
82
|
+
def etape(n)
|
|
83
|
+
|
|
84
|
+
case(n)
|
|
85
|
+
when 1
|
|
86
|
+
return "Bienvenue sur l'explication de la technique "+self.class.to_s+"."
|
|
87
|
+
when 2
|
|
88
|
+
return "Recherchez les candidats possibles pour chaque case d'une ligne/colonne."
|
|
89
|
+
when 3
|
|
90
|
+
return "Il arrive que N candicats soient possibles sur N cases d'une même ligne/colonne"
|
|
91
|
+
when 4
|
|
92
|
+
return "Dans ce cas, les N candidats sont applicable uniquement dans ces N cases et non ailleur."
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
return nil
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
## Author:: BastienMor
|
|
2
|
+
## Developers: BastienMor
|
|
3
|
+
## Version:: 0.1
|
|
4
|
+
## Copyright:: © 2017
|
|
5
|
+
## License:: Distributes under the same terms as Ruby
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
## Génération de grille de Sudoku (création de difficulté)
|
|
10
|
+
##
|
|
11
|
+
class Generateur
|
|
12
|
+
|
|
13
|
+
@grid
|
|
14
|
+
@difficulte
|
|
15
|
+
|
|
16
|
+
attr_reader :grid, :difficulte
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
## Initialisation
|
|
20
|
+
##
|
|
21
|
+
## @param difficulte Difficulté à prendre en compte
|
|
22
|
+
##
|
|
23
|
+
def initialize(difficulte)
|
|
24
|
+
@grid = Array.new()
|
|
25
|
+
ligne = Array.new()
|
|
26
|
+
|
|
27
|
+
@difficulte = difficulte
|
|
28
|
+
|
|
29
|
+
9.times do
|
|
30
|
+
val = 1+rand(9)
|
|
31
|
+
while(ligne.include? val)
|
|
32
|
+
val = 1+rand(9)
|
|
33
|
+
end
|
|
34
|
+
ligne.unshift(val)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
3.times do
|
|
38
|
+
3.times do
|
|
39
|
+
@grid.push(ligne.clone)
|
|
40
|
+
3.times do
|
|
41
|
+
ligne.unshift(ligne.pop())
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
ligne.unshift(ligne.pop())
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
4.times do
|
|
48
|
+
a = rand(3)
|
|
49
|
+
b = rand(3)
|
|
50
|
+
while(a == b)
|
|
51
|
+
b = rand(3)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
switchrow(a, b)
|
|
55
|
+
switchcol(a, b)
|
|
56
|
+
switchrow(5-a, 5-b)
|
|
57
|
+
switchcol(8-a, 8-b)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
complexifier()
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
## Génère une grille avec une difficulté variable
|
|
66
|
+
##
|
|
67
|
+
def generer()
|
|
68
|
+
self.convert()
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
## Echange la place de 2 lignes.
|
|
73
|
+
##
|
|
74
|
+
## @param a Première ligne
|
|
75
|
+
## @param b Deuxième ligne
|
|
76
|
+
##
|
|
77
|
+
def switchrow(a, b)
|
|
78
|
+
@grid[a], @grid[b] = @grid[b], @grid[a]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
##
|
|
82
|
+
## Echange la place de 2 colonnes.
|
|
83
|
+
##
|
|
84
|
+
## @param a Première colonne
|
|
85
|
+
## @param b Deuxième colonne
|
|
86
|
+
##
|
|
87
|
+
def switchcol(a, b)
|
|
88
|
+
@grid.map {|e| e[a], e[b] = e[b], e[a]}
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
##
|
|
93
|
+
## Retire des cases pour créer la difficulté.
|
|
94
|
+
##
|
|
95
|
+
## @return la grille
|
|
96
|
+
def complexifier()
|
|
97
|
+
|
|
98
|
+
present = Array.new
|
|
99
|
+
9.times do
|
|
100
|
+
val = 1+rand(9)
|
|
101
|
+
while(present.include? val)
|
|
102
|
+
val = 1+rand(9)
|
|
103
|
+
end
|
|
104
|
+
present.unshift(val)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
1.upto(@difficulte) do
|
|
108
|
+
victime = present.pop()
|
|
109
|
+
@grid.each do |a|
|
|
110
|
+
a.each_with_index do |c, index|
|
|
111
|
+
if c == victime
|
|
112
|
+
a[index] = nil
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
nbkill = 0
|
|
120
|
+
@grid.each do |a|
|
|
121
|
+
nbkill += a.count(nil)
|
|
122
|
+
end
|
|
123
|
+
nbkill = (81-nbkill)* @difficulte *0.1
|
|
124
|
+
|
|
125
|
+
0.upto(nbkill) do
|
|
126
|
+
x = rand(9)
|
|
127
|
+
y = rand(9)
|
|
128
|
+
while(@grid[x][y] == nil)
|
|
129
|
+
x = rand(9)
|
|
130
|
+
y = rand(9)
|
|
131
|
+
end
|
|
132
|
+
@grid[x][y] = nil
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
return @grid
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
##
|
|
140
|
+
## Convertit la grille de list
|
|
141
|
+
##
|
|
142
|
+
## @return la grille convertie.
|
|
143
|
+
##
|
|
144
|
+
def convert()
|
|
145
|
+
|
|
146
|
+
res = Array.new()
|
|
147
|
+
ligne = Array.new()
|
|
148
|
+
|
|
149
|
+
@grid.each do |line|
|
|
150
|
+
line.each do |elem|
|
|
151
|
+
val = Hash.new()
|
|
152
|
+
val["value"] = elem
|
|
153
|
+
val["editable"] = false
|
|
154
|
+
|
|
155
|
+
if(elem == nil)
|
|
156
|
+
val["editable"] = true
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
ligne.push(val.clone())
|
|
160
|
+
end
|
|
161
|
+
res.push(ligne.clone())
|
|
162
|
+
ligne = Array.new()
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
return res
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# gen = Generateur.new()
|
|
170
|
+
# g1 = gen.generer(1)
|
|
171
|
+
# g2 = gen.generer(1)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# => Author:: yguenver
|
|
2
|
+
# => Version:: 0.1
|
|
3
|
+
# => Copyright:: © 2016
|
|
4
|
+
# => License:: Distributes under the same terms as Ruby
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
## Technique des jumeaux et triplés
|
|
9
|
+
##
|
|
10
|
+
class HPTriple < Technique
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
## Constructeur de la classe HPTriple
|
|
14
|
+
##
|
|
15
|
+
## @return une instance de la classe HPTriple
|
|
16
|
+
##
|
|
17
|
+
def HPTriple.creer
|
|
18
|
+
new()
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
## Recherche une solution pour la technique utilisée
|
|
23
|
+
##
|
|
24
|
+
## @param grille La grille
|
|
25
|
+
##
|
|
26
|
+
## @return Les informations pour aider l'utilisateur, ou nil si la méthode ne trouve rien
|
|
27
|
+
##
|
|
28
|
+
def solution(grille)
|
|
29
|
+
grilleIndice = indice(grille)
|
|
30
|
+
|
|
31
|
+
# res = Array.new()
|
|
32
|
+
# [1,2,3,4,5,6,7,8,9].sort_by{rand}.each { |b|
|
|
33
|
+
# [0,1,2,3,4,5,6,7,8].sort_by{rand}.each { |x|
|
|
34
|
+
# [1,2,3,4,5,6,7,8,9].sort_by{rand}.each{ |n|
|
|
35
|
+
# col = colonne(block(grilleIndice,b),x)
|
|
36
|
+
# col.each_with_index{ |hash,y| if hash[n.to_s] then res << [x,y] end}
|
|
37
|
+
# }
|
|
38
|
+
# }
|
|
39
|
+
# }
|
|
40
|
+
|
|
41
|
+
return nil
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
## Retourne le nombre d'étape pour faire la technique
|
|
46
|
+
##
|
|
47
|
+
## @return Le nombre d'étape(s)
|
|
48
|
+
##
|
|
49
|
+
def combienEtape()
|
|
50
|
+
return 4
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
##
|
|
54
|
+
## Retourne les étapes pour faire la technique
|
|
55
|
+
##
|
|
56
|
+
## @param n Le numéro de la technique
|
|
57
|
+
##
|
|
58
|
+
## @return Un texte expliquant l'étape sinon nil
|
|
59
|
+
##
|
|
60
|
+
def etape(n)
|
|
61
|
+
|
|
62
|
+
# case(n)
|
|
63
|
+
# when 1
|
|
64
|
+
# return "Bienvenue sur l'explication de la technique "+self.class.to_s+"."
|
|
65
|
+
# when 2
|
|
66
|
+
# return "Recherchez les candidats possibles pour chaque case d'une ligne/colonne."
|
|
67
|
+
# when 3
|
|
68
|
+
# return "Il arrive que N candicats soient possibles sur N cases d'une même ligne/colonne"
|
|
69
|
+
# when 4
|
|
70
|
+
# return "Dans ce cas, les N candidats sont applicable uniquement dans ces N cases et non ailleur."
|
|
71
|
+
# end
|
|
72
|
+
|
|
73
|
+
return nil
|
|
74
|
+
end
|
|
75
|
+
end
|
data/app/utils/Peche.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# => Author:: yguenver
|
|
2
|
+
# => Version:: 0.1
|
|
3
|
+
# => Copyright:: © 2016
|
|
4
|
+
# => License:: Distributes under the same terms as Ruby
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
## Classe pour la technique 'Pêche à la ligne'.
|
|
8
|
+
##
|
|
9
|
+
class Peche < Technique
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
## Constructeur de la classe Peche
|
|
13
|
+
##
|
|
14
|
+
## @return Une instance de la classe Peche
|
|
15
|
+
##
|
|
16
|
+
def Peche.creer()
|
|
17
|
+
new()
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
## Recherche une solution pour la technique utilisée
|
|
22
|
+
##
|
|
23
|
+
## @param grille La grille
|
|
24
|
+
##
|
|
25
|
+
## @return res, les informations pour aider l'utilisateur ou nil si la méthode ne trouve rien
|
|
26
|
+
##
|
|
27
|
+
def solution(grille)
|
|
28
|
+
|
|
29
|
+
# res = Array.new()
|
|
30
|
+
|
|
31
|
+
# [1,2,3,4,5,6,7,8,9].sort_by{rand}.each { |numero|
|
|
32
|
+
# listPresent = nombreDejaPresent(grille, numero)
|
|
33
|
+
|
|
34
|
+
# x = 1
|
|
35
|
+
# y = 1
|
|
36
|
+
|
|
37
|
+
# listPresent.each{ |case,index|
|
|
38
|
+
# if case.nil? then
|
|
39
|
+
|
|
40
|
+
# end
|
|
41
|
+
# }
|
|
42
|
+
# }
|
|
43
|
+
|
|
44
|
+
return nil
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# => Author:: yguenver
|
|
2
|
+
# => Version:: 0.1
|
|
3
|
+
# => Copyright:: © 2016
|
|
4
|
+
# => License:: Distributes under the same terms as Ruby
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
## Classe pour la technique 'Single Candidate'.
|
|
8
|
+
##
|
|
9
|
+
class SCandidate < Technique
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
## Constructeur de la classe SCandidate
|
|
13
|
+
##
|
|
14
|
+
## @return Une instance de la classe SCandidate
|
|
15
|
+
##
|
|
16
|
+
def SCandidate.creer()
|
|
17
|
+
new()
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
## Recherche une solution pour la technique utilisée
|
|
22
|
+
##
|
|
23
|
+
## @param grille La grille
|
|
24
|
+
##
|
|
25
|
+
## @return res, les informations pour aider l'utilisateur ou nil si la méthode ne trouve rien
|
|
26
|
+
##
|
|
27
|
+
def solution(grille)
|
|
28
|
+
grilleIndice = indice(grille)
|
|
29
|
+
|
|
30
|
+
[1,2,3,4,5,6,7,8,9].sort_by{rand}.each { |numero|
|
|
31
|
+
grilleIndice.sort_by{rand}.each_with_index { |col,x|
|
|
32
|
+
cpt=0
|
|
33
|
+
ytmp=0
|
|
34
|
+
col.sort_by{rand}.each_with_index { |c,y|
|
|
35
|
+
if c[numero.to_s] then
|
|
36
|
+
cpt +=1
|
|
37
|
+
ytmp = y
|
|
38
|
+
end
|
|
39
|
+
}
|
|
40
|
+
if cpt == 1 then return [x,ytmp,numero.to_s] end
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[0,1,2,3,4,5,6,7,8].sort_by{rand}.each { |y|
|
|
44
|
+
cpt=0
|
|
45
|
+
xtmp=0
|
|
46
|
+
[0,1,2,3,4,5,6,7,8].sort_by{rand}.each { |x|
|
|
47
|
+
if grilleIndice[x][y][numero.to_s] then
|
|
48
|
+
cpt +=1
|
|
49
|
+
xtmp = x
|
|
50
|
+
end
|
|
51
|
+
}
|
|
52
|
+
if cpt == 1 then return [xtmp,y,numero.to_s] end
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return nil
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
## Retourne le nombre d'étapes pour faire la technique
|
|
61
|
+
##
|
|
62
|
+
## @return Le nombre d'étapes
|
|
63
|
+
##
|
|
64
|
+
def combienEtape()
|
|
65
|
+
return 2
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
##
|
|
69
|
+
## Retourne les étapes pour faire la technique
|
|
70
|
+
##
|
|
71
|
+
## @param n Le numéro de la technique
|
|
72
|
+
##
|
|
73
|
+
## @return Un texte expliquant l'étape sinon nil
|
|
74
|
+
##
|
|
75
|
+
def etape(n)
|
|
76
|
+
|
|
77
|
+
case(n)
|
|
78
|
+
when 1
|
|
79
|
+
return "Bienvenue sur l'explication de la technique "+self.class.to_s+"."
|
|
80
|
+
when 2
|
|
81
|
+
return "Recherchez les candidats possibles pour chaque case d'une ligne/colonne. Remarquez que dans certaines, un candidat n'est possible que dans une seule case de la ligne/colonne."
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
return nil
|
|
85
|
+
end
|
|
86
|
+
end
|