for x in range(4,10): print range(3,x+1,2)+[1]+range(4,x+1,2)+[2]
9
[3, 1, 4, 2] [3, 5, 1, 4, 2] [3, 5, 1, 4, 6, 2] [3, 5, 7, 1, 4, 6, 2] [3, 5, 7, 1, 4, 6, 8, 2] [3, 5, 7, 9, 1, 4, 6, 8, 2]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!