Skip to content

Instantly share code, notes, and snippets.

View rdbuf's full-sized avatar

Ilya Pikulin rdbuf

View GitHub Profile
@rdbuf
rdbuf / grub.cfg
Last active May 3, 2016 18:41
multiboot usb
# grub.cfg
# it lets you boot linux from iso directly
# the files tree is at the end of file
# last modified: 2016-03-07
set timeout=30
set defaut=0
set fallback=1 # what's it?
set pager=1 # what's it?
00 01 10 11
00000 NUL Spc @ `
00001 SOH ! A a
00010 STX " B b
00011 ETX # C c
00100 EOT $ D d
00101 ENQ % E e
00110 ACK & F f
00111 BEL ' G g
01000 BS ( H h
@rdbuf
rdbuf / .template.cc
Last active April 11, 2017 03:38
Solution template for GCJ problems.
/* Don't overcomplicate. */
/* Don't construct unnecessary objects. */
/* Stack is for everything. */
#include <bits/stdc++.h>
#include <experimental/optional>
#include <experimental/any>
using namespace std;
using namespace std::experimental;
@rdbuf
rdbuf / init.vim
Last active April 15, 2017 00:48
Neovim config for GCJ rounds.
highlight ImplReminder ctermfg=red
match ImplReminder /\/\/ IMPLEMENT ME/
autocmd FileType cpp nnoremap <F12> :0r ~/gcj/.template.cc<CR>/IMPLEMENT ME<CR>
@rdbuf
rdbuf / linked-lists.hh
Last active July 19, 2017 08:45
Simple concurrent linked lists
#include <array>
#include <future>
#include <iostream>
#include <list>
#include <mutex>
#include <vector>
namespace list {
template<class ElemT>
class list_base {
@rdbuf
rdbuf / mergesort.hs
Created August 27, 2017 20:49
Naive mergesort implementation in Haskell
import Data.List.Utils (merge)
import Data.List.Split (chunksOf)
import Control.Monad (join)
import Control.Arrow -- (***)
import Data.List (sort)
dat = [4,3,2,4,5,6,3,22,4,6,2,1,10,1234,12351,2134,51] :: [Int]
makePair :: [[t]] -> ([t], [t])
@rdbuf
rdbuf / mergesort.cc
Last active August 31, 2017 02:29
A more efficient mergesort implementation in Haskell
#include <algorithm>
#include <vector>
#include <list>
#include <iostream>
using elem_t = uint64_t;
std::list<elem_t> msort(std::vector<elem_t>::iterator begin, std::vector<elem_t>::iterator end) {
if (end - begin == 1) {
return std::list<elem_t>(begin, end);
@rdbuf
rdbuf / quicksort.cc
Created September 1, 2017 11:00
A Quicksort implementation
#include <iostream>
#include <vector>
#include <algorithm>
using elem_t = uint64_t;
template<class Container>
void qsort(const typename Container::iterator begin, const typename Container::iterator end) {
if (end - begin <= 1) {
return;
@rdbuf
rdbuf / bintree.hs
Last active September 17, 2017 20:12
Tree implementations in Haskell
import Data.Maybe
import Data.Functor
data Tree a = Node a (Maybe (Tree a)) (Maybe (Tree a))
deriving Show
instance Functor Tree where
fmap f (Node x left right) = Node (f x) (left >>= return . fmap f) (right >>= return . fmap f)
main = print $ fmap (2*) (Node 2 (Just $ Node 10 Nothing Nothing) Nothing)
@rdbuf
rdbuf / quicksort.cc
Last active November 13, 2017 19:02
Generic Quicksort implementation in C++
/* Ilya Pikulin, 2017
*
* This is a generic implementation of quicksort.
*/
#include <algorithm>
#include <iostream>
#include <random>
#include <forward_list>
// #include <array>