Learning knots and ties