Post Reply 
I was bored and found a HP-27S
06-27-2014, 12:43 PM
Post: #47
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
Find all posts by this user
Quote this message in a reply
Post Reply 


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 - jebem - 06-10-2014, 09:35 AM
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 - 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 - jebem - 06-26-2014, 03:57 PM
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 - 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 - 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 - jebem - 06-27-2014, 10:58 PM
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 - jebem - 06-27-2014, 10:46 PM
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 - jebem - 06-27-2014, 10:56 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 - jebem - 06-28-2014, 04:44 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 - jebem - 11-09-2020, 07:14 AM



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