Commit 8cd34c49 authored by rforder's avatar rforder

Ignoring repeated subsequences

parent b6966b0b
......@@ -153,6 +153,26 @@ domino *get_ith_domino(int i, domino *domino_list)
else
return d;
}
int is_repetition(int *sequence, int seq_len)
{
int i, j, k;
if (seq_len == 1) return 0;
for (i = 1; i < seq_len / 2; i++)
{
if (seq_len % i == 0)
{
for (j = 1; j < seq_len / i; j++)
{
for (k = 0; k < i; k++)
{
if (sequence[k] != sequence[j * i + k])
return 0;
}
}
}
}
return 1;
}
int is_accepted(int *sequence, int seq_len, domino *domino_list, char *input)
{
......@@ -208,7 +228,7 @@ int test_seq_length_k(domino *domino_list, int k, char *input)
int i;
while (1)
{
if (is_accepted(seq, k, domino_list, input))
if (!is_repetition(seq, k) && is_accepted(seq, k, domino_list, input))
{
int x;
for (x = 0; x < k; x++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment