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
package csw; | |
import java.util.Random; | |
public class Quick { | |
public static void main(String[] args) { | |
Random rd = new Random(); | |
Double[] test = new Double[500_000]; |
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 bigO import bigO | |
class Comparator: | |
def __init__(self): | |
self.comparisons = 0 | |
def compare(self, a, b): | |
self.comparisons += 1 | |
if a < b: |
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
class MTP: | |
def __init__(self): | |
# Coefficients | |
self.a = 0x9908B0DF # 2567483615 | |
self.b = 0x9D2C5680 # 2636928640 | |
self.c = 0xEFC60000 # 4022730752 | |
self.f = 1812433253 | |
self.l = 18 | |
self.m = 397 | |
self.n = 624 |
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 fastcore.all import * | |
class Node: | |
def __init__(self, val, start=-1, end=-1): | |
store_attr() | |
def print(self): | |
print(f"{self.val}: index from {self.start} to {self.end}.") |
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 fastcore.utils import Self, L | |
if __name__ == "__main__": | |
f = Self.sum() | |
x = L(1, 2, 3) | |
print(f(x)) | |
f = Self.map(lambda a: a + 1) | |
x = L(1, 2, 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
static PyObject *python_bubblesort(PyObject *module, PyObject *arg) | |
{ | |
assert(arg); | |
Py_INCREF(arg); | |
if (!PyList_CheckExact(arg)) | |
{ | |
PyErr_SetString(PyExc_ValueError, "Argument is not a list."); | |
goto except; | |
} |
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 bubbleSort(list array): | |
return bubbleSort_c(array) | |
cdef bubbleSort_c(list array): | |
cdef bint isSorted = False | |
cdef int count = 0 | |
cdef Py_ssize_t i | |
cdef Py_ssize_t n = len(array) - 1 | |
while not isSorted: |
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
// Tuples | |
int a = 1; | |
int b = 2; | |
(a, b) = (b, a); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
class Node: | |
__slots__ = ("key", "val", "prev", "next") | |
def __init__(self, key, val): | |
self.key = key | |
self.val = val | |
self.prev = None | |
self.next = None | |