Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# DFS | |
def preorder(self, root): | |
if not root: | |
return [] | |
ret = [] | |
stack = [root] | |
while stack: | |
node = stack.pop() | |
ret.append(node.val) | |
if node.right: |
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
# Iterative | |
def dfs(graph, start): | |
visited, stack = set(), [start] | |
while stack: | |
node = stack.pop() | |
visited.add(node) | |
for neighbor in graph[node]: | |
if not neighbor in visited: | |
stack.append(neighbor) | |
return visited |
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
def is_valid_state(state): | |
# check if it is a valid solution | |
return True | |
def get_candidates(state): | |
return [] | |
def search(state, solutions): | |
if is_valid_state(state): | |
solutions.append(state.copy()) |
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
class CreatorDefinedDisplayable(renpy.Displayable): | |
def __init__(self): | |
super(CreatorDefinedDisplayable, self).__init__() | |
def render(self, width, height, st, at): | |
render = renpy.Render(width, height) | |
return render | |
def event(self, ev, x, y, st): |
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
from itertools import product | |
class SudokuSolver: | |
""" | |
Solve a sudoku puzzle given as a 81-digit string with . denoting empty | |
""" | |
SHAPE = 9 | |
GRID = 3 | |
EMPTY = '.' |
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 java.io.*; | |
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.xhtmlrenderer.extend.FontResolver; | |
import org.xhtmlrenderer.pdf.ITextRenderer; | |
public class HtmlToPdf { | |
public static void main(String[] args) throws IOException { | |
String html = "<h1>hello</h1>"; | |
String xhtml = htmlToXhtml(html); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<!-- Just a dummy html to redirect to my subdirectory --> | |
<meta http-equiv="refresh" content="0; url=[INSERT URL HERE]"> | |
</head> | |
<body> | |
</body> |
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
from IPython.display import Audio | |
import numpy as np | |
from numpy.fft import fft, ifft | |
from scipy.fftpack import dct, idct | |
from scipy.signal import stft | |
import soundfile as sf |
NewerOlder