This file contains 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 java.util.*; | |
import java.util.stream.Collectors; | |
class BigInteger { | |
private int[] num; | |
private String numStr; | |
public BigInteger(int n) { | |
num = new int[] { n }; | |
numStr = converterToString(); |
This file contains 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 | |
""" | |
Eventloop framework demo. | |
""" | |
import warnings | |
from selectors import DefaultSelector, EVENT_READ, EVENT_WRITE | |
from types import coroutine | |
from collections import namedtuple | |
This file contains 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 | |
class Rc4KeyStream: | |
key = None | |
N = 256 | |
def __init__(self, key, N=256): | |
self.key = key | |
self.N = N |
This file contains 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
class LZ77Coding: | |
SLIDING_WINDOW_SIZE = 4096 | |
LOOKHEAD_BUFFER_SIZE = 32 | |
def search_longest_match(self, data, cursor): | |
best_position, best_length, next_char = 0, 0, 0 | |
search_index = max(cursor - self.SLIDING_WINDOW_SIZE, 0) | |
end_buffer_index = min(len(data) - 1, | |
cursor + self.LOOKHEAD_BUFFER_SIZE - 1) |
This file contains 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 heapq | |
class HuffmanNode: | |
def __init__(self, symbol=None, freq=None): | |
self.symbol = symbol | |
self.freq = freq | |
self.parent = None | |
self.left = None | |
self.right = None |
This file contains 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 bubble_sort(data, compare=lambda x, y: x <= y): | |
length = len(data) | |
for i in range(length): | |
for j in range(0, length - i - 1): | |
if not compare(data[j], data[j + 1]): | |
data[j], data[j + 1] = data[j + 1], data[j] | |
return data |
This file contains 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/python3 | |
# -*- coding:utf-8 -*- | |
AUTHER = 'ArianX' | |
GITHUB = 'https://github.com/arianxx' | |
BLOG = 'https://arianx.me' | |
class Heap: | |
def __init__(self, nodes=None, compare=None): |
This file contains 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/python3 | |
# -*- coding:utf-8 -*- | |
from collections.abc import MutableSequence | |
from copy import deepcopy | |
AUTHER = 'ArianX' | |
GITHUB = 'https://github.com/Arianxx' | |
BLOG = 'https://arianx.me' | |