day 1 ivy solution
parent
64779081cb
commit
71b38be272
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,8 @@
|
|||
) get "input.ivy"
|
||||
|
||||
# part 1
|
||||
max/ +/ input
|
||||
|
||||
# part 2
|
||||
sums = +/ input
|
||||
+/ sums[3 take down sums]
|
|
@ -0,0 +1,23 @@
|
|||
"""reads a ragged array and converts it to ivy code
|
||||
input: whitespace separated values, with each chunk separated by a blank line
|
||||
"""
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
with open("input") as f:
|
||||
chunks = f.read().split("\n\n")
|
||||
|
||||
data = []
|
||||
for x in chunks:
|
||||
data.append(x.replace(",", " ").split())
|
||||
|
||||
cols = max(len(row) for row in data)
|
||||
|
||||
print("input = {} {} rho".format(len(data), cols), end="")
|
||||
for x in data:
|
||||
print("", *x, end="")
|
||||
if len(x) < cols:
|
||||
print(" 0" * (cols - len(x)), end="")
|
||||
print()
|
||||
|
Loading…
Reference in New Issue