Artifact 329a03d219b36e695a0615f6d5bc239f4bc0f052:
File master_theorem/murder_at_sea.rx part of check-in [48a095494d] - more master theorem solutions by crc on 2011-09-05 15:12:40. [annotate]
0000: 46 6c 61 67 20 73 65 6d 61 70 68 6f 72 65 73 20 Flag semaphores 0010: 61 72 65 20 61 74 20 74 68 65 20 68 65 61 72 74 are at the heart 0020: 20 6f 66 20 74 68 69 73 20 70 75 7a 7a 6c 65 2e of this puzzle. 0030: 20 49 6e 20 74 68 65 20 74 65 78 74 2c 0a 4d 20 In the text,.M 0040: 70 72 6f 76 69 64 65 73 20 61 20 73 65 72 69 65 provides a serie 0050: 73 20 6f 66 20 74 69 6d 65 73 2e 20 54 68 65 73 s of times. Thes 0060: 65 20 63 6f 72 72 65 73 70 6f 6e 64 20 74 6f 20 e correspond to 0070: 66 6c 61 67 20 73 65 6d 61 70 68 6f 72 65 0a 70 flag semaphore.p 0080: 6f 73 69 74 69 6f 6e 73 2e 20 49 66 20 79 6f 75 ositions. If you 0090: 20 70 69 63 74 75 72 65 20 74 68 65 20 66 6c 61 picture the fla 00a0: 67 20 70 6f 73 69 74 69 6f 6e 73 20 61 73 20 74 g positions as t 00b0: 68 65 20 68 61 6e 64 73 20 6f 6e 20 61 6e 0a 61 he hands on an.a 00c0: 6e 61 6c 6f 67 20 63 6c 6f 63 6b 2c 20 74 68 69 nalog clock, thi 00d0: 73 20 73 68 6f 75 6c 64 20 62 65 63 6f 6d 65 20 s should become 00e0: 63 6c 65 61 72 2e 0a 0a 53 6f 3a 0a 0a 20 20 37 clear...So:.. 7 00f0: 31 35 20 31 33 30 20 36 32 35 20 37 33 30 20 39 15 130 625 730 9 0100: 32 35 20 37 34 35 20 37 33 30 20 39 31 35 20 37 25 745 730 915 7 0110: 30 30 0a 0a 54 68 65 73 65 20 61 72 65 20 6f 75 00..These are ou 0120: 72 20 74 69 6d 65 73 2e 0a 0a 20 20 3a 20 64 69 r times... : di 0130: 73 70 6c 61 79 20 28 20 6e 2d 20 29 0a 20 20 20 splay ( n- ). 0140: 20 5b 20 37 33 30 20 3d 20 5d 20 5b 20 64 72 6f [ 730 = ] [ dro 0150: 70 20 27 41 20 70 75 74 63 20 5d 20 77 68 65 6e p 'A putc ] when 0160: 0a 20 20 20 20 5b 20 31 33 30 20 3d 20 5d 20 5b . [ 130 = ] [ 0170: 20 64 72 6f 70 20 27 45 20 70 75 74 63 20 5d 20 drop 'E putc ] 0180: 77 68 65 6e 0a 20 20 20 20 5b 20 36 32 35 20 3d when. [ 625 = 0190: 20 5d 20 5b 20 64 72 6f 70 20 27 47 20 70 75 74 ] [ drop 'G put 01a0: 63 20 5d 20 77 68 65 6e 0a 20 20 20 20 5b 20 37 c ] when. [ 7 01b0: 34 35 20 3d 20 5d 20 5b 20 64 72 6f 70 20 27 48 45 = ] [ drop 'H 01c0: 20 70 75 74 63 20 5d 20 77 68 65 6e 0a 20 20 20 putc ] when. 01d0: 20 5b 20 37 30 30 20 3d 20 5d 20 5b 20 64 72 6f [ 700 = ] [ dro 01e0: 70 20 27 4b 20 70 75 74 63 20 5d 20 77 68 65 6e p 'K putc ] when 01f0: 0a 20 20 20 20 5b 20 37 31 35 20 3d 20 5d 20 5b . [ 715 = ] [ 0200: 20 64 72 6f 70 20 27 4d 20 70 75 74 63 20 5d 20 drop 'M putc ] 0210: 77 68 65 6e 0a 20 20 20 20 5b 20 39 31 35 20 3d when. [ 915 = 0220: 20 5d 20 5b 20 64 72 6f 70 20 27 52 20 70 75 74 ] [ drop 'R put 0230: 63 20 5d 20 77 68 65 6e 0a 20 20 20 20 5b 20 39 c ] when. [ 9 0240: 32 35 20 3d 20 5d 20 5b 20 64 72 6f 70 20 27 53 25 = ] [ drop 'S 0250: 20 70 75 74 63 20 5d 20 77 68 65 6e 20 3b 0a 0a putc ] when ;.. 0260: 4c 65 73 73 20 65 6c 65 67 61 6e 74 20 74 68 61 Less elegant tha 0270: 6e 20 61 20 6c 6f 6f 6b 75 70 20 74 61 62 6c 65 n a lookup table 0280: 2c 20 62 75 74 20 73 75 69 74 61 62 6c 65 20 66 , but suitable f 0290: 6f 72 20 74 68 69 73 0a 71 75 69 63 6b 20 61 6e or this.quick an 02a0: 64 20 64 69 72 74 79 20 73 6f 6c 75 74 69 6f 6e d dirty solution 02b0: 2e 20 4d 61 70 20 65 61 63 68 20 74 69 6d 65 20 . Map each time 02c0: 74 6f 20 61 20 63 68 61 72 61 63 74 65 72 0a 61 to a character.a 02d0: 6e 64 20 64 69 73 70 6c 61 79 20 74 68 65 6d 2e nd display them. 02e0: 0a 0a 20 20 22 22 20 5e 62 75 66 66 65 72 27 73 .. "" ^buffer's 02f0: 65 74 0a 0a 53 65 74 75 70 20 61 20 74 65 6d 70 et..Setup a temp 0300: 6f 72 61 72 79 20 73 74 72 69 6e 67 20 61 73 20 orary string as 0310: 61 20 62 75 66 66 65 72 2e 0a 0a 20 20 64 65 70 a buffer... dep 0320: 74 68 20 5b 20 5e 62 75 66 66 65 72 27 61 64 64 th [ ^buffer'add 0330: 20 5d 20 74 69 6d 65 73 0a 0a 41 64 64 73 20 61 ] times..Adds a 0340: 6c 6c 20 6f 66 20 74 68 65 20 74 69 6d 65 73 20 ll of the times 0350: 74 6f 20 74 68 65 20 62 75 66 66 65 72 2e 0a 0a to the buffer... 0360: 20 20 5e 62 75 66 66 65 72 27 73 74 61 72 74 20 ^buffer'start 0370: 5e 73 74 72 69 6e 67 73 27 72 65 76 65 72 73 65 ^strings'reverse 0380: 0a 0a 52 65 76 65 72 73 65 20 74 68 65 20 6f 72 ..Reverse the or 0390: 64 65 72 20 6f 66 20 74 68 65 20 62 75 66 66 65 der of the buffe 03a0: 72 2c 20 61 6e 64 20 6c 65 61 76 65 20 61 20 70 r, and leave a p 03b0: 6f 69 6e 74 65 72 2e 2e 2e 0a 0a 20 20 5b 20 40 ointer..... [ @ 03c0: 20 64 69 73 70 6c 61 79 20 5d 20 5e 74 79 70 65 display ] ^type 03d0: 73 27 53 54 52 49 4e 47 20 65 61 63 68 40 0a 0a s'STRING each@.. 03e0: 41 6e 64 20 61 70 70 6c 79 20 61 20 71 75 6f 74 And apply a quot 03f0: 65 20 74 6f 20 65 61 63 68 20 69 74 65 6d 20 69 e to each item i 0400: 6e 20 74 68 65 20 62 75 66 66 65 72 2e 20 54 68 n the buffer. Th 0410: 69 73 20 69 73 20 70 72 65 74 74 79 0a 73 69 6d is is pretty.sim 0420: 70 6c 65 3a 20 66 65 74 63 68 20 74 68 65 20 69 ple: fetch the i 0430: 74 65 6d 2c 20 61 6e 64 20 67 69 76 65 20 69 74 tem, and give it 0440: 20 74 6f 20 74 68 65 20 64 69 73 70 6c 61 79 20 to the display 0450: 66 75 6e 63 74 69 6f 6e 2e 0a 0a 54 68 69 73 20 function...This 0460: 79 69 65 6c 64 73 20 74 68 65 20 61 6e 73 77 65 yields the answe 0470: 72 3a 20 4d 45 47 41 53 48 41 52 4b 0a 0a 41 6c r: MEGASHARK..Al 0480: 6c 20 69 6e 20 61 6c 6c 2c 20 61 20 62 6f 72 69 l in all, a bori 0490: 6e 67 20 70 75 7a 7a 6c 65 2e 20 4f 6e 63 65 20 ng puzzle. Once 04a0: 79 6f 75 20 66 69 67 75 72 65 20 6f 75 74 20 74 you figure out t 04b0: 68 61 74 20 4d 20 77 61 6e 74 73 0a 79 6f 75 20 hat M wants.you 04c0: 74 6f 20 75 73 65 20 66 6c 61 67 20 73 65 6d 61 to use flag sema 04d0: 70 68 6f 72 65 73 20 69 6e 20 70 6c 61 63 65 20 phores in place 04e0: 6f 66 20 74 69 6d 65 73 2c 20 69 74 27 73 20 65 of times, it's e 04f0: 61 73 79 20 74 6f 20 66 69 6e 64 0a 74 68 65 20 asy to find.the 0500: 61 6e 73 77 65 72 2e 0a 0a answer...