Skip to content

Instantly share code, notes, and snippets.

View qrno's full-sized avatar

Eduardo Quirino qrno

View GitHub Profile
import numpy as np
from time import sleep
import matplotlib.pyplot as plt
from requests import get
def get_color(rating):
if rating >= 2400:
return 'r'
elif rating >= 2100:
@qrno
qrno / countinv.cpp
Created March 22, 2022 19:17
Inversion Couting
// Very simple Inversion Counting based on a merge sort
// by cf/cebolinha
#include <bits/stdc++.h>
using namespace std;
#define int long long
int count_inversions(vector<int> &v) {
if (v.size() == 1) return 0;
@qrno
qrno / mergesort.cpp
Created March 22, 2022 18:10
Merge Sort
// Very simple mergesort implementation by cf/cebolinha
// Uses O(NlogN) memory, a bit more than the usual O(N)
#include <bits/stdc++.h>
using namespace std;
void merge_sort(vector<int> &v) {
if (v.size() == 1) return;
// Divide v into two vectors - Left and Right
vector<int> L, R;
#include <bits/stdc++.h>
using namespace std;
#define int long long
//( Experimental Template (x1.1.1) (cf/cebolinha)
// G++ Sorcery
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
@qrno
qrno / sort.s
Created September 7, 2021 01:49
Sorting numbers in Risc-V Assembly (Bubble Sort)
.data
arr: .word 71 27 50 81 34 12 84 41 68 7 57 69 40 51 85 66 63 47 65 61 28 92 80 70 88 98 35 89 54 56 13 30 46 45 64 91 5 86 3 87 2 6 99 11 79 72 14 29 44 60 55 22 26 31 9 43 37 24 52 42 67 83 74 18 10 73 8 20 53 0 96 4 16 82 58 62 15 95 38 76 1 97 75 33 49 21 23 32 36 59 25 17 94 39 48 77 93 90 19 78
arrS: .word 100
.macro print_int
li a7 1
ecall
.end_macro
.macro print_array
mv a0 s0
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
void printTheString(string myStringIWantToPrint) {
#include <iostream>
using namespace std;
void swap(int &x, int &y) {
int aux = x;
x = y;
y = aux;
}