Skip to content

Commit

Permalink
Add Baklava in Solidity (#3891)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm authored Oct 7, 2024
1 parent 358d16f commit 7ff2179
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions archive/s/solidity/Baklava.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8;

contract Baklava {
function main (string memory) public pure returns (string memory) {
string memory output = '';
for (int i = -10; i <= 10; i++) {
int numSpaces = (i >= 0) ? i : -i;
output = string.concat(output, strRepeat(numSpaces, ' '));
output = string.concat(output, strRepeat(21 - 2 * numSpaces, '*'));
output = string.concat(output, '\n');
}

return output;
}

function strRepeat(int n, string memory s) private pure returns (string memory) {
string memory r = '';
for (int i = 0; i < n; i++) {
r = string.concat(r, s);
}

return r;
}
}
2 changes: 1 addition & 1 deletion archive/s/solidity/testinfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ folder:

container:
image: "rzuckerm/solidity"
tag: "0.8.21-1"
tag: "0.8.21-2"
build: "compile_solidity {{ source.name }}{{ source.extension }}"
cmd: "run_solidity {{ source.name }}"

0 comments on commit 7ff2179

Please sign in to comment.