python初学者贴个python的
def dist(word1, word2):
wordlist = ['this','this','is']
l1,l2 = -1,-1
dist = len(wordlist)
for p in range(len(wordlist)):
if word1==wordlist[p]:
l1 = p
if word1==word2:
l1,l2 = l2,l1
elif word2 == wordlist[p]:
l2 = p
if l1*l2>-1:
if dist>abs(l2-l1):
dist = abs(l2-l1)
if dist==len(wordlist): return None
else: return dist
python初学者贴个python的
def dist(word1, word2):
wordlist = ['this','this','is']
l1,l2 = -1,-1
dist = len(wordlist)
for p in range(len(wordlist)):
if word1==wordlist[p]:
l1 = p
if word1==word2:
l1,l2 = l2,l1
elif word2 == wordlist[p]:
l2 = p
if l1*l2>-1:
if dist>abs(l2-l1):
dist = abs(l2-l1)
if dist==len(wordlist): return None
else: return dist
在VS2015花40多秒,如果wordList有2455个4个字母构成的字符串。但是在leetcode上
只要半秒。为啥呢?
size_t distance(string a, string b) {
size_t c = 0;
for (size_t i = 0;i
if (a[i] != b[i])
if (c++==1)
return c;
return c;
}
size_t size = wordList.size();
size_t from = SIZE_MAX;
size_t dest = SIZE_MAX;
vector> closest; // stores the list of list of shortest
nodes
closest.reserve(size);
for (size_t i = 0;i
vector tmpv;
tmpv.r... 阅读全帖
public class Solution {
public int ladderLength(String beginWord, String endWord, Set
wordList) {
Queue q = new LinkedList<>();
q.add(beginWord);
wordList.remove(beginWord);
int level = 1;
while(!q.isEmpty()){
int size = q.size();
for(int i = 0; i < size; i++){
String s = q.remove();
for(int j = 0; j < s.length(); j++){
for(char c = 'a'; c <= 'z'; c++){
... 阅读全帖
lolhaha 的算法的复杂度是 O(N^2).
应该没有比 O(N^2) 更好的算法了,
但是有一个优化可以把算法运行速度大大提升。
根据 lolhaha 的算法,
1.create hash for each word
2.sort the dictionary by word length.
assume the dictionary become
a[0],a[1]......
find the largest k so that hash(a[0])&hash(a[k])==0,
get max=len(a[0])*len(a[k])
find max i in [2,k-1] so that hash(a[1])&hash(a[i])==0,
compare max and len(a[1])*len(a[i])
next step find max j in [3,i-1]....
Using this online word list: http://www.sil.org/linguistics/wordlists/english/wordlist/words
(co... 阅读全帖
网上的搜索的众说纷纭 https://goo.gl/ebfvvD
public class Solution {
public int ladderLength(String beginWord, String endWord, List
wordList) {
Queue q = new LinkedList<>();
HashSet list = new HashSet<>(wordList);
int level = 0;
q.add(beginWord);
HashSet set = new HashSet<>();
set.add(beginWord);
while(!q.isEmpty()){
int size = q.size();
level++;
for(int i = 0; i < size; i++){
... 阅读全帖
【 以下文字转载自 English_Communication 俱乐部 】
发信人: SwiftDove (Swift Dove), 信区: English_Communication
标 题: Word List Web Tool for Anyone + Dictionary Lookup in page.
发信站: BBS 未名空间站 (Wed Jul 18 00:38:41 2012, 美东)
If you use Google Chrome Browser, I extended a dictionary lookup tool which
can let you lookup with one click the word without leaving the page. At the
same time, you can add the word to your word lists at http://www.elookinto.com/wordlist. The extension is at: https://chrome.google.com/webstore... 阅读全帖
IPMI 2.0 RAKP Authentication Remote Password Hash Retrieval
More recently, Dan Farmer identified an even bigger issue with the IPMI 2.0
specification. In short, the authentication process for IPMI 2.0 mandates
that the server send a salted SHA1 or MD5 hash of the requested user's
password to the client, prior to the client authenticating. You heard that
right - the BMC will tell you the password hash for any valid user account
you request. This password hash can broken using an offline brutefor... 阅读全帖
昨天,我做了一些Google Dictionaryhttps://chrome.google.com/webstore/detail/
mgijmajocgfcbeboacabfgobmjgjcoja)的延伸工作。 我看到一行:
console.log("FUCK YOU MOTHERFUCKER");
在page_page_action_js_min.js 出现。For windows, the code is located at
C:\Users\userid\AppData\Local\Google\Chrome\User Data\Default\Extensions\
mgijmajocgfcbeboacabfgobmjgjcoja if you have the extension installed.
By the way, I did extended the function at: https://chrome.google.com/
webstore/detail/mkjnchpohljkinmppeljneimbbjblcbd for http://www... 阅读全帖
以前曾告诉大家youaudio,现在终于有点用处。欢迎秀秀你的英文口语。
【 以下文字转载自 WaterWorld 讨论区 】
发信人: zhengchg (zhengchenggong), 信区: WaterWorld
标 题: 谁来秀一把美国PHD水平的英文?
发信站: BBS 未名空间站 (Sun Nov 11 01:41:38 2012, 美东) http://www.elookinto.com/wordlist/youaudio/
念这段
"I'm truly honoured to receive (the) John Maddox Prize. Science in China
faces great challenges from superstition, psuedoscience, anti-science and
scientific misconduct. There are more and more Chinese people (who) realise
this is a big problem and are standing up for sci... 阅读全帖
From http://www.pokerstars.com/poker/terms/wordlist/
"D" for Diamond, "H" for Heart, "S" for spade, "C" for club
Action - (1) Opportunity to act. If a player appears not to realize it's his
turn, the dealer will say "Your action, sir." (2) Bets and raises. "If a
third heart hits the board and there's a lot of action, you have to assume
that somebody has made the flush."
Ante - A small portion of a bet contributed by each player to seed the pot
at the beginning of a poker hand. Most hold'em games
From http://www.pokerstars.com/poker/terms/wordlist/
"D" for Diamond, "H" for Heart, "S" for spade, "C" for club
Call - To put into the pot an amount of money equal to the most recent bet
or raise. The term "see" (as in "I'll see that bet") is considered
colloquial.
Calling Station - A weak-passive player who calls a lot, but doesn't raise
or fold much. This is the kind of player you like to have in your game.
Cap - To put in the last raise permitted on a betting round. This is
typically the thi
From http://www.pokerstars.com/poker/terms/wordlist/
"D" for Diamond, "H" for Heart, "S" for spade, "C" for club
Equity - Your "rightful" share of a pot. If the pot contains $80, and you
have a 50% chance of winning it, you have $40 equity in the pot. This term
is somewhat fanciful since you will either win $80 or $0, but it gives you
an idea of how much you can "expect" to win.
Expectation - (1) The amount you expect to gain on average if you make a
certain play. For instance, suppose you put $
From http://www.pokerstars.com/poker/terms/wordlist/
"D" for Diamond, "H" for Heart, "S" for spade, "C" for club
Jackpot - A special bonus paid to the loser of a hand if he gets a very good
hand beaten. In hold'em, the "loser" must typically get aces full or better
beaten. In some of the large southern California card clubs, jackpots have
gotten over $50,000. Of course, the jackpot is funded with money removed
from the game as part of the rake.
Kicker - An unpaired card used to determine the bet
From http://www.pokerstars.com/poker/terms/wordlist/
"D" for Diamond, "H" for Heart, "S" for spade, "C" for club
Pay Off - To call a bet when the bettor is representing a hand that you can'
t beat, but the pot is sufficiently large to justify a call anyway. Example:
"He played it exactly like he made the flush, but I had top set so I paid
him off."
Play the Board - To show down a hand in hold'em when your cards don't make a
hand any better than is shown on the board. For instance, if you have 22
From http://www.pokerstars.com/poker/terms/wordlist/
"D" for Diamond, "H" for Heart, "S" for spade, "C" for club
Scare Card - A card that may well turn the best hand into trash. If you have
TC -8C and the flop comes QD-JD-9S , you almost assuredly have the best
hand. However, a turn card of TD would be very scary because it would
almost guar-antee that you are now beaten.
Second Pair - A pair with the second highest card on the flop. If you have
AS -TS, and the flop comes KD-TH-6C , you have fl
From http://www.pokerstars.com/poker/terms/wordlist/
"D" for Diamond, "H" for Heart, "S" for spade, "C" for club
Table Stakes - A rule in a poker game meaning that a player may not go into
his pocket for money during a hand. He may only invest the amount of money
in front of him into the current pot. If he runs out of chips during the
hand, a side pot is created in which he has no interest. All casino poker is
played table stakes. The definition sometimes also includes the rule that a
player may
【 以下文字转载自 WaterWorld 讨论区 】
发信人: zhengchg (zhengchenggong), 信区: WaterWorld
标 题: 谁来秀一把美国PHD水平的英文?
发信站: BBS 未名空间站 (Sun Nov 11 01:41:38 2012, 美东) http://www.elookinto.com/wordlist/youaudio/
念这段
"I'm truly honoured to receive (the) John Maddox Prize. Science in China
faces great challenges from superstition, psuedoscience, anti-science and
scientific misconduct. There are more and more Chinese people (who) realise
this is a big problem and are standing up for science. I consider this award
as an ack... 阅读全帖
【 以下文字转载自 WaterWorld 讨论区 】
发信人: zhengchg (zhengchenggong), 信区: WaterWorld
标 题: 谁来秀一把美国PHD水平的英文?
发信站: BBS 未名空间站 (Sun Nov 11 01:41:38 2012, 美东) http://www.elookinto.com/wordlist/youaudio/
念这段
"I'm truly honoured to receive (the) John Maddox Prize. Science in China
faces great challenges from superstition, psuedoscience, anti-science and
scientific misconduct. There are more and more Chinese people (who) realise
this is a big problem and are standing up for science. I consider this award
as an ack... 阅读全帖
http://www.elookinto.com/wordlist/youaudio/
念这段
"I'm truly honoured to receive (the) John Maddox Prize. Science in China
faces great challenges from superstition, psuedoscience, anti-science and
scientific misconduct. There are more and more Chinese people (who) realise
this is a big problem and are standing up for science. I consider this award
as an acknowledgement of our efforts from (the) international science
community and I deeply appreciate it. Thank you."
【 以下文字转载自 WaterWorld 讨论区 】
发信人: zhengchg (zhengchenggong), 信区: WaterWorld
标 题: 谁来秀一把美国PHD水平的英文?
发信站: BBS 未名空间站 (Sun Nov 11 01:41:38 2012, 美东) http://www.elookinto.com/wordlist/youaudio/
念这段
"I'm truly honoured to receive (the) John Maddox Prize. Science in China
faces great challenges from superstition, psuedoscience, anti-science and
scientific misconduct. There are more and more Chinese people (who) realise
this is a big problem and are standing up for science. I consider this award
as an ack... 阅读全帖
JS这块:
function uploadlist() {
var selectstar=document.getElementById("selectstar");
if (!selectstar) {
wordlist.value="is null";
return;
}
。。。
为什么老是跳到 if 里面去呢??(也就是说,得不到sel... 阅读全帖