Updated Mastermind, Fibonacci.

This commit is contained in:
Jacob Signorovitch
2024-11-19 19:05:35 -05:00
parent 3b66749f41
commit 0f8c20aa73
2 changed files with 643 additions and 255 deletions

View File

@@ -36,7 +36,8 @@ class Examples {
}
// A generic list.
interface ILo<A> {}
interface ILo<A> {
}
class Cons<A> implements ILo<A> {
@@ -49,7 +50,8 @@ class Cons<A> implements ILo<A> {
}
}
class Mt<A> implements ILo<A> {}
class Mt<A> implements ILo<A> {
}
interface ISequence<X> {
// Returns the current element in the sequence.
@@ -78,19 +80,14 @@ class Fibonacci implements ISequence<Integer> {
public Integer get() {
int ret; // What to return.
/*
idx pen pre ret
0 0 1 0
1 0 1 1
2 1 1 2
3 1 2 3
4 2 3 5
5 3 5 8
*/
*
* idx pen pre ret 0 0 1 0 1 0 1 1 2 1 1 2 3 1 2 3 4 2 3 5 5 3 5 8
*
*/
// F(0) = 0; F(1) = 1
if (this.idx <= 1) ret = this.idx;
if (this.idx <= 1)
ret = this.idx;
else { // F(n) = F(n-1) + F(n-2)
ret = this.pre + this.pen;

File diff suppressed because it is too large Load Diff