Artificial Intelligence Programs For Programming in Python

Traveling Salesman Problem ( TSP )] Artificial Intelligence Programs For Master Leval Programming in Python from iter tools import permutations def distance(point1, point2): >>> distance([3,4],[0,0]) 5.0 >>> distance([3,6],[10,6]) 7.0 return ((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) ** 0.5 def total_distance(points): all the points are in the given order. >>> total_distance([[1,2],[4,6]]) 5.0 >>> total_distance([[3,6],[7,6],[12,6]]) 9.0 return sum([distance(point, points[index + 1]) for index, point in enumerate(points[:-1])]) def travelling_salesman(points, start=None): Time complexity is O(N!), so never use on long lists. >>> travelling_salesman([[0,0],[10,0],[6,0]]) ([0, 0], [6, 0], [10, 0]) >>> travelling_salesman([[0,0],[6,0],[2,3],[3,7],[0.5,9],[3,5],[9,1]]) ([0, 0], [6, 0], [9, 1], [2, 3], [3, 5], [3, 7], [0.5, 9]) """ if the start is None: start = points[0] return min([perm for perm ...

How to Create a calculator in PHP - codingonly4u

How to Create a calculator in PHP
How to create calculator in php
Calculator in PHP


Create php file and run into wamp

<form>
    <table>
        <tr>
            <td>Value 1</td>
            <td colspan="3">
                <input type="text" name="txt1" <?php if(isset($_REQUEST[ "txt1"])){echo " value='".$_REQUEST[ "txt1"]. "'";} ?>></td>
        </tr>
        <tr>
            <td>Value 2</td>
            <td colspan="3">
                <input type="text" name="txt2" <?php if(isset($_REQUEST[ "txt2"])){echo " value='".$_REQUEST[ "txt2"]. "'";} ?>></td>
        </tr>
        <tr>
            <td>Answer</td>
            <td colspan="3">
                <input type="text" name="txtans" <?php if(isset($_REQUEST[ "submit"])) { if($_REQUEST[ "submit"]=="+" ) echo " value='".($_REQUEST[ "txt1"]+$_REQUEST[ "txt2"]). "'"; elseif($_REQUEST[ "submit"]=="-" ) echo " value='".($_REQUEST[ "txt1"]-$_REQUEST[ "txt2"]). "'"; elseif($_REQUEST[ "submit"]=="*" ) echo " value='".($_REQUEST[ "txt1"]*$_REQUEST[ "txt2"]). "'"; elseif($_REQUEST[ "submit"]=="/" ) echo " value='".($_REQUEST[ "txt1"]/$_REQUEST[ "txt2"]). "'"; } ?> >
            </td>
        </tr>
        <tr align="center">
            <td>
                <input type="Submit" name="submit" value="+">
            </td>
            <td>
                <input type="Submit" name="submit" value="-">
            </td>
            <td>
                <input type="Submit" name="submit" value="*">
            </td>
            <td>
                <input type="Submit" name="submit" value="/">
            </td>
        </tr>
    </table>
</form>

Comments

Post a Comment

Popular posts from this blog

MongoDB Exercises Practice Solution Exercise First

Simple Basic Commands For MongoDB

Artificial Intelligence Programs For Programming in Python