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
/** | |
* Script to calculate the iRating gain/loss for a driver based on their current position | |
**/ | |
// Sample data | |
const drivers: Driver[] = [ | |
{ idx: 0, rating: 2502, position: 1, didNotStart: false }, | |
{ idx: 1, rating: 1202, position: 2, didNotStart: false }, | |
{ idx: 2, rating: 1585, position: 3, didNotStart: false }, | |
{ idx: 3, rating: 1409, position: 4, didNotStart: false }, |
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
using System; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
namespace AdminService.Middleware | |
{ | |
public class WebSocketsMiddleware | |
{ | |
private readonly RequestDelegate _next; |
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
let serial = 5719 | |
let calcPower x y serial = | |
let rackId = x + 10; | |
let powerLevel = ((rackId * y) + serial) * rackId; | |
let strPower = string powerLevel | |
if strPower.Length < 3 then 0 else | |
strPower | |
|> Seq.item (strPower.Length - 3) |
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
open System.IO | |
open System.Text.RegularExpressions | |
let input = File.ReadLines("2018-day-10.txt") | |
type Star = { position: int * int; velocity: int * int } | |
let regexPattern = "^position=<[\s]*(\-?[\d]+),[\s]*(\-?[\d]+)> velocity=<[\s]*(\-?[\d]+),[\s]*(\-?[\d]+)>$" | |
let parser line = | |
let groups = Regex.Match(line, regexPattern).Groups |
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
open System.IO | |
open System.Text.RegularExpressions | |
open System | |
let input = File.ReadLines("2018-day-7.txt") | |
let regexPattern = "^Step (\w) must be finished before step (\w) can begin\.$" | |
let parser line = | |
let groups = Regex.Match(line, regexPattern).Groups | |
let captures = List.tail [ for g in groups -> g.Value ] | |
(captures.[0], captures.[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
open System.IO | |
open System | |
let input = File.ReadLines("2018-day-6.txt") | |
type PlaceDistance = { id: int; distance: int; location: int * int } | |
let coords = | |
input | |
|> Seq.map (fun i -> i.Split(',')) |
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
open System.IO | |
open System | |
let input = File.ReadLines("2018-day-5.txt") | |
let rec polymerExploder input: string = | |
let polymerSome = | |
input | |
|> Seq.toArray | |
|> Seq.pairwise |
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
open System.IO | |
open System | |
open System.Text.RegularExpressions | |
let input = File.ReadLines("day-4.txt") | |
type ActionType = | |
| Sleep | |
| Awake | |
| Begin |
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
open System.IO | |
open System.Text.RegularExpressions | |
type Claim = { id: string; pos: int * int; size: int * int} | |
let (|Regex|_|) pattern input = // snippet to make a regex function and return capturing groups | |
let m = Regex.Match(input, pattern) | |
if m.Success then Some(List.tail [ for g in m.Groups -> g.Value ]) | |
else None |
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
open System.IO | |
open System | |
let input = File.ReadLines("day-2.txt") | |
// part 1 | |
let countTwosAndThrees line = | |
line | |
|> Seq.countBy id | |
|> Seq.map snd // only take counts (second param), letter not important |
NewerOlder