更新时间:2021-07-29 23:26:23
我不确定你的意思,但你可以检查每个投票是否在Fibonacci序列中进行了相邻投票,如下所示。您需要对列表中的第一个或最后一个投票进行错误检查等。
I am not sure exactly what you mean, but you can check if each vote has an adjacent vote in a Fibonacci sequence with something like below. You will need error check for the vote being first or last of list etc.
List<int> votes =;//however you get your list
List<int> sequence =; //Generate your Fibonacci sequence
foreach (int vote in votes)
{
if (!sequence.Contains(vote))
{
//That vote isn't even in a Fibonacci sequence!
}
List<int> adjacentFibNumbers = new List<int>() { votes.Where(v => v < vote).Max(), votes.Where(v => v > vote).Min() };
bool thereIsAnAdjacentVote = votes.Any(v => adjacentFibNumbers.Contains(v));
}
然后我想你可以检查每次投票,看看它是否与至少另一张投票相邻。
Then I think you can just check each vote to see if it is adjacent to at least one other vote.
我不确定这是否会让你到达你需要去的地方,但无论如何它都是一个开始。
I am not sure if this gets you to where you need to go, but it is a start anyway.
Ethan