SIA algorithm implementation on python