Fixed all the bugs, code works as intended, added is integer soulution
function, added a init table solution. need test init solution