September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -15,13 +15,7 @@ integer A(list);
|
|||
integer
|
||||
B(list l)
|
||||
{
|
||||
integer x;
|
||||
|
||||
x = l[1];
|
||||
x -= 1;
|
||||
l_r_integer(l, 1, x);
|
||||
|
||||
return A(l_assemble(B, x, l, l[-5], l[-4], l[-3], l[-2]));
|
||||
return A(l_assemble(B, l[1] = __integer(l[1]) - 1, l, l[-5], l[-4], l[-3], l[-2]));
|
||||
}
|
||||
|
||||
integer
|
||||
|
|
@ -29,7 +23,7 @@ A(list l)
|
|||
{
|
||||
integer x;
|
||||
|
||||
if (l_q_integer(l, 1) < 1) {
|
||||
if (l[1] < 1) {
|
||||
x = eval(l[-2]) + eval(l[-1]);
|
||||
} else {
|
||||
x = B(l);
|
||||
|
|
@ -52,8 +46,7 @@ main(void)
|
|||
l_append(fn1, F);
|
||||
l_append(fn1, -1);
|
||||
|
||||
o_integer(A(l_assemble(B, 10, f1, fn1, fn1, f1, f0)));
|
||||
o_byte('\n');
|
||||
o_(A(l_assemble(B, 10, f1, fn1, fn1, f1, f0)), "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
#import system.
|
||||
#import extensions.
|
||||
import extensions.
|
||||
|
||||
#symbol A = (:k:x1:x2:x3:x4:x5)
|
||||
A = (:k:x1:x2:x3:x4:x5)
|
||||
[
|
||||
#var m := Integer new:k.
|
||||
#var b := ()[ m -= 1. ^ A eval:m:this:x1:x2:x3:x4. ].
|
||||
var m := Integer new:k.
|
||||
var b := [ m reduce:1. ^ A eval(m,closure,x1,x2,x3,x4) ].
|
||||
|
||||
(m <= 0)
|
||||
? [ ^ x4 eval + x5 eval. ]
|
||||
! [ ^ b eval. ].
|
||||
if (m int <= 0)
|
||||
[ ^ x4 eval + x5 eval. ];
|
||||
[ ^ b eval. ].
|
||||
].
|
||||
|
||||
#symbol program =
|
||||
program =
|
||||
[
|
||||
0 to:13 &doEach:n
|
||||
0 to:14 do(:n)
|
||||
[
|
||||
console writeLine:(A eval:n:()[1]:()[-1]:()[-1]:()[1]:()[0]).
|
||||
console printLine(A eval(n,[^1],[^-1],[^-1],[^1],[^0])).
|
||||
].
|
||||
].
|
||||
|
|
|
|||
16
Task/Man-or-boy-test/Kotlin/man-or-boy-test.kotlin
Normal file
16
Task/Man-or-boy-test/Kotlin/man-or-boy-test.kotlin
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// version 1.1.3
|
||||
|
||||
typealias Func = () -> Int
|
||||
|
||||
fun a(k: Int, x1: Func, x2: Func, x3: Func, x4: Func, x5: Func): Int {
|
||||
var kk = k
|
||||
fun b(): Int = a(--kk, ::b, x1, x2, x3, x4)
|
||||
return if (kk <= 0) x4() + x5() else b()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(" k a")
|
||||
for (k in 0..12) {
|
||||
println("${"%2d".format(k)}: ${a(k, { 1 }, { -1 }, { -1 }, { 1 }, { 0 })}")
|
||||
}
|
||||
}
|
||||
22
Task/Man-or-boy-test/Phix/man-or-boy-test.phix
Normal file
22
Task/Man-or-boy-test/Phix/man-or-boy-test.phix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
forward function A(integer k, object x1, x2, x3, x4, x5)
|
||||
|
||||
function B(sequence s)
|
||||
object {kptr,x1,x2,x3,x4} = s
|
||||
integer k = peek4s(kptr)-1
|
||||
poke4(kptr,k)
|
||||
return A(k,{kptr,x1,x2,x3,x4},x1,x2,x3,x4)
|
||||
end function
|
||||
|
||||
function A(integer k, object x1, x2, x3, x4, x5)
|
||||
if k<=0 then
|
||||
return iff(sequence(x4)?B(x4):x4)+
|
||||
iff(sequence(x5)?B(x5):x5)
|
||||
end if
|
||||
atom kptr = allocate(4,1)
|
||||
poke4(kptr,k)
|
||||
return B({kptr,x1,x2,x3,x4})
|
||||
end function
|
||||
|
||||
for k=0 to 10 do
|
||||
?{"k=",k,A(k,1,-1,-1,1,0)}
|
||||
end for
|
||||
16
Task/Man-or-boy-test/Zkl/man-or-boy-test.zkl
Normal file
16
Task/Man-or-boy-test/Zkl/man-or-boy-test.zkl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
fcn A(k, x1, x2, x3, x4, x5){ // -->1,0,-2,0,1,0,1,-1,-10,-30,-67,-138
|
||||
B:=CB(k, x1, x2, x3, x4, x5);
|
||||
if(k <= 0) x4()+x5() else B.B();
|
||||
}
|
||||
|
||||
foreach k in (12){
|
||||
println("k=%2d A=%d".fmt(k, A(k, 1, -1, -1, 1, 0)))
|
||||
}
|
||||
|
||||
class CB{ var k, x1, x2, x3, x4, x5;
|
||||
fcn init{ k, x1, x2, x3, x4, x5 = vm.arglist; }
|
||||
fcn B{
|
||||
k= k - 1;
|
||||
A(k, B, x1, x2, x3, x4);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue