Returns true if two collections contain the same elements regardless of order, false otherwise.

Use IEnumerable.GroupBy() to create groups for each distinct value in each collection, IEnumerable.ToDictionary() to convert the result to a Dictionary.
Use IEnumerable.Union() and IEnumerable.Distinct() to find the distinct values from both collections and loop over them using a foreach loop.
Use Dictionary.ContainsKey() to check that each distinct value exists in both collections and compare the count for each one.
Return false if any value is not found in either collection or if any count does not match, true otherwise.

继续阅读 30秒学会 C# 片段 – HaveSameContents

Returns true if the elements of the first collection are contained in the second one regardless of order, false otherwise.

Use IEnumerable.GroupBy() to create groups for each distinct value in each collection, IEnumerable.ToDictionary() to convert the result to a Dictionary.
Use IEnumerable.Distinct() to find the distinct values from the first collection and loop over them using a foreach loop.
Use Dictionary.ContainsKey() to check that each distinct value exists in the second collection and compare the count for each one.
Return false if any value is not found in the second collection or if any count in it is lower than in the first one, true otherwise.

继续阅读 30秒学会 C# 片段 – IsContainedIn

Creates a dictionary with the same keys as the provided dictionary and values generated by running the provided function for each value.

Use dict.keys() to iterate over the dictionary’s keys, assigning the values produced by fn to each key of a new dictionary.

继续阅读 30秒学会 Python 片段 – map_values

Returns a Dictionary with the unique values of a collection as keys and their frequencies as the values.

Use IEnumerable.GroupBy() to create groups for each distinct value in the collection.
Use IEnumerable.ToDictionary() to convert the result of the previous operation to a Dictionary.

继续阅读 30秒学会 C# 片段 – Frequencies

Combines two lists into a dictionary, where the elements of the first one serve as the keys and the elements of the second one serve as the values.
The values of the first list need to be unique and hashable.

Use zip() in combination with a list comprehension to combine the values of the two lists, based on their positions.

继续阅读 30秒学会 Python 片段 – to_dictionary