Skip to content

Instantly share code, notes, and snippets.

View aflaag's full-sized avatar
💭
coding

Alessio Bandiera aflaag

💭
coding
  • Sapienza University of Rome
  • Italy
View GitHub Profile
@aflaag
aflaag / hw2.py
Last active November 9, 2022 14:59
def decode_XKCD_tuple(xkcd_values: tuple[str,...], k: int) -> list[int]:
l = [decode_value(x) for x in xkcd_values]
l.sort(reverse=True)
return l[:k]
def decode_value(s: str) -> int:
mappa = {'1': 1, '5': 5}
zeros = 1
@aflaag
aflaag / classif.py
Last active September 29, 2022 21:37
from PIL import Image
import jax.numpy as jnp
import numpy as np
import jax
from IPython import display
STEP_SIZE = 1e-3
BETA = 0.9
BATCH_SIZE = 32
from mnist import MNIST
from PIL import Image
import jax.numpy as jnp
import numpy as np
import jax
STEP_SIZE = 1e-4
BETA = 0.99
# mndata = MNIST("./mnist")
from functools import partial
import jax.numpy as jnp
import jax
# STEP_SIZE = 0.0010
STEP_SIZES = jnp.array([1., 0.5, 0.1, 0.05, 0.01, 0.005, 0.001])
k = STEP_SIZES.shape[0]
STEP_SIZES = STEP_SIZES.reshape((1, k, 1))
import sys
HEADER_LINES = 7
PADDING_MAP = {
"CodiceLRT": 0,
"Part Name": 0,
"CodiceFornitore": 0,
"Descrizione": 0,
"Valore": 0,
@aflaag
aflaag / es.s
Last active March 21, 2024 09:18
.globl main
.data
W: .asciiz "+6-4+3-2"
.text
main:
la $a0, W # a0 = W_address
jal calc
.globl main
.data
L: .word 3
A: .half 0x002A, 0xA5FF, 0x5BE1
.text
main:
# prepare arguments for the parity function
lw $a1, L
.globl main
.data
N: .word 3
M: .word 0, 1, 2, 3, 4, 5, 6, 7, 8
.text
main:
la $a0, M # a0 = M pointer
.globl main
.text
main:
addi $a0, $a0, -3 # a0 = -3
addi $a1, $a1, 4 # a1 = 4
addi $a2, $a2, 5 # a2 = 5
addi $a3, $a3, 8 # a3 = 8
jal f # f(a0, a1, a2, a3)
fn build_max_heap(array: &mut [usize], heap_size: usize) {
(1..=array.len() / 2).rev().for_each(|index| {println!("{}", index);max_heapify(array, index, heap_size);
println!("{:?}", array)});
}
fn get_left_child_index(index: usize) -> usize {
2 * index
}