input = """
2494
8013
1055
5425
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
| add(M1, M2) -> | |
| case {M1, M2} of | |
| {{money, Cents1, Currency}, {money, Cents2, Currency1}} -> | |
| {ok, {money, Cents1 + Cents2, Currency1}}; | |
| {{money, _, C1}, {money, _, C2}} -> | |
| {error, {currencies_mismatch, C1, C2}} | |
| end. |
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
| diff --git lib/myxql/client.ex lib/myxql/client.ex | |
| index 54309c2..769f956 100644 | |
| --- lib/myxql/client.ex | |
| +++ lib/myxql/client.ex | |
| @@ -169,7 +169,7 @@ defmodule MyXQL.Client do | |
| end | |
| def recv_packets(client, decoder, decoder_state, timeout \\ :infinity) do | |
| - case recv_data(client, timeout) do | |
| + case recv_data(client, 0, timeout) do |
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
| defmodule Project.AbsintheAddDeprecateDirective do | |
| @moduledoc """ | |
| This pipeline modifier is a first, local attempt at potentially fixing | |
| https://github.com/absinthe-graphql/absinthe/pull/1045 upstream. | |
| The phase is inserted just before Directives expansion. | |
| Deprecation directives are built if `deprecation` attribute is present on | |
| the node (e.g. a FieldDefinition). | |
| It's not entirely clear if instantiating the Directive and its Arguments | |
| is the canonical way of doing it - to be verified with upstream devs. | |
| """ |
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 std/tables | |
| var points = 0 | |
| let choicePoints = { | |
| 'R': 1, | |
| 'P': 2, | |
| 'S': 3 | |
| }.toTable |
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 std/sequtils, std/sets, std/tables, std/os, std/strformat | |
| let priorities = concat( | |
| zip(toSeq('a'..'z'), toSeq(1..26)), | |
| zip(toSeq('A'..'Z'), toSeq(27..52)) | |
| ).toTable | |
| iterator chunks[T](a: seq[T], size: int): seq[T] = | |
| var chunk: seq[T] = @[] |
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 std/sequtils, std/os, std/strformat, std/strscans, std/sets, sugar | |
| proc countPairs(input: seq[string], fun: (HashSet[int], HashSet[int]) -> bool): int = | |
| var count = 0 | |
| for line in input: | |
| let (ok, lower1, upper1, lower2, upper2) = scanTuple( | |
| line, "$i-$i,$i-$i") | |
| if ok: |
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 std/strformat, std/sequtils, std/strscans, std/strutils, sugar | |
| proc extractInput*(input: seq[string]): (seq[string], seq[string]) = | |
| runnableExamples: | |
| let (s, i) = extractInput(@["foo", "bar", "", "baz", "bax"]) | |
| assert s == @["foo", "bar"] | |
| assert i == @["baz", "bax"] | |
| var storage: seq[string] | |
| var instructions: seq[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
| import std/strformat, std/sets | |
| proc findMarker(input: string, length: int): int = | |
| for idx in 0..<input.len: | |
| if input[idx..<idx+length].toHashSet.len == length: | |
| result = idx + length | |
| break | |
| proc findStartOfPacket*(input: string): int = | |
| findMarker(input, 4) |
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 std/sequtils, std/strutils, std/sugar, std/strformat | |
| type | |
| NodeKind = enum File, Dir | |
| Node = object | |
| kind: NodeKind | |
| name: string | |
| size: int | |
| children: seq[Node] |