Post Reply 
HHC 2015 RPN programming Contest is now open
09-28-2015, 01:40 AM
Post: #27
RE: HHC 2015 RPN programming Contest is now open
(09-28-2015 12:21 AM)Allen Wrote:  Here is what I finished last night. I have not edited it for optimization but nothing is obvious to me without rethinking how it's done: http://www.enterhp.com/images/HHC2015_AllenT.zip
(Zip file includes python test code, and 2 routines to check every possible YATZEE solution, along with a RAW file for Free42.)

Allen,

Nice documentation provided by you and others, unlike my uncommented code. I started only yesterday, late at night. I wasn't thinking of trying this one, so I am glad I came up with a working solution. I hope the lack of comments might be compensated by a QBASIC program which checks every permutation and gives a list of the only 16 permutations that passes three consecutive tests (I had to make sure these three tests would suffice). It is interesting to see the various approaches presented in this thread for the same problem.


Gerson.

Code:

DEFINT A-Z
DIM MS(1500, 5), M(5), D(4)
CLS
CT = 0
FOR A = 1 TO 6
  FOR B = 1 TO 6
    FOR C = 1 TO 6
      FOR D = 1 TO 6
        FOR E = 1 TO 6
          M(1) = A: M(2) = B: M(3) = C: M(4) = D: M(5) = E
          FOR I = 1 TO 4
            FOR J = I + 1 TO 5
              IF M(I) > M(J) THEN SWAP M(I), M(J)
            NEXT J
          NEXT I
          FOR I = 1 TO 4
            D(I) = M(I + 1) - M(I)
          NEXT I
          ZEROS = 0: ONES = 0
          FOR I = 1 TO 4
            IF D(I) = 0 THEN ZEROS = ZEROS + 1
            IF D(I) = 1 THEN ONES = ONES + 1
          NEXT I
          IF ONES > ZEROS THEN IF ONES >= 3 THEN IF (D(2) + D(3)) < 3 THEN CT = CT + 1: MS(CT, 1) = M(1): MS(CT, 2) = M(2): MS(CT, 3) = M(3): MS(CT, 4) = M(4): MS(CT, 5) = M(5)
        NEXT E
      NEXT D
    NEXT C
  NEXT B
NEXT A
PRINT CT: PRINT
FOR I = 1 TO CT - 1
  FOR J = I + 1 TO CT
    IF (MS(I, 1) = MS(J, 1) AND MS(I, 2) = MS(J, 2) AND MS(I, 3) = MS(J, 3) AND MS(I, 4) = MS(J, 4) AND MS(I, 5) = MS(J, 5)) THEN MS(J, 1) = 0
  NEXT J
NEXT I
C2 = 0
FOR I = 1 TO CT
  FOR J = 1 TO 5
    IF MS(I, 1) <> 0 THEN PRINT MS(I, J);
  NEXT J
  IF MS(I, 1) <> 0 THEN PRINT : C2 = C2 + 1
NEXT I
PRINT : PRINT C2
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HHC 2015 RPN programming Contest is now open - Gerson W. Barbosa - 09-28-2015 01:40 AM



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