Skip to main content
added 263 characters in body
Source Link
Elcan
  • 1.1k
  • 8
  • 15

Dart, 213213 168 bytes

f(s,{t,i}){t=s.runes.map((r)=>r.toRadixString(2).padLeft(7,'0')).join().split('').toList();for(i=t.length-1;i>0;i--)t[i]=t[i]==t[i-1]?'0':'1';t[0]='1';return t.join();}

Previous one-liner

f(String s)=>'1'+s.runes.map((r)=>r.toRadixString(2).padLeft(7,'0')).join().split('').toList().reversed.reduce((p,e)=>p.substring(0,p.length-1)+(p[p.length-1]==e?'0':'1')+e).split('').reversed.join().substring(1);

Try it online!Try it online!

This verbosity and lack of easy built ins is really killing this one. Still managed to pull a one liner though.

  • -45 bytes by not using a one liner and using a for loop

Dart, 213 bytes

f(String s)=>'1'+s.runes.map((r)=>r.toRadixString(2).padLeft(7,'0')).join().split('').toList().reversed.reduce((p,e)=>p.substring(0,p.length-1)+(p[p.length-1]==e?'0':'1')+e).split('').reversed.join().substring(1);

Try it online!

This verbosity and lack of easy built ins is really killing this one. Still managed to pull a one liner though

Dart, 213 168 bytes

f(s,{t,i}){t=s.runes.map((r)=>r.toRadixString(2).padLeft(7,'0')).join().split('').toList();for(i=t.length-1;i>0;i--)t[i]=t[i]==t[i-1]?'0':'1';t[0]='1';return t.join();}

Previous one-liner

f(String s)=>'1'+s.runes.map((r)=>r.toRadixString(2).padLeft(7,'0')).join().split('').toList().reversed.reduce((p,e)=>p.substring(0,p.length-1)+(p[p.length-1]==e?'0':'1')+e).split('').reversed.join().substring(1);

Try it online!

This verbosity and lack of easy built ins is really killing this one. Still managed to pull a one liner though.

  • -45 bytes by not using a one liner and using a for loop
Source Link
Elcan
  • 1.1k
  • 8
  • 15

Dart, 213 bytes

f(String s)=>'1'+s.runes.map((r)=>r.toRadixString(2).padLeft(7,'0')).join().split('').toList().reversed.reduce((p,e)=>p.substring(0,p.length-1)+(p[p.length-1]==e?'0':'1')+e).split('').reversed.join().substring(1);

Try it online!

This verbosity and lack of easy built ins is really killing this one. Still managed to pull a one liner though