Skip to main content
deleted 74 characters in body
Source Link
ngn
  • 15.3k
  • 2
  • 43
  • 87

K (ngn/k), 18 bytes

{+/2!0N 2#0,x^"_"}

Try it online!

{ } function with argument x

x^"_" remove all _s

0, prepend a 0

0N 2# split in pairs

2! mod 2 (asas ascii codes): P→80→0, o→111→1, ~→126→0

+/ sum

K (ngn/k), 18 bytes

{+/2!0N 2#0,x^"_"}

Try it online!

{ } function with argument x

x^"_" remove all _s

0, prepend a 0

0N 2# split in pairs

2! mod 2 (as ascii codes)

+/ sum

K (ngn/k), 18 bytes

{+/2!0N 2#0,x^"_"}

Try it online!

{ } function with argument x

x^"_" remove all _s

0, prepend a 0

0N 2# split in pairs

2! mod 2 as ascii codes: P→80→0, o→111→1, ~→126→0

+/ sum

Post Undeleted by ngn
deleted 74 characters in body
Source Link
ngn
  • 15.3k
  • 2
  • 43
  • 87

K (ngn/k), 6318 bytes

{$[~2=#x:"P"\x^"_";`error;|//^x:2#',+/2!0N 2#/:"o~"?x;`error;+/x]2#0,x^"_"}

Try it online!Try it online!

{ } function with argument x

x^"_" remove all _s

0, prepend a 0

0N 2# split in pairs

2! mod 2 (as ascii codes)

+/ sum

K (ngn/k), 63 bytes

{$[~2=#x:"P"\x^"_";`error;|//^x:2#',/0N 2#/:"o~"?x;`error;+/x]}

Try it online!

K (ngn/k), 18 bytes

{+/2!0N 2#0,x^"_"}

Try it online!

{ } function with argument x

x^"_" remove all _s

0, prepend a 0

0N 2# split in pairs

2! mod 2 (as ascii codes)

+/ sum

Post Deleted by ngn
added 38 characters in body
Source Link
ngn
  • 15.3k
  • 2
  • 43
  • 87

K (ngn/k), 5063 bytes

{$[|$[~2=#x:"P"\x^"_";`error;|//^r^x:2#',/0N 2#/:2^"o~""o~"?"P"\x^"_";`error;+x;`error;+/r]x]}

Try it online!Try it online!

K (ngn/k), 50 bytes

{$[|//^r:2#',/0N 2#/:2^"o~"?"P"\x^"_";`error;+/r]}

Try it online!

K (ngn/k), 63 bytes

{$[~2=#x:"P"\x^"_";`error;|//^x:2#',/0N 2#/:"o~"?x;`error;+/x]}

Try it online!

Source Link
ngn
  • 15.3k
  • 2
  • 43
  • 87
Loading