Time spent here:

Tuesday, 22 November 2016

need help : chef new relic infrastructure setup recipes

can somebody help me with the chef recipes ..........


name "newrelic_infrastructure" do

run_list(
  "recipe[newrelic_plugins::newrelic_infrastructure]"
)
default_attributes(
  "newrelic" => {
    "license_key"            => "NEW_RELIC_LICENSE_KEY",
    "newrelic_infrastructure" => {
      "install_path"         => "",
      "user"                 => "newrelic"
    }
  }
)
end

Monday, 20 June 2016

PRINT PATTERN NO:3

Problem statement:
Print the pattern.

Input:
9

Output:


code:

#include <stdio.h>

int main()
{
  int n,i,j;
  scanf("%d",&n);
  int k=(n*2)-1;
   int l=1,r=k,mid=(k/2)+1,m1=mid,m2=mid;
  
  for(i=1;i<=n;i++)
   {    for(j=1;j<=k;j++)
          {
              if(j>=l && j<=r)
                 {
                     
                     if(i<(n/2)+1)
                      {
                          if(i!=0 && (j>m1 && j<m2))
                           {
                               printf(" ");
                           }               
                          else
                            printf("*");
                      }
                      else
                        printf("*");
                 }
               else 
                 printf(" ");
          }
   l=l+1;
   r=r-1;
   if(i<mid)
    {m2++; m1--;}
   printf("\n");
  }  
    return 0;
}


Sunday, 19 June 2016

Find the smallest number where the product of the digits is equal to N.

Problem statement:
Given a number N. Find the smallest number where the product of the digits is equal to N.

E.g.:
if N is 8 then output should be 18 because 1*8=8 and not 24 (2*4) or 42 (4*2)

Input:
8

Output:
18

CODE:

#include <stdio.h>

int main()
{
   int n,i,j,arr[100],k=0;
   scanf("%d",&n);
   if(n<10)
     printf("%d",10+n);
   else
    {
        for(i=9;i>1;i--)
        {
            while(n%i==0)
            {
            
                 n=n/i;
                 arr[k]=i;
                 k++;
            
            }
     
           
        }
    if(n>10)
          printf("No Such Number");
    for(j=k-1;j>=0;j--)
            printf("%d",arr[j]);
     
    }
    return 0;

}

OUTPUT:

REVERSE STRING IN SPECIAL ORDER

Problem statement:
Given a string, that contains special character together with alphabets (‘a’ to ‘z’ and ‘A’
to ‘Z’), reverse the string in a way that special characters are not affected.

E.g.:
Input:
str = "a,b$c"

Output:
str = "c,b$a"

Note that $ and, are not moved anywhere.
Only sub-sequence "abc" is reversed

Input:
str = "Ab,c,de!$"

Output:
str = "ed,c,bA!$"

CODE:

#include <stdio.h>
#include<string.h>
int main()
{
    char a[100];
    scanf("%s",a);
    int i=0,j=strlen(a)-1;
    while(1)
        {
        char temp;
        if(i>j)
         { break;}
    if((a[i] >= 65 && a[i]<91  || a[i]>=97 && a[i]<=122) && (a[j] >= 65 && a[j]<91
                    || a[j]>=97 &&a[j]<=122))
          {
              temp=a[i];
              a[i]=a[j];
              a[j]=temp;
              j--;i++;
        }
        if(a[i] < 65 || a[i]>91  && a[i]<97 || a[i]>=122)
           i++;
        if ((a[j] < 65 || a[j]>91  && a[j]<97 || a[j]>=122))
          j--;
     
    
    }
    printf("%s",a);
    return 0;

}


Saturday, 18 June 2016

PRINT THE SUM OF DIAGONALS

Problem statement:
Print the sum of diagonals.
 
E.g.:
Consider the following matrix for n=3
7 8 9
6 1 2
5 4 3
the sum of the diagonal elements is 25 
 
Input: 
5
 
Output:
101

Code:
#include <stdio.h>
int main()
{
    int n,sum,count,itr,i,val;
    scanf("%d",&n);
    if(n%2==0)
    {
                val=1;itr=2; sum=0;count=0;
    }
     else
     {
       val=2;itr=3; sum=1;count=1;
     }
     
      
      
        while(itr <= n)
        {
            for(i=0;i<4;i++)
              {
                 count=count+val;
                 sum=sum+count;
              }
        itr=itr+2;val+=2;
        }
        printf("%d\n",sum);
   
    return 0;
}

OUTPUT:


 

FACTOR FUN.......!!!!1

Problem statement:
To find the factors of the numbers given in an array and to sort the numbers in descending order
according to the factors present in it.

Input:
Given array : 8, 2, 3, 12, 16

Output:
12, 16, 8, 2, 3

Code:
#include <stdio.h>
int main()
{
  int i,j,list[5],count[5],c=0;
  for(i=0;i<5;i++)
    {
        scanf("%d",&list[i]);
        for(j=1;j<list[i]/2;j++)
            {
                if(list[i]%j==0)
                  c++;
            }
            count[i]=c;
            c=0;
       
    }
    for(i=0;i<5;i++)
     {
         for(j=0;j<5;j++)
         {
             if(count[j]<count[j+1])
             {
                 int temp=count[j];
                 count[j]=count[j+1];
                 count[j+1]=temp;
                 temp=list[j];
                 list[j]=list[j+1];
                 list[j+1]=temp;
             }
         }
     }
     for(i=0;i<5;i++)
       printf("%d ",list[i]);
    return 0;

}

PRINT THE PATTERN

Problem statement:
Print the pattern.

Input:
PROGRAM

Output:

P         M
 R      A
   O  R
     G
  O    R
 R       A
P          M

Code:

#include <stdio.h>
#include<string.h>
int main()
{
  char string[100];
   int left,right,length,i,j;
  scanf("%s",string);
  left=0;length=strlen(string);right=length-1;
  for(i=0;i<length;i++)
  {
    
      for(j=0;j<length;j++)
      {
         if(j==left && left==right)
            { printf("%c",string[j]); break;}
          else if(j==left || j==right)
              printf("%c",string[j]);
         else
              printf(" ");
      }
   printf("\n");
   if(i<length/2)
    { left++;right--;}
   else
    { left--;right++;}
  }
  
    return 0;

}