ADVERTISEMENT

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Friday 2 September 2016

CSE1002:PP3:Guiding a travelling salesman


Given 'N' cities the possible paths will be the permutation of 'N-1' cities as start and the end city is mentioned(i.e the home city).
The permutations is given by (N-1)!.(factorial of N-1).
-------------------------------------------------------------------------------------------------------------
#include<iostream>
using namespace std;
int fact(int);
int fact(int n)
{
if(n==1)
return 1;
else
{
return n*fact(n-1);
}
}
int main()
{
int n;
cin>>n;
string city[n];
for(int i=0;i<n;i++)
{
cin>>city[i];
}
string home;
cin>>home;
cout<<fact(n-1);
return 0;
}

CSE1002:PP3:Automatic vending machine

#include<iostream>
using namespace std;
class item
{
long id;
long cost;
long stock;
public:
void read()
{
cin>>id;
cin>>cost;
cin>>stock;
}
int check(int n)
{
if(n==id)
return 1;
else
throw(0);
}
int costcheck(int n)
{
if(n>cost)
return 1;
else
throw(0.0);
}
int stockcheck()
{
if(stock>=1)
return 1;
else
throw string("ERROR");
}
void display()
{
 cout<<id;
}


};
int main()
{
int n;
cin>>n;
item I[n];
for(int i=0;i<n;i++)
{
I[i].read();
}
int it,c;
cin>>it;
cin>>c;
int c2=0;
//cout<<"\n";
for(int i=0;i<n;i++)
{
try
{
I[i].check(it);
I[i].costcheck(c);
I[i].stockcheck();
I[i].display();
}
catch(int i)
{
 c2++;
}
catch(double k)
{
 cout<<"Insufficient amount"<<endl;
 break;
}catch(string a)
{
 cout<<"Less stock"<<endl;
 break;
}
}
if(c2==n)
cout<<"Wrong item code";
return 0;
}

CSE1002:PP3:Tender scrutiny using refferrence variable


#include<iostream>
using namespace std;
class vendor
{
long r;
string name;
public:
long v;
void read()
{
 cin>>r;
 cin>>name;
 cin>>v;
}
void display()
{
 cout<<r<<endl;
 cout<<name<<endl;
}
};
vendor * search(vendor * V,int n);
vendor * search(vendor * V,int n)
{
 long min=V->v;
 vendor * A;
 A=V;
 for(int i=0;i<n;i++)
 {
  if(min>V->v)
  {
   min=V->v;
   A=V;
  }
  V++;
 }
 return A;
 
}
int main()
{
 int n;
 cin>>n;
 vendor V[n];
 for(int i=0;i<n;i++)
 {
  V[i].read();
 }
 vendor * MINV=search(&V[0],n);
 MINV->display();
 
 
return 0;
}


CSE1002:PP3:Snake and Ladders

void read_Values(board &b,snakes &snake_Det,ladders &ladder_Det,position &cur_Pos,rolls &r)
{
 cin>>b.row;
 cin>>b.col;
 cin>>snake_Det.num;
 for(int i=0;i<snake_Det.num;i++)
 {
  cin>>snake_Det.st_Grid[i];
  cin>>snake_Det.end_Grid[i];
 }
 cin>>ladder_Det.num;
 for(int i=0;i<snake_Det.num;i++)
 {
  cin>>ladder_Det.st_Grid[i];
  cin>>ladder_Det.end_Grid[i];
 }
 cin>>cur_Pos.row;
 cin>>cur_Pos.col;
 cin>>r.num;
 for(int i=0;i<r.num;i++)
 {
  cin>>r.roll[i];
 }
}
int find_New_Pos(board &b,snakes &snake_Det,ladders &ladder_Det,position &cur_Pos, rolls &r)
{
 for(int i=0;i<r.num;i++)
 {
   int g=(cur_Pos.row-1)*b.col+cur_Pos.col;
      g+=r.roll[i];
      cur_Pos.row=(g/b.col)+1;
      cur_Pos.col=g%b.col;
   g=(cur_Pos.row-1)*b.col+cur_Pos.col;
  for(int i=0;i<snake_Det.num;i++)
  {
  if(snake_Det.st_Grid[i]==g)
  g=snake_Det.end_Grid[i];
  //break;
  }
  for(int i=0;i<ladder_Det.num;i++)
  {
  if(ladder_Det.st_Grid[i]==g)
  g=ladder_Det.end_Grid[i];
  }
  //cout<<cur_Pos.row<<",";
  //cout<<cur_Pos.col<<endl;
      cur_Pos.row=(g/b.col)+1;
      cur_Pos.col=g%b.col;
 }
 return (cur_Pos.row-1)*b.col+cur_Pos.col;
}

CSE1002:PP3:Chess,Carrom,Scrabble

void set::get()
{
 int n;
 cin>>n;
 int i;
 cin.get();
 for(i=0;i<n;i++)
 {
  cin.getline(names[i],20);
 }
 names[i][0]='\0';
}
void set::print() const
{
 int i=0;
 while(names[i][0]!='\0')
 {
  if(i==0)
  cout<<names[i];
  else
  cout<<","<<names[i];
  i++;
 }
 cout<<endl;
 
}
set set::difference(set& a)
{
 set diff;
 int i=0;
 int p=0;
 while(names[i][0]!='\0')
 {
  int j=0;
  int c=0;
 
  while(a.names[j][0]!='\0')
  {
   if(strcmp(names[i],a.names[j])==0)
   {
    c=1;
    break;
   }
   j++;
  }
  if(c!=1)
  {
   strcpy(diff.names[p],names[i]);
   p++;
  }
  i++;
 }
 diff.names[p][0]='\0';
 return diff;
 
}
set set::intersection(set& a)
{
 set diff;
 int i=0;
 int p=0;
 while(names[i][0]!='\0')
 {
  int j=0;
  int c=0;
 
  while(a.names[j][0]!='\0')
  {
   if(strcmp(names[i],a.names[j])==0)
   {
    c=1;
    break;
   }
   j++;
  }
  if(c==1)
  {
   strcpy(diff.names[p],names[i]);
   p++;
  }
  i++;
 }
 diff.names[p][0]='\0';
 return diff;
 
}



Monday 15 August 2016

CSE 1001 : PP2 : Digits Factors

a=input()
n=int(a)
c=0
for i in a[::-1]:
    if(n%int(i)==0):
        c=c+1
        print(i)
if(c==0):
    print("No factors");

CSE 1001 :PP2 : Co Prime ,Mutually Prime

a=int(input())
b=int(input())
flag=0
for p in range(2,min(a,b)):
    if(a%p==0 and b%p==0):
        flag=1;
if(flag==1):
    print("Not coprime")
else:
    print("Coprime")