* Rotates string representation of bits to the left * * @param {string} bits - string representation of bits * @param {int} turns - number of rotations to make * @return {string} - string representation of bits after rotation * * @example * rotateLeft("1011", 3); // "1101"
(bits, turns)
| 55 | * rotateLeft("1011", 3); // "1101" |
| 56 | */ |
| 57 | function rotateLeft(bits, turns) { |
| 58 | return bits.substr(turns) + bits.substr(0, turns) |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Pre-processes message to feed the algorithm loop |