Skip to content

Instantly share code, notes, and snippets.

View andrsGutirrz's full-sized avatar
🏠
Working

Andrés Gutiérrez andrsGutirrz

🏠
Working
View GitHub Profile
@andrsGutirrz
andrsGutirrz / readability_not_sugar.py
Last active September 19, 2021 19:07
Redability_3
def get_laptop_not_sugar(payload: dict) -> List:
response = []
items = payload.get("items")
if items:
for item in items:
memories = item.get("memory", [])
processors = item.get("processor", [])
for memory in memories:
if memory.get("size") == 16:
for processor in processors:
def get_laptop_sugar_2(payload: dict) -> List:
return [i for i in payload.get("items", []) if
{"size": 16} in i.get("memory", []) and [j for j in i.get("processor", []) if
j.get("make", "").upper() == "RYZEN"]]
def get_laptop_sugar_1(payload: dict) -> List:
return list(filter(lambda l:
list(filter(lambda ll: ll.get("size") == 16, l.get("memory", [])))
and
list(filter(lambda ll: ll.get("make", "").upper() == "RYZEN", l.get("processor", [])))
,
payload.get("items", [])))
@andrsGutirrz
andrsGutirrz / payload.json
Last active September 19, 2021 18:53
Readability
{
"items": [
{
"make": "acer",
"model": "aspire",
"screen_size": "17",
"memory": [
{
"size": 8
},