Skip to content

Instantly share code, notes, and snippets.

View aksiksi's full-sized avatar
🏠
Working from home

Assil Ksiksi aksiksi

🏠
Working from home
View GitHub Profile
@aksiksi
aksiksi / sudoku-parser.py
Created December 26, 2011 15:03
A simple Sudoku puzzle parser.
def parse(grid):
''' Parses a Sudoku grid by converting it from xxx...x..xx....xx format to a friendly-looking grid.
Sample input: ...5.14582.14.28.1.99128.9..2....992...536..89.8....7.....1..9.93.3.9..219.....7.
Sample output:
. . . | 5 . 1 | 4 5 8
2 . 1 | 4 . 2 | 8 . 1
. 9 9 | 1 2 8 | . 9 .
- - - - - - - - - - -
@aksiksi
aksiksi / sudoku-slicer.py
Created December 27, 2011 21:45
Sudoku grid slicer
# Written by: Assil Ksiksi
# Date: Decemeber 28th, 2011
# A simple script that "slices" a Sudoku grid into 9 3x3 boxes. A similar method
# may be included in my Sudoku solver to determine whether or not a number can
# be placed in a certain cell. Should also be applicable to rows and columns.
from random import seed, choice
def create_grid():
@aksiksi
aksiksi / products.py
Created December 28, 2011 23:31
Finds all products of the digits of 5-digit numbers and creates two files: one contains the products and keys, ranked by products, while the other contains the number of occurrences of each product, ranked by occurrence, both in ascending order.
# Written by Assil Ksiksi
# Date: Thursday, December 29th, 3:12 am (GMT +4)
# I basically wrote this to determine whether or not a pattern exists in the products of the digits
# of all 5-digit numbers. Sadly, none exist, or at least I didn't see one.
# Runtime is fairly slow. It takes 1.05916786194s for all 5-digit numbers. I don't see how it
# can be optimized, so that should do the trick.
# References:
@aksiksi
aksiksi / passgen.py
Created January 16, 2012 09:20
Generates a number of random passwords of chosen length and outputs them to a file.
from random import choice
types = [
map(chr, range(97, 123)),
map(chr, range(65, 91)),
range(0, 10)
]
def password_gen(length): # Generates a random password
password = []
@aksiksi
aksiksi / metascore-file.py
Created March 10, 2012 20:49
Grabs Metascore of games in text file.
# Uses httplib2 instead of urllib2 - runs faster
#import urllib2
import httplib2
import time
s = time.time()
game_console = {}
@aksiksi
aksiksi / goodreads-popular.py
Created March 15, 2012 15:24
Scrapes most popular books from Goodreads.
@aksiksi
aksiksi / newton-method.py
Created April 12, 2012 12:31
Newton's Method in Python
# Finds a root of a number using Newton's method. Outputs the first 5 approximations.
def newton(n, x):
x1 = x - (x*x-n)/(2*x*x)
return x1
root = float(raw_input("Enter a number to approximate the square root of: "))
approx = float(raw_input("Enter approximation for root: "))
print ''
@aksiksi
aksiksi / imdbtop250-scrape.py
Created July 7, 2012 18:08
Scrapes IMDB Top 250 list and writes data to a database.
#################################################################
## Written by: Assil Ksiksi ##
## ## ## ##
## Scrapes IMDB for movie IDs, makes API requests, then writes ##
## the results to a database. ##
## ## ## ##
#################################################################
import re, requests, sqlite3, json, time
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aksiksi
aksiksi / spectre_vector_stimulus.py
Created March 15, 2016 13:56
Generates a Spectre input stimulus file for n vectors. Run with --help for details and an example.
#!/usr/bin/python
'''
Outputs a Cadence ADE stimulus file for n input vectors.
Supports Python 2.x only. I created this for use on a RHEL
box running Cadence.
Global variables
SOURCE: the source type generated for each bit of the vectors.