Skip to content

Competition Update: Test your Skill

Vector 2:3, page 104

competitions and puzzles

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 104

Maurice Jordan from British Airways has kindly sent in some timings for the skillsmatch functions presented in VECTOR 2.1. Here are his results for Adrian Smith’s looping solution \<SM9>, Maurice’s own APL*PLUS nested arrays production system answer \<SMNAPS> and the winning entry \<SM10>. By the way, as Phil Last has correctly pointed out, the function \<SM10> requires the addition of a 29 to the vector of prime numbers if 10 skills are to be correctly processed.

      JOBS
1 2 3
7 9 0
1 4 0
1 3 0
1 6 3
      CONS
1 2 3 7 0 0
1 3 7 9 2 6
7 9 0 0 0 0
1 6 5 3 9 0
      ⎕VR'SM9'
    ∇ Z←JB SM9 CN;SK;LAB;CT
[1]    SK←⌈/,JB
[2]    Z←((1↑⍴JB),1↑⍴CN)⍴1
[3]   LOOP:→LAB←1+(SK⍴LOOP),END,CT←1
[4]    Z←Z∧(JB∨.=CT)∘.⍲(CN∧.≠CT)
[5]   END:→LAB[CT←CT+1]
    ∇
      ⎕VR'SMNAPS'
    ∇ Z←J SMNAPS C
[1]    Z←∧/↑(↓J)∘.∊↓C,0
    ∇
      10 TESTTIME 'Z←JOBS SM9 CONS'
4.5
      10 TESTTIME 'Z←JOBS SMNAPS CONS'
2.3
      ⍝ But still the best
      10 TESTTIME 'Z←JOBS SM10 CONS'
0.4
      ⎕VR'SM10'
    ∇ Z←J SM10 C;P;⎕IO
[1]    ⎕IO←0
[2]    P← 1 2 3 5 7 11 13 17 19 23
[3]    Z←0=(×/P[J])∘.|×/P[C]
    ∇