you're reading...

Clojure Programming Quiz #2

Write a functional Clojure program to determine the number of binary necklaces of length n. Your program should include a function that will generate a sequence of all length-n binary necklaces.

Here is a link to the integer sequence of the count of binary necklaces: https://oeis.org/A00031

As discussed in class, one approach is  to write a function ‘rotation-class’, that will take a binary chain as a single argument and return a sequence containing all chains that are equivalent to the argument under rotation. By comparing each element in the rotation-class to the original chain (using map and compare functions) you should determine if the chain is a unique representative for the class (as say the smallest or largest lexicographically).

Produce a graph of the function f [n] – > # binary necklace / (2^n /n) . As discussed in class, the value of f should alway be between 1 < f(n) < n.



No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: