Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sequences of bid values:
- List<int> bidValues1 = new List<int>() { 1, 2, 3, 4, 5 };
- List<int> bidValues2 = new List<int>() { 5, 3, 4, 1, 2 };
- List<int> bidValues3 = new List<int>() { 4, 5, 2, 3, 5 };
- List<int> bidValues4 = new List<int>() { 3, 3, 0, 2, 3 };
- // Add all four collections to a new list:
- List<List<int>> bidValues = new List<List<int>>();
- bidValues.Add(bidValues1);
- bidValues.Add(bidValues2);
- bidValues.Add(bidValues3);
- bidValues.Add(bidValues4);
- // Uses Aggregate extension method to compare all four sequences:
- bidValues.Aggregate((bids1, bids2) =>
- bids1.Zip(bids2, (bid1, bid2) => Math.Max(bid1, bid2)).ToList())
- .Dump("Maximum Bids (General Approach)");
- bidValues.Aggregate((bids1, bids2) =>
- bids1.Zip(bids2, (bid1, bid2) => Math.Min(bid1, bid2)).ToList())
- .Dump("Minimum Bids (General Approach)");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement