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.19; | |
contract MaximumMultiple { | |
function maxMultiple(int d, int b) public pure returns (int) { | |
// | |
int max = d > b ? d : b; | |
int min = d < b ? d : b; | |
return max - max % min; | |
} | |
} |
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.19; | |
contract Century { | |
function get(int year) public pure returns (int) { | |
return (year - 1) / 100 + 1; | |
} | |
} |
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.19; | |
contract Problem { | |
function rowSumOddNumbers(int n) public pure returns (int) { | |
int end = (1 + n ) * n - 1; | |
int start = end - 2 * (n - 1); | |
int sum = (start + end) * n / 2; | |
return sum; | |
} | |
} |
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]; |
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.19; | |
contract Roman { | |
uint[] key = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; | |
string[] numerals = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; | |
function solution(uint n) public view returns (string) { | |
// Convert the positive integer to a Roman Numeral | |
string memory res = ""; |
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
<!-- HTML --> | |
<video id="video" width="160" height="120" autoplay></video><br> | |
<div id="div"></div> | |