Skip to content

Instantly share code, notes, and snippets.

View vr2262's full-sized avatar
👀
ok

Viktor Roytman vr2262

👀
ok
View GitHub Profile
import numpy as np
import csv
def compute_sum(infile):
"""
Returns the sum of numbers in a file with one column and a header row.
Parameters
----------
infile : File object
import math
# Get the value of n and initialize the matrices A and B.
with open("input.txt", "r") as matrix_info:
n = int(matrix_info.readline())
assert n == 2 ** math.log(n, 2), "The first line must be a power of 2."
mat_a = []
mat_b = []
@vr2262
vr2262 / flipper.py
Last active December 12, 2015 09:08
import sys
import argparse
import itertools as it
import numpy as np
def flipper(n):
def cool_range_doritos(*args, **kwargs):
if sys.version_info[0] < 3:
return xrange(*args, **kwargs)
from scipy import special
from scipy import misc
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
def relative_error(accepted, approximation):
# Helper function for finding relative error.
return abs((accepted - approximation) / float(accepted))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def ruffinis_rule(coefficients, factor):
"""Perform synthetic division and evaluate a polynomial at a factor."""
deflated = np.empty(len(coefficients) - 1, dtype=complex)
deflated[0] = coefficients[0]
for i, coeff in enumerate(coefficients[1:-1], start=1):
deflated[i] = coeff + deflated[i - 1] * factor
evaluation = coefficients[-1] + deflated[-1] * factor
return deflated, evaluation
9e87a6cb860f761cb15a1bd220ac59a4c09f7cbf
@vr2262
vr2262 / python_3_instructions.md
Last active October 5, 2015 15:34
Python 3 development environment

##Instructions

  1. Install the dependencies from the top of this page: https://github.com/yyuu/pyenv/wiki/Common-build-problems
  2. $ git clone git://github.com/yyuu/pyenv.git ~/.pyenv

pyenv allows you to manage Python (and pip, etc) versions easily. 3. $ echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc (Assuming you're using bash) 4. $ echo 'eval "$(pyenv init -)"' >> ~/.bashrc 5. $ source ~/.bashrc 6. To install a particular version of Python to your machine:

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for

Keybase proof

I hereby claim:

  • I am vr2262 on github.
  • I am vr2262 (https://keybase.io/vr2262) on keybase.
  • I have a public key whose fingerprint is 8E58 B319 65B8 C929 93F2 92E0 52F7 73FE A9C4 5CFD

To claim this, I am signing this object: