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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dirent.h> | |
#include <string.h> | |
#include <stdint.h> | |
typedef struct { | |
char* path; | |
struct Directory** sub_dirs; | |
} Directory; |
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
#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)); |
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
det ← {∧/1≠⍴⍵:-⌿((~l)(⌿⍤1 2)⍵/⍨~r)×(∇⍤2)(l←∘.≠⍨⍳≢⍵)(⌿⍤1 2)⍵/⍨r←0,1/⍨¯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
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, |
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
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("-")))))) |
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 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) |
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)) |