This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum67(nums): | |
return sum(map(lambda inums: reduce(lambda acc, (x, y): acc + sum(x), [(list(takewhile(lambda x: x != 6, inums)), list(takewhile(lambda x: x != 7, inums))) for _ in range(nums.count(6) + 1)],0) if nums.count(6) else sum(nums), [iter(nums)])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import attrgetter | |
import os | |
from django.db.models import Model | |
from django.core.management.base import BaseCommand | |
from rest_framework.serializers import ModelSerializer | |
from rest_framework.viewsets import ModelViewSet | |
from my_app import serializers, models, views |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import log, floor, ceil | |
is_odd = lambda n: n % 2 | |
is_even = lambda n: not is_odd(n) | |
log2 = lambda n: log(n, 2) | |
is_power_of_2 = lambda n: log2(n) == int(log2(n)) | |
def find_number_of_steps(n): | |
if is_power_of_2(n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from timeit import timeit | |
random_list = ''' | |
from random import randint | |
l = [randint(0, 1000) for _ in range(1000000)] | |
value = 50 | |
''' | |
loop = ''' |