Skip to content

Instantly share code, notes, and snippets.

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

Jason chairco

🏠
Working from home
View GitHub Profile
git filter-branch -f --env-filter \
"GIT_AUTHOR_NAME='chairco'; GIT_AUTHOR_EMAIL='<chairco@gmail.com>'; GIT_COMMITTER_NAME='chairco'; GIT_COMMITTER_EMAIL='<chairco@gmail.com>';" HEAD
import numpy as np
def normalize(X):
"""數據標準化處理
Args:
X 樣本
Returns:
XNorm 標準化後的樣本
"""
XNorm = X.copy()
def solveSudoku(board):
"""
:type board: List[List[str]]
:rtype: void Do not return anything, modify board in-place instead.
"""
while True:
board = check_row(board=board)
board = check_col(board=board)
board = check_group(board=board)
時間複雜度:
O(1) = 公式解
O(n) = 1 層迴圈
O(n^2) = 2 層迴圈
0(log n) = 對半切
空間複雜度:
O(1) = 不會用到額外 array
O(n) = 會用到跟 input 成正本的一層 array
@chairco
chairco / boring_py.md
Last active December 19, 2018 01:41
一些想到的寫法

九宮格分群

#

#-*- coding: utf-8 -*-

a = [[1,1,1,1,1,1,1,1,1], [2,2,2,2,2,2,2,2,2], [3,3,3,3,3,3,3,3,3],
     [4,4,4,4,4,4,4,4,4], [5,5,5,5,5,5,5,5,5], [6,6,6,6,6,6,6,6,6],
@chairco
chairco / go_race_condition.md
Last active November 20, 2018 02:29
Goroutine
package main

import "fmt"

func main() {
    a := 0
    times := 10000  // <-- HERE
    c := make(chan bool)

無聊看到人家 fb 上問題

sum([ i**2 for i in list(range(10, 115, 13)) if (i**2)%10 not in [1,6,9]])
def solution(A):
    # write your code in Python 3.6
    points = []
    for row_idx, row in enumerate(A):
        row_max = max(row[1:-1])
        row_min = min(row[1:-1])
        for col_idx, col in enumerate(row[:-1]):
            col_max = max(list(zip(*A[1:-1]))[col_idx])
            col_min = min(list(zip(*A[1:-1]))[col_idx])
@chairco
chairco / .gitignore
Created October 27, 2018 00:49
gitignore sample
# not upload
# local test file
client/
.pytest_cache/
src/.pytest_cache/
command.txt
src/render.html
@chairco
chairco / binary.md
Last active November 21, 2023 13:21
Python 其淫技巧大整理