Skip to content

Instantly share code, notes, and snippets.

View wasi0013's full-sized avatar
💤

Wasi wasi0013

💤
View GitHub Profile
@wasi0013
wasi0013 / N-Queen.cpp
Last active August 29, 2015 14:05
This is a simple 8-Queen puzzle solution written in C++
#include"bits/stdc++.h"
using namespace std;
main(){
int vec[]={0,1,2,3,4,5,6,7},n=8,c=0;
set <int> mset,nset;
set<int>::iterator it;
do{
mset.clear();
nset.clear();
@wasi0013
wasi0013 / Sudoku.py
Last active August 29, 2015 14:06
Naive sudoku solver
import cProfile
def row_check(i,j): return i//9==j//9
def col_check(i,j): return (i-j)%9==0
def blocks_check(i,j): return i//27==j//27 and (i%9)//3==(j%9)//3
def show(grid):
print "".join(num+" "+" "*((i+1)%3==0)+"\n"*((i+1)%9==0) for i,num in enumerate(grid))
def solve(grid):
@wasi0013
wasi0013 / crypto.py
Last active August 29, 2015 14:14
Various crypto algorithims simple implementations
__author__ = 'wasi0013'
#Algorithm resources: http://crypto.interactive-maths.com/introduction-to-cryptography.html
def caeser_encrypt(text, key):
"""
Takes string as text and encrypts it with the key
>>> caeser_encrypt("Hello World",2)
'JGNNQ YQTNF'
>>> caeser_encrypt("Hello World",0)
'HELLO WORLD'
@wasi0013
wasi0013 / send_more_money.cpp
Created May 10, 2015 12:32
SEND MORE MONEY riddle in Artificial Intelligence
#include"bits/stdc++.h"
/*
Problem Name: SEND MORE MONEY riddle in Artificial Intelligence
Problem Category:
-----------------
Constraint Optimisation Problem
Problem Description:
--------------------
SEND
+ MORE
@wasi0013
wasi0013 / spoj_bd_ranklist_parser.py
Created June 29, 2015 15:52
parses spoj's Bangladesh ranklist (http://www.spoj.com/ranks/users/BD/) to get 100 top users of Spoj from country Bangladesh
__author__ = "wasi0013"
"""
parses spoj's Bangladesh ranklist (http://www.spoj.com/ranks/users/BD/) to get
100 top users of Spoj from country Bangladesh
"""
import requests, bs4
url = 'http://spoj.com/ranks/users/BD'
@wasi0013
wasi0013 / digits_of_pi.py
Last active August 29, 2015 14:25
Calculates digits of pi using the Gauss-Legendre Algorithm
__author__ = "wasi0013"
'''
Calculates digits of pi using the Gauss-Legendre Algorithm
Link: https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_algorithm
'''
import decimal
import requests, bs4
@wasi0013
wasi0013 / anagram.py
Created July 31, 2016 16:18
A naive implementation of an Anagram Generator
__author__ = "wasi0013"
import glob
def get_dictionary(path):
"""
returns: a dictionary of words (with sorted string as key)
from files in the path
"""
words = set()
@wasi0013
wasi0013 / brainfry.py
Created August 4, 2016 16:46
encrypts text as unicode-emoji and decrypts encrypted unicode-emoji as text
__author__ = "wasi0013"
import urllib2
from bs4 import BeautifulSoup
import re
from fractions import gcd
import random
def affine_encrypt(text, a, b, m=26):
@wasi0013
wasi0013 / tkinter_autocomplete_listbox.py
Created August 25, 2017 20:27
Tkinter - Entry with Auto complete Suggestion
import tkinter as tk
import re
"""
This is slight modification of the script: https://gist.github.com/uroshekic/11078820
Changes:
- Fixed value selection
- Added Support for tab or, enter key press to select value
"""
def matches(fieldValue, acListEntry):
from abc import ABC, abstractmethod
class Polygon(ABC):
@abstractmethod
def area(self):
pass
@abstractmethod
def perimeter(self):