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
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.15; | |
import {Test} from "forge-std/Test.sol"; | |
/// @author Philippe Dumonet <https://github.com/philogy> | |
contract StringTest is Test { | |
bytes str; | |
function testBytesLikeStorage(bytes memory _inputStr) public { |
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 | |
import os | |
import dotenv | |
import requests | |
from collections import defaultdict | |
from decimal import Decimal as D | |
dotenv.load_dotenv() | |
# Instructions: |
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
#!/bin/python3 | |
import pyperclip | |
import argparse | |
def check_width(args, base_width): | |
min_width = len(args.text) + base_width | |
if args.width < min_width: | |
raise ValueError( | |
f'Width of {args.width} cannot fit "{args.text}" (len: {len(args.text)} + {base_width})' |
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
use std::fs; | |
fn sort_desc<T: Ord>(v: &mut Vec<T>) { | |
v.sort_by(|a, b| b.cmp(a)); | |
} | |
/// # Advent Of Code 2022 (Day 1). | |
/// | |
/// Challenge is you an input which displays "calories of elves" ([link](https://adventofcode.com/2022/day/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
use std::cmp::{Ordering, PartialOrd}; | |
use std::fs; | |
#[derive(Debug, PartialEq, Eq, Clone)] | |
enum Move { | |
Rock, | |
Paper, | |
Scissors, | |
} |
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 frange(start, end=None, step=None): | |
assert (end is None) <= (step is None) | |
if end is None: | |
start, end, step = 0, start, 1 | |
elif step is None: | |
step = 1 | |
assert step != 0 | |
sign = -1 if step < 0 else 1 | |
v = start | |
while v * sign < end * sign: |
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
struct MyQueue { | |
queue: Vec<i32>, | |
stack: Vec<i32>, | |
} | |
/** | |
* `&self` means the method takes an immutable reference. | |
* If you need a mutable reference, change it to `&mut self` instead. | |
*/ | |
impl MyQueue { |
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
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.21; | |
/// @author philogy <https://github.com/philogy> | |
contract Proxy { | |
uint256 internal constant IMPL_SLOT = uint256(keccak256("eip1967.proxy.implementation")) - 1; | |
uint256 internal constant ADMIN_SLOT = uint256(keccak256("eip1967.proxy.admin")) - 1; | |
address[0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff] internal slots; |
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
/// @notice Simple EIP-6909 for IDs that are solely non-fungible. | |
/// @author Forked from Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC6909.sol) | |
/// @author philogy <https://github.com/philogy> | |
/// | |
/// @dev Note: | |
/// The ERC6909 standard allows minting and transferring to and from the zero address, | |
/// minting and transferring zero tokens, as well as self-approvals. |
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
(defn _double [:uint256 x] :uint256 [:internal :pure] | |
(* x 2)) | |
(defn add [:uint256 x] :uint256 [:external :pure] | |
(if (< x 10) 0 (self/_double x))) |