I hereby claim:
- I am abhin4v on github.
- I am abhin4v (https://keybase.io/abhin4v) on keybase.
- I have a public key whose fingerprint is D2AA 0E12 9D4B 6D06 0FC6 4B22 7C91 66A6 F546 5AD5
To claim this, I am signing this object:
| nextGrids :: Grid -> (Grid, Grid) | |
| nextGrids grid = | |
| let (i, first@(Fixed _), rest) = | |
| fixCell | |
| . Data.List.minimumBy (compare `Data.Function.on` (possibilityCount . snd)) | |
| . filter (isPossible . snd) | |
| . zip [0..] | |
| . concat | |
| $ grid | |
| in (replace2D i first grid, replace2D i rest grid) |
| readGrid :: String -> Maybe Grid | |
| readGrid s | |
| | length s == 81 = traverse (traverse readCell) . Data.List.Split.chunksOf 9 $ s | |
| | otherwise = Nothing | |
| where | |
| readCell '.' = Just $ Possible [1..9] | |
| readCell c | |
| | Data.Char.isDigit c && c > '0' = Just . Fixed . Data.Char.digitToInt $ c | |
| | otherwise = Nothing |
| +-------------------------------------+-------------------------------------+-------------------------------------+ | |
| | [123456789] [123456789] [123456789] | [123456789] [123456789] [123456789] | [123456789] 1 [123456789] | | |
| | 4 [123456789] [123456789] | [123456789] [123456789] [123456789] | [123456789] [123456789] [123456789] | | |
| | [123456789] 2 [123456789] | [123456789] [123456789] [123456789] | [123456789] [123456789] [123456789] | | |
| +-------------------------------------+-------------------------------------+-------------------------------------+ | |
| | [123456789] [123456789] [123456789] | [123456789] 5 [123456789] | 4 [123456789] 7 | | |
| | [123456789] [123456789] 8 | [123456789] [123456789] [123456789] | 3 [123456789] [123456789] | | |
| | [123456789] [123456789] 1 | [123456789] 9 [123456789] | [123456789] [123456789] [123456789] | | |
| +-------------------------------------+-------------------------------------+------------------- |
| defmodule CacheServer do | |
| use GenServer | |
| @name CS | |
| ## Client API | |
| def start_link(opts \\ []) do | |
| GenServer.start_link(__MODULE__, :ok, opts ++ [name: CS]) | |
| end |
| defmodule PingPong do | |
| def ping(parent_pid) do | |
| receive do | |
| {_, _, 0} -> send parent_pid, :done | |
| {pid, :pong, n} -> | |
| IO.puts("ping: " <> Integer.to_string(n)) | |
| send pid, {self(), :ping, n-1} | |
| ping parent_pid | |
| end | |
| end |
| module Main where | |
| import Data.List (sort) | |
| import Data.List.Split (chunksOf) | |
| import System.IO.Temp (writeSystemTempFile) | |
| readI :: String -> Int | |
| readI = read | |
| merge :: (Ord a) => [a] -> [a] -> [a] |
| import Control.Arrow ((&&&)) | |
| import Control.Applicative ((<|>)) | |
| import Control.DeepSeq (NFData(..)) | |
| import Control.Monad (foldM) | |
| import Control.Parallel.Strategies (withStrategy, rdeepseq, parBuffer) | |
| import Data.Bits | |
| import Data.Char (isDigit, digitToInt) | |
| import Data.Function (on) | |
| import Data.List (nub, foldl', group, sort) | |
| import Data.Maybe (isJust) |
I hereby claim:
To claim this, I am signing this object:
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| module Transformers where | |
| import Control.Applicative | |
| import Control.Monad | |
| import qualified Data.Char as Char |
| (ns guava-cache | |
| (:refer-clojure :exclude [get]) | |
| (:import [com.google.common.cache Cache CacheBuilder] | |
| (java.util Map))) | |
| (defn create [cache-spec] | |
| (.build (CacheBuilder/from ^String cache-spec))) | |
| (def ^:private nil-sentinal "ABC_NIL_SENTINAL_XYZ") |