June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -112,9 +112,9 @@ The table below shows the result, call depths, and total calls for a range of ''
|
|||
|align="right"| 6,100,852
|
||||
|align="right"| 13,172,239
|
||||
|align="right"| 28,499,827
|
||||
|
|
||||
|
|
||||
|
|
||||
|align="right"| 61,786,266
|
||||
|align="right"| 134,202,509
|
||||
|align="right"| 292,011,464
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -218,4 +218,7 @@ The table below shows the result, call depths, and total calls for a range of ''
|
|||
|
|
||||
|
|
||||
|}
|
||||
<br><br>
|
||||
<br>
|
||||
;Related tasks:
|
||||
* [[Jensen's Device]]
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
integer
|
||||
F(list l)
|
||||
{
|
||||
return l[1];
|
||||
l[1];
|
||||
}
|
||||
|
||||
integer
|
||||
eval(list l)
|
||||
{
|
||||
return call(l[0], l);
|
||||
l[0](l);
|
||||
}
|
||||
|
||||
integer A(list);
|
||||
|
|
@ -15,7 +15,7 @@ integer A(list);
|
|||
integer
|
||||
B(list l)
|
||||
{
|
||||
return A(l_assemble(B, l[1] = __integer(l[1]) - 1, l, l[-5], l[-4], l[-3], l[-2]));
|
||||
A(list(B, l[1] = l[1] - 1, l, l[-5], l[-4], l[-3], l[-2]));
|
||||
}
|
||||
|
||||
integer
|
||||
|
|
@ -29,7 +29,7 @@ A(list l)
|
|||
x = B(l);
|
||||
}
|
||||
|
||||
return x;
|
||||
x;
|
||||
}
|
||||
|
||||
integer
|
||||
|
|
@ -46,7 +46,7 @@ main(void)
|
|||
l_append(fn1, F);
|
||||
l_append(fn1, -1);
|
||||
|
||||
o_(A(l_assemble(B, 10, f1, fn1, fn1, f1, f0)), "\n");
|
||||
o_(A(list(B, 10, f1, fn1, fn1, f1, f0)), "\n");
|
||||
|
||||
return 0;
|
||||
0;
|
||||
}
|
||||
|
|
|
|||
39
Task/Man-or-boy-test/Rust/man-or-boy-test.rust
Normal file
39
Task/Man-or-boy-test/Rust/man-or-boy-test.rust
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
trait Arg {
|
||||
fn run(&self) -> i32;
|
||||
}
|
||||
|
||||
impl Arg for i32 {
|
||||
fn run(&self) -> i32 { *self }
|
||||
}
|
||||
|
||||
struct B<'a> {
|
||||
k: &'a Cell<i32>,
|
||||
x1: &'a Arg,
|
||||
x2: &'a Arg,
|
||||
x3: &'a Arg,
|
||||
x4: &'a Arg,
|
||||
}
|
||||
|
||||
impl<'a> Arg for B<'a> {
|
||||
fn run(&self) -> i32 {
|
||||
self.k.set(self.k.get() - 1);
|
||||
a(self.k.get(), self, self.x1, self.x2, self.x3, self.x4)
|
||||
}
|
||||
}
|
||||
|
||||
fn a(k: i32, x1: &Arg, x2: &Arg, x3: &Arg, x4: &Arg, x5: &Arg) -> i32 {
|
||||
if k <= 0 {
|
||||
x4.run() + x5.run()
|
||||
} else {
|
||||
B{
|
||||
k: &Cell::new(k),
|
||||
x1, x2, x3, x4
|
||||
}.run()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
println!("{}", a(10, &1, &-1, &-1, &1, &0));
|
||||
}
|
||||
|
|
@ -1,9 +1,16 @@
|
|||
func A(k: Int, _ x1: () -> Int, _ x2: () -> Int, _ x3: () -> Int, _ x4: () -> Int, _ x5: () -> Int) -> Int {
|
||||
func A(_ k: Int,
|
||||
_ x1: @escaping () -> Int,
|
||||
_ x2: @escaping () -> Int,
|
||||
_ x3: @escaping () -> Int,
|
||||
_ x4: @escaping () -> Int,
|
||||
_ x5: @escaping () -> Int) -> Int {
|
||||
var k1 = k
|
||||
|
||||
func B() -> Int {
|
||||
k1-=1
|
||||
k1 -= 1
|
||||
return A(k1, B, x1, x2, x3, x4)
|
||||
}
|
||||
|
||||
if k1 <= 0 {
|
||||
return x4() + x5()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
func A(var k: Int, x1: () -> Int, x2: () -> Int, x3: () -> Int, x4: () -> Int, x5: () -> Int) -> Int {
|
||||
var B: (() -> Int)!
|
||||
B = {
|
||||
k--
|
||||
return A(k, B, x1, x2, x3, x4)
|
||||
}
|
||||
if k <= 0 {
|
||||
return x4() + x5()
|
||||
} else {
|
||||
return B()
|
||||
}
|
||||
func A(k: Int, _ x1: () -> Int, _ x2: () -> Int, _ x3: () -> Int, _ x4: () -> Int, _ x5: () -> Int) -> Int {
|
||||
var k1 = k
|
||||
func B() -> Int {
|
||||
k1-=1
|
||||
return A(k1, B, x1, x2, x3, x4)
|
||||
}
|
||||
if k1 <= 0 {
|
||||
return x4() + x5()
|
||||
} else {
|
||||
return B()
|
||||
}
|
||||
}
|
||||
|
||||
println(A(10, {1}, {-1}, {-1}, {1}, {0}))
|
||||
print(A(10, {1}, {-1}, {-1}, {1}, {0}))
|
||||
|
|
|
|||
14
Task/Man-or-boy-test/Swift/man-or-boy-test-3.swift
Normal file
14
Task/Man-or-boy-test/Swift/man-or-boy-test-3.swift
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
func A(var k: Int, x1: () -> Int, x2: () -> Int, x3: () -> Int, x4: () -> Int, x5: () -> Int) -> Int {
|
||||
var B: (() -> Int)!
|
||||
B = {
|
||||
k--
|
||||
return A(k, B, x1, x2, x3, x4)
|
||||
}
|
||||
if k <= 0 {
|
||||
return x4() + x5()
|
||||
} else {
|
||||
return B()
|
||||
}
|
||||
}
|
||||
|
||||
println(A(10, {1}, {-1}, {-1}, {1}, {0}))
|
||||
Loading…
Add table
Add a link
Reference in a new issue