Skip to content

Instantly share code, notes, and snippets.

View yao2030's full-sized avatar

yao2030 yao2030

  • Shanghai, China
View GitHub Profile
function is_onestep_palidrome(str) {
function is_palindrome(str_) {
return str_ == str_.split('').reverse().join('');
}
function swapStr(str, first, last) {
if (first == last) {
return str;
}
@yao2030
yao2030 / movietransitions.swift
Created December 2, 2016 09:09 — forked from SheffieldKevin/movietransitions.swift
Make a movie with transitions with AVFoundation and swift
//
// main.swift
// mutablecomposition
//
// Created by Kevin Meaney on 24/08/2015.
// Copyright (c) 2015 Kevin Meaney. All rights reserved.
//
import Foundation
import Foundation
struct Builder {
typealias Attributes = Dictionary<String, AnyObject>
typealias Block = () -> ()
typealias Visitor = (Node) -> ()
class Node {
var name: String
extension Int {
func times(block: () -> ()) {
for _ in 0..self {
block()
}
}
func times(block: (Int) -> ()) -> Int {
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
const double EPS = 1e-6;
inline double f(double x) { return x * x * x - 5 * x * x + 10 * x - 80; }
int main(void) {
double root, x1 = 0, x2 = 100, y = 0.0;
root = x1 + (x2 - x1) / 2;
#include <iostream>
using namespace std;
int Count(int m, int n) {
if (n == 0 || n == 1) {
return 1;
}
if (n > m) {
return Count(m, m);
#include <iostream>
using namespace std;
struct Problem {
int n;
char src, mid, dest;
};
Problem stack[200];
int main(void) {
cin >> stack[1].n;
#include <iostream>
#include <cmath>
using namespace std;
const int NUMS = 16;
int num[NUMS + 10];
inline int Bit(int n, int i) { return ( n & (1 << i)); }
int main(void) {
int BinarySearch(int a[], int size, int p) {
int L = 0;
int R = size - 1;
while (L <= R) {
int mid = (L + R) / 2;
if (p == a[mid]) {
return mid;
} else if (p > a[mid]) {
L = mid + 1;
} else {
#include <iostream>
using namespace std;
void Hanoi(int n, char src, char mid, char dest) {
if (n == 1) {
cout << src << " -> " << dest << endl;
return;
}
Hanoi(n-1, src, dest, mid);
cout << src << " -> " << dest << endl;