I was bored and found a HP-27S
06-27-2014, 12:43 PM
Post: #47
 rprosperi Super Moderator Posts: 5,197 Joined: Dec 2013
RE: I was bored and found a HP-27S
(06-27-2014 09:45 AM)Thomas Klemm Wrote:
(06-26-2014 10:41 PM)rprosperi Wrote:  But I can tell you from experience that looking at those pieces of Solver art before you've used it a lot is really confusing. Sometimes even after.

This is an equivalent program written for Python:
Code:
for I in range(1, 9):   for J in range(1, 9):     if I != J and abs(I - J) != 1:       for K in range(1, 9):         if I != K and abs(I - K) != 2 and \            J != K and abs(J - K) != 1:           for L in range(1, 9):             if I != L and abs(I - L) != 3 and \                J != L and abs(J - L) != 2 and \                K != L and abs(K - L) != 1:               for M in range(1, 9):                 if I != M and abs(I - M) != 4 and \                    J != M and abs(J - M) != 3 and \                    K != M and abs(K - M) != 2 and \                    L != M and abs(L - M) != 1:                   for N in range(1, 9):                     if I != N and abs(I - N) != 5 and \                        J != N and abs(J - N) != 4 and \                        K != N and abs(K - N) != 3 and \                        L != N and abs(L - N) != 2 and \                        M != N and abs(M - N) != 1:                       for O in range(1, 9):                         if I != O and abs(I - O) != 6 and \                            J != O and abs(J - O) != 5 and \                            K != O and abs(K - O) != 4 and \                            L != O and abs(L - O) != 3 and \                            M != O and abs(M - O) != 2 and \                            N != O and abs(N - O) != 1:                           for P in range(1, 9):                             if I != P and abs(I - P) != 7 and \                                J != P and abs(J - P) != 6 and \                                K != P and abs(K - P) != 5 and \                                L != P and abs(L - P) != 4 and \                                M != P and abs(M - P) != 3 and \                                N != P and abs(N - P) != 2 and \                                O != P and abs(O - P) != 1:                               print I, J, K, L, M, N, O, P

The index parameters I-O are local variables and therefore can't be used directly to display the result. Thus the variables A-H are used to propagate the result. They must be used or they won't show up in the menu. But we're not really interested in the sum of them. It's only for this side-effect that they are used here:
Code:
Q=A+B+C+D+E+F+G+H+

Instead of a for-loop the $$\Sigma$$ function is used. We don't have ABS but we can use SQ (square) instead:
Code:
Σ(M:1:8:1: IF(I<>M AND SQ(I-M)<>16 AND J<>M AND SQ(J-M)<>9 AND K<>M AND SQ(K-M)<>4 AND L<>M AND SQ(L-M)<>1:

Code:
for M in range(1, 9):   if I != M and abs(I - M) != 4 and \      J != M and abs(J - M) != 3 and \      K != M and abs(K - M) != 2 and \      L != M and abs(L - M) != 1:

As we can't display all 92 solutions an error (division by zero) is used to stop the program:
Code:
L(A:I)xL(B:J)xL(C:K)xL(D:L)xL(E:M)xL(F:N)xL(G:O)xL(H:P)/0
And here's where the local variables are copied to the corresponding menu variables using the let-function. Again we're not interested in that product but we have to use a single expression where everything is used.

While the Python program prints all solutions the solver stops with the 1st one. A counter could be used to stop with the n-th solution.

HTH
Thomas

I imagine this was to highlight my point above: Sometimes even after!!

To quote Joe Horn, just looking at the above code makes my eyes bleed.

This stuff is truly amazing Thomas, clearly well beyond what the Solver designers ever imagined, and I would guess well beyond what it was tested for, but it seems solid.

I really enjoy these kinds of creative abuses of tools like the Solver as they really dramatically show how creative, smart folks like yourself can bend tools to their own will, and teach us all new ways to use the tools.

Entering some of these long equations on a 17B or 27S, I don't enjoy so much (e.g. I cannot claim to have entered Gerson's long equation succesfully. 2 hours was my limit, or perhaps it was my eyesight).

Thanks for continuing to shine a light into dark corners, its interesting and entertaining, even if I don't follow all the math involved.

Jebem - You've got some catching up to do with your newest toy

--Bob Prosperi
 « Next Oldest | Next Newest »

 Messages In This Thread I was bored and found a HP-27S - jebem - 06-09-2014, 10:38 PM RE: I was bored and found a HP-27S - Don Shepherd - 06-09-2014, 11:37 PM RE: I was bored and found a HP-27S - Katie Wasserman - 06-10-2014, 02:10 AM RE: I was bored and found a HP-27S - rprosperi - 06-10-2014, 03:25 AM RE: I was bored and found a HP-27S - jebem - 06-10-2014, 09:35 AM RE: I was bored and found a HP-27S - Don Shepherd - 06-10-2014, 11:18 AM RE: I was bored and found a HP-27S - Katie Wasserman - 06-10-2014, 03:52 PM RE: I was bored and found a HP-27S - Thomas Radtke - 06-10-2014, 04:06 PM RE: I was bored and found a HP-27S - Katie Wasserman - 06-10-2014, 07:19 PM Turing Completeness [was: RE: I was bored and found a HP-27S] - Thomas Radtke - 06-11-2014, 08:04 AM RE: I was bored and found a HP-27S - Dave Britten - 06-11-2014, 10:50 AM RE: I was bored and found a HP-27S - Don Shepherd - 06-11-2014, 12:18 PM RE: I was bored and found a HP-27S - Dave Britten - 06-11-2014, 12:28 PM RE: I was bored and found a HP-27S - rprosperi - 06-10-2014, 04:45 PM RE: I was bored and found a HP-27S - Dave Britten - 06-10-2014, 08:46 PM RE: I was bored and found a HP-27S - Don Shepherd - 06-10-2014, 10:38 PM RE: I was bored and found a HP-27S - Dave Britten - 06-11-2014, 12:22 AM RE: I was bored and found a HP-27S - rprosperi - 06-11-2014, 01:34 AM RE: I was bored and found a HP-27S - Don Shepherd - 06-11-2014, 02:13 AM RE: I was bored and found a HP-27S - Dave Britten - 06-11-2014, 02:26 AM RE: I was bored and found a HP-27S - rprosperi - 06-11-2014, 01:22 PM RE: I was bored and found a HP-27S - Don Shepherd - 06-12-2014, 01:29 AM RE: I was bored and found a HP-27S - Katie Wasserman - 06-11-2014, 02:00 AM RE: I was bored and found a HP-27S - Steve Sabin - 06-28-2021, 10:23 AM RE: I was bored and found a HP-27S - Don Shepherd - 06-28-2021, 11:49 PM RE: I was bored and found a HP-27S - Steve Sabin - 06-29-2021, 12:17 AM RE: I was bored and found a HP-27S - Steve Sabin - 06-29-2021, 12:30 AM RE: I was bored and found a HP-27S - John R - 06-10-2014, 04:39 AM RE: I was bored and found a HP-27S - walter b - 06-10-2014, 05:55 AM RE: I was bored and found a HP-27S - Didier Lachieze - 06-10-2014, 06:37 AM RE: I was bored and found a HP-27S - walter b - 06-10-2014, 07:09 AM RE: I was bored and found a HP-27S - Bruce Larrabee - 06-10-2014, 10:56 PM RE: I was bored and found a HP-27S - Thomas Klemm - 06-11-2014, 11:21 AM RE: I was bored and found a HP-27S - Thomas Radtke - 06-11-2014, 11:55 AM RE: I was bored and found a HP-27S - Thomas Klemm - 06-11-2014, 12:48 PM RE: I was bored and found a HP-27S - Thomas Klemm - 06-11-2014, 01:08 PM RE: I was bored and found a HP-27S - Thomas Radtke - 06-11-2014, 02:34 PM RE: I was bored and found a HP-27S - Dave Britten - 06-11-2014, 03:03 PM RE: I was bored and found a HP-27S - Thomas Radtke - 06-11-2014, 03:19 PM RE: I was bored and found a HP-27S - Katie Wasserman - 06-11-2014, 03:41 PM RE: I was bored and found a HP-27S - jebem - 06-25-2014, 06:49 PM RE: I was bored and found a HP-27S - rprosperi - 06-26-2014, 01:23 PM RE: I was bored and found a HP-27S - Don Shepherd - 06-26-2014, 01:35 PM RE: I was bored and found a HP-27S - jebem - 06-26-2014, 01:44 PM RE: I was bored and found a HP-27S - jebem - 06-26-2014, 01:40 PM RE: I was bored and found a HP-27S - rprosperi - 06-26-2014, 10:34 PM RE: I was bored and found a HP-27S - Thomas Klemm - 06-26-2014, 02:14 PM RE: I was bored and found a HP-27S - jebem - 06-26-2014, 03:57 PM RE: I was bored and found a HP-27S - rprosperi - 06-26-2014, 10:41 PM RE: I was bored and found a HP-27S - Thomas Klemm - 06-27-2014, 09:45 AM RE: I was bored and found a HP-27S - rprosperi - 06-27-2014 12:43 PM RE: I was bored and found a HP-27S - jebem - 06-27-2014, 01:15 PM RE: I was bored and found a HP-27S - Thomas Radtke - 06-27-2014, 01:32 PM RE: I was bored and found a HP-27S - walter b - 06-27-2014, 02:20 PM RE: I was bored and found a HP-27S - Don Shepherd - 06-27-2014, 02:21 PM RE: I was bored and found a HP-27S - jebem - 06-27-2014, 08:50 PM RE: I was bored and found a HP-27S - HP67 - 06-27-2014, 02:56 PM RE: I was bored and found a HP-27S - Don Shepherd - 06-27-2014, 03:10 PM RE: I was bored and found a HP-27S - HP67 - 06-27-2014, 03:28 PM RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:18 PM RE: I was bored and found a HP-27S - Katie Wasserman - 06-27-2014, 10:28 PM RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:58 PM RE: I was bored and found a HP-27S - Don Shepherd - 06-28-2014, 12:35 AM RE: I was bored and found a HP-27S - jebem - 06-28-2014, 08:02 AM RE: I was bored and found a HP-27S - Dave Frederickson - 06-28-2014, 02:13 PM RE: I was bored and found a HP-27S - Marcus von Cube - 06-28-2014, 07:17 AM RE: I was bored and found a HP-27S - walter b - 06-28-2014, 08:00 AM RE: I was bored and found a HP-27S - Dave Frederickson - 06-27-2014, 10:40 PM RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:46 PM RE: I was bored and found a HP-27S - Mark Hardman - 06-28-2014, 12:05 AM RE: I was bored and found a HP-27S - jebem - 06-28-2014, 07:55 AM RE: I was bored and found a HP-27S - Dave Frederickson - 06-27-2014, 10:52 PM RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:56 PM RE: I was bored and found a HP-27S - Dave Frederickson - 06-27-2014, 11:01 PM RE: I was bored and found a HP-27S - jebem - 06-27-2014, 11:05 PM RE: I was bored and found a HP-27S - Dave Frederickson - 06-27-2014, 11:12 PM RE: I was bored and found a HP-27S - jebem - 06-28-2014, 04:44 PM RE: I was bored and found a HP-27S - Dave Frederickson - 06-28-2014, 12:33 AM RE: I was bored and found a HP-27S - Dave Frederickson - 06-28-2014, 05:33 PM RE: I was bored and found a HP-27S - jebem - 06-28-2014, 05:37 PM HP-27S that does not turn on - franz.b - 11-06-2020, 08:24 PM RE: I was bored and found a HP-27S - Massimo Gnerucci - 11-06-2020, 08:42 PM RE: I was bored and found a HP-27S - franz.b - 11-08-2020, 06:39 PM RE: I was bored and found a HP-27S - jebem - 11-09-2020, 07:14 AM RE: I was bored and found a HP-27S - franz.b - 11-09-2020, 08:17 AM RE: I was bored and found a HP-27S - franz.b - 11-11-2020, 08:51 PM RE: I was bored and found a HP-27S - Eric Rechlin - 06-29-2021, 01:13 AM RE: I was bored and found a HP-27S - Steve Sabin - 06-29-2021, 01:21 AM RE: I was bored and found a HP-27S - Steve Simpkin - 06-29-2021, 01:48 AM RE: I was bored and found a HP-27S - Christoph Giesselink - 06-29-2021, 09:09 PM RE: I was bored and found a HP-27S - Massimo Gnerucci - 06-29-2021, 09:41 PM RE: I was bored and found a HP-27S - Eric Rechlin - 06-29-2021, 01:33 AM RE: I was bored and found a HP-27S - Jake Schwartz - 06-30-2021, 03:59 PM

User(s) browsing this thread: 1 Guest(s)