Skip to content

Instantly share code, notes, and snippets.

View Arianxx's full-sized avatar
🎯
Focusing

ArianX Arianxx

🎯
Focusing
View GitHub Profile
@Arianxx
Arianxx / BigInteger.java
Last active May 7, 2019 11:13
At present, only addition and multiplication functions are implemented.
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();
#!/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
#!/usr/bin/env python3
class Rc4KeyStream:
key = None
N = 256
def __init__(self, key, N=256):
self.key = key
self.N = N
@Arianxx
Arianxx / LZ77.py
Created June 26, 2018 08:36
LZ77 Coding
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)
@Arianxx
Arianxx / Huffman Coding Python Implementation.py
Last active December 19, 2019 15:34
Huffman Coding Python Implementation
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
@Arianxx
Arianxx / Ten common sorting algorithms.py
Created June 23, 2018 10:00
Ten common sorting algorithms
# 冒泡排序
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
@Arianxx
Arianxx / Python Heap Sorting
Last active June 17, 2018 15:14
Python Heap Sorting
#! /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):
@Arianxx
Arianxx / Python AVL Binary Tree
Last active March 21, 2020 08:38
Python AVL Binary Tree
#! /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'