Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title>Showing the relationship graph for question {{n}}</title>
<style>
#graph-container {
top: 0;
bottom: 0;
left: 0;
right: 0;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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):
{-
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)
{-
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))
Resolving dependencies...
Configuring aeson-0.11.1.3...
Building aeson-0.11.1.3...
Failed to install aeson-0.11.1.3
Build log ( /home/dani/.cabal/logs/aeson-0.11.1.3.log ):
Configuring aeson-0.11.1.3...
Building aeson-0.11.1.3...
Preprocessing library aeson-0.11.1.3...
[ 1 of 16] Compiling Data.Aeson.Functions ( Data/Aeson/Functions.hs, dist/build/Data/Aeson/Functions.o )
[ 2 of 16] Compiling Data.Aeson.Internal.Time ( Data/Aeson/Internal/Time.hs, dist/build/Data/Aeson/Internal/Time.o )
from random import randint as ri
from sys import argv
d = {}
n = int(argv[1])
for i in xrange(n):
d[i] = ri(1, 100)
import qualified Data.Map as M
import System.Random
import System.Environment
import Control.Monad
insert :: Int -> M.Map Int Int -> [Int] -> M.Map Int Int
insert n m randoms
| n < 1 = m
| otherwise = insert (n - 1) new_map new_randoms
{-# LANGUAGE ViewPatterns #-}
import qualified Data.Sequence as S
import System.Environment
import Control.Monad
data List a = Nil | Cons a (List a)
mylast :: S.Seq a -> Maybe a
mylast (S.viewr -> xs S.:> x) = Just x
-- A spinoff of the Vcard.hs example from http://book.realworldhaskell.org/read/programming-with-monads.html
import Control.Monad
data Context = Home | Mobile | Business
deriving (Eq, Show)
type Phone = String
type Phones = [Phone]
albulena = [(Home, "+35-1234")]