Skip to content

8. Give Me a Break!

In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your function will be checked by the APL Challenge system using several tests to see whether it is correct.

Now for \ (Backslash) which is very similar to / from problem 6, but gives a list instead of a single number. The first number of the answer is the same as the first number in the given list. The second number of the answer is calculated by putting the function between the first and second items of the given list. The third number of the answer is calculated by putting the function between the first three items of the given list. And so on.

For example, +\ 1 9 2 0 1 2 1 7 gives 1 10 12 12 13 15 16 23, as follows:

  1. 1 from 1
  2. 10 from 1 + 9
  3. 12 from 1 + 9 + 2
  4. 12 from 1 + 9 + 2 + 0
  5. 13 from 1 + 9 + 2 + 0 + 1
  6. 15 from 1 + 9 + 2 + 0 + 1 + 2
  7. 16 from 1 + 9 + 2 + 0 + 1 + 2 + 1
  8. 23 from 1 + 9 + 2 + 0 + 1 + 2 + 1 + 7

and <\ 0 0 1 0 1 0 1 gives 0 0 1 0 0 0 0, as follows:

  1. 0 from 0
  2. 0 from 0 < 0
  3. 1 from 0 < 0 < 1
  4. 0 from 0 < 0 < 1 < 0
  5. 0 from 0 < 0 < 1 < 0 < 1
  6. 0 from 0 < 0 < 1 < 0 < 1 < 0
  7. 0 from 0 < 0 < 1 < 0 < 1 < 0 < 1

Using + with / from problem 6, from problem 5 with \, and = from problem 1, write a function that takes a text and counts how many leading spaces it has. For example:

      {answer} ' JUST ONE'
1

      {answer} 'NOT EVEN ONE'
0

      {answer} '    SOME'
4