You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
572 B
Python
30 lines
572 B
Python
10 years ago
|
#!/usr/bin/python
|
||
|
#
|
||
|
# What's the minimum value for:
|
||
|
#
|
||
|
# ABC
|
||
|
# -------
|
||
|
# A+B+C
|
||
|
#
|
||
|
# From http://www.umassd.edu/mathcontest/abc.cfm
|
||
|
#
|
||
|
from constraint import *
|
||
|
|
||
|
def main():
|
||
|
problem = Problem()
|
||
|
problem.addVariables("abc", range(1,10))
|
||
10 years ago
|
results = []
|
||
|
for solution in problem.getSolutions():
|
||
10 years ago
|
a = solution["a"]
|
||
|
b = solution["b"]
|
||
|
c = solution["c"]
|
||
10 years ago
|
results.append((((a*100) + (b*10) + c) / (a + b + c + 0.0), (a*100) + (b*10) + c))
|
||
|
|
||
|
results.sort()
|
||
|
|
||
|
print results[0]
|
||
|
|
||
10 years ago
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|