Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Lone ​​​​​​ones

Perl, 28 bytes Takes input as newline-separated list of binary strings. perl -ple's/11+//g;$_=y/1//' -p - assign each line of input to $_, manipulate, then print -l - strip trailing newline...

posted 7mo ago by jhnc‭  ·  edited 7mo ago by jhnc‭

Answer
#4: Post edited by user avatar jhnc‭ · 2026-03-04T11:17:36Z (7 months ago)
  • Perl, 28 bytes
  • ---
  • Take input as binary string.
  • ```perl
  • perl -ple's/11+//g;$_=y/1//'
  • ```
  • * `-p` - assign each line of input to `$_`, manipulate, then print
  • * `-l` - strip trailing newline from input, add back to output
  • * `-e` - program follows
  • * `s/11+//g` - strip runs of two or more 1s
  • * `y/1//` - count remaining 1s, assign to `$_`
  • Perl, 28 bytes
  • ---
  • Takes input as newline-separated list of binary strings.
  • ```perl
  • perl -ple's/11+//g;$_=y/1//'
  • ```
  • * `-p` - assign each line of input to `$_`, manipulate, then print
  • * `-l` - strip trailing newline from input, add back to output
  • * `-e` - program follows
  • * `s/11+//g` - strip runs of two or more 1s
  • * `y/1//` - count remaining 1s, assign to `$_`
#3: Post edited by user avatar jhnc‭ · 2026-03-04T10:56:39Z (7 months ago)
  • Perl, 28 bytes
  • ---
  • Take input as binary string.
  • ```perl
  • perl -ple's/11+//g;$_=y/1//'
  • ```
  • * `-p` - assign each line of input to `$_`, manipulate, then print
  • * `-l` - strip trailing newline from input, add back to output
  • * `-e` - program follows
  • * `s///g` - strip runs of two or more 1s
  • * `y///` - count remaining 1s, assign to `$_`
  • Perl, 28 bytes
  • ---
  • Take input as binary string.
  • ```perl
  • perl -ple's/11+//g;$_=y/1//'
  • ```
  • * `-p` - assign each line of input to `$_`, manipulate, then print
  • * `-l` - strip trailing newline from input, add back to output
  • * `-e` - program follows
  • * `s/11+//g` - strip runs of two or more 1s
  • * `y/1//` - count remaining 1s, assign to `$_`
#2: Post edited by user avatar jhnc‭ · 2026-03-04T10:55:50Z (7 months ago)
  • Perl, 31 bytes
  • ---
  • Take input as binary string.
  • ```perl
  • perl -ple's/11+|0+//g;$_=y/1//'
  • ```
  • * `-p` - assign each line of input to `$_`, manipulate, then print
  • * `-l` - strip trailing newline from input, add back to output
  • * `-e` - program follows
  • * `s///g` - strip all runs of 0s or two or more 1s
  • * `y///` - count remaining 1s, assign to `$_`
  • Perl, 28 bytes
  • ---
  • Take input as binary string.
  • ```perl
  • perl -ple's/11+//g;$_=y/1//'
  • ```
  • * `-p` - assign each line of input to `$_`, manipulate, then print
  • * `-l` - strip trailing newline from input, add back to output
  • * `-e` - program follows
  • * `s///g` - strip runs of two or more 1s
  • * `y///` - count remaining 1s, assign to `$_`
#1: Initial revision by user avatar jhnc‭ · 2026-03-04T01:12:03Z (7 months ago)
Perl, 31 bytes
---

Take input as binary string.

```perl
perl -ple's/11+|0+//g;$_=y/1//'
```

* `-p` - assign each line of input to `$_`, manipulate, then print
* `-l` - strip trailing newline from input, add back to output
* `-e` - program follows
* `s///g` - strip all runs of 0s or two or more 1s
* `y///` - count remaining 1s, assign to `$_`