remove utils.py

This commit is contained in:
2025-03-14 06:20:24 -05:00
parent 80cd711709
commit 5c1697d8f4

View File

@@ -1,31 +0,0 @@
import secrets
def secure_fisher_yates_shuffle(arr: list) -> list:
n = len(arr)
for i in range(n - 1, 0, -1):
j = secrets.randbelow(i + 1)
arr[i], arr[j] = arr[j], arr[i]
return arr
def xor_lists(l1: list[int], l2: list[int]):
if len(l1) != len(l2):
raise ValueError("Lists must be of equal length")
return [l2[i] ^ l1[i] for i in range(len(l1))]
def matrix_to_list(mat: list[list[int]]) -> list[int]:
return [val for row in mat for val in row]
def list_to_matrix(lst: list[int], cols: int) -> list[list[int]]:
return [lst[i:i + cols] for i in range(0, len(lst), cols)]
def matrix_transpose(mat: list[list[int]]) -> list[list[int]]:
return [list(row) for row in zip(*mat)]
def int_array_to_bytes(int_arr: list[int], byte_size: int = 2) -> bytes:
return b"".join([numb.to_bytes(byte_size, byteorder='big') for numb in int_arr])