Skip to main content
join lmap
Source Link
vo1stv
  • 119
  • 9

[Tcl]Tcl, 215 167 142140 bytes

{{s {B binary} {X ~$w/64}} {lmapjoin [lmap c [split $s {}] {$B scan $c c w;$B scan [$B format i [expr 2*$w^$w^$X<<7]] B7 r;set X $w;append R$w;set $rr};set] R""}}

[Try it online!][TIO-jy8172pf]Try it online!

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character using appendby joining list returned by lmap.

Uses lambdas with default arguments to save bytes on initialization and repeated commands.

Relies heavily on order of operation. Fails on Works for empty string. [Tcl]: http://tcl.tk/ [TIO-jy8172pf]: https://tio.run/##ZU/BaoQwFLz7FVONl142KaV7cE8uhV62haVQwVqwroKQ1RAtdpH0122MRmo3eeRNXt6bmbQZH5q8RYH3oe8b9CE@yyqVF4U@wg/pNg/3SmN@TgUyxI3gZQuiG1WCnoRosrQCyfRbF9hrrEFRy3PaokScfwuJu1vSfYwR7XbbJEG4hQxG4QikC1Ih8uqEI4hUpnpUahBfbQOXMaqDsnEbwGZsE53qJllAzZombCedp/XhOoY71rL8AlLAfco5r/FWS366cRPHSrOJdEmWfDZE6T8vbDJjAWOL5mR8Ibt24PvYvxwOj8@v8P2VheXn9HrK83Tr8Ne9s7qsWB3P@wU "Tcl – Try It Online"

[Tcl], 215 167 142 bytes

{{s {B binary} {X ~$w/64}} {lmap c [split $s {}] {$B scan $c c w;$B scan [$B format i [expr 2*$w^$w^$X<<7]] B7 r;set X $w;append R $r};set R}}

[Try it online!][TIO-jy8172pf]

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character using append.

Uses lambdas with default arguments to save bytes on initialization and repeated commands.

Relies heavily on order of operation. Fails on empty string. [Tcl]: http://tcl.tk/ [TIO-jy8172pf]: https://tio.run/##ZU/BaoQwFLz7FVONl142KaV7cE8uhV62haVQwVqwroKQ1RAtdpH0122MRmo3eeRNXt6bmbQZH5q8RYH3oe8b9CE@yyqVF4U@wg/pNg/3SmN@TgUyxI3gZQuiG1WCnoRosrQCyfRbF9hrrEFRy3PaokScfwuJu1vSfYwR7XbbJEG4hQxG4QikC1Ih8uqEI4hUpnpUahBfbQOXMaqDsnEbwGZsE53qJllAzZombCedp/XhOoY71rL8AlLAfco5r/FWS366cRPHSrOJdEmWfDZE6T8vbDJjAWOL5mR8Ibt24PvYvxwOj8@v8P2VheXn9HrK83Tr8Ne9s7qsWB3P@wU "Tcl – Try It Online"

Tcl, 215 167 140 bytes

{{s {B binary} {X ~$w/64}} {join [lmap c [split $s {}] {$B scan $c c w;$B scan [$B format i [expr 2*$w^$w^$X<<7]] B7 r;set X $w;set r}] ""}}

Try it online!

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character by joining list returned by lmap.

Uses lambdas with default arguments to save bytes on initialization and repeated commands.

Relies heavily on order of operation. Works for empty string.

final submission
Source Link
vo1stv
  • 119
  • 9

Tcl[Tcl], 215 167167 142 bytes

{{s {B binary} {X ~$w} {R ""/64}} {lmap c [split $s {}] {$B scan $c c w;$B scan [$B format i [expr 2*($w^((64&$X)|$w/2))]]2*$w^$w^$X<<7]] B7 r;set X [subst {$w*64}];append$w;append R $r};set R}}

Try it online! [Try it online!][TIO-jy8172pf]

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character using append.

Uses lambdas with default arguments to save bytes on initialization and repeated commands.

Relies heavily on order of operation. Fails on empty string. [Tcl]: http://tcl.tk/ [TIO-jy8172pf]: https://tio.run/##ZU/BaoQwFLz7FVONl142KaV7cE8uhV62haVQwVqwroKQ1RAtdpH0122MRmo3eeRNXt6bmbQZH5q8RYH3oe8b9CE@yyqVF4U@wg/pNg/3SmN@TgUyxI3gZQuiG1WCnoRosrQCyfRbF9hrrEFRy3PaokScfwuJu1vSfYwR7XbbJEG4hQxG4QikC1Ih8uqEI4hUpnpUahBfbQOXMaqDsnEbwGZsE53qJllAzZombCedp/XhOoY71rL8AlLAfco5r/FWS366cRPHSrOJdEmWfDZE6T8vbDJjAWOL5mR8Ibt24PvYvxwOj8@v8P2VheXn9HrK83Tr8Ne9s7qsWB3P@wU "Tcl – Try It Online"

Tcl, 215 167 bytes

{{s {B binary} {X ~$w} {R ""}} {lmap c [split $s {}] {$B scan $c c w;$B scan [$B format i [expr 2*($w^((64&$X)|$w/2))]] B7 r;set X [subst {$w*64}];append R $r};set R}}

Try it online!

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character using append.

Uses lambdas with default arguments to save bytes on initialization and repeated commands.

[Tcl], 215 167 142 bytes

{{s {B binary} {X ~$w/64}} {lmap c [split $s {}] {$B scan $c c w;$B scan [$B format i [expr 2*$w^$w^$X<<7]] B7 r;set X $w;append R $r};set R}}

[Try it online!][TIO-jy8172pf]

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character using append.

Uses lambdas with default arguments to save bytes on initialization and repeated commands.

Relies heavily on order of operation. Fails on empty string. [Tcl]: http://tcl.tk/ [TIO-jy8172pf]: https://tio.run/##ZU/BaoQwFLz7FVONl142KaV7cE8uhV62haVQwVqwroKQ1RAtdpH0122MRmo3eeRNXt6bmbQZH5q8RYH3oe8b9CE@yyqVF4U@wg/pNg/3SmN@TgUyxI3gZQuiG1WCnoRosrQCyfRbF9hrrEFRy3PaokScfwuJu1vSfYwR7XbbJEG4hQxG4QikC1Ih8uqEI4hUpnpUahBfbQOXMaqDsnEbwGZsE53qJllAzZombCedp/XhOoY71rL8AlLAfco5r/FWS366cRPHSrOJdEmWfDZE6T8vbDJjAWOL5mR8Ibt24PvYvxwOj8@v8P2VheXn9HrK83Tr8Ne9s7qsWB3P@wU "Tcl – Try It Online"

still maybe room for 1 or 2 bytes of savings
Source Link
vo1stv
  • 119
  • 9

Tcl, 215215 167 bytes

{{s {RB ""binary} {BX binary~$w} {PR set""}} {lmap c [split $s {}] {$B scan $c c w;if [catch {$P o $b}] {$P o [expr !($w>>6)]};$Bw;$B scan [$B format i [expr 2*($w^($o<<6|$w(64&$X)|$w/2))]] b7B7 r;set bX [expr[subst $w&1];$P{$w*64}];append R $R[string reverse $r]$r};$P;set R}}

Try it online!Try it online!

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character using append.

41Uses lambdas with default arguments to save bytes foron initialization for test case 1 seems wasteful, but worksand repeated commands.

Tcl, 215 bytes

{{s {R ""} {B binary} {P set}} {lmap c [split $s {}] {$B scan $c c w;if [catch {$P o $b}] {$P o [expr !($w>>6)]};$B scan [$B format i [expr $w^($o<<6|$w/2)]] b7 r;set b [expr $w&1];$P R $R[string reverse $r]};$P R}}

Try it online!

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character.

41 bytes for initialization for test case 1 seems wasteful, but works.

Tcl, 215 167 bytes

{{s {B binary} {X ~$w} {R ""}} {lmap c [split $s {}] {$B scan $c c w;$B scan [$B format i [expr 2*($w^((64&$X)|$w/2))]] B7 r;set X [subst {$w*64}];append R $r};set R}}

Try it online!

Uses shift-by-one and exclusive-or to detect transitions. Carries lsb of current character to msb of next character. Combines output for each character using append.

Uses lambdas with default arguments to save bytes on initialization and repeated commands.

pro
Source Link
vo1stv
  • 119
  • 9
Loading
Source Link
vo1stv
  • 119
  • 9
Loading