Python script for optimization of calendar schedule