24 lines
507 B
Python
24 lines
507 B
Python
"""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()
|
|
|