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
/* | |
12306 Auto Submit => A javascript snippet to help you auto submit. | |
Copyright (C) 2011 Kevintop | |
Includes jQuery | |
Copyright 2011, John Resig | |
Dual licensed under the MIT or GPL Version 2 licenses. | |
http://jquery.org/license | |
Includes 12306.user.js |
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
/* | |
12306 Auto Submit => A javascript snippet to help you auto submit. | |
Copyright (C) 2011 Kevintop | |
Includes jQuery | |
Copyright 2011, John Resig | |
Dual licensed under the MIT or GPL Version 2 licenses. | |
http://jquery.org/license | |
Includes 12306.user.js |
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
/* | |
12306 Auto Query => A javascript snippet to help you book tickets online. | |
Copyright (C) 2011-2012 Jingqin Lynn | |
Includes jQuery | |
Copyright 2011, John Resig | |
Dual licensed under the MIT or GPL Version 2 licenses. | |
http://jquery.org/license | |
Includes Sizzle.js |
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
#!/usr/bin/ruby | |
def palindrome?(string) | |
string.downcase! | |
string=string.gsub(/[^a-z]+/,'') # 正则表达式替换 | |
string==string.reverse | |
end | |
p palindrome?('thissiht') |
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
class WrongNumberOfPlayersError < StandardError ; end | |
class NoSuchStrategyError < StandardError ; end | |
def compare_game?(game) | |
return (game[0][1] + game[1][1]) =~ /rs|sp|pr|rr|ss|pp/i | |
end | |
def rps_game_winner(game) | |
strategy=["r","p","s"] | |
raise WrongNumberOfPlayersError unless game.length == 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
def anagrams?(w1, w2) | |
w1.downcase.split('').sort == w2.downcase.split('').sort | |
end | |
def combine_anagrams(words) | |
ret=[] | |
while words.length>0 do | |
i=0 | |
temp=[words[i]] | |
j=i+1 |
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
# (a) Create a class Dessert with getters and setters for name and calories. Define | |
# instance methods healthy?, which returns true if a dessert has less than 200 | |
# calories, and delicious?, which returns true for all desserts. | |
# | |
# (b) Create a class JellyBean that extends Dessert, and add a getter and setter for | |
# flavor. Modify delicious? to return false if the flavor is black licorice (but delicious? | |
# should still return true for all other flavors and for all non-JellyBean desserts). | |
class Dessert | |
attr_accessor :name |
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
# advanced OOP with some metaprogramming | |
class Class | |
def attr_accessor_with_history(attr_name) | |
attr_name = attr_name.to_s | |
# getter | |
attr_reader attr_name | |
attr_reader attr_name+"_history" | |
# 为类动态添加方法 | |
class_eval %{ |
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 <sstream> | |
#include <cmath> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
unsigned long long factorialDivide(int num, int den){ | |
unsigned long long rValue = 1; |
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
def isPrime(n): | |
n=abs(n) | |
if n<=1: | |
return False | |
if n==2: | |
return True | |
if not n&1: | |
return False | |
i=3 | |
while i*i<=n: |
OlderNewer