Given name last name objects find the person with shortest name.
names = [{'name': 'huseyin', 'last_name': 'yilmaz'}, {'name': 'sila', 'last_name': 'yilmaz'}] get_shortest(names) >>> {'name': 'sila', 'last_name': 'yilmaz'}
(function injected(eventName, injectedIntoContentWindow) | |
{ | |
let checkRequest; | |
/* | |
* Frame context wrapper | |
* | |
* For some edge-cases Chrome will not run content scripts inside of frames. | |
* Website have started to abuse this fact to access unwrapped APIs via a | |
* frame's contentWindow (#4586, 5207). Therefore until Chrome runs content |
from collections import defaultdict | |
def run(): | |
print("RUNNING") | |
return 'val' | |
test = {'store':1} | |
print(test.get('store', run)) | |
print(test.get('not_stored', run)) | |
test2 = defaultdict(run) |
#!/usr/bin/env stack | |
-- stack --install-ghc runghc --package turtle | |
{-# LANGUAGE OverloadedStrings #-} | |
import Turtle | |
import System.Process(callProcess) | |
import qualified Data.Text as Text | |
-- adds virtualenv wrapper to path |
unbind C-b | |
set -g prefix C-q | |
bind-key C-q send-prefix | |
# enable vi keys. | |
# setw -g mode-keys vi | |
# set window split | |
bind-key v split-window -h | |
bind-key s split-window -v |
from collections import Counter | |
def get_unique(ls): | |
uniques = set(i | |
for (i, c) in Counter(ls).iteritems() | |
if c == 1) | |
return next((e for e in ls if e in uniques), None) | |
module Main where | |
-- inserts a to all possible places in list bs | |
-- insert 1 [2,3] -> [[1,2,3], [2,1,3], [2,3,1]] | |
insert :: t -> [t] -> [[t]] | |
insert a [] = [[a]] | |
insert a bs@(b:rest) = (a:bs):fmap (b:) (insert a rest) | |
-- Returns all permitations of given list | |
-- perms [1,2,3] -> [[1,2,3],[2,1,3],[2,3,1],[1,3,2],[3,1,2],[3,2,1]] |
-- https://leetcode.com/problems/rectangle-area/ | |
module Main where | |
import Test.HUnit | |
import Control.Monad(guard) | |
import Data.List(nub) | |
-- Data Types | |
data Point = Point Int Int | |
deriving (Eq, Show) |