This file contains hidden or 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
| use std::io; | |
| use std::io::prelude::*; | |
| use std::io::BufReader; | |
| use std::fs::File; | |
| fn main() -> io::Result<()> { | |
| let f = File::open("input.txt")?; | |
| let reader = BufReader::new(f); | |
| let mut adp = Vec::<usize>::new(); |
This file contains hidden or 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
| "A generic function that produces a memoized version | |
| of the given [[function|fun]]. Works for any function | |
| arity." | |
| Callable<Return,Args> memoize<Return,Args>(Callable<Return,Args> fun) | |
| given Args satisfies Anything[] { | |
| value cache = HashMap<Args,Return&Object|Finished>(); | |
| function callFun(Args args) { | |
| //we'll use finished as a convenient | |
| //unit value to represent the case | |
| //that the function returned null |