-3
0
Suppose I have a linear inequality like
x0A0 + x1A1 + ... + xnAn <= C
with xi a non-zero positive integer and Ai and C a positive non-zero multiple of 0.01
. Find all the positive integer n-tuples {x1,...,xn} such that:
D <= x0A0 + x1A1 + ... + xnAn <= C
where D is also a positive non-zero multiple of 0.01
.
Challenge: Find the shortest code to produce the n-tuple solution(s) for any Ai, C, D.
Example: Let A0,A1=1, C = 2.5, and D=1.5. This gives
1.5 <= x01+x11 <= 2.5
Here, the (only) 2-tuple solution is {1,1}:
5Why not simply multiply the equations by
100
and have everything in terms of integers ? The multiples of0.01
don't add anything – Ton Hospel – 2018-03-14T07:13:48.3931Welcome to PPCG! I think this challenge has potential but needs some clarifications. Do I understand correctly that the program takes C, D and a vector A as input and then should return all vectors X? Adding some examples and test cases would also help to understand the challenge. – Laikoni – 2018-03-14T09:31:47.137
1Also, what are the y and z vectors? – user202729 – 2018-03-14T09:34:13.217
1@user202729 He means other solution tuples, they aren't extra variables – Ton Hospel – 2018-03-14T12:00:32.457
@TonHospel, you can do that. – two black lines in the middle – 2018-03-14T17:28:52.760
@Laikoni, yes, exactly like you said, "the program takes C, D and a vector A as input and then should return all vectors X." – two black lines in the middle – 2018-03-14T17:29:21.290
@user202729, the X,Y,...,Z vectors are the possible multiple solutions. There may be just one. There may be 187. Depends on the input, which, as mentioned above, is C, D, and a vector A. – two black lines in the middle – 2018-03-14T17:31:44.447
1
This made enough sense to me. link
– Kelly Lowder – 2018-03-14T19:08:34.927TIO