Merge pull request #485 from 30-seconds/retitle-snippets
Update snippet titles
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: function_name
|
||||
title: Function name
|
||||
tags: utility,intermediate
|
||||
firstSeen: 2021-06-13T05:00:00-04:00
|
||||
---
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: add_days
|
||||
title: Add days to date
|
||||
tags: date,intermediate
|
||||
firstSeen: 2020-10-28T16:19:04+02:00
|
||||
lastUpdated: 2020-10-28T16:19:04+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: all_equal
|
||||
title: Check if list elements are identical
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T11:39:18+03:00
|
||||
lastUpdated: 2020-10-11T13:40:42+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: all_unique
|
||||
title: Check if list has no duplicates
|
||||
tags: list,beginner
|
||||
firstSeen: 2018-04-01T11:03:09+03:00
|
||||
lastUpdated: 2021-01-07T23:30:28+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: arithmetic_progression
|
||||
title: Arithmetic progression
|
||||
tags: math,beginner
|
||||
firstSeen: 2020-07-28T13:57:33+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
@ -15,5 +15,5 @@ def arithmetic_progression(n, lim):
|
||||
```
|
||||
|
||||
```py
|
||||
arithmetic_progression(5, 25) # [5, 10, 15, 20, 25]
|
||||
arithmetic_progression(5, 25) # [5, 10, 15, 20, 25]
|
||||
```
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: average
|
||||
title: Average
|
||||
tags: math,list,beginner
|
||||
firstSeen: 2018-01-27T07:16:41+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: average_by
|
||||
title: Mapped list average
|
||||
tags: math,list,intermediate
|
||||
firstSeen: 2019-08-20T11:55:10+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: bifurcate
|
||||
title: Bifurcate list based on values
|
||||
tags: list,intermediate
|
||||
firstSeen: 2019-08-20T12:37:06+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
---
|
||||
|
||||
Splits values into two groups, based on the result of the given `filter` list.
|
||||
Splits values into two groups, based on the result of the given `filter` list.
|
||||
|
||||
- Use a list comprehension and `zip()` to add elements to groups, based on `filter`.
|
||||
- If `filter` has a truthy value for any element, add it to the first group, otherwise add it to the second group.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: bifurcate_by
|
||||
title: Bifurcate list based on function
|
||||
tags: list,intermediate
|
||||
firstSeen: 2019-08-20T12:41:21+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: binomial_coefficient
|
||||
title: Binomial coefficient
|
||||
tags: math,beginner
|
||||
firstSeen: 2020-10-04T11:56:31+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: byte_size
|
||||
title: Byte size of string
|
||||
tags: string,beginner
|
||||
firstSeen: 2018-02-01T10:19:59+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: camel
|
||||
title: Camelcase string
|
||||
tags: string,regexp,intermediate
|
||||
firstSeen: 2019-08-21T08:59:54+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: capitalize
|
||||
title: Capitalize string
|
||||
tags: string,intermediate
|
||||
firstSeen: 2018-02-01T10:19:59+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: capitalize_every_word
|
||||
title: Capitalize every word
|
||||
tags: string,beginner
|
||||
firstSeen: 2018-02-01T10:19:59+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: cast_list
|
||||
title: Cast to list
|
||||
tags: list,intermediate
|
||||
firstSeen: 2019-08-20T12:47:43+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: celsius_to_fahrenheit
|
||||
title: Celsius to Fahrenheit
|
||||
tags: math,beginner
|
||||
unlisted: true
|
||||
firstSeen: 2020-04-05T12:29:03+03:00
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
---
|
||||
title: check_prop
|
||||
title: Check property
|
||||
tags: function,intermediate
|
||||
firstSeen: 2020-01-02T16:49:25+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
---
|
||||
|
||||
Creates a function that will invoke a predicate function for the specified property on a given object.
|
||||
Creates a function that will invoke a predicate function for the specified property on a given dictionary.
|
||||
|
||||
- Return a `lambda` function that takes an object and applies the predicate function, `fn` to the specified property.
|
||||
- Return a `lambda` function that takes a dictionary and applies the predicate function, `fn` to the specified property.
|
||||
|
||||
```py
|
||||
def check_prop(fn, prop):
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: chunk
|
||||
title: Split list into chunks
|
||||
tags: list,intermediate
|
||||
firstSeen: 2018-01-09T06:39:42+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: chunk_into_n
|
||||
title: Split list into n chunks
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-10-12T22:11:30+03:00
|
||||
lastUpdated: 2020-10-23T05:35:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: clamp_number
|
||||
title: Clamp number
|
||||
tags: math,beginner
|
||||
firstSeen: 2019-08-20T12:50:38+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: collect_dictionary
|
||||
title: Invert dictionary
|
||||
tags: dictionary,intermediate
|
||||
firstSeen: 2020-04-07T21:15:06+03:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
@ -7,7 +7,7 @@ lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
Inverts a dictionary with non-unique hashable values.
|
||||
|
||||
- Create a `collections.defaultdict` with `list` as the default value for each key.
|
||||
- Create a `collections.defaultdict` with `list` as the default value for each key.
|
||||
- Use `dictionary.items()` in combination with a loop to map the values of the dictionary to keys using `dict.append()`.
|
||||
- Use `dict()` to convert the `collections.defaultdict` to a regular dictionary.
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: combine_values
|
||||
title: Combine dictionary values
|
||||
tags: dictionary,intermediate
|
||||
firstSeen: 2021-03-07T12:30:47+02:00
|
||||
lastUpdated: 2021-04-04T14:32:35+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: compact
|
||||
title: Compact list
|
||||
tags: list,beginner
|
||||
firstSeen: 2018-01-19T12:17:06+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: compose
|
||||
title: Compose functions
|
||||
tags: function,advanced
|
||||
firstSeen: 2020-01-02T15:51:20+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: compose_right
|
||||
title: Reverse compose functions
|
||||
tags: function,advanced
|
||||
firstSeen: 2020-01-02T15:51:26+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: count_by
|
||||
title: Count grouped elements
|
||||
tags: list,intermediate
|
||||
firstSeen: 2018-02-07T10:33:47+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: count_occurrences
|
||||
title: Count occurrences
|
||||
tags: list,beginner
|
||||
firstSeen: 2021-01-10T00:00:36+02:00
|
||||
lastUpdated: 2021-01-10T00:00:36+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: cumsum
|
||||
title: Partial sum list
|
||||
tags: list,intermediate
|
||||
firstSeen: 2021-01-13T23:30:41+02:00
|
||||
lastUpdated: 2021-01-13T23:30:41+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: curry
|
||||
title: Curry function
|
||||
tags: function,intermediate
|
||||
firstSeen: 2020-01-02T16:14:50+02:00
|
||||
lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: daterange
|
||||
title: Date range
|
||||
tags: date,intermediate
|
||||
firstSeen: 2020-10-28T16:19:14+02:00
|
||||
lastUpdated: 2021-01-07T23:30:28+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: days_ago
|
||||
title: Days ago
|
||||
tags: date,intermediate
|
||||
firstSeen: 2020-10-28T16:19:30+02:00
|
||||
lastUpdated: 2020-10-28T16:19:30+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: days_diff
|
||||
title: Date difference in days
|
||||
tags: date,beginner
|
||||
firstSeen: 2020-10-28T16:19:39+02:00
|
||||
lastUpdated: 2020-10-28T16:19:39+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: days_from_now
|
||||
title: Days from now
|
||||
tags: date,intermediate
|
||||
firstSeen: 2020-10-28T16:19:51+02:00
|
||||
lastUpdated: 2020-10-28T16:19:51+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: decapitalize
|
||||
title: Decapitalize string
|
||||
tags: string,intermediate
|
||||
firstSeen: 2018-02-01T10:19:59+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: deep_flatten
|
||||
title: Deep flatten list
|
||||
tags: list,recursion,intermediate
|
||||
firstSeen: 2018-01-16T16:54:14+02:00
|
||||
lastUpdated: 2020-12-29T19:53:45+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: degrees_to_rads
|
||||
title: Degrees to radians
|
||||
tags: math,beginner
|
||||
firstSeen: 2019-10-15T14:31:11+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: delay
|
||||
title: Delayed function execution
|
||||
tags: function,intermediate
|
||||
firstSeen: 2020-01-02T16:24:51+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: dict_to_list
|
||||
title: Dictionary to list
|
||||
tags: dictionary,list,intermediate
|
||||
firstSeen: 2020-10-16T21:24:14+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: difference
|
||||
title: List difference
|
||||
tags: list,beginner
|
||||
firstSeen: 2018-01-20T16:16:44+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: difference_by
|
||||
title: List difference based on function
|
||||
tags: list,function,intermediate
|
||||
firstSeen: 2018-02-08T15:59:27+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: digitize
|
||||
title: Digitize number
|
||||
tags: math,list,beginner
|
||||
firstSeen: 2019-08-20T13:00:27+03:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: drop
|
||||
title: Drop list elements from the left
|
||||
tags: list,beginner
|
||||
firstSeen: 2020-03-10T21:59:41+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: drop_right
|
||||
title: Drop list elements from the right
|
||||
tags: list,beginner
|
||||
firstSeen: 2020-03-10T21:59:41+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: every
|
||||
title: Test if every list element is truthy
|
||||
tags: list,intermediate
|
||||
firstSeen: 2019-08-20T11:34:24+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: every_nth
|
||||
title: Every nth element in list
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T13:10:12+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: factorial
|
||||
title: Factorial
|
||||
tags: math,recursion,beginner
|
||||
firstSeen: 2018-01-27T07:29:56+02:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: fahrenheit_to_celsius
|
||||
title: Fahrenheit to Celsius
|
||||
tags: math,beginner
|
||||
unlisted: true
|
||||
firstSeen: 2020-04-05T12:29:03+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: fibonacci
|
||||
title: Fibonacci
|
||||
tags: math,list,intermediate
|
||||
firstSeen: 2018-10-06T06:06:33+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: filter_non_unique
|
||||
title: Filter non-unique list values
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T13:13:51+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: filter_unique
|
||||
title: Filter unique list values
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-10-02T20:06:24+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find
|
||||
title: Find matching value
|
||||
tags: list,beginner
|
||||
firstSeen: 2020-03-10T22:38:48+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find_index
|
||||
title: Find matching index
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-03-10T22:38:48+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find_index_of_all
|
||||
title: Find all matching indexes
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-10-11T13:45:19+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find_key
|
||||
title: Find key of value
|
||||
tags: dictionary,intermediate
|
||||
firstSeen: 2020-04-16T19:13:20+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find_keys
|
||||
title: Find keys with value
|
||||
tags: dictionary,intermediate
|
||||
firstSeen: 2020-04-16T19:17:13+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find_last
|
||||
title: Find last matching value
|
||||
tags: list,beginner
|
||||
firstSeen: 2020-03-10T22:38:48+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find_last_index
|
||||
title: Find last matching index
|
||||
tags: list,beginner
|
||||
firstSeen: 2020-03-10T22:38:48+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: find_parity_outliers
|
||||
title: Find parity outliers
|
||||
tags: list,math,intermediate
|
||||
firstSeen: 2020-01-08T18:54:35+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: flatten
|
||||
title: Flatten list
|
||||
tags: list,intermediate
|
||||
firstSeen: 2019-09-19T15:46:10+03:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: for_each
|
||||
title: Execute function for each list element
|
||||
tags: list,beginner
|
||||
firstSeen: 2020-03-15T12:54:08+02:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: for_each_right
|
||||
title: Execute function for each list element in reverse
|
||||
tags: list,beginner
|
||||
firstSeen: 2020-03-15T12:54:08+02:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: frequencies
|
||||
title: Value frequencies
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-03-15T12:54:08+02:00
|
||||
lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: from_iso_date
|
||||
title: Date from ISO format
|
||||
tags: date,intermediate
|
||||
firstSeen: 2020-10-28T16:20:04+02:00
|
||||
lastUpdated: 2021-01-07T23:30:28+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: gcd
|
||||
title: Greatest common divisor
|
||||
tags: math,beginner
|
||||
firstSeen: 2018-01-08T16:26:35+02:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
---
|
||||
title: geometric_progression
|
||||
title: Geometric progression
|
||||
tags: math,list,intermediate
|
||||
firstSeen: 2020-10-04T12:19:28+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
---
|
||||
|
||||
Initializes a list containing the numbers in the specified range where `start` and `end` are inclusive and the ratio between two terms is `step`.
|
||||
Returns an error if `step` equals `1`.
|
||||
|
||||
- Use `range()`, `math.log()` and `math.floor()` and a list comprehension to create a list of the appropriate length, applying the step for each element.
|
||||
- Returns an error if `step` equals `1`.
|
||||
- Omit the second argument, `start`, to use a default value of `1`.
|
||||
- Omit the third argument, `step`, to use a default value of `2`.
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: get
|
||||
title: Get nested value
|
||||
tags: dictionary,list,intermediate
|
||||
firstSeen: 2020-10-28T12:21:39+02:00
|
||||
lastUpdated: 2020-10-28T12:21:39+02:00
|
||||
@ -11,7 +11,7 @@ Retrieves the value of the nested key indicated by the given selector list from
|
||||
- Apply `operator.getitem()` for each key in `selectors`, retrieving the value to be used as the iteratee for the next iteration.
|
||||
|
||||
```py
|
||||
from functools import reduce
|
||||
from functools import reduce
|
||||
from operator import getitem
|
||||
|
||||
def get(d, selectors):
|
||||
@ -23,7 +23,7 @@ users = {
|
||||
'freddy': {
|
||||
'name': {
|
||||
'first': 'fred',
|
||||
'last': 'smith'
|
||||
'last': 'smith'
|
||||
},
|
||||
'postIds': [1, 2, 3]
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: group_by
|
||||
title: Group list elements
|
||||
tags: list,dictionary,intermediate
|
||||
firstSeen: 2019-08-20T13:29:00+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: hamming_distance
|
||||
title: Hamming distance
|
||||
tags: math,intermediate
|
||||
firstSeen: 2021-01-17T13:04:06+02:00
|
||||
lastUpdated: 2021-02-18T14:22:25+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: has_duplicates
|
||||
title: Check for duplicates in list
|
||||
tags: list,beginner
|
||||
firstSeen: 2018-04-01T11:03:09+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: have_same_contents
|
||||
title: Check lists have same contents
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-03-15T12:54:08+02:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: head
|
||||
title: List head
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T14:08:52+03:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: hex_to_rgb
|
||||
title: Hex to RGB
|
||||
tags: string,math,intermediate
|
||||
firstSeen: 2020-09-13T01:08:21+03:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: in_range
|
||||
title: Number in range
|
||||
tags: math,beginner
|
||||
firstSeen: 2019-08-20T13:41:40+03:00
|
||||
lastUpdated: 2020-09-15T16:13:06+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: includes_all
|
||||
title: List includes all values
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-03-15T12:54:08+02:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: includes_any
|
||||
title: List includes any values
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-03-15T12:54:08+02:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: index_of_all
|
||||
title: All indexes of value
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-10-11T13:40:42+03:00
|
||||
lastUpdated: 2020-10-11T13:45:19+03:00
|
||||
@ -16,5 +16,5 @@ def index_of_all(lst, value):
|
||||
|
||||
```py
|
||||
index_of_all([1, 2, 1, 4, 5, 1], 1) # [0, 2, 5]
|
||||
index_of_all([1, 2, 3, 4], 6) # []
|
||||
index_of_all([1, 2, 3, 4], 6) # []
|
||||
```
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: initial
|
||||
title: List without last element
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T14:08:52+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: initialize_2d_list
|
||||
title: Initialize 2D list
|
||||
tags: list,intermediate
|
||||
firstSeen: 2019-10-25T10:11:51+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: initialize_list_with_range
|
||||
title: Initialize list with range
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T15:21:41+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: initialize_list_with_values
|
||||
title: Initialize list with values
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T14:12:06+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: intersection
|
||||
title: List intersection
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T15:14:26+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: intersection_by
|
||||
title: List intersection based on function
|
||||
tags: list,function,intermediate
|
||||
firstSeen: 2019-08-20T15:16:27+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: invert_dictionary
|
||||
title: Invert dictionary
|
||||
tags: dictionary,intermediate
|
||||
firstSeen: 2020-04-07T21:13:32+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_anagram
|
||||
title: String is anagram
|
||||
tags: string,intermediate
|
||||
firstSeen: 2018-10-01T13:17:29+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_contained_in
|
||||
title: List is contained in other list
|
||||
tags: list,intermediate
|
||||
firstSeen: 2020-03-16T19:48:15+02:00
|
||||
lastUpdated: 2021-01-07T23:30:28+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_divisible
|
||||
title: Number is divisible
|
||||
tags: math,beginner
|
||||
unlisted: true
|
||||
firstSeen: 2019-08-20T14:19:55+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_even
|
||||
title: Number is even
|
||||
tags: math,beginner
|
||||
unlisted: true
|
||||
firstSeen: 2019-08-20T14:21:44+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_odd
|
||||
title: Number is odd
|
||||
tags: math,beginner
|
||||
unlisted: true
|
||||
firstSeen: 2019-08-20T14:21:44+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_prime
|
||||
title: Number is prime
|
||||
tags: math,intermediate
|
||||
firstSeen: 2020-10-03T18:03:32+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
@ -15,7 +15,7 @@ Checks if the provided integer is a prime number.
|
||||
from math import sqrt
|
||||
|
||||
def is_prime(n):
|
||||
if n <= 1 or (n % 2 == 0 and n > 2):
|
||||
if n <= 1 or (n % 2 == 0 and n > 2):
|
||||
return False
|
||||
return all(n % i for i in range(3, int(sqrt(n)) + 1, 2))
|
||||
```
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_weekday
|
||||
title: Date is weekday
|
||||
tags: date,beginner
|
||||
firstSeen: 2020-10-28T16:20:18+02:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
@ -15,7 +15,7 @@ Checks if the given date is a weekday.
|
||||
from datetime import datetime
|
||||
|
||||
def is_weekday(d = datetime.today()):
|
||||
return d.weekday() <= 4
|
||||
return d.weekday() <= 4
|
||||
```
|
||||
|
||||
```py
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: is_weekend
|
||||
title: Date is weekend
|
||||
tags: date,beginner
|
||||
firstSeen: 2020-10-28T16:20:27+02:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
@ -15,7 +15,7 @@ Checks if the given date is a weekend.
|
||||
from datetime import datetime
|
||||
|
||||
def is_weekend(d = datetime.today()):
|
||||
return d.weekday() > 4
|
||||
return d.weekday() > 4
|
||||
```
|
||||
|
||||
```py
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: kebab
|
||||
title: Kebabcase string
|
||||
tags: string,regexp,intermediate
|
||||
firstSeen: 2019-08-21T08:59:54+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: key_in_dict
|
||||
title: Key in dictionary
|
||||
tags: dictionary,beginner
|
||||
firstSeen: 2020-10-16T21:30:49+03:00
|
||||
lastUpdated: 2020-10-16T21:30:49+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: key_of_max
|
||||
title: Key of max value
|
||||
tags: dictionary,beginner
|
||||
firstSeen: 2021-01-07T23:15:48+02:00
|
||||
lastUpdated: 2021-01-07T23:15:48+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: key_of_min
|
||||
title: Key of min value
|
||||
tags: dictionary,beginner
|
||||
firstSeen: 2021-01-07T23:15:48+02:00
|
||||
lastUpdated: 2021-01-07T23:15:48+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: keys_only
|
||||
title: Dictionary keys
|
||||
tags: dictionary,list,beginner
|
||||
firstSeen: 2018-04-01T23:56:31+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: km_to_miles
|
||||
title: Km to miles
|
||||
tags: math,beginner
|
||||
unlisted: true
|
||||
firstSeen: 2020-10-04T00:23:49+03:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: last
|
||||
title: Last list element
|
||||
tags: list,beginner
|
||||
firstSeen: 2019-08-20T15:11:47+03:00
|
||||
lastUpdated: 2020-11-02T19:28:05+02:00
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
title: lcm
|
||||
title: Least common multiple
|
||||
tags: math,list,intermediate
|
||||
firstSeen: 2018-01-08T22:30:17+02:00
|
||||
lastUpdated: 2020-11-02T19:31:15+02:00
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: longest_item
|
||||
title: Longest item
|
||||
tags: list,string,intermediate
|
||||
firstSeen: 2019-08-20T15:27:49+03:00
|
||||
lastUpdated: 2021-10-17T18:24:43+02:00
|
||||
---
|
||||
|
||||
Takes any number of iterable objects or objects with a length property and returns the longest one.
|
||||
Takes any number of iterable objects or objects with a length property and returns the longest one.
|
||||
|
||||
- Use `max()` with `len()` as the `key` to return the item with the greatest length.
|
||||
- If multiple items have the same length, the first one will be returned.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user