This file contains hidden or 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
{- | |
Based on | |
- https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/guide-to-ghc-extensions/list-and-comprehension-extensions | |
-} | |
{-# LANGUAGE ParallelListComp, TransformListComp #-} | |
f :: (Num a, Ord a) => [a] -> [a] -> [(a, a)] | |
f xs ys = [(x, y) | x <- xs, | |
then (filter (\z -> z > 10)) |
This file contains hidden or 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
{- | |
The file is based on: | |
https://ocharles.org.uk/blog/guest-posts/2014-12-07-list-comprehensions.html | |
-} | |
{-# LANGUAGE TransformListComp, RecordWildCards #-} | |
import GHC.Exts (groupWith, the) | |
import Data.Ord (comparing) | |
import Data.List (sortBy) |
This file contains hidden or 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 random import randint as ri, shuffle | |
width, height = 5, 5 | |
ship_count = 5 | |
try_count = 5 | |
class NotOnTable(Exception): | |
pass | |
def guess(row, col): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Showing the relationship graph for question {{n}}</title> | |
<style> | |
#graph-container { | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; |
This file contains hidden or 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
""" The problem description: | |
Given a Data Structure having first n integers and next n chars. | |
A = i1 i2 i3 ... iN c1 c2 c3 ... cN.Write an in-place algorithm | |
to rearrange the elements of the array ass A = i1 c1 i2 c2 ... in cn | |
""" | |
def swap(arr, ind1, ind2): |
This file contains hidden or 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
""" Solver logic for https://boardgamegeek.com/boardgame/1198/set """ | |
from random import shuffle | |
from itertools import product, combinations | |
revd = [ | |
["one", "two", "three"], | |
["red", "green", "blue"], | |
["empty", "half", "full"], | |
["ellipse", "rectangle", "wavy"]] |
This file contains hidden or 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
import java.util.Date; | |
import java.text.SimpleDateFormat; | |
SimpleDateFormat formatter = new SimpleDateFormat( "yyyyMMddHHmmss" ); | |
return formatter.format( new java.util.Date() ); |
This file contains hidden or 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 delete(tree, key): | |
remove_node = find(tree, key) | |
if remove_node is None: | |
raise KeyError | |
remove_color = remove_node.color | |
replace_node = None | |
rl, rr, tl = remove_node.left, remove_node.right, tree.leaf | |
if rl == tl and rr == tl: | |
replace_node = tree.leaf | |
transplant(tree, remove_node, tree.leaf) |
This file contains hidden or 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
import numpy as np | |
def gradient_descent(x, y, alpha, rounds): | |
z = np.ones(x.shapes[1]) | |
for _ in xrange(rounds): | |
z = z - alpha * np.dot(np.dot(X, z) - y, X) | |
return z |