-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompareStrings.sol
More file actions
39 lines (21 loc) · 859 Bytes
/
CompareStrings.sol
File metadata and controls
39 lines (21 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
PROBLEM STATEMENT
Objective
This challenge will help you learn about string data type and their comparison in Smart Contracts. While developing a smart contract you will use strings most of the time.
Task
1. Create a public function compare which accepts two arguments of type string and returns true if they are equal otherwise returns false, the function should be declared as pure
2. Make sure you do not use require, revert or assert conditions anywhere
* the functions name should match as defined above
Sample Input 0
"Hello", "World"
Sample Output
False
*/
//PROGRAM
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
contract Sample {
function compare(string memory num,string memory num1) public pure returns(bool){
return keccak256(abi.encodePacked((num))) == keccak256(abi.encodePacked((num1)));
}
}