8000 Finished the printing script for numerical_3_dimensional_matching.lp by joshuaguerin · Pull Request #35 · joshuaguerin/Answer-Set-Programming-Algorithms · GitHub
[go: up one dir, main page]

Skip to content

Finished the pr 8000 inting script for numerical_3_dimensional_matching.lp #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
% GENERATE
% Custom instance works with a parameter of n=10
x(7 ; 1 ; 5 ; 4).
y(0 ; 2 ; 1 ; 3).
z(5 ; 8 ; 0 ; 4).
33 changes: 33 additions & 0 deletions Numerical-3-Dimensional-Matching/print/print.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Use:
# clingo numerical_3_dimensional_matching.lp instance.lp -c n=<val> | python3 print/print.py
# where instance.lp contains predicates enumerating x, y, and z.
#
# To be ran in previous directory where numerical_3_dimensional_matching.lp and instance.lp are.


import re


def get_input():
toks = input().split()

while not toks[0].startswith("Answer:"):
if toks[0].startswith("UNSATISFIABLE"):
return None
toks = input().split()

toks = input().split()
return toks

toks = get_input()

# output
if toks is None:
print("No solution found.")

else:
print("Triples found:")

for t in toks:
nums = re.findall(r'\d+', t)
print(sum(int(n) for n in nums), '= ' + ' + '.join(nums))
0