# 成功获得安排的清单金额

0
2019-05-03 22:39:05

create table numbers(n int not null)
insert into numbers(n) values(1),(1), (2), (2), (3), (4)

select distinct num1.n+num2.n sum2n
from numbers num1
inner join numbers num2
on num1.n<>num2.n
order by sum2n


C＃LINQ：

List<int> num = new List<int>{ 1, 1, 2, 2, 3, 4};
var uNum = num.Distinct().ToList();
var sums=(from num1 in uNum
from num2 in uNum
where num1!=num2
select num1+num2).Distinct();
foreach (var s in sums)
{
Console.WriteLine(s);
}

0
2019-05-22 21:05:45

allSums = set(a+b for a in X for b in X)
allSums = sorted(allSums)


@deuseldorf，Peter有一些复杂的问题（n！）我严重质疑deuseldorf建议“n factorial”但仅仅是“n，（真的很激动）！”

0
2019-05-19 23:22:04

0
2019-05-07 19:59:41

matrixOfSums list = [[a+b | b <- list, b >= a] | a <- list]

sortedSums = foldl merge [] matrixOfSums

--A normal merge, save that we remove duplicates
merge xs [] = xs
merge [] ys = ys
merge (x:xs) (y:ys) = case compare x y of
LT -> x:(merge xs (y:ys))
EQ -> x:(merge xs (dropWhile (==x) ys))
GT -> y:(merge (x:xs) ys)


-- wide-merge does a standard merge (ala merge-sort) across an arbitrary number of lists
-- wideNubMerge does this while eliminating duplicates
wideNubMerge :: Ord a => [[a]] -> [a]
wideNubMerge ls = wideNubMerge1 $filter (/= []) ls wideNubMerge1 [] = [] wideNubMerge1 ls = mini:(wideNubMerge rest) where mini = minimum$ map head ls
rest = map (dropWhile (== mini)) ls

betterSortedSums = wideNubMerge matrixOfSums


0
2019-05-07 18:54:28

step 1 (startinglist)
for each number num1 in startinglist
for each number num2 in startinglist
add num1 plus num2 into templist
add templist to sumlist
return sumlist


Symphonious 2由于故意排列清单（在安排的清单中每个组件添加一个数字，并且肯定还会安排清单）我们只能通过将每个清单相互组合来进行合并，而不是合并排序。整个很棒。 最终这需要花费O（n ^ 2）时间。

step 2 (sumlist)
create an empty list mergedlist
for each list templist in sumlist
set mergelist equal to: merge(mergedlist,templist)
return mergedlist


0
2019-05-07 17:31:57