https://github.com/serpent7776/msquare
https://github.com/serpent7776/msquare
awk fun rectangle
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/serpent7776/msquare
- Owner: serpent7776
- License: bsd-2-clause
- Created: 2016-07-24T21:09:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-05T21:03:22.000Z (over 9 years ago)
- Last Synced: 2025-01-18T07:31:34.241Z (about 1 year ago)
- Topics: awk, fun, rectangle
- Language: Awk
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
msquare
=======
Small awk script solving following puzzle:
Input is a rectangle of numbers. First row and first column specify target sum
of corresponding column/row. The task is to remove some values from rectangle
so that sums of rows/column match with values given in first column/row. Values
at first row/column cannot be modified.
# 4 10 6 -- these values specifies sums of corresponding columns
2 1 2 3
10 4 5 6
8 7 8 9
|
\- these values specifies sums of corresponding rows
Simple input data is given in simple.data file:
# 4 10 6
2 1 2 3
10 4 5 6
8 7 8 9
Feeding above file to msquare.awk with `cat simple.data | awk -f msquare.awk`
will produce:
# 4 10 6
2 _ 2 _
10 4 _ 6
8 _ 8 _