Skip to content

Instantly share code, notes, and snippets.

@wkentaro
Created November 16, 2022 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkentaro/96d0cd0774390f5981f145f3b87daf19 to your computer and use it in GitHub Desktop.
Save wkentaro/96d0cd0774390f5981f145f3b87daf19 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import numpy as np
arr = sys.stdin.read().split()
arr = np.array(arr)
for operation in sys.argv[1:]:
if operation.startswith("."):
if operation == ".T":
arr = arr.T
else:
raise NotImplementedError
else:
shape = tuple(map(int, operation.split(",")))
arr = arr.reshape(shape)
np.savetxt(sys.stdout.buffer, arr, fmt="%s")
@wkentaro
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment