mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
forth wizard / stack juggler
This commit is contained in:
parent
e1c004bd38
commit
4373200e6a
2 changed files with 4 additions and 7 deletions
|
@ -29,9 +29,9 @@ public class Dictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String name) {
|
public void remove(String name) {
|
||||||
Word exiting = at(name);
|
Word existing = at(name);
|
||||||
if (exiting != null)
|
if (existing != null)
|
||||||
dict.remove(exiting);
|
dict.remove(existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> wordList() {
|
public Set<String> wordList() {
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class Juggler {
|
||||||
this.rstack = new Stack<>();
|
this.rstack = new Stack<>();
|
||||||
this.code = new ArrayList<>();
|
this.code = new ArrayList<>();
|
||||||
this.availableWords = populateWords(excluded);
|
this.availableWords = populateWords(excluded);
|
||||||
|
this.code.add(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Word> populateWords(Set<String> excluded) {
|
private List<Word> populateWords(Set<String> excluded) {
|
||||||
|
@ -82,10 +83,6 @@ public class Juggler {
|
||||||
private List<String> solve() {
|
private List<String> solve() {
|
||||||
if (input.isEmpty() && output.isEmpty() || input.equals(output))
|
if (input.isEmpty() && output.isEmpty() || input.equals(output))
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
||||||
code.clear();
|
|
||||||
code.add(0);
|
|
||||||
|
|
||||||
while (code.size() <= maxSteps) {
|
while (code.size() <= maxSteps) {
|
||||||
if (goodCode(code))
|
if (goodCode(code))
|
||||||
return result(code);
|
return result(code);
|
||||||
|
|
Loading…
Reference in a new issue