Skip to content

Commit 1c88d67

Browse files
authored
Added stringMatching algorithm in Maths (#51)
* Added stringMatching algorithm in Maths * changed formatting using prettier solidity
1 parent 82fa15e commit 1c88d67

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Maths/stringMatch.sol

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: GPL-3.0
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
* @title String Matching.
6+
* @author Sreek https://github.com/sreekar9601.
7+
* @dev Contract to demonstrate matching of two strings.
8+
*/
9+
10+
contract StringMatch {
11+
string firstString;
12+
string secondString;
13+
14+
function setFirstString(string memory _firstString) public {
15+
firstString = _firstString;
16+
}
17+
18+
function setSecondString(string memory _secondString) public {
19+
secondString = _secondString;
20+
}
21+
22+
function stringMatch() public view returns (bool) {
23+
if (
24+
keccak256(abi.encodePacked(firstString)) ==
25+
keccak256(abi.encodePacked(secondString))
26+
) {
27+
return true;
28+
}
29+
return false;
30+
}
31+
}

0 commit comments

Comments
 (0)