Quantcast
Channel: Break an integer into even- and odd-indexed bits - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 15

Answer by Julian for Break an integer into even- and odd-indexed bits

$
0
0

PowerShell Core, 130 bytes

($b=[Convert]::ToString(+"$args",2)|% t*y)|%{$c=$b[-++$i]if($i%2){$e="$c$e"}else{$o="$c$o"}}$e,$o|%{[Convert]::ToInt16("0$_",2)}

Try it online!

Takes an integer and returns two shorts


Viewing all articles
Browse latest Browse all 15

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>