code:https://ide.codingblocks.com/s/227345 pl debug,
check out this solution crisp and understandable