This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prints pseudo 3D image in ASCII | |
import shutil | |
c, r = shutil.get_terminal_size() | |
print(''.join(('*' if (j-c/2) % (i+1) == 1 else '-' if 4*r/(i+1)%2==0 else ' ') for i in range(r) for j in range(c)), end='') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = """ | |
We develop a methodology for automatically analyzing text to aid in discriminating firms that encounter catastrophic | |
financial events. The dictionaries we create from Management Discussion and Analysis Sections (MD&A) of 10-Ks | |
discriminate fraudulent from non-fraudulent firms 75% of the time and bankrupt from nonbankrupt firms 80% of the | |
time. Our results compare favorably with quantitative prediction methods. We further test for complementarities by | |
merging quantitative data with text data. We achieve our best prediction results for both bankruptcy (83.87%) and | |
fraud (81.97%) with the combined data, showing that that the text of the MD&A complements the quantitative financial | |
information. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from flask import Flask, request | |
class Game: | |
X = 'X' | |
O = 'O' | |
N = ' ' | |
def __init__(self, size=3, to_win=3): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from flask import Flask, request | |
class Game: | |
X = 'X' | |
O = 'O' | |
N = ' ' | |
def __init__(self, size=3, to_win=3): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class ASCIICanvas: | |
def __init__(self, w=50, h=100): | |
assert 0 < w < 1000 and 0 < h < 1000 | |
self.w = w | |
self.h = h | |
self.buffer = [] | |
self.clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is Radix sort prove of O(n) time complexity | |
import random | |
import matplotlib.pyplot as plt | |
import time | |
def radix_sort(a_list, radix=10): | |
max_length_achieved = False | |
tmp, placement = -1, 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
class Item: | |
def __init__(self, name, price, qty): | |
self.name = name | |
self.price = price | |
self.qty = qty | |
def total_cost(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import select | |
from urllib.parse import urlsplit | |
def brutal_download(url, save_to): | |
url_components = urlsplit(url) | |
host = url_components.netloc | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((host, 80)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# нажми здесь shift+enter, чтобы увидеть список магий\n", | |
"%lsmagic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
from collections import namedtuple | |
Task = namedtuple('Task', 'priority, id, content') | |
class TaskFlow: | |
def __init__(self): | |
self._queue = [] | |
self._id = 0 |
OlderNewer