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 ...

PHP Calendar Event Management using Full Calendar WithText File

PHP Calendar Event Management 
php calaender event management in php
Create Event in Calender in PHP

1) Create File index.php

<table border="1" align="center" style="text-align:center;">
<tr>
<th colspan="7">Current Month Calander</th>
</tr>
<tr>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
<th>Sunday</th>
</tr>
<?php
$dayNo=date("N",strtotime("first day of this month"));
$lastDate=date("d",strtotime("last day of this month"));
$temp=0;
$test=1;
for($i=1;$i<=$lastDate;$i++)
{
if($test==1)
echo "<tr>";
if($temp==0)
{
$temp++;
$test=$dayNo;
for($j=1;$j<$dayNo;$j++)
{
echo "<td>&nbsp;</td>";
}
}
echo "<td><a href='Event.php?Date=".$i."'>".$i."</a></td>";
if($test==7)
{
echo "</tr>";
$test=1;
}
else
$test++;
}
?>
</table>


2. NEXT create AddEditEvent.php

<?php
if(!isset($_POST["Date"])){header("Location: index.php");}
if(isset($_POST["Save"]) && isset($_POST["Event"]))
{
$f=$_POST["Date"].".txt";
fwrite(fopen($f,"w"),$_POST["Event"]);
header("location:Event.php?Date=".$_POST["Date"]);
}
echo "<form method='POST'>";
echo "<input type='hidden' name='Date' value='".$_POST["Date"]."'>";
echo "<textarea name='Event' style='height: 75%;width: 100%;'>";
$f=$_POST["Date"].".txt";
if(file_exists($f))
{
$handle=fopen($f,"rb");
$size=filesize($f);
if($size>0) //if file is blank so give error in reading
echo fread($handle,$size);
fclose($handle);
}
echo "</textarea><br>";
echo "<center>";
if($_POST["submit"]=="Add Event")
echo "<input type='submit' name='Save' value='Save'>";
else
echo "<input type='submit' name='Save' value='Update'>";
echo "</center>";
echo "</form>";
?>

3. Create Event.php

<?php
if(!isset($_GET["Date"])){header("Location: index.php");}
echo "<form action='AddEditEvent.php' method='POST'>";
echo "<input type='hidden' name='Date' value='".$_GET["Date"]."'>";
$f=$_GET["Date"].".txt";
if(file_exists($f))
{
echo "<pre style='border-style: double;padding: 5px;'>";
$handle=fopen($f,"rb");
$size=filesize($f);
if($size>0) //if file is blank so give error in reading
echo fread($handle,$size);
echo "</pre>";
echo "<input type='submit' name='submit' value='Edit Event'>";
}
else
{
echo "<input type='submit' name='submit' value='Add Event'>";
}
echo "<br><a href='index.php'>Calander</a>";
echo "</form>";
?>

4.Run in Wamp Localhost

I hope it useful..😉😉😉😉😉

Comments

Popular posts from this blog

MongoDB Exercises Practice Solution Exercise First

Simple Basic Commands For MongoDB

Artificial Intelligence Programs For Programming in Python