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 maybeAdd = (prev, candidate) => | |
| prev.endsAt <= candidate[1] | |
| ? [prev, { | |
| chosen: [...prev.chosen, candidate[0]], | |
| endsAt: candidate[2] | |
| }] | |
| : [prev]; | |
| const combine = ts => | |
| ts.reduce( |
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 taskListEndsAt = ts => | |
| Math.max(...ts.map(t => t[2])); | |
| const maybeAdd = (ts, candidate) => | |
| (taskListEndsAt(ts) <= candidate[1]) | |
| ? [ts, [...ts, candidate]] | |
| : [ts] | |
| ; | |
| const combinations = ts => |
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 repeatedIntegers_0(n) { | |
| const ret = []; | |
| for(let i = 0; i <= n; i++) | |
| ret.push(...String(i).repeat(i).split("").map(i => Number(i))); | |
| return ret; | |
| } | |
| function* repeatedIntegers_1(n) { | |
| let i = 0; | |
| while(++i <= n) |
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
| // Set up: | |
| // - dotnet new console | |
| // - dotnet add package OneOf | |
| // Implement each of the methods below so that they all compile | |
| // There only one valid implementation for each function (apart from f5 & f6) | |
| using OneOf; | |
| A F1<A>(A a) { |
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
| class Cat { | |
| speak() { return "meow"; } | |
| } | |
| function process(cat) { | |
| return cat.speak(); | |
| } | |
| class Ball { | |
| } |
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
| terraform { | |
| required_version = ">= 0.12" | |
| } | |
| provider "aws" { | |
| region = "eu-west-1" | |
| } | |
| resource "aws_instance" "web" { |
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 ordinalSuffixes = { | |
| "en": { | |
| "one": "st", | |
| "two": "nd", | |
| "few": "rd", | |
| "other": "th" | |
| } | |
| }; | |
| export class OrdinalFormat { |
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 { OrdinalFormat } from "./ordinal-formatting.js"; | |
| const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" }); | |
| const now = new Date(); | |
| const parts = fullFormat.formatToParts(now); | |
| const weekDayName = parts.find(p => p.type === "weekday").value; | |
| const dayName = parts.find(p => p.type === "day").value; |
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 fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" }); | |
| const ordinalSuffixes = { | |
| "one": "st", | |
| "two": "nd", | |
| "few": "rd", | |
| "other": "th" | |
| }; | |
| const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" }); |
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 ordinalSuffixes = { | |
| "one": "st", | |
| "two": "nd", | |
| "few": "rd", | |
| "other": "th" | |
| }; | |
| const ordinalPluralRules = new Intl.PluralRules("en", { type: "ordinal" }); | |
| function withOrdinalSuffix(x) { |
NewerOlder