Last active
April 13, 2018 01:30
-
-
Save Sophia-Gold/ffaeebe1cc6b5f2121dfd0207a52858a to your computer and use it in GitHub Desktop.
type level `fix` for calculating supernecklace cardinality
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
| {-# LANGUAGE DeriveFoldable #-} | |
| import Data.List | |
| data NList a = [a] :-: (NList [a]) | |
| | Nil deriving (Show, Foldable) | |
| fixT :: NList a -> NList a | |
| fixT Nil = Nil | |
| fixT (x :-: Nil) = x :-: (subsequences x :-: Nil) | |
| fixT (x :-: xs) = x :-: f xs | |
| supernecklaceT degree size = length . last . take (degree - 1) $ iterate fixT (enumFromTo 1 size :-: Nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment