-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4217239
commit e7ac915
Showing
14 changed files
with
3,127 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from starkware.cairo.common.bool import TRUE, FALSE | ||
from starkware.cairo.common.alloc import alloc | ||
|
||
func compare_arrays(array_a: felt*, array_b: felt*, array_length: felt, iterator: felt) -> ( | ||
r: felt | ||
) { | ||
if (iterator == array_length) { | ||
return (TRUE,); | ||
} | ||
if (array_a[iterator] != array_b[iterator]) { | ||
return (FALSE,); | ||
} | ||
return compare_arrays(array_a, array_b, array_length, iterator + 1); | ||
} | ||
|
||
func fill_array(array: felt*, base: felt, step: felt, array_length: felt, iterator: felt) { | ||
if (iterator == array_length) { | ||
return (); | ||
} | ||
assert array[iterator] = base + step * iterator; | ||
return fill_array(array, base, step, array_length, iterator + 1); | ||
} | ||
|
||
func main() { | ||
alloc_locals; | ||
tempvar array_length = 250000; | ||
let (array_a: felt*) = alloc(); | ||
let (array_b: felt*) = alloc(); | ||
fill_array(array_a, 7, 3, array_length, 0); | ||
fill_array(array_b, 7, 3, array_length, 0); | ||
let result: felt = compare_arrays(array_a, array_b, array_length, 0); | ||
assert result = TRUE; | ||
return (); | ||
} | ||
|
Oops, something went wrong.