Sunday 19 October 2014

Nekops-Nu Sequences

A Nekops-Nu sequence is computed from any sequence of integers by following these rules starting from the first number (left-most number) in the sequence:
Count the number of successive repetitions of the same number.
Output the count and then the number.
Repeat steps 1-3 for the next digit in the sequence
For example, given the sequence “1 2 1 1”, the Nekops-Nu sequence can be computed as:
There is 1 instance of the number 1.
There is 1 instance of the number 2.
There are 2 instances of the number 1.
The new Nekops-Nu sequence is “1 1 1 2 2 1”
The same set of rules can be applied to the resulting sequence to generate more patterns. See the sample
output for further continuations to the example provided.
Task
Write a program that computes the next K instances of the Nekops-Nu sequence for a given sequence of
numbers.
Input
The input will contain:
0 <= Number of iterative sequences to compute, K <= 10
Initial sequence of 1 <= N <= 250
The numbers in the sequence can have any valid 32-bit integer value.
Outpu The output contains one Nekops-Nu sequence per line starting with the initial input sequence and followed by the K sequences computed. The numbers in each sequence are separated by a single space character. To make the output look more interesting, add periods to pad all the sequences (before and after) such that they are centered align with respect to the longest sequence computed. Given the example above, the two sequences were “1 2 1 1” (length 7 characters) and “1 1 1 2 2 1” (length 11 characters). Therefore the output
should show:
..1 2 1 1..
1 1 1 2 2 1
If a specific row and the longest row do not line up (because of odd and even numbers of characters), then
add an extra dot before the sequence as shown in input/output #2, or refer to the following example:
.....9999 9999....
......2 9999......
....1 2 1 9999....
1 1 1 2 1 1 1 9999
(i.e. if the number of characters is even in a specific row, then there should be an extra dot before the
sequence)
Finally, on the last line, output the number of elements found in the last sequence.
Note: There is a newline character at the end of the last line of the output.
Sample Input 1
3 1 2 1 1
Sample Output 1
....1 2 1 1....
..1 1 1 2 2 1..
..3 1 2 2 1 1..
1 3 1 1 2 2 2 1
8
Sample Input 2
1 1 1 1 1 1 1 1 1 1 1
Sample Output 2
1 1 1 1 1 1 1 1 1 1
........10 1.......
2

/* Coding */


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    // input stream of number
    long int number;
    int limit,new_number,i
    int first_number, next_number;
    int count=0;
    cin>>number;
    //predicting how long the number is...
    if( number > 10 && number < 100 )
        {
        limit=number/10;
        new_number=number%10;
        }
    if( number > 100 && number < 1000 )
        {
        limit=number/100;
        new_number=number%100;
        }
    if( number > 1000 && number < 10000 )
        {
        limit=number/1000;
        new_number=number%1000;
        }
     if( number > 10000 && number < 100000 )
        {
        limit=number/10000;
        new_number=number%10000;
        }
     if( number > 100000 && number < 1000000 )
        {
        limit=number/100000;
        new_number=number%100000;
        }
    // limit. control. loop
   
    for(i=0;i<3;i++)
        {
        if( i=0 )
            {
            cout<<"....";
        }
        if( i=1 )
            {
            cout<<"...";
            }
        if( i=2 )
            {
            cout<<"..";
        }
       
        if( new_number > 0 && new_number < 10 )
            {
            first_number=new_number;
            cout<<"1"<<first_number;
            count = count + 2;
        }
        if(new_number > 10 && new_number < 100 )
            {
            first_number=new_number/10;
            //new_number=new_number%10;
            next_number=new_number%10;
            if ( first_number == next_number )
                {
                cout<<"2"<<first_number;
                count = count + 3;
            }
            else
                {
                cout<<"1"<<first_number;
                cout<<"1"<<next_number;
                count = count + 4;
            }
        }
        if(new_number > 100 && new_number < 1000 )
            {
            first_number=new_number/100;
            new_number=new_number%100;
            next_number=new_number/10;
            if ( first_number == next_number )
                {
                cout<<"2"<<first_number;
                count = count + 3;
            }
            else
                {
                cout<<"1"<<first_number;
                cout<<"1"<<next_number;
                count = count + 4;
            }
        }
        if(new_number > 1000 && new_number < 10000 )
            {
            first_number=new_number/1000;
            new_number=new_number%1000;
            next_number=new_number/100;
            if ( first_number == next_number )
                {
                cout<<"2"<<first_number;
                count = count + 3;
            }
            else
                {
                cout<<"1"<<first_number;
                cout<<"1"<<next_number;
                count = count + 4;
            }
        } 
        if(new_number > 10000 && new_number < 100000 )
            {
            first_number=new_number/10000;
            new_number=new_number%10000;
            next_number=new_number/1000;
            if ( first_number == next_number )
                {
                cout<<"2"<<first_number;
                count = count + 3;
            }
            else
                {
                cout<<"1"<<first_number;
                cout<<"1"<<next_number;
                count = count + 4;
            }
        }
        if(new_number > 100000 && new_number < 1000000 )
            {
            first_number=new_number/100000;
            new_number=new_number%100000;
            next_number=new_number/10000;
            if ( first_number == next_number )
                {
                cout<<"2"<<first_number;
                count = count + 3;
            }
            else
                {
                cout<<"1"<<first_number;
                cout<<"1"<<next_number;
                count = count + 4;
            }
        }
        if(i=0)
            {
            cout<<"...."<<endl;
        }
        if(i=1)
            {
            cout<<"..."<<endl;
        }
        if(i=2)
            {
            cout<<".."<<endl;
        }
       
    }
    cout<<count;
      return 0;
}

Wednesday 27 August 2014

Zero Count :) :)

William played a number game with his sister as to count the number of Hole in each of the digit. His sister who is poor in mathematics. We have to help her to count the number of Zeros.

Sample Test Case:
989
4

100
2

1456
1

/* Code to Crack it is */

# include <iostream.h>
# include <conio.h>
int main()
{
 clrscr();
 long int n,sum;
 cin>>n;
 sum=0;
 while(n!=0)
 {
  int r;
  r=n%10;
  //cout<<r;
  if(r==6||r==9||r==0)
       sum=sum+1;
  if(r==8)
       sum=sum+2;
  else
       sum=sum+0;

  r=0;
  n=n/10;
 }
 cout<<sum;
return 00;

ZOHO Interview Process :) :)

Zoho Interview Process
**********************
Zoho which is a multi production company reli on its employees.
Its Interview process goes on long and long tedious process..
but nothing to worry ..
it will be your turing point in life either by giving success or experience
The interview process may occupy two to three days based upon their need...
**************************************
Interview process - My Experience
**************************************
Round 1: 02:15 min extra time will be given 15 min
40 questions full program
first 10 questions will carry 1/2 mark each....
 - just finding the out put of the program
second 5 questions carry 1 mark each
 - simple error predicting and modification of program
third 5 questions carry 1 mark each
 - simple output predicting program
fourth 10 questions carry 1 mark each
 - simple input predicting program
fifth 5 questions carry 1 mark each
 - find out similar programs producing similar outputs
sixth 5 questions carry 1 mark each
 - find the order of function call from the main section to get the output.
Round 2:
Phase I: /* depending upon the number of candidates the number of phases may increase */
Will give you a question paper consists of 3-4 problems
solidly it took 4 hours
After completeion questions will be given to you which may contain other set of questions
i was given the following problems.

1. To calculate the summatiom of odd numbers between the given limit.
Sample test case:
22 55
23 27 29 31 37 41 43 47 51 53
382

2. To odrer the number in Desending order in the manner of their factors.
Sample Test case:
3 13 15 21 5 80
80 21 3 13 15 5

3. To print the number in letters
Sample test case:
121
one hundred and twenty one
33
thirty three
/* END of phase1 in round 2*/
/* I got selected and pass on to phase 2 */
Phase 2: this round just simply follows the phase I principle and question paper follows.
Same here solidly it took 4 hours.
in this round you will not be given all the question at time.
instead you will be given a question by question...
time of completion will also be noted.
1. to print the m x n matrix in the following format.

x x x x x x x
x o o o o o x
x o x x x o x
x o x x x o x
x o o o o o x
x x x x x x x

2. form universsal set of numbers, have to find the subset of number which satisfy the stipulated conditions
Sample test case
{ 1,3,4,5,6,7,9}
3
{1,5} {3,6} {4,5} {1,5,6} {4,5,6} {1,5,9} {4,5,9}

3. to predict the lines whether it is parallal, intersecting or overlapping lines
 with four co ordinators given.

i quit from this stage... :) :)

/*****************/
Make everything simple yaar... :)
dont be complex ...
simple will always be wanted ... :) :)
/************/
All the best do well


Thank you
For reading the post


Wednesday 9 July 2014

Caesar Cipher Encryption and decryption concept

Caesar Cipher Encryption and decryption concept is very essential technique when working with Cryptography. The key values can be set on the basis of the programmers need. Here I have set the default key as 4 here. And my loop will cover 26 alphabets only... Hope it will help you...
*********************************************************************************

import javax.swing.JOptionPane;


public class Caesar_Cipher {

/* It is not needed to show our assumption explicitly */
    private final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
    /* function _encrypt to encrypt the plain text with key value assumed
     * The key value assumed here is _shiftKey=4 indexed in main */
    public String encrypt(String plainText,int shiftKey)
    {
    /*converting to lower case as per the assumption*/
          plainText = plainText.toLowerCase();
          String cipherText="";
          for(int i=0;i<plainText.length();i++)
          {
               int charPosition = ALPHABET.indexOf(plainText.charAt(i));
               /* appending key value to the actual index */
               int keyVal = (shiftKey+charPosition)%26;
               char replaceVal = this.ALPHABET.charAt(keyVal);
               cipherText += replaceVal;
          }
          return cipherText;
    }
    public String decrypt(String cipherText, int shiftKey)
    {
          cipherText = cipherText.toLowerCase();
          String plainText="";
          for(int i=0;i<cipherText.length();i++)
          {
               int charPosition = this.ALPHABET.indexOf(cipherText.charAt(i));
               int keyVal = (charPosition-shiftKey)%26;
               if(keyVal<0)
               {
                     keyVal = this.ALPHABET.length() + keyVal;
               }
               char replaceVal = this.ALPHABET.charAt(keyVal);
               plainText += replaceVal;
          }
          return plainText;
    }
}

class CaesarDemo {
 

public static void main(String args[])
    {
  String plainText = (JOptionPane.showInputDialog("Input Data to encypt:"));
          int shiftKey=4;
       
          Caesar_Cipher cc = new Caesar_Cipher();
       
          String cipherText = cc.encrypt(plainText,shiftKey);
          System.out.println("Your Plain  Text :" + plainText);
          System.out.println("Your Cipher Text :" + cipherText);
       
          String cPlainText = cc.decrypt(cipherText,shiftKey);
          System.out.println("Your Plain Text  :" + cPlainText.replaceAll("z", " "));
    }
}

*****************************Thank You*******************************

Saturday 14 June 2014

DOUBLE POINTER TO REVERSE ARRAY

# include <stdio.h>
# include <conio.h>
display(int *a);
show(int **b);
int main()
{
 clrscr();
 int arr[]={1,2,3};
 for(int i=2;i>=0;i--)
 {
  display(&arr[i]);
 }
 return 00;
}
 display(int *p)
 {
  show(&p);
 }
 show(int **pointer)
 {
  printf("\n %d",**pointer);
 }

 

Friday 24 January 2014

scrolling Tag in html

<html>
<head>
<title> Dragon Scroll </title>
<body bgcolor="pink">
<h1>
<marquee dir="right" > <font color="red" > Dragon warrior will have the dragon Scroll...... !! </font> </marquee>
</h1>
</body>
</html>


Smart Table

<html>
<head>
<title> Table </title>
</head>
<body>
<table border="2">
<tr>
  <th rowspan="2"> S.No </th>
  <th colspan="2"> Name </th>
</tr>
<tr>
  <th> First Name </th>
  <th> Last Name </th>
</tr>
<tr>
 <td> 1 </td>
 <td> TOM </td>
 <td> FARCRY </td>
</tr>
</table>
 </body>
 </html>



Red color link in html

<html>
<head>
<title> Link </title>
</head>
<body bgcolor="blue">
<h1> Exciting
<a href="http://www.wallcg.com" > <Font color="red" size="48"> Wall papers <Font> </a>
</h1>
</body>
</html>



Paragraph tag

<html>
<head>
<title> Sample Paragraph </title>
</head>
<body>
<h1> Internet Protocols </h1>
<p> Protocols are just like guide lines for packet. The Internet Protocol (IP) is the principal communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.
</p>
</body>
</html>


Proper Alingment

<html>
<head>
<title> Proper align </title>
</head>
<body>
<h1> STUDENT DETAIL </h1>
<h5> Name : Tom Farcry </h5>
<h5> Roll NO : 12xyz12 </h5>
<h5> Age : 20 </h5>
<h5> PhoneNo : 1234567890 </h5>
<h5> Address : DownTown street </h5>
</body>
</html>

Nested list ......... ??

<html>
<head>
<title> Nested List </title>
</head>
<body>
<h4>
<ul type="fill round">
 <li> First Year </li>
 <ul type="round">
  <li> Semester I </li>
  <li> Semester II </li>
 </ul>
 <li> Second Year </li>
  <ul type="round">
  <li> Semester III </li>
  <li> Semester IV </li>
  </ul>
 <li> Third Year </li>
  <ul type="round">
   <li> Semester V </li>
   <li> Semester VI </li>
  </ul>
  <li> Fourth year </li>
   <ul type="round">
    <li> Semester VII  </li>
<li> Semester VIII </li>
</ul>
  </ul>
</h4>
 <body>
 </html>


list tag in html

<html>
<head>
<title> Ordered & Unordered List </title>
<body>
<h1>
<ol>
<li> Tom Farcry </li>
<li> Poo </li>
<li> Jacky </li>
<li> Bheem </li>
<li> Moore </li>
<li> Bill Inmann </li>
</ol>
<ul>
<li> Tom Farcry </li>
<li> Poo </li>
<li> Jacky </li>
<li> Bheem </li>
<li> Moore </li>
<li> Bill Inmann </li>
</ul>
</h1>
</body>
</html>



Image in new tab...

when clicking the image it should open in new tab........???

<html>
<head>
<title> Image_NewTab </title>
</head>
<body>
<h1> Make a Click .... </h1>
<a href="http://www.cms2cms.com/wp-content/uploads/2013/10/html-1.jpg" target="_blank">
        <img src="http://www.cms2cms.com/wp-content/uploads/2013/10/html-1.jpg" attributes="#"\>
    </a>
</body>
</html>

to place image at the center of the Web page???

<html>
<head>
<title> Image </title>
</head>
<body>
<center>
<img src="http://www.cms2cms.com/wp-content/uploads/2013/10/html-1.jpg"  alt="HTML">
</center>
</body>
</html>

Frame Tag usage in Html??

/* frame.html*/
<html>
<head>
<title> Frame </title>
</head>

<frameset cols="25%,*,25%">
<frame src="A&V link.html" >
<frame src="abbr.html" >
<frame src="Bg_Red.html">
</frameset>

</html>

/*bg_red.html*/
<html>
<head>
<title> Hello Html...!! </title>
</head>
<body bgcolor=red>
</body>
</html>

/*abbr.html*/
<html>
<head>
<title> abbreviation </title>
</head>
<body>
<h1><abbr title="Internet Protocol and Web technology"> IP/Web </abbr></h1>
</body>
</html>

/*a&v link */
<html>
<head>
<title> A&V link </title>
<body link="green" vlink="violet">
<h1> Exciting
<a href="http://www.wallpaper.com" target="_blank"> Wallpaper </a></h1>
</body>
</html>







Different Attributes of font tag?

<html>
<head>
<title> Font </title>
</head>
<body>
<font face="FoughtKnight Victory" size="24" color="blue" > Hello Html... !! </font>
</body>
</html>



Background Color Changing in Html

<html>
<head>
<title> Hello Html...!! </title>
</head>
<body bgcolor=red>
</body>
</html>





Wednesday 22 January 2014

Simple program to verify abbr tag???

<html>
<head>
<title> abbreviation </title>
</head>
<body>
<h1><abbr title="Internet Protocol and Web technology"> IP/Web </abbr></h1>
</body>
</html>


A&V link

Simple Program to verify A&V link??

<html>
<head>
<title> A&V link </title>
<body link="green" vlink="violet">
<h1> Exciting
<a href="http://www.wallpaper.com" target="_blank"> Wallpaper </a></h1>
</body>
</html>