edvakf
|
codepad
|
|
edvakf
|
Saved pastes by edvakf:
import List (sort)
solveCoin :: Integer -> [Integer] -> [[Integer]]
solveCoin total coins =
let coins' = reverse $ sort coins
|
view (19 lines, 1 line of output) |
bubbleSort :: Ord a => [a] -> [a]
bubbleSort = bubbleSortBy compare
bubbleSortBy :: Ord a => (a -> a -> Ordering) -> [a] -> [a]
bubbleSortBy _ [] = []
|
view (16 lines, 1 line of output) |
bubbleSort :: Ord a => [a] -> [a]
bubbleSort = bubbleSortBy compare
bubbleSortBy :: Ord a => (a -> a -> Ordering) -> [a] -> [a]
bubbleSortBy cmp xs = bubbleSortBy' cmp xs []
|
view (18 lines, 1 line of output) |
import List
-- shell sort
shellSort :: Ord a => [a] -> [a]
shellSort = shellSortBy compare
|
view (43 lines, 1 line of output) |
mergeSort :: Ord a => [a] -> [a]
mergeSort = mergeSortBy compare
mergeSortBy :: Ord a => (a -> a -> Ordering) -> [a] -> [a]
mergeSortBy _ [] = []
|
view (25 lines, 1 line of output) |
mergeSort :: Ord a => [a] -> [a]
mergeSort = mergeSortBy compare
mergeSortBy :: Ord a => (a -> a -> Ordering) -> [a] -> [a]
mergeSortBy cmp xs = mergeSortBy' cmp xs $ length xs
|
view (23 lines, 1 line of output) |
mergeSort :: Ord a => [a] -> [a]
mergeSort = mergeSortBy compare
mergeSortBy :: Ord a => (a -> a -> Ordering) -> [a] -> [a]
mergeSortBy cmp [] = []
|
view (25 lines, 1 line of output) |
import List
insertionSort :: Ord a => [a] -> [a]
insertionSort = insertionSortBy compare
|
view (10 lines, 1 line of output) |
insertionSort p [] = []
insertionSort p (x:xs) = fst $ foldl (\(os,m) n -> if not (p m n) then ((insert p os n), m) else (os++[n], n)) ([x], x) xs
insert p os u = ls ++ (u:hs)
where
|
view (8 lines, 1 line of output) |
insertionSort p [] = []
insertionSort p (x:xs) = fst $ foldl (\(os,m) n -> if m > n then ((insert p os n), m) else (os++[n], n)) ([x], x) xs
insert p os u = ls ++ (u:hs)
where
|
view (8 lines, 1 line of output) |
insertionSort p [] = []
insertionSort p (x:xs) = fst $ foldl (\(os,m) n -> if m > n then ((insert p os n), m) else (os++[n], n)) ([x], x) xs
insert p os u = ls ++ (u:hs)
where
|
view (8 lines, 1 line of output) |
insertionSort [] = []
insertionSort (x:xs) = fst $ foldl (\(os,m) n -> if m > n then ((insert os n), m) else (os++[n], n)) ([x], x) xs
insert os u = ls ++ (u:hs)
where
|
view (8 lines, 1 line of output) |
insertionSort :: (Ord a) => (a -> a -> Bool) -> [a] -> [a]
insertionSort p [] = []
insertionSort p (x:xs) = insertionSort' [x] xs
where
insertionSort' os [] = os
|
view (26 lines, 1 line of output) |
insertionSort :: (Ord a) => (a -> a -> Bool) -> [a] -> [a]
insertionSort p [] = []
insertionSort p (x:xs) = insertionSort' [x] xs
where
insertionSort' os [] = os
|
view (26 lines, 1 line of output) |