-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathSimulateArray.huff
29 lines (24 loc) · 969 Bytes
/
SimulateArray.huff
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
/**
* SUM_ARRAY HUFF EXERCISE
*
* In this puzzle, the task is to simulate an array in Huff using the "exact" storage pattern as solidity. Expected functions can;
* - Push numbers onto a array,
* - Pop the last index from the array,
* - View what's stored at an index,
* - Gets the length of the array,
* - Write to an index if it is valid.
*
* - Writes and reads outside of length revert.
* - Popping off a zero length array reverts.
*
* NOTICE: The contract should revert when an unrecognized function is called
*/
#define function pushh(uint256 num) payable returns()
#define function popp() payable returns()
#define function read(uint256 index) payable returns(uint256)
#define function length() payable returns(uint256)
#define function write(uint256 index, uint256 num) payable returns()
#define error OutOfBounds()
#define error ZeroArray()
#define macro MAIN() = takes(0) returns(0) {
}