Skip to content

5. What, where?!

In this problem, you’re asked to enter an APL expression (some APL code), including arguments (data given to APL symbols). Your code will be tested by the APL Challenge system to check whether it gives the correct answer and uses the methods described below.

An APL function takes the result of all code to its right as its right argument (the data on the right of the symbol). For example, 2×3+4 gives 14 (rather than the 10 you might expect) because the × takes the result of 3+4 as its right argument.

You can use round brackets ( () ) to change the order in which things are calculated. When used, the right argument only goes as far as the nearest closing bracket on its right:

  1. 2×3+4 gives 14 because × takes the result of all code to its right, 3+4, as its right argument.
  2. 2×(3+4) gives 14 because × takes the result of all code to its right, (3+4), as its right argument.
  3. (2×3)+4 gives 10 because the right argument of × only goes as far as the nearest closing bracket.

Remember from problem 1 that APL uses 1 and 0 for yes and no. The And function (looks a bit like the letter A for And) allows you to combine such values; it gives 1 if both left and right arguments are 1, but 0 if either is 0. For example, 1 1 0 0 ∧ 0 1 0 1 gives 0 1 0 0, because:

  1. 0 no: 1 is yes but 0 is no
  2. 1 yes: 1 and 1 are both yes
  3. 0 no: neither 0 nor 0 is are yes
  4. 0 no: 0 is no, even though 1 is yes

Write an expression that uses = from problem 1, from problem 3, and round brackets, to show that the 2nd letter of 'DYALOG' is a 'Y' and that the 6th letter of 'DYALOG' is a G. The result should be 1 for yes.