Skip to content

Commit

Permalink
update school rank problem
Browse files Browse the repository at this point in the history
  • Loading branch information
BriFuture committed Jul 24, 2019
1 parent 498fbe7 commit 113abea
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions leetcode/school_rank_problem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
题目:
有A、B、C、D、E5所学校,在一次检查评比中,已知E校肯定不是第2名或第3.他们相互进行推测。A校有人说,E校一定是第1名。
有A、B、C、D、E5所学校,在一次检查评比中,已知E校肯定不是第2名或第3.他们相互进行推测。
A校有人说,E校一定是第1名。
B校有人说,我校可能是第2名。
C校有人说,A校最差。
D校有人说,C校不是最好的。
Expand All @@ -21,26 +22,26 @@

pred = [
{
"Pos": ('E', (1, )),
"Neg": ('E', (4, 5))
"Pos": ('E', (1, ), "D"),
"Neg": ('E', (4, 5)) # E 不会是 2 3
},
{
"Pos": ('B', (1, 2, 3, 4, 5)),
"Pos": ('B', (1, 2, 3, 4, 5), "M"),
"Neg": ('B', (1, 2, 3, 4, 5))
},

{
"Pos": ('A', (5, )),
"Pos": ('A', (5, ), "D"),
"Neg": ('A', (1, 2, 3, 4))
},

{
"Pos": ('C', (2, 3, 4, 5)),
"Pos": ('C', (2, 3, 4, 5), "D"),
"Neg": ('C', (1, ))
},

{
"Pos": ('D', (1, )),
"Pos": ('D', (1, ), "D"),
"Neg": ('D', (2, 3, 4, 5))
}
]
Expand All @@ -63,6 +64,9 @@ def diff(A, B):


def predictRank(si, sj):
"""si 和 sj 是排名在前两名的学校序号,
如猜测 A 在前两名,则 si、sj 中有一个是 0
"""
predictSchool = [0] * len(schools)

# 收集结果集
Expand Down

0 comments on commit 113abea

Please sign in to comment.