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 / tree.c
Last active April 21, 2023 14:53
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#include <stdint.h>
typedef struct {
char* path;
struct Directory** sub_dirs;
} Directory;
@aflaag
aflaag / es6.c
Last active April 16, 2023 09:09
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Clones the available portion of the first block into the second one */
int clone_block(char* m1, char* m2, const int size_m1, const int size_m2) {
int size = size_m1 <= size_m2 ? size_m1 : size_m2;
memcpy(m2, m1, size * sizeof(char));
det ← {∧/1≠⍴⍵:-⌿((~l)(⌿⍤1 2)⍵/⍨~r)×(∇⍤2)(l←∘.≠⍨⍳≢⍵)(⌿⍤1 2)⍵/⍨r←0,1/⍨¯1+≢⍵⋄⍵}
@aflaag
aflaag / hw8.py
Last active December 17, 2022 19:10
def find_neighbours_opponent(board, x, y, w, h, opponent):
neighbours = set()
up, down, left, right = y > 0, y < h - 1, x > 0, x < w - 1
checks = {
(0, 0): False,
(0, -1): up,
(+1, -1): up and right,
(+1, 0): right,
print(sum(((t[0]<=t[2]and t[1]>=t[3])or(t[0]>=t[2]and t[1]<=t[3]))for l in open("a").read().split()if(o:=l.split(","))!=[""]and(t:=list(map(int,o[0].split("-")+o[1].split("-"))))))
@aflaag
aflaag / hw4.py
Last active November 13, 2022 21:07
def get_words(first_filename):
strings = open(first_filename).read().split()
curr_filename, words = strings.pop(0), strings
while first_filename != curr_filename:
strings = open(curr_filename).read().split()
curr_filename = strings.pop(0)
words.extend(strings)
@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))