Data update

This commit is contained in:
Ingy döt Net 2023-12-16 21:33:55 -08:00
parent 35bcdeebf8
commit 74c69a0df6
2427 changed files with 31826 additions and 3468 deletions

View file

@ -13,7 +13,7 @@ class ExpressionTree
{
auto level := new Integer(0);
s.forEach:(ch)
s.forEach::(ch)
{
var node := new DynamicStruct();
@ -22,9 +22,9 @@ class ExpressionTree
$45 { node.Level := level + 1; node.Operation := mssg subtract } // -
$42 { node.Level := level + 2; node.Operation := mssg multiply } // *
$47 { node.Level := level + 2; node.Operation := mssg divide } // /
$40 { level.append(10); ^ self } // (
$41 { level.reduce(10); ^ self } // )
: {
$40 { level.append(10); ^ self } // (
$41 { level.reduce(10); ^ self } // )
! {
node.Leaf := ch.toString().toReal();
node.Level := level + 3
};
@ -112,34 +112,34 @@ class TwentyFourGame
{
theNumbers := new object[]
{
1 + randomGenerator.nextInt:9,
1 + randomGenerator.nextInt:9,
1 + randomGenerator.nextInt:9,
1 + randomGenerator.nextInt:9
1 + randomGenerator.nextInt(9),
1 + randomGenerator.nextInt(9),
1 + randomGenerator.nextInt(9),
1 + randomGenerator.nextInt(9)
}
}
help()
{
console
.printLine:"------------------------------- Instructions ------------------------------"
.printLine:"Four digits will be displayed."
.printLine:"Enter an equation using all of those four digits that evaluates to 24"
.printLine:"Only * / + - operators and () are allowed"
.printLine:"Digits can only be used once, but in any order you need."
.printLine:"Digits cannot be combined - i.e.: 12 + 12 when given 1,2,2,1 is not allowed"
.printLine:"Submit a blank line to skip the current puzzle."
.printLine:"Type 'q' to quit"
.printLine("------------------------------- Instructions ------------------------------")
.printLine("Four digits will be displayed.")
.printLine("Enter an equation using all of those four digits that evaluates to 24")
.printLine("Only * / + - operators and () are allowed")
.printLine("Digits can only be used once, but in any order you need.")
.printLine("Digits cannot be combined - i.e.: 12 + 12 when given 1,2,2,1 is not allowed")
.printLine("Submit a blank line to skip the current puzzle.")
.printLine("Type 'q' to quit")
.writeLine()
.printLine:"Example: given 2 3 8 2, answer should resemble 8*3-(2-2)"
.printLine:"------------------------------- --------------------------------------------"
.printLine("Example: given 2 3 8 2, answer should resemble 8*3-(2-2)")
.printLine("------------------------------- --------------------------------------------")
}
prompt()
{
theNumbers.forEach:(n){ console.print(n," ") };
theNumbers.forEach::(n){ console.print(n," ") };
console.print:": "
console.print(": ")
}
resolve(expr)
@ -147,13 +147,10 @@ class TwentyFourGame
var tree := new ExpressionTree(expr);
var leaves := new ArrayList();
tree.readLeaves:leaves;
tree.readLeaves(leaves);
ifnot (leaves.ascendant().sequenceEqual(theNumbers.ascendant())) {
console
.printLine:"Invalid input. Enter an equation using all of those four digits. Try again.";
^ self
};
ifnot (leaves.ascendant().sequenceEqual(theNumbers.ascendant()))
{ console.printLine("Invalid input. Enter an equation using all of those four digits. Try again."); ^ self };
var result := tree.Value;
if (result == 24)
@ -181,7 +178,7 @@ extension gameOp
{
if (expr == "")
{
console.printLine:"Skipping this puzzle"; self.newPuzzle()
console.printLine("Skipping this puzzle"); self.newPuzzle()
}
else
{
@ -191,7 +188,7 @@ extension gameOp
}
catch(Exception e)
{
console.printLine:e
console.printLine(e)
//console.printLine:"An error occurred. Check your input and try again."
}
};

View file

@ -1,6 +1,6 @@
import "random" for Random
import "/ioutil" for Input
import "/seq" for Stack
import "./ioutil" for Input
import "./seq" for Stack
var R = Random.new()