Count trailing truths
Inspired by, and in memory of, my dear friend and colleague,
Dan Baronet, 1956 – 2016. R.I.P.
He found the shortest possible APL solution to this task:
Task
Given a Boolean list, count the number of trailing truth values.
Example cases
{} → 0
{0} → 0
{1} → 1
{0, 1, 1, 0, 0} → 0
{1, 1, 1, 0, 1} → 1
{1, 1, 0, 1, 1} → 2
{0, 0, 1, 1, 1} → 3
{1, 1, 1, 1, 1, 1} → 6
Adám
- 31.8k
- 4
- 131
- 292