Post Reply 
Vietnamese snake puzzle - Closed
05-27-2015, 10:12 AM
Post: #36
RE: Vietnamese snake puzzle - Closed
@Gilles: thanks. I have a 'DOCOMB' lying around for years as well, that will let you execute an object for all combinations of m (input) out of n (size of list) objects.

For the arithmetic puzzle:
The G-H equivalence can be implemented in a much easier way: just test G>H (or vice versa) at the appropriate level ( 5 here):
Code:
  { 1 2 3 4 5 6 7 8 9 }
  \<<
    CASE
    DUP 4 SAME THEN DROP
      9 DUPN DROP2
      \-> B C G H I J ob
      \<<
        'G*H/I' EVAL
        IF DUP FP
        THEN DROP
        ELSE
          '13*B/C' EVAL + 'J' STO
          \<<
            4 DUPN
            \-> E F A D
            \<<
              'J+A+D-F+12*E' EVAL
              IF 87 SAME THEN
                A B C D E F G H I
                9 \->LIST
                10 ROLLD
              END
            \>>
          \>>
          'ob' STO

          1 4 START
            4 ROLL
            ROT ob EVAL
            ROT ob EVAL
            ROT ob EVAL
          NEXT

        END
        1
      \>>
    END
    DUP 5 SAME THEN DROP    @ test G > H
      7 PICK 7 PICK >
    END
    DUP 7 SAME THEN DROP
      9 PICK 9 PICK MOD        @ test C divides B
    END
    DROP 0            @ default: continue
    END
  \>>
  DOPERM2

And it's even slightly faster.

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Vietnamese snake puzzle - Dave Britten - 05-20-2015, 11:27 AM
RE: Vietnamese snake puzzle - Gerald H - 05-20-2015, 11:33 AM
RE: Vietnamese snake puzzle - Gerald H - 05-20-2015, 12:58 PM
RE: Vietnamese snake puzzle - Closed - Werner - 05-27-2015 10:12 AM



User(s) browsing this thread: