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://edabit.com/challenge/Fz92j7nQEkoRXhRE7 | |
from typing import Union, List | |
def _jumping_frog(n: int, stones: List[int], path: List[int]=None, visited: List[int]=None, paths: List[List[int]]=None) -> None: | |
current_position = path[-1] | |
# reched final state | |
if current_position == n: | |
paths.append(path) |
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
/* | |
* morse code [w/o spaces] isn't a prefix code. | |
* O(n * 2^n) | |
*/ | |
const MORSE_CODE = { | |
'.-': 'A', | |
'-...': 'B', | |
'-.-.': 'C', | |
'-..': 'D', | |
'.': 'E', |
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 random import choice, randrange, sample | |
class MontyHall: | |
def __init__(self) -> None: | |
self.doors = sample(['car', 'goat', 'goat'], 3) # without replacement | |
def play(self, switch: bool) -> bool: | |
# find car door index | |
car_door = self.doors.index('car') |
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
(async () => { | |
const keyPair = await crypto.subtle.generateKey( | |
{ | |
name:'ECDH', | |
namedCurve:'P-256' | |
}, | |
true, | |
['deriveKey', 'deriveBits'] | |
) | |
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 os | |
import json | |
def dict_to_str(props, keys, DELIMITER, QUOTE): | |
s = [] | |
for key in keys: | |
value = props.get(key) | |
if value: |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <switch.h> | |
Result initializeServices() { | |
gfxInitDefault(); | |
consoleInit(NULL); | |
Result res; |
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
''' | |
based on the work of: | |
- nwert https://gist.github.com/nwert/9430a454c64248dd1186868c00b682c6 | |
- hexkyz https://gist.github.com/hexkyz/d5b3f5b1700b507b41e7fc1dc12e8dfd | |
''' | |
from Crypto.Cipher import AES | |
from Crypto.Util import Counter | |
import struct |