Last active
February 11, 2022 11:44
-
-
Save maymax777/1270c56a47c7fe59813610ee9811f19c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.13; | |
contract Repeater { | |
function multiply(uint8 repeat, string pattern) returns (string) { | |
bytes memory bpattern = bytes(pattern); | |
uint resultLength = repeat * bpattern.length; | |
string memory result = new string(resultLength); | |
bytes memory bresult = bytes(result); | |
for (uint i = 0; i < resultLength; i++) { | |
bresult[i] = bpattern[i % bpattern.length]; | |
} | |
return string(bresult); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment