forth wizard / stack juggler

This commit is contained in:
zeroflag 2021-08-07 16:04:58 +02:00
parent e1c004bd38
commit 4373200e6a
2 changed files with 4 additions and 7 deletions

View file

@ -29,9 +29,9 @@ public class Dictionary {
}
public void remove(String name) {
Word exiting = at(name);
if (exiting != null)
dict.remove(exiting);
Word existing = at(name);
if (existing != null)
dict.remove(existing);
}
public Set<String> wordList() {

View file

@ -68,6 +68,7 @@ public class Juggler {
this.rstack = new Stack<>();
this.code = new ArrayList<>();
this.availableWords = populateWords(excluded);
this.code.add(0);
}
private List<Word> populateWords(Set<String> excluded) {
@ -82,10 +83,6 @@ public class Juggler {
private List<String> solve() {
if (input.isEmpty() && output.isEmpty() || input.equals(output))
return Collections.emptyList();
code.clear();
code.add(0);
while (code.size() <= maxSteps) {
if (goodCode(code))
return result(code);