This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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") |
This file contains hidden or 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
| 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)) |
This file contains hidden or 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
| import sys | |
| HEADER_LINES = 7 | |
| PADDING_MAP = { | |
| "CodiceLRT": 0, | |
| "Part Name": 0, | |
| "CodiceFornitore": 0, | |
| "Descrizione": 0, | |
| "Valore": 0, |
This file contains hidden or 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
| .globl main | |
| .data | |
| W: .asciiz "+6-4+3-2" | |
| .text | |
| main: | |
| la $a0, W # a0 = W_address | |
| jal calc |
This file contains hidden or 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
| .globl main | |
| .data | |
| L: .word 3 | |
| A: .half 0x002A, 0xA5FF, 0x5BE1 | |
| .text | |
| main: | |
| # prepare arguments for the parity function | |
| lw $a1, L |
This file contains hidden or 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
| .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 |
This file contains hidden or 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
| .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) |
This file contains hidden or 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
| 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 | |
| } | |