Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Count trailing truths

Inspired by, and in memory of, my dear friend and colleague,

Dan Baronet

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

Answer*

Draft saved
Draft discarded
Cancel
3
  • 2
    \$\begingroup\$ Hint: This can be done in only 3 bytes, using the J translation of Dan's solution. \$\endgroup\$ Commented Nov 6, 2016 at 17:25
  • 1
    \$\begingroup\$ @Adám I tried looking for a solution. Didn't think of base conversion. That's really quite clever of him! \$\endgroup\$ Commented Nov 6, 2016 at 18:44
  • 1
    \$\begingroup\$ Yes. That was Dan. :-( \$\endgroup\$ Commented Nov 6, 2016 at 19:20

AltStyle によって変換されたページ (->オリジナル) /