-
Notifications
You must be signed in to change notification settings - Fork 1
/
ques-2.cairo
31 lines (29 loc) · 1.15 KB
/
ques-2.cairo
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
%lang starknet
from starkware.cairo.common.math import assert_nn
from starkware.cairo.common.cairo_builtins import HashBuiltin
from starkware.cairo.common.alloc import alloc
from starkware.cairo.common.find_element import find_element
from starkware.cairo.common.uint256 import (
Uint256,
uint256_eq,
uint256_le,
uint256_lt,
uint256_signed_div_rem,
)
from starkware.cairo.common.math import assert_nn_le, split_felt, unsigned_div_rem
from starkware.cairo.common.bool import FALSE, TRUE
from starkware.cairo.common.default_dict import default_dict_new
from starkware.cairo.common.dict import dict_read, dict_write
from starkware.cairo.common.dict_access import DictAccess
from starkware.cairo.common.math_cmp import is_le
func reverse_arr{syscall_ptr : felt*, pedersen_ptr : HashBuiltin*, range_check_ptr}(
array_len : felt, array : felt*
) -> (rev_array_len : felt, rev_array : felt*):
if array_len == 0:
let (rev_array) = alloc()
return (0, rev_array)
end
let (rev_array_len, rev_array) = reverse_arr(array_len - 1, array + 1)
assert rev_array[rev_array_len] = array[0]
return (rev_array_len + 1, rev_array)
end