Skip to content

Instantly share code, notes, and snippets.

Adrian Wielgosik adrian17

  • Polska
Block or report user

Report or block adrian17

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View main.cpp
#include <cmath>
#include <vector>
#include "windows.h"
#include "lodepng.h"
#include "SDL.h"
typedef std::vector<unsigned char> Image;
@adrian17
adrian17 / main.cpp
Last active Aug 29, 2015
Quadtrees but not really
View main.cpp
#include <cmath>
#include <functional>
#include <set>
#include "windows.h"
#include "lodepng.h"
#include "SDL.h"
const int MIN_RECT_SIZE = 2;
@adrian17
adrian17 / main.cpp
Last active Aug 29, 2015
EdgeSolver with templates
View main.cpp
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <fstream>
using std::cout;
using std::endl;
typedef std::vector<std::array<char, 4>> Board;
@adrian17
adrian17 / main.cpp
Last active Aug 29, 2015
DailyProgrammer #197 Intermediate Dijikstra
View main.cpp
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <tuple>
#include <algorithm>
#include <climits>
#include <map>
#include <set>
@adrian17
adrian17 / words_game.py
Last active Aug 29, 2015
For /r/dailyprogrammer, Challenge 198
View words_game.py
# [2015-01-23] Challenge #198 [Hard] Words with Enemies -- The Game!
# http://www.reddit.com/r/dailyprogrammer/comments/2tfs0b/20150123_challenge_198_hard_words_with_enemies/
from functools import lru_cache
import random
import string
@lru_cache(maxsize=1)
def load_wordlist(filename="enable1.txt"):
return open(filename).read().splitlines()
@adrian17
adrian17 / main.py
Last active Aug 29, 2015
numbers_cleanup
View main.py
#Ugly but working
dataz="""\
_ _ _ _ _ _ _ _ _
| || || || || || || || || |
|_||_||_||_||_||_||_||_||_|
| | | | | | | | |
| | | | | | | | |
View sieve.ijs
prime_sieve =: 3 : 0
sieve_size =. y
sieve =. sieve_size # 0
indices =. i. sieve_size
sieve =. 1 (0 1) } sieve
result =. ''
while. sieve_size ~: +/ sieve do. NB. while it has at least one 0
num =. {. (-. sieve) # indices NB. get first number not marked with 1
result =. result, num
divisible =. 0 = num | indices
@adrian17
adrian17 / sudoku.ijs
Created Mar 5, 2015
sudoku in J (translation of APL algorithm)
View sudoku.ijs
s44 =: 4 4 $ 0 0 0 0 0 0 2 1 3 0 0 4 0 0 0 0
box =: (] #"1 ] # ([: i. 2 # ]))
indices =: 3 : 0
yy =. {. y
a =. yy #"0 i. yy
b =. |: a
c =. a ,/"0 b
)
@adrian17
adrian17 / collatz.ijs
Last active Aug 29, 2015
collatz fractal in J
View collatz.ijs
load 'viewmat'
gen_table =: 4 : '(0j1*(i: x)) +/ i: y'
fractal =: 1 : 0
:
x u"0 (y +~ 30000 %~ 150 gen_table 150) NB. resolution and scale, not sure how to decouple them
)
collatz =: 4 %~ 2 + (7*]) - (2+5*])* 2 o. o.
is_bounded_c =: 4 : '((0: collatz^:x) :: 1:) y' NB. collatz
@adrian17
adrian17 / contour_plot.py
Created Mar 18, 2015
/r/dailyprogrammer #206I on reals
View contour_plot.py
import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
header, *lines = open("map2.txt").read().splitlines()
R = float(header.split()[2])
H, W = len(lines), len(lines[0])
crops = []
for y, line in enumerate(lines):
for x, c in enumerate(line):
You can’t perform that action at this time.