all stats

pyrotelekinetic's stats

guessed the most

namecorrect guessesgames togetherratio

were guessed the most by

namecorrect guessesgames togetherratio

entries

round #15

2 likes

guesses
comments 0

post a comment


bingo.hs ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{-# OPTIONS_GHC -Wno-tabs #-}

import Data.List

type Card = [[(Bool, Int)]]

makeCard :: [[a]] -> [[(Bool, a)]]
makeCard [] = []
makeCard (a : as) = map (\x -> (False, x)) a : makeCard as

horiz :: [[(a, b)]] -> [[a]]
horiz = (map . map) fst

vert :: [[(a, b)]] -> [[a]]
vert = transpose . (map . map) fst

trimColumn :: [[a]] -> [[a]]
trimColumn [] = []
trimColumn a = transpose . tail . transpose $ a

diagL :: [[(a, b)]] -> [a]
diagL [] = []
diagL a = (fst . head . head) a : (diagL $ (trimColumn . tail) a)

diagR :: [[(a, b)]] -> [a]
diagR [] = []
diagR a = (fst . head . last) a : (diagR $ (trimColumn . init) a)

bingos :: [[(a, b)]] -> [[a]]
bingos a = diagL a : diagR a : horiz a ++ vert a

markLine :: [(Bool, Int)] -> Int -> [(Bool, Int)]
markLine (x : xs) i
	| i == snd x = (True, snd x) : xs
	| otherwise = x : markLine xs i

mark :: Card -> Int -> Card
mark c i = map (flip markLine i) c

marks :: Card -> [Int] -> Card
marks c [] = c
marks c (i : is) = marks (mark c i) is

hasBingo :: Card -> Bool
hasBingo c = elem [True, True, True, True, True] (bingos c)

won :: [Bool] -> Int
won a = go 0 a
	where
	go :: Int -> [Bool] -> Int
	go i (b : bs)
		| b = i
		| otherwise = go (i + 1) bs

entry :: [[[Int]]] -> [Int] -> Int
entry cs is = won . map hasBingo . map (flip marks is) $ map makeCard cs

round #14

submitted at
2 likes

guesses
comments 0

post a comment


a.rs ASCII text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
pub fn entry (	
               a : &[f64], b : &[f64]	
             ) -> f64	
                      {	
                        let mut x = 0.0;	
                        for (i, l)	
                        in a . iter() . zip(b . iter())	
                                         {	
                                           x += i * l;	
                                         }	
                        x	
                      }	

round #8

guesses
comments 0

post a comment


bee.py ASCII text
1
2
3
4
5
6
7
8
9
def entry(haystack, needle):
    done = False
    for i in range(0, len(haystack)):
        if haystack[i:i+len(needle)] == needle:
            done = True
            return i
            break
    if not done:
        return -1