Skip to main content

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*

4
  • 1
    \$\begingroup\$ I think gsub("(.)\\1","",a)=="" would do the trick as well; many others use the same regex. \$\endgroup\$ Commented Aug 6, 2019 at 18:05
  • \$\begingroup\$ @Giuseppe This whole regex thing is pretty new to me. Thanks. \$\endgroup\$ Commented Aug 6, 2019 at 18:10
  • \$\begingroup\$ R + pryr gets you a 32-byter trivially modified from this answer. \$\endgroup\$ Commented Aug 6, 2019 at 18:19
  • 3
    \$\begingroup\$ If input can be taken as a vector, then function(a)!sum(rle(a)$l%%2) for 28 \$\endgroup\$ Commented Aug 6, 2019 at 19:55