This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Function; | |
public class Main { | |
static <T> Function<T, T> ycomb(Function<Function, Function<T,T>> le) { | |
return ((Function<Function, Function>) (f) -> (Function) ((Function) f).apply(f) ) | |
.apply(((f) -> (le.apply( (x) -> ( (Function) (((Function) f).apply(f))).apply(x) )))); | |
} | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Function; | |
public class Main { | |
static Function ycomb(Function<Function, Function> le) { | |
return ((Function<Function, Function>) (f) -> (Function) ((Function) f).apply(f) ) | |
.apply(((f) -> (le.apply( (x) -> ( (Function) (((Function) f).apply(f))).apply(x) )))); | |
} | |
// Using the y-combinator to make Factorials. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
def water(levels): | |
# state machine | |
filling = False | |
h = 0 | |
total = 0 | |
cur = 0 | |
for i in xrange(1, len(levels)): |