Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [char[]]$stream ??= $puzzleInput -split '\n' | Select -SkipLast 1
- Function Get-Header {
- Param($stream,$uniqueCount)
- Process {
- $queue = [System.Collections.Queue]::new()
- for ($i = 0; $i -lt $stream.count; $i++) {
- [void]$queue.Enqueue($stream[$i])
- if (($queue | group).Name.count -eq $uniqueCount) {break}
- if (($queue.count % $uniqueCount) -eq 0) {$queue.Dequeue()}
- }
- $i+1
- }
- }
- Get-Header $stream 4
- # Part 2
- Get-Header $stream 14
Advertisement
Add Comment
Please, Sign In to add comment