This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// mutablecomposition | |
// | |
// Created by Kevin Meaney on 24/08/2015. | |
// Copyright (c) 2015 Kevin Meaney. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Builder { | |
typealias Attributes = Dictionary<String, AnyObject> | |
typealias Block = () -> () | |
typealias Visitor = (Node) -> () | |
class Node { | |
var name: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Int { | |
func times(block: () -> ()) { | |
for _ in 0..self { | |
block() | |
} | |
} | |
func times(block: (Int) -> ()) -> Int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct Problem { | |
int n; | |
char src, mid, dest; | |
}; | |
Problem stack[200]; | |
int main(void) { | |
cin >> stack[1].n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
NewerOlder