1 | initial version |
Among the 128 solutions found, only 2 are integer solutions:
sage: len(sol)
128
sage: def is_integer_solution(solution):
....: return all(eq.rhs() in ZZ for eq in solution)
....:
sage: integer_solutions = [s for s in sol if is_integer_solution(s)]
sage: len(integer_solutions)
2
sage: integer_solutions
[[x == 127,
y == -254,
N == 1019,
M == 32512,
F == 30496,
f == -63,
G == 32016,
g == -31,
L == 32392,
l == -15,
Q == 32484,
q == -7,
S == 32506,
s == -3,
U == 32511,
u == -1],
[x == 127,
y == 255,
N == 1019,
M == 32512,
F == 30496,
f == -63,
G == 32016,
g == -31,
L == 32392,
l == -15,
Q == 32484,
q == -7,
S == 32506,
s == -3,
U == 32511,
u == -1]]
2 | No.2 Revision |
In Python, you can filter a list using list comprehension. Among the 128 solutions found, only 2 are integer solutions:
sage: len(sol)
128
sage: def is_integer_solution(solution):
....: return all(eq.rhs() in ZZ for eq in solution)
....:
sage: integer_solutions = [s for s in sol if is_integer_solution(s)]
sage: len(integer_solutions)
2
sage: integer_solutions
[[x == 127,
y == -254,
N == 1019,
M == 32512,
F == 30496,
f == -63,
G == 32016,
g == -31,
L == 32392,
l == -15,
Q == 32484,
q == -7,
S == 32506,
s == -3,
U == 32511,
u == -1],
[x == 127,
y == 255,
N == 1019,
M == 32512,
F == 30496,
f == -63,
G == 32016,
g == -31,
L == 32392,
l == -15,
Q == 32484,
q == -7,
S == 32506,
s == -3,
U == 32511,
u == -1]]