Shortcut for chapter specific information

Tuesday, April 26, 2011

Insertion sort 43 (perl one-liner)

:) Quite epic. 

perl -lane '{push @A,$_}END{for($j=1;$j<$#A+1;$j++){$k=$A[$j];$i=$j-1;while($i>=0&&$A[$i]>$k){$A[$i+1]=$A[$i];$i--}$A[$i+1]=$k;} printf("%s\n",join(" ",@A))}'

33_P

No comments:

Post a Comment