# Dan Baronet, 1956 – 2016. R.I.P.

He found the shortest possible APL solution to this 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

• Can we take the list as a string of zeros and ones? e.g. 01100? Nov 6, 2016 at 12:57
• @Adnan only if that is the most normal way for your language to represent boolean lists.
Nov 6, 2016 at 15:42
• Sorry for your loss. Nov 6, 2016 at 17:03
• @MartinEnder Thank you. It will be tough going forward. Dan taught me all I needed to know to work for Dyalog.
Nov 6, 2016 at 17:32
• Farewell to Dan. RIP... Nov 7, 2016 at 12:46

# MBASIC, 112 bytes

1 INPUT B$:T=0:FOR I=LEN(B$) TO 1 STEP -1:C$=MID$(B$,I,1):IF C$="0" THEN 4
2 IF C\$="1" THEN T=T+1
3 NEXT
4 PRINT T


Just wanted to see if I could do it.

Explanation

Input is a string of 1's and 0's. String is traversed from right to left. If the current digit is a 0, bail out and print the total. If the digit is a 1, increment the total and continue to loop.

Output

? 01100
0

? 11011
2

? 11101
1

? 111111
6


# 05AB1E, 3 bytes

γθO


Try it online!

γθO  # full program
O  # sum of...
θ   # last...
γ    # group of consecutive equal elements in...
# implicit input
# implicit output