Skip to content

Instantly share code, notes, and snippets.

View hiroshi-maybe's full-sized avatar

Hiroshi Kori hiroshi-maybe

  • San Jose, CA, United States
View GitHub Profile
@hiroshi-maybe
hiroshi-maybe / TCOTests.swift
Created April 21, 2016 06:45
Tail Call Optimization test
//
// TCOTests.swift
// Playground
//
// Created by kori on 4/20/16.
// Copyright © 2016 hiroshi.kori. All rights reserved.
//
import XCTest
-- Beautiful fibonacci implementation
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
//
// LazyStreamTests.swift
// Playground
//
// Created by kori on 4/20/16.
// Copyright © 2016 hiroshi.kori. All rights reserved.
//
import Foundation
@hiroshi-maybe
hiroshi-maybe / getNearbyWords.swift
Created August 5, 2016 06:09
getNearbyWords.swift
//: Playground - noun: a place where people can play
import UIKit
// https://www.facebook.com/video.php?v=10152735777427200&set=vb.9445547199&type=2&theater
var str = "Hello, playground"
func getNearbyChars(ch: String) -> Set<String> {
switch ch {
case "g": return Set(["g","h","f"])
@hiroshi-maybe
hiroshi-maybe / ub_lb.cpp
Created December 24, 2016 05:13
Upper bound / lower bound
// http://cpp.sh
// Example program
#include <iostream>
#include <algorithm> // max,min
#include <vector>
#include <string>
#include <sstream>
#include <map>
#include <iostream>
protocol OptionalType {
associatedtype W
var optional: W? { get }
}
extension Optional: OptionalType {
typealias W = Wrapped
var optional: W? { return self }
}
@hiroshi-maybe
hiroshi-maybe / SRM588.cpp
Created November 15, 2017 19:29
SRM588 solutions
#include <vector>
#include <string>
using namespace std;
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
// type alias
typedef long long LL;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) for(int i=0;i<=(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
typedef long long LL;
typedef pair< int , int > II;
typedef unordered_map < int, int > MAPII;