Skip to content

Instantly share code, notes, and snippets.

View speedcell4's full-sized avatar

Yiran Wang speedcell4

  • NICT
  • Nara, Japan
  • 12:31 (UTC +09:00)
  • X @nlp_yiran
View GitHub Profile
(def fib-lazy-cat
(lazy-cat [0 1] (map +' fib-lazy-cat (rest fib-lazy-cat))))
(defn infix
([x op y] (op x y))
([x op y & more]
(apply infix (cons (infix x op y) more))))
@speedcell4
speedcell4 / Main.java
Created October 20, 2014 13:19
POJ3461-Oulipo
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
static Scanner cin = new Scanner(System.in);
static PrintWriter cout = new PrintWriter(System.out, true);
int MAXV = 10012;
(def prime-seq
((fn prime [seq]
(lazy-cat [(first seq)] (prime (filter #(not= 0 (rem % (first seq))) (rest seq)))))
(iterate inc 2)))
(take 10 prime-seq)
;; (2 3 5 7 11 13 17 19 23 29)
@speedcell4
speedcell4 / action.hs
Last active August 29, 2015 14:20
Real World Haskell
import qualified Data.ByteString.Lazy as L
str2action :: String -> IO ()
str2action input = putStrLn ("Data: " ++ input)
list2actiosn :: [String] -> [IO ()]
list2actiosn = map str2action
numbers :: [Int]
numbers = [1..10]
@speedcell4
speedcell4 / add-binary.py
Last active August 29, 2015 14:21
LeetCode algorithm problems
class Solution:
# @param {string} a
# @param {string} b
# @return {string}
def addBinary(self, a, b):
return bin(long(a, 2) + long(b, 2))[2:]
@speedcell4
speedcell4 / 4clojure.clj
Last active November 14, 2016 14:20
4clojure problem solutions
; 1, Nothing but the Truth
true
; 2, Simple Math
4
; 3, Intro to Strings
"HELLO WORLD"
; 4, Intro to Lists
@speedcell4
speedcell4 / regex-alf-nu.md
Last active August 29, 2015 14:22
solution to Regex Golf

solutions to Regex Golf

Play

  1. Warmup: foo
  2. Anchors: ick$
  3. Ranges: ^[a-f]+$
  4. Backrefs: (...).*\1
  5. Four: (.)(.\1){3}
@speedcell4
speedcell4 / A.cpp
Last active February 16, 2016 10:38
Codeforces #622
#include <iostream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <algorithm>
using namespace std;
typedef long long i64;
@speedcell4
speedcell4 / R1B-a.cpp
Last active May 1, 2016 08:31
Google Code Jam 2016
#include <iostream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <algorithm>
using namespace std;
typedef long long i64;