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
#!/usr/bin/env python3 | |
import os | |
import argparse | |
from openai import OpenAI | |
def main(): | |
parser = argparse.ArgumentParser() |
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 enum | |
from typing import Any, Optional | |
class Priority(enum.Enum): | |
HIGH = 1 | |
MEDIUM = 2 | |
LOW = 3 | |
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 <array> | |
#include <unordered_map> | |
#include <memory> | |
#include <iostream> | |
#include <string> | |
template<typename T> | |
using Ptr = std::shared_ptr<T>; | |
struct Node{ |
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 <iostream> | |
#include <array> | |
#include <functional> | |
#include <memory> | |
template<typename T> | |
using Ptr = std::unique_ptr<T>; | |
template<typename T> | |
struct Node { |
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
// - function makes a binary search tree from an array | |
// - traverse the tree from left to right | |
#include <iostream> | |
#include <vector> | |
template<typename T=int> | |
struct Node { | |
Node* left; | |
Node* 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
import argparse | |
countries = { | |
'belgium': {'currency': 'EUR', 'rate': 0.869943, 'threshold': 24990, 'default': 390}, | |
'france': {'currency': 'EUR', 'rate': 0.869943, 'threshold': 19995, 'default': 312}, | |
} | |
def plan1(annual_salary_in_currency: float, country: str) -> float: | |
data = countries.get(country) |
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
#!/usr/bin/env python3 | |
import os | |
import pypact as pp | |
import pypact.analysis as ppa | |
# your FISPACT-II output file | |
filename = os.path.join( | |
os.path.dirname(os.path.abspath(__file__)), "..", "..", "reference", "test127.out" |
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 __future__ import print_function | |
import json | |
from typing import Any, Optional, Union | |
def get_interest_per_month(interest_rate_per_year: float) -> float: | |
interest_rate_per_month = (1.0 + interest_rate_per_year) ** (1.0 / 12.0) | |
# we do not consider anything more than 1e-5 for rate | |
interest_rate_per_month = round(interest_rate_per_month, 5) |
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
""" | |
# https://www.theguardian.com/science/2022/dec/26/can-you-solve-it-argentinas-creative-genius | |
Replace the ten letters of the following sum with the ten digits 0,1,2, … 9, | |
such that the sum is correct. | |
Each letter represents a unique digit. | |
There are two solutions, so find the one with the largest MESSI. | |
MESSI | |
+ MESSI |
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
# define in some util somewhere | |
class MyException(Exception): | |
class A: | |
value = 4 | |
# raise an exception with a custom value to be caught elsewhere | |
def myfunc(b): | |
a = MyException | |
a.value = b | |
raise a |
NewerOlder