Skip to content

Instantly share code, notes, and snippets.

View grhkm21's full-sized avatar
💭
exams.

grhkm21

💭
exams.
View GitHub Profile
@grhkm21
grhkm21 / install_mpfr.py
Created September 15, 2023 12:33
Installs mpfr (for python-flint)
import os
import ctypes
import requests
import subprocess
from tarfile import TarFile
# from logging import log
def get_env(env_name: str, error: bool = True) -> str:
res = os.environ[env_name]
@grhkm21
grhkm21 / activate-linux.fish
Last active May 16, 2024 21:31
Conda CC/CXX/FC compilers setup for Fish
function _tc_activation
set act_nature $argv[1]
set tc_prefix $argv[2]
set argv $argv[3..-1]
set pass
set from
set to
if test "$act_nature" = "activate"
set from ""
set to "CONDA_BACKUP_"
import sys
content = sys.stdin.read().rstrip()
grid = [list(line) for line in content.split('\n')]
r, c = len(grid), len(grid[0])
def is_valid(cr):
return 0 <= cr[0] < r and 0 <= cr[1] < c
@grhkm21
grhkm21 / B.py
Created November 29, 2022 03:14
NWERC 2022 Solutions
from decimal import *
getcontext().prec = 100
# abstract into two blocks, air and water
# let height of water be x
# then water CoM has position x / 2 and mass x * d_w
# and air CoM has position (h + x) / 2 and mass (h - x) * d_a
# and combined CoM has position c and mass x * d_w + (h - x) * d_a