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
  • \$\begingroup\$ -4 Bytes for using $_GET \$\endgroup\$ Commented May 3, 2017 at 13:32
  • \$\begingroup\$ @JörgHülsermann That would have empty output for any list full of 1s. \$\endgroup\$ Commented May 3, 2017 at 14:50
  • \$\begingroup\$ Okay now I have realize it \$\endgroup\$ Commented May 3, 2017 at 16:48

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