Skip to content

Instantly share code, notes, and snippets.

View rurumimic's full-sized avatar
♟️
턴제코딩

rurumimic

♟️
턴제코딩
View GitHub Profile
@rurumimic
rurumimic / kakao2017-3.5.swift
Created September 14, 2018 13:47
2017 카카오 3차 5번 내 풀이
import Foundation
class Node {
var parent: Node?
var childrens: [Character:Node] = [:]
var isWord: Bool = false
var count: Int = 0
init(parent: Node?) {
self.parent = parent
}
@rurumimic
rurumimic / BinarySearch.swift
Created September 14, 2018 14:03
Binary Search
import Foundation
func binarySearch<T: Comparable>(_ A: [T], key: T, _low: Int = 0, _high: Int = 0) -> Int? {
var low = _low
var high = _high
if _high == 0 {
high = A.count
}
while low < high {
let mid = low + (high - low) / 2
@rurumimic
rurumimic / gcd & lcm.swift
Created September 15, 2018 04:31
GCD & LCM
import Foundation
func gcd(_ p: Int, _ q: Int) -> Int {
return q == 0 ? p : gcd(q, p % q)
}
func lcm(_ p: Int, _ q: Int) -> Int {
return p / gcd(p, q) * q
}
@rurumimic
rurumimic / Bit.swift
Created September 15, 2018 04:32
비트 놀이
import Foundation
let x = 20
print(x&(x-1)) // 오른쪽 비트 끄기
print(x|(x+1)) // 제일 오른쪽 0의 비트 켜기
print(x&(x+1)) // 뒤에 딸린 1들을 끄기
print(x|(x-1)) // 뒤에 딸린 0들을 켜기
print((~x)&(x+1)) // 제일 오른쪽 0만 켜고 다른 것 다 끄기
print((~x)|(x-1)) // 제일 오른쪽 1만 끄고 다른 것 다 켜기
print((~x)&(x-1)) // 뒤에 딸린 0들만 켜고 다른 것 다 끄기
@rurumimic
rurumimic / board.cpp
Created September 28, 2018 13:10
C++ Board
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
template <typename T>
struct Board {
int w;
int h;
@rurumimic
rurumimic / gcd&lcm.cpp
Created September 28, 2018 13:15
C++ gcd & lcm
#include <iostream>
using namespace std;
int gcd(int p, int q) {
return q == 0 ? p : gcd(q, p % q);
}
int lcm(int p, int q) {
return p / gcd(p, q) * q;
#include <iostream>
using namespace std;
struct node {
int key;
node *left;
node *right;
node *parent;
@rurumimic
rurumimic / binaryTree.cpp
Created September 28, 2018 13:19
Binary Tree
#include <iostream>
using namespace std;
struct node {
int key;
int size;
node *left;
node *right;
@rurumimic
rurumimic / docker-compose.yml
Last active November 25, 2018 06:56
Kafka compose
version: '3.2'
services:
zoo1:
image: zookeeper
restart: always
hostname: zoo1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
@rurumimic
rurumimic / bash_profile.md
Created August 2, 2019 01:42
My .bash_profile

.bash_profile

PS1='\W \$ '

/etc/bashrc

# System-wide .bashrc file for interactive bash(1) shells.