Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
coding

Selim Ozturk selimslab

:octocat:
coding
View GitHub Profile
@selimslab
selimslab / get_gists.py
Last active Jun 18, 2021 — forked from leoloobeek/get_gists.py
Download all gists of a user
View get_gists.py
import sys
from subprocess import call
import json
import os
import requests
def download_gists(gists: list):
for gist in gists:
call(["git", "clone", gist["git_pull_url"]])
@selimslab
selimslab / blockchain.py
Last active Feb 12, 2021
a simple blockchain in 100 lines
View blockchain.py
import time
import hashlib
import uuid
import random
from dataclasses import dataclass
from typing import List
@dataclass
class Node:
uid: str
@selimslab
selimslab / search.py
Last active Feb 11, 2021
a search engine in 200 lines
View search.py
import re
import math
import operator
import logging
from collections import defaultdict, Counter
import numpy as np
class Tokenizer:
def __init__(self, stop_words, ):
View minSteps.go
/*
Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step:
Copy All: You can copy all the characters present on the notepad (partial copy is not allowed).
Paste: You can paste the characters which are copied last time.
Given a number n. You have to get exactly n 'A' on the notepad by performing the minimum number of steps permitted. Output the minimum number of steps to get n 'A'.
Example 1:
View 0-structs.c
#include <stdio.h>
#include <stdlib.h>
#define STACK_MAX 256
typedef enum
{
OBJ_INT,
OBJ_PAIR
} ObjectType;
View morse.go
func uniqueMorseRepresentations(words []string) int {
morse := []string{".-","-...","-.-.","-..",".","..-.",
"--.","....","..",".---","-.-",".-..","--","-.","---",
".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--",
"--.."}
tf := make(map[string]bool)
for _, word := range words {
rep := ""
for _, r := range word {
@selimslab
selimslab / postorder.go
Created Nov 15, 2020
n-ary tree traversal
View postorder.go
/**
* Definition for a Node.
* type Node struct {
* Val int
* Children []*Node
* }
*/
import "fmt"
View readme.txt
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
Note:
The same word in the dictionary may be reused multiple times in the segmentation.
You may assume the dictionary does not contain duplicate words.
Example 1:
Input: s = "leetcode", wordDict = ["leet", "code"]
Output: true
View maxSlidingWindow.go
/*
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.
Return the max sliding window.
Example 1:
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3