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
| const parseSantaRoute = (str, roboMode = false) => { | |
| const charFns = { | |
| '^': (x, y) => [x , y + 1], | |
| 'v': (x, y) => [x , y - 1], | |
| '>': (x, y) => [x + 1, y ], | |
| '<': (x, y) => [x - 1, y ] | |
| }; | |
| let error; | |
| let position = [0, 0]; |
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
| const calcPaper = (l, w, h) => { | |
| const sides = [l * w, w * h, h * l]; | |
| return Math.min(...sides) + sides.reduce((n, v) => n + 2 * v, 0); | |
| }; | |
| const calcRibbon = (...dimensions) => { | |
| const max = Math.max(...dimensions); | |
| return 2 * dimensions.filter(n => n !== max).reduce((n, v) => n + v, 0) + | |
| dimensions.reduce((n, v) => n * v, 1); | |
| } |
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
| const parseFloor = (str) => { | |
| const floorCharFns = { | |
| '(': n => n + 1, | |
| ')': n => n - 1 | |
| }; | |
| let floor = 0; | |
| let error; | |
| let firstBasementPos; | |
| for (let i = 0; i < str.length; i++) { | |
| const char = str[i]; |
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
| import 'package:benchmark_harness/benchmark_harness.dart'; | |
| import 'dart:math'; | |
| void main() { | |
| var keyFn = (n) { | |
| var sum = n % 9; | |
| if (sum == 0 && n > 0) sum = 9; | |
| return sum; | |
| }, | |
| compFn = (n1, n2) => keyFn(n1).compareTo(keyFn(n2)); |
NewerOlder