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
| type Result<T, E> = Generator<E, T, never>; | |
| function Err<T, E>(e: E): Result<T, E> { | |
| return { | |
| [Symbol.iterator](): Result<T, E> { | |
| return this; | |
| }, | |
| return(value: T): IteratorResult<E, T> { | |
| throw "never return"; | |
| }, |
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 frunk::{ | |
| hlist::{HCons, HNil}, | |
| labelled::{Field, LabelledGeneric}, | |
| }; | |
| use frunk_derives::LabelledGeneric; | |
| trait GShow<T> { | |
| fn gshow(self) -> String; | |
| } |
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
| adjacent_clockwise(X, Y, S) :- append(_, [X, Y|_], S). | |
| adjacent_clockwise(X, Y, S) :- append([Y|_], [X], S). | |
| adjacent(X, Y, S) :- adjacent_clockwise(X, Y, S) ; adjacent_clockwise(Y, X, S). | |
| riddle(S) :- | |
| S = [ | |
| [_, north, _, _, _, _], | |
| [_, east, _, _, _, _], | |
| [_, south_east, _, _, _, _], | |
| [_, south_west, _, _, _, _], |
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
| function num_at(n, r, c) { //trả về số tại ô (r, c) của ma trận xoắn ốc nxn | |
| var square = Math.min(r, c, n - r - 1, n - c - 1) | |
| var num = 4 * square * (n - square) //số ngay trước hình vuông này | |
| var top = square | |
| var right = n - square - 1; | |
| var bottom = n - square - 1; | |