http://aimath.org/news/primegaps70m/
第一段就很有料,四月后期投稿,五月中旬便接受,对于一篇55页的paper来说速度惊
人。
Zhang's Theorem on Bounded Gaps Between Primes
by Dan Goldston
In late April 2013 Yitang Zhang of the University of New Hampshire submitted
a paper to the Annals of Mathematics proving that there are infinitely many
pairs of primes that differ by less than 70 million. The proof of this
amazing result was verified with high confidence by several experts in the
field and accepted for publication. A public slightly re... 阅读全帖
Initialization:
1. Given a list of meetings with each meeting represented by (meeting
id, start time, end time)
2. Convert each meeting (meeting id, start time, end time) into 2 tuples
meeting tuple (time, end type, meeting id). Sort all start and end meeting
tuples by time.
3. Initial a meeting number counter. If a new meeting room is needed,
the the next meeting room id is the counter value.
4. Initialize a hash map {meeting id: room id} to record which room uses
which id.
... 阅读全帖
boost::tuple< boost::tuple, boost::tuple >
...x( boost::tuple<1, 2>, boost::tuple<3, 4, 5> >
...
x.get<0>().get<1>() = 2;
...
Whenever you resort to tricks, things are really going wrong. C++ has
everything you want for normal tasks.
好久没做题了,为了20个包子,我来试试吧。
从左边开始,看第一个3-tuple,{a0, a1, a2}
maintain the following info:
current best solution length: 0
hash each new number's first occurrence: a0~0, a1~1
case1: current 3-tuple is valid
find a2 in hash table:
if (found) {
current_best = MAX(current_best, |hash[a2] - current index of a2|;
} else {
hash[a2] = current index of a2; // insert a2 into hash table.
}
case2: current 3-tuple is invalid:
possible_best = solution of (a1 ... an);
return MAX(current_best, possible_best);
I can think of a two-pass approach.
First pass, Find the digits that do not have enough ones (i.e. bit positions
for which less than 50 inputs have a value of one in that bit position).
This first step is optional - even if you skip this step, you still only
need to accumulate ( 30 * 29 / 2 ) = 435 histogram bins.
// initialize
foreach bitIndex
accum [ bitIndex] = 0
// accumulate
foreach inputIndex
foreach bitIndex
accum [ bitIndex ] += input [ inputIndex ] . bit [ bitIndex ]
// Second ... 阅读全帖
The possible reason could be that you have a SELECT ... INTO statement.
Before long there is only 1 tuple qualified by WHERE clause. As you
just inserted some new tuples, now there are more than 1 tuples qualified.
Then SELECT INTO can't handle it, you must use cursor now.
I have several tables with identical schema:
tupleId int unique,
data bytea
I am writing some server procedures that trys to lookup
a tuple using (tableOid, tupleId) pair. The reason to
break down the tables are to make indexing easier (data
is indexed using custom functions).
What's the efficient way of getting Datnum that represents
the tuple? Most of the time I have 1 tuple to retrieve,
but there also times that I have a bunch.
I could get the Relation using RelationIdGetRelation (
The world beyond batch: Streaming 101: A high-level tour of modern data-
processing concept http://radar.oreilly.com/2015/08/the-world-beyond-batch-streami
by Tyler Akidau August 5, 2015
Editor’s note: This is the first post in a two-part series about the
evolution of data processing, with a focus on streaming systems, unbounded
data sets, and the future of big data.
Streaming data processing is a big deal in big data these days, and for good
reasons. Amongst them:
Businesses crave ever more tim... 阅读全帖
def print_valid_parenthese_iterative(n):
stack = []
result = [] # current result
# each tuple in the stack contains three items:
# first item: number of left parenthesis remaining
# second item: number of right parenthesis remaing
# third item: the parenthesis that should add to the
# result when this tuple is popped
stack.append((n - 1, n, '('))
while stack:
left, right, parenthesis = stack.pop()
result.append(parenthesis)
# if no more... 阅读全帖
之前好像有人整理过了,但是找不到了,我综合了几个地方的整理了一下,贡献给大家
啦。感谢原作者。
Why Yelp?
Why would we hire you?
Ideal job at Yelp?
NETWORK
What is DNS?
protocol used to transfer message in HTTP application? TCP reliable
What is SSL?
Port number for HTTP? 80
What does HTML stand for?
What is the protocol used underneath FTP?
Difference between POST and GET?
UNIX
UNIX command to search for a specific text through files in a directory.
Find number of unique lines in a file.
signal for kill command? 9, SIGKILL
What is the comma... 阅读全帖
You may want to customize your own ResultSet class
implemented
by array or something else, so that you can display the
tuples
you want by specifying the index of the selected tuples.
When
the user click the links to "next" or to specified page
number,
you can either recall the servlet to do the query again or
store
the query reselt in session. I am not sure if this is what
you
want but hope it will help.
2-to-many doesn't make sense here.
The so-called 1-to-many (1-to-1, many-to-many, respectively) means
1 ROW/TUPLE in left entity is associated with many ROWS/TUPLES in right entity,
not 1 COLUMN/ATTIBUTE to many COLUMNS/ATTRIBUTES.
Your case is two COLUMNS/ATTRIBUTES in a table referring to another table.
This is not 2-to-many relationship in ER model. This is just 2 foreign key
attributes in relational model.
CREATE TABLE player
( player_id NUMBER NOT NULL,
player_name VARCHAR(100),
PRI
Relational calculus has two major categories:
tuple relational calculus and domain relational calculus,
First-order logic expression must be used and the BBS doesn't support
the math notations.
Even though SQL follows tuple relational calculus, SQL is NOT relational
calculus. When this guy submit your answer as his homework solution,
TA may give him 0 point. :)
I think that you misunderstood.
Predicate logic is merely the fundamental of the query mechanism.
It has nothing to do with physical representation.
However, in practice, triples are used to store the knowledges, as in
prolog, decl, RDF etc. Triples, in a way, are EAV models (entity,
attribute, values). Sometimes it may be represented as
target>, or action
Hmm, as I pointed out, storing triples as tuples is one way doing it
with sacrifices. AFAIK, there are 3 categories of storing RDF data
(w/ considering the solving mechanism) and tuple is just one, storing
as triple is another.
I am not particularly familiar with the knowledge representations you
mentioned. It is a big topic that overs EE, AI and SAT problems.
Although there are quite a bit common backgrounds between AI and
databases, I don't think DB people would normally link the two as far
呵呵。基于某个COLUMN属性的查询,比如说 SELECT * FROM A a.prop = 1. 结果查询出
来之后,Hibernate把命中的对象放在二级缓存里,假如说全表所有的TUPLE都满足a.pr
op =1,那么其实全表都已经LOAD在内存里了。第二次查询的时候,我select * from A
where a.prop = 2。 虽然结果集已经在MEM里了,因为HIBERNATE不知道满足a.prop =
2的TUPLE有哪些,它还是会做SQL从DB里取,而且REFLECT生成结果集,并且重新REFRES
H二级缓存。所以,并不是说你的结果集已经在MEM中,HIBERNATE就不去DB了。这是HIB
ERNATE的DESIGN决定的。我觉得这不是一个有效率的好方法。
The 3sum problem is defined as follows:
given a set S of n integers, dothere exist three elements {a, b, c} 2 S such
that a + b + c = 0?
This is a linear satisfiability problem. 3sum can be solved using a simple
algorithm with O(n^2) runtime (sort S, then test 3-tuples intelligently).
我不是特别清楚如何 "test 3-tuples intelligently" in O(n^2).
能给点意见吗? 多谢
Thanks a lot!
I did learn a lot (how to use tuple) starting from reading this post . But
this solution might not work as well as it looks.
The problem is, you need to hard-code your tuple structure, don't you?
#!/usr/bin/python
def permu(xs):
if xs:
r , h = [],[]
for x in xs:
if x not in h:
ts = xs[:]; ts.remove(x)
for p in permu(ts):
r.append([x]+p)
h.append(x)
return r
else:
return [[]]
def product(*args, **kwds):
# product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
... 阅读全帖
#!/usr/bin/python
def permu(xs):
if xs:
r , h = [],[]
for x in xs:
if x not in h:
ts = xs[:]; ts.remove(x)
for p in permu(ts):
r.append([x]+p)
h.append(x)
return r
else:
return [[]]
def product(*args, **kwds):
# product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
... 阅读全帖
Twitter don’t use Storm anymore.
At Twitter, Storm has been decommissioned and Heron is now the de-facto
streaming system. It has been in production for several months and runs
hundreds of development and production topologies in multiple data centers.
These topologies process several tens of terabytes of data, generating
billions of output tuples…. results from an empirical evaluation of Heron
demonstrate large reductions in CPU resources when using Heron, while
delivering 6-14X improvement... 阅读全帖