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 Generate QR Code in PHP with jquery Learn Now

Generate QR Code PHP
How to Generate QR code in PHP?



QR Code Generate in PHP Use Following Code 


1 >> home.php

<?php include "QR_BarCode.php"; $desc = $_POST['desc']; $kishan = ' WayToWeb'; $qr = new QR_BarCode(); $qr->text($desc." ".$kishan); $qr->qrCode();?>


2.>> index.php


<html>

<head>

</head>

<body>

<center>

<form method="post" action="home.php">

<textarea name="desc" cols="50" rows="5"></textarea>
<br>
<input type="submit" name="submit">
</form>
</center>
</body>
</html>

3.>> QR_BarCode.php


<?php

class QR_BarCode{

private $googleChartAPI = 'http://chart.apis.google.com/chart';


private $codeData;


public function url($url = null){
$this->codeData = preg_match("#^https?\:\/\/#", $url) ? $url : "http://{$url}";
}
public function text($text){
$this->codeData = $text;
}
public function email($email = null, $subject = null, $message = null) {
$this->codeData = "MATMSG:TO:{$email};SUB:{$subject};BODY:{$message};;";
}
public function phone($phone){
$this->codeData = "TEL:{$phone}";
}
public function sms($phone = null, $msg = null) {
$this->codeData = "SMSTO:{$phone}:{$msg}";
}
public function contact($name = null, $address = null, $phone = null, $email = null) {
$this->codeData = "MECARD:N:{$name};ADR:{$address};TEL:{$phone};EMAIL:{$email};;";
}
public function content($type = null, $size = null, $content = null) {
$this->codeData = "CNTS:TYPE:{$type};LNG:{$size};BODY:{$content};";
}
public funtion qrCode($size = 200, $filename = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->googleChartAPI);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "chs={$size}x{$size}&cht=qr&chl=" . urlencode($this->codeData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$img = curl_exec($ch);
curl_close($ch);
if($img) {
if($filename) {
if(!preg_match("#\.png$#i", $filename)) {
$filename .= ".png";
}
return file_put_contents($filename, $img);
} else {
header("Content-type: image/png");
print $img;
return true;
}
}

return false;
}
}
?>


Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. Learn PHP

    ReplyDelete

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