### Thread: To Check if a List is Cube Free?

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
15
Rep Power
0

#### 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 cube-free.

This means:
[1,0,1,0,1,0] is not cube-free 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.

Norm
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
15
Rep Power
0
I believe I would need to generate all substrings first, then check those?
3. [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.
4. I believe you're clueless.
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
15
Rep Power
0
Originally Posted by b49P23TIvg
I believe you're clueless.
Actually, you are clueless. Cube-free 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...
6. 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.
7. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
15
Rep Power
0
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.
8. No Profile Picture
Contributing User
Devshed Intermediate (1500 - 1999 posts)

Join Date
Feb 2004
Location
San Francisco Bay
Posts
1,939
Rep Power
1316
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 cube-free 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 for-loop.