From 55028090fd6fd350f425ac7581c80a80e971c783 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 4 Jun 2025 00:11:27 -0600 Subject: [PATCH 1/2] Finished the printing script for numerical_3_dimensional_matching.lp --- .../print/print.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Numerical-3-Dimensional-Matching/print/print.py diff --git a/Numerical-3-Dimensional-Matching/print/print.py b/Numerical-3-Dimensional-Matching/print/print.py new file mode 100644 index 0000000..7764058 --- /dev/null +++ b/Numerical-3-Dimensional-Matching/print/print.py @@ -0,0 +1,33 @@ +# Use: +# clingo numerical_3_dimensional_matching.lp instance.lp -c n= | 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)) From 521550ba46ce60b8e70fb4ed06911861860e6a4c Mon Sep 17 00:00:00 2001 From: "Joshua T. Guerin" Date: Wed, 4 Jun 2025 11:06:25 -0600 Subject: [PATCH 2/2] Added note about correct argument since I had to track it donw in the README. XD --- Numerical-3-Dimensional-Matching/instance.lp | 1 + 1 file changed, 1 insertion(+) diff --git a/Numerical-3-Dimensional-Matching/instance.lp b/Numerical-3-Dimensional-Matching/instance.lp index e68b150..b026479 100644 --- a/Numerical-3-Dimensional-Matching/instance.lp +++ b/Numerical-3-Dimensional-Matching/instance.lp @@ -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).