Skip to content

Instantly share code, notes, and snippets.

View MadJayhawk's full-sized avatar

MadJayhawk MadJayhawk

View GitHub Profile
@abecus
abecus / LIS.py
Created August 9, 2019 17:55
longest Increasing Subsequence in python
def lisArray(arr, n):
"""
returns a array of LIS
"""
dp = [[arr[0]]]
for i in range(1, n):
temp = 0
tempSubArray = []
class Solution(object):
def maxIncreaseKeepingSkyline(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
colMax = [0] * len(grid[0])
rowMax = []
for i in grid:
@lawrencechen0921
lawrencechen0921 / Python Counter.py
Created August 9, 2019 13:36
使用Counter模組找出最常出現的五個字以及次數
#再windos按鈕畫面點擊右鍵(並按下執行)
#先在cmd 命令提示字元 輸入python再輸入import this
#將那段話存入 xxx.txt
from collections import Counter #記住從from 甚麼 import 甚麼都要放在第一行 以免篩選器錯誤
fin=open('xxx.txt','rt')
s=fin.read().lower() #物件fin 使用函式read一次讀取所有內容, 使用函式lower將所有字母轉換小寫
words=re.findall(r'[\w\']+',s) #用re.findall找出大小寫字母、數字、底線、和單引號
c=Counter(words) #將物件counter以words為輸入, 將獲得的counter物件轉換成c
print(c.most_common(5)) #把c內容最常出現的五個屬性字找出
# Pickling
import pickle
# An arbitrary collection of objects supported by pickle.
data = {
'a': [1, 2.0, 3, 4+6j],
'b': ("character string", b"byte string"),
'c': {None, True, False}
}
@nikhilkumarsingh
nikhilkumarsingh / paint.py
Created November 3, 2017 16:26
A simple paint application using tkinter in Python 3
from tkinter import *
from tkinter.colorchooser import askcolor
class Paint(object):
DEFAULT_PEN_SIZE = 5.0
DEFAULT_COLOR = 'black'
def __init__(self):
@jahendrie
jahendrie / get_attachment.py
Created February 2, 2017 14:34
Extracts attachments (pictures) from email files
#!/usr/bin/env python
import sys, os
import base64
token = "X-Attachment-Id"
def print_usage():
print( "Usage: exatt.py [OPTION] EMAIL_FILES" )
@arindampradhan
arindampradhan / spin.py
Last active August 12, 2019 05:38
Spinners for python | python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import signal
from os import system
### MENU ###
# Here are all the elements you can import
# Box elements