From d1b96f1324d4766f334cee927e5b180e0ba6635d Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Sat, 3 Dec 2022 00:41:36 -0800 Subject: [PATCH] day 3 ivy solution --- day03/input.ivy | 1 + day03/sol.ivy | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 day03/input.ivy create mode 100644 day03/sol.ivy diff --git a/day03/input.ivy b/day03/input.ivy new file mode 100644 index 0000000..4cfbc36 --- /dev/null +++ b/day03/input.ivy @@ -0,0 +1 @@ +input = "WjmsdnddnmQPZPPJPL\nbQllTtpBlgwtrbbCwfZcfSFPSfLCSF\nGgVgQrlpphBGrlVGgTtsRHRWVRMzRdVsqdnDnV\nMMTcbpnfNGQbMjgsRwSzRptRzz\nlPqCCqQdQqQmCPRzRVSwtzgqqwqR\nlrDdllPdBWdDFQFnMbDNDn\nFldWTldlpBSLzvpnpSTpWbDhbHNDPHhJcNHNDwbH\nqVCGQRGrrgMQrJhPNchgvgJhNc\nfrjGfMrGQMjsRrRQjvQGmrQQszTTpSLBznlzBlLLSBLLSZTn\nTPZZZMTTbNTZNtTlTbjPVRVGzpGQLLzdGgmslhzSzgLzQh\nwrfwDDvcnFvCfrrSQsmzGGQQdndsGg\nqfHwHCqCqCrFJrcBHCCJRmWTRTmVMttjRjRHZMNV\nvpbqnzbPmWLFjFLBnjZg\nNltQcCClQlcGQGtMTCRdGTGBFZRLZjFFZZhBPLrFHZFjHf\nlMtlGMwMsCCNlTwtsCPzzmPmmVpmpWqVWsWz\nVmWVSchSrScGtwlVtBnwBVFF\nRZZPRNpPCLZvZPZNCLbQPZNBFtttmwBMTMTtttCwtgwBgl\nRNNmPvbQQjPRQQNNHpNbhsfzWJqqSJcsGHhHcfhq\ndtJvcpccWvLDztRCRRCrCC\nqHVslPzPqHqzmPhTzmDFggjrHrSCNFFFSjgR\nqPVPMhszZPVhwBZcdpvZJncbcJ\nHBNLlBDtvLDHhHLvfwlFjqfQTFqqWfST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zQnHjSBSQWJHPhHnSvHnJJJ\nGRgllbgfRgbzfRmwwcGdFMcTVPrFCF" diff --git a/day03/sol.ivy b/day03/sol.ivy new file mode 100644 index 0000000..780b84c --- /dev/null +++ b/day03/sol.ivy @@ -0,0 +1,48 @@ +) get "input.ivy" + +alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +op vec str = or/ alpha o.== str + +# find the first occurence of an element in a vector +op c index str = +/ and\ c != str + +# reshapes a vector as a 1-row matrix +op lift v = (1, rho v) rho v + +op a concat b = + 0 == rho rho a: b + 0 == rho rho b: a + a, b + +nl = "\n" +null = 0 rho 0 + +op m parse input = + (rho input) == 0: m # if input is empty return the matrix + i = nl index input # find the first newline + k = (i+1) min (rho input) + line = i take input # get chars before the newline + rest = k drop input # get chars after the newline + n = (rho line) / 2 # split line into two equal pieces + A = vec n take line # and convert them to 1-hot vectors + B = vec n drop line + C = (lift A), (lift B) # make a pair + m = m concat lift C # add the pair to the accumulator matrix + m parse rest # recurse + +op parse input = null parse input + +op score m = +/ (iota rho alpha) * +/ transp m + +op solve m = + score m[;1] and m[;2] + +op solve2 m = + m = m[;1] or m[;2] + n = (rho m)[1] / 3 + i = -2 + 3 * iota n + score m[i] and m[i+1] and m[i+2] + +m = parse input +solve m +solve2 m