October 27th, 2012, 01:02 PM

To Check if a List is Cube Free?
Hey guys,
I need to write a function that when it is sent a list, it will check the list to see if it is cubefree.
This means:
[1,0,1,0,1,0] is not cubefree because 10 three times in a row
[1,0,0,1,1,0,0,1,1,0,0,1] is not cube free because 1001 three times
[1,0,0,1,1,0,0,1,1,0,0,0] is cube free.
Thanks in advance!
Norm
October 27th, 2012, 01:41 PM

I believe I would need to generate all substrings first, then check those?
October 27th, 2012, 02:06 PM

[1,0,0,1,1,0,0,1,1,0,0,0] is cube free.
NO! That list is NOT cube free because
1 appears 3 or more times.
0 appears 3 or more times.
10 appears 3 times.
100 appears 3 times.
[code]
Code tags[/code] are essential for python code and Makefiles!
October 27th, 2012, 02:07 PM

I believe you're clueless.
[code]
Code tags[/code] are essential for python code and Makefiles!
October 27th, 2012, 02:12 PM

Originally Posted by b49P23TIvg
I believe you're clueless.
Actually, you are clueless. Cubefree means it does not appear three times IN A ROW. Almost any sequence would not be cube free if what you were saying were true...
October 27th, 2012, 03:09 PM

I can define an infinite number of "cube free" sequences. All arrangements of the counting numbers are an infinite number of infinite length "cube free" sequences.
[code]
Code tags[/code] are essential for python code and Makefiles!
October 27th, 2012, 03:12 PM

Originally Posted by b49P23TIvg
I can define an infinite number of "cube free" sequences. All arrangements of the counting numbers are an infinite number of infinite length "cube free" sequences.
Of course you could, but if you do not know how to write the program, then who cares, go help someone else because you are no help here.
October 27th, 2012, 06:12 PM

This may not be the most efficient solution, but one approach:  A list L of length 3*n is a perfect cube if and only if L[:n] == L[n:2*n] and L[n:2*n] == L[2*n:].
 A list L is not cubefree if and only if L[a:a+3*n] is a perfect cube for some values of a and n.
You can turn those observations directly into a forloop.