-
Notifications
You must be signed in to change notification settings - Fork 286
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
Antoine Sinton
committed
Dec 7, 2024
1 parent
6734f06
commit cffe3a6
Showing
4 changed files
with
23 additions
and
1 deletion.
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
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
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,19 @@ | ||
import sys | ||
import random | ||
|
||
|
||
def main(): | ||
cdef int u, r, i, j | ||
cdef int a[10000] | ||
|
||
u = int(sys.argv[1]) # Get an input number from the command line | ||
r = random.randint(0, 10000) # Get a random number 0 <= r < 10k | ||
a = [0] * 10000 # Array of 10k elements initialized to 0 | ||
for i in range(10000): # 10k outer loop iterations | ||
for j in range(100000): # 100k inner loop iterations, per outer loop iteration | ||
a[i] += j % u # Simple sum | ||
a[i] += r # Add a random value to each element in array | ||
print(a[r]) # Print out a single element from the array | ||
|
||
|
||
main() |
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