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 select div tag row using JavaScript - Codingonly4u

 

JavaScript selection

Select div tag row using javascript

Set Styles

<style>
.selecttt
{
    background-color: #e5f7ff;
border: 1px solid black;
border-radius: 10px;
width: 100%;
}
details > summary {
  padding: 4px;
  width: 99%;
  background-color: #ffffff;
  border: none;
  box-shadow: 1px 1px 2px #bbbbbb;
  cursor: pointer;
}

details summary > * { 
  display: inline;
}
details summary::before { 
  content:"🡒"; 
  color: blue; 
  /* you can style it however you want, use background-image for example */
}

/* By using [open] we can define different styles when the disclosure widget is open */
details[open] summary::before { 
  content:"🡑"; 
  color: blue; 
}
summary {list-style: none}
summary::-webkit-details-marker {display: none; }
</style>

Set HTML Dynamic Content

        <div class="row animate__animated animate__fadeIn">
<div class="col-md-12">
    <h4 align="center" id="ids">Subject Questions </h4>
</div>
</div>
<div class="row mt-3 animate__animated animate__fadeIn">
<div class="col-md-12">
<?php $j=0; ?>
@foreach($data as $dd)
<?php $j+=1;  ?>
<div class="row">
<div class="col-md-12 ml-4">
@if(count($dd['questions_list']) > 0)
<hr style="margin:3px">
<details>
<summary><label style="font-weight:700">({{$j}}).{{$dd['question_type']}}</label></summary>
<hr style="margin:1px">
<div class="row">
<div class="col-md-9">
<strong>Question</strong>
</div>
<div class="col-md-2">
<strong>Que.MARK</strong>
</div>
</div>
@endif
<?php $i=0; ?>
@foreach($dd['questions_list'] as $v)
<?php $i+=1;  ?>
<div class="row mt-3" >
<div class="col-md-9 quee" qid="{{$v['question_id']}}" id="questionrow_{{$v['question_id']}}">
<label class="custom-control-labels" for="customCheck_{{$v['question_id']}}"> <font style="font-color:blue;font-weight:700">Q.{{$i}}-({{$v['question_id']}})</font> : {!!  html_entity_decode(str_replace('<p>','',str_replace('font-family','',str_replace('font-size','',$v['question_title'])))) !!}</label> 
</div>
<div class="col-md-2 text-center" style="font-color:blue;font-weight:700">
{{$v['question_mark']}}
</div>
<div class="col-md-1 text-center remove" qid="{{$v['question_id']}}" id="remove_{{$v['question_id']}}" style="font-color:red;font-weight:700;display:none">
<i class="fa fa-trash text-danger"></i>
</div>
</div>
@endforeach
</div>
</details>
</div>
@endforeach
<input type="text" value="" name="question_idss" id="question_idss" hidden>
</div>
</div>

note : highlighted part is important for selection of div class's

JavaScript Code For selection of DIV

<script type="text/javascript">
$('#divfix').hide();
const queids = [];
$('.quee').on('click',function(e){
var ques_id = $(this).attr('qid');
if(queids.includes(ques_id))
{
const index2 = queids.indexOf(ques_id);
if (index2 > -1) {
  queids.splice(index2, 1);
}
/*remove css*/
$('#questionrow_'+ques_id).css("background-color", "white");
$('#remove_'+ques_id).hide();
}
else
{
queids.push(ques_id);
/*selected css*/
$('#questionrow_'+ques_id).css("background-color", "#e5f7ff");
$('#questionrow_'+ques_id).css("border-radius", "10px");
$('#remove_'+ques_id).show();
}
var match = queids.join(',');
 
// $('#ids').text(match);
$('#question_idss').val(match);
// alert(match);
});
$('.remove').on('click',function(e){
var remve_ques_id = $(this).attr('qid');
//manage css
$('#questionrow_'+remve_ques_id).css("background-color", "white");
$('#remove_'+remve_ques_id).hide();
const index = queids.indexOf(remve_ques_id);
if (index > -1) {
  queids.splice(index, 1);
}
var matchs = queids.join(',');
//$('#ids').text(matchs);
$('#question_idss').val(match);
});
</script>

Comments

Popular posts from this blog

MongoDB Exercises Practice Solution Exercise First

Simple Basic Commands For MongoDB

Artificial Intelligence Programs For Programming in Python