Friday 1 December 2017

Code Challenge Solutions 5

1.  The FizzBizz Problem


Write a program to print numbers upto n.
With a catch that, if the number is a multiple of 3 print FIZZ
print BIZZ if multiple of 5
and FIZZBIZZ if it is both multiple of 3 and 5.


Program:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,j,k;
    int arr[100];
scanf("%d",&n);
    for(i=0;i<n;i++)
{
arr[i]=i;
}

for(i=1;i<n;i++)
        {
            if((arr[i]%5==0) && (arr[i]%3==0))
            printf("FizzBizz\n");
            else if(arr[i]%5==0)
            printf("Bizz\n");
            else if(arr[i]%3==0)
            printf("Fizz\n");
            else
            printf("%d\n",arr[i]);
        }

    if((n%5==0) && (n%3==0))
            printf("FizzBizz\n");
            else if(n%5==0)
            printf("Bizz\n");
            else if(n%3==0)
            printf("Fizz\n");
            else
            printf("%d\n",n);
    return 0;

}



2. Given two strings,

That may or may not be of the same length, determine the minimum number of character deletions required to make  and  anagrams. Any characters can be deleted from either of the strings.


Program:



#include<bits/stdc++.h>

using namespace std;

int main() {
    string str1,str2;
    getline(cin,str1);
    getline(cin,str2);

    int A[26],B[26],i;
    for(i=0 ; i< 26 ; i++)
        A[i] = B[i] = 0;
    for(i = 0 ; i< str1.length() ; i++)
        A[(int)(str1[i] - 'a')]++;
    for(i = 0 ; i< str2.length() ; i++)
        B[(int)(str2[i] - 'a')]++;
    int outp = 0;
    for(i=0 ; i< 26 ; i++)
    {
        outp = outp + A[i] + B[i] - 2*min(A[i],B[i]);
    }
    cout<<outp<<endl;
    return 0;

}


Monday 13 November 2017

Mahabalipuram - A seventh century Marvel

Situated along the coast of Bay of Bengal, Mahabalipuram Temple is really a marvel.

Ratha Temples (Temples in  the shape of Chariots)


Make Money with Elance (now upwork.com)


Elance.Com, (now UpWork.com) the world's leading platform for online jobs (please contact online support before registering on this website). You can sign up for free on this site. Click on Sign In button at the top right corner of the website.

Next, you have to select if you want to hire people or need work. Just check “I want to Work” and click on Continue button.


Next, you have to select a membership plan. We just need a free basic account, click on the Select button of basic profile.

Fill out the registration form. Check the declaration box and click on Register.


Select type of jobs next, data entry jobs can be found in the Admin Support section.


To complete the registration process they will ask you to verify your E-mail address.


Log in to your mailbox, open the mail received from Elance, and click the blue box “Click to verify your email address”


You will be redirected to a new Elance window and they will prompt you to Start your profile. Click on that button to get started.


You will have to provide a few more details. Click on next to continue.


Next page is Hourly rates and skills. You can upload an image as your profile picture and give tagline and overview.


Confirm your commitment by clicking “Yes, I Take the Pledge” button on the next page.


You will be redirected to your profile. Before proposing for jobs, you should verify your phone number. Click on the link “Verify your contact phone number”


You will receive a call soon from Elance. They will ask you to press # and speak the code displayed on your monitor. You can now apply for jobs by clicking “Find work” from the menu displayed on top.




Make Money Online

Scam free ways to make money online
Sell stock photos
iStockPhoto is just one site that allows you to sell stock photos; there are others. Before you decide to upload your whole album, take note of what’s selling well and try doing something similar. iStockPhoto also works for those who know how to render images; some of their most popular images were created on a computer! Have three stock photos ready for iStockPhoto’s inspection; they will want them when you sign up.
Sell stuff on eBay
Start by selling your own extra stuff. Then, once you get a feel for selling your extra stuff, go door-to-door in nicer neighborhoods in your town. Develop an eye for what will sell and what won’t (old laptops, for instance, could be a gold mine–if you know how to format them to remove previous owner’s personal data.) Sign a contract where you take 25-30% (or more) of the sale. Your customers will be happy to get cash for their old stuff, and you’ll make some good money selling other people’s stuff on eBay.
Become a freelance article writer
It may not pay well, but there is a growing demand for this. Write 200-300 word articles and submit them to article directories. Potential clients include bloggers, marketers, and small businesses. You can write articles in a niche in batches and sell them as a package to one or more clients, or you can offer your services for hire per word or article and let your client give you direction. A foundation of keyword research is important to succeed at this job (unless you’re just taking direction from a client), but keyword research is learnable.
Write articles for magazines or other publications
If you have a background in journalism, or just a passion for it, you can try submitting articles to publications. Don’t just randomly fire off articles, however; have a plan and, preferably, a contact at the publication you wish to submit to. The good news is that there are publications in pretty much any niche you can think of. To see some publications that are hiring, visit Online Writing Jobs, PoeWar Freelance Jobs, and Writing.com.
Transcribe audio files
An easy job; doesn’t pay well, but also a quick way to make some money. Sign up on eLance or oDesk to start, and/or advertise your services in entrepreneur forums. Requires good hearing and a good command of the English language. You may also want to invest in a foot pedal if you plan to transcribe often. Make sure you know how to transcribe interviews before you start your first job.
Write articles on eHow.com
If you understand the basics of keyword research, you can make a good monthly income from eHoweHow pays you a percentage of the ad revenue they make from each “How to” article you create. You can crank out a few articles a day with relative ease. Try this for a month; assuming your article titles match up with what people are searching for in Google, you can make a significant income. The great news is that you write your articles once and get paid month after month. Make money writing for eHow.com.
Write an ebook targeted to people who need help.
The key? Finding people who are in need for the information you provide and then doing good research to find a real solution to their problems. The result? Happy customers whose problem is solved, and money for you. Here are some hints: When were you last in a situation where information would have either saved you a lot of money or a lot of pain? Has someone else close to you been in a situation where they could have used information to avert pain? Think legal, medical, and financial niches.

Work From Home

Become a Freelancer

To start, all you need to do is signup. It's free!Click here to go to the website.


Click on “Work” link at the centre of the website. This will lead you to a screen like below. Select “Sign up with your email address”.

To fill up the registration form, you will be asked to provide a unique username to identify you on your system. You need to provide a valid e-mail address. Also you have to create a password which should be a combination of letters and numeric. You are on the website to find work, so you have to check “Work” box which can be seen under password box. Click on “Create an account” button to complete the registration.


Select your skills. You can search for skills and add them, or click on any skill listed under popular skills.

When you click on a skill, they will suggest more skills based on your first entry. You can add up to 20 skills to your profile. Click on save your skills button.


Next step is to update your profile. A profile in freelancer.in is similar to your CV. You can add any picture as your profile picture

if you are not comfortable in uploading your own picture. When finished, click on update your profile button to continue.

You’ve now finished signing up for your account in freelancer.in
To start using freelancer website, you have to verify your e-mail address. For that, login to your e-mail.



Open e-mail received from Freelancer website. Click on “Verify your e-mail address” button
You will be redirected to a new freelancer window and within 2 seconds you will reach your dashboard automatically. So you have successfully completed your registration and you are now a Freelancer. 










Working in oDesk (UpWork.com)

Working in oDesk



Upwork.com (formerly oDesk) offers the world’s largest, most comprehensive and fastest-growing online workplace. (please contact online support before registering on this website.)




Click on “Sign up” link at the top right corner of the website. This will lead you to a screen like below.


In this case, you are here to find work, so click on “Contractors start here”.


 To fill up the registration form, you will be asked to provide a unique username to identify you on your system. 
You need to provide a valid e-mail address. Also you have to create a password which should be a combination of letters and numeric.
Click on “Get Started” button to complete the registration. You will be redirected to a screen like below.



You see the box in yellow on that page? First step is to “Verify your E-mail”. By this time you should have received an e-mail from ODesk team
 in the address you provided. Go to your mailbox. E-mail we received is shown below.



Complete the verification by clicking on the link in the e-mail. You will be redirected to a new oDesk window
So you have successfully completed your registration and you are now an oDesker.
We are here to complete our profile, so we can use second menu bar, click on “Edit Account Details”  from the drop down menu obtained after clicking 'Profile'.

Below shown is the account details fill up form. First one is choosing a Display Name, you can choose either one of them which ever you like. Second one is “Picture or logo”. You can upload any picture which is less than 500kb as your profile picture by clicking browse button next to the image. Having a profile picture is not necessary. Fill out all other fields. Then click on “Save button”.

You will be redirected to a screen like below.


You can apply for work now.
Click on “Find Jobs” from the tab of “Find Work” menu. Choose a job from the list of jobs given.


You will directed to the page below. Click on “Apply to this Job” and you will be directed to the next page.



Fill out the details needed in the below form and type “ACCEPT” in the below box to enable the “Accept and Apply to this Job” button. Click on “Accept and Apply to this Job” to apply for the job.


If you have completed a project successfully, you will be credited the contract amount in your oDesk account. For withdrawing money, go to Wallet.


First you need to confirm your tax payer status. So select the “W-8BEN Foreign Status Certification” from the first yellow box “Please confirm your taxpayer status. Here you have to do is that you have to type, “ACCEPT” in the below text box as shown below and Click on “ ACCEPT” button and you are done.

There is so many types of withdrawal methods. We will mention Local Funds Transfer (LFT) and Paypal methods. To activate the LFT, Click on Set up now. You will be redirected to next page.


You can view your earnings and other income details on “Transaction History” tab. oDesk will show every transaction you had with the clients in this page.

You can withdraw the amount from “Withdraw” tab. You can choose one withdrawal method and Click on the Withdraw button which only gets enabled after choosing the withdrawal method and the amount you choose.



Amazon Mechanical Turk (Mturk)

Amazon Mechanical Turk


Amazon Mechanical Turk is a web service that provides an on-demand, human workforce to complete jobs that humans can do better than computers, such as recognizing objects in photographs. To sign up, simply click on the “Sign in as a Worker” link from the top-right corner and follow the instructions. The terms used in this website are totally different than other three websites. Here are some examples.



Requester: A Requester is a company or person that creates and submits tasks to Amazon Mechanical Turk for Workers to perform.
Human Intelligence Task: A Human Intelligence Task (HIT) is a task that a Requester submits to Amazon Mechanical Turk for Workers to perform. A HIT represents a single task, for example, "Identify the car color in the photo." Each HIT has a lifetime, specified by the Requester, that determines how long the HIT is available to Workers. A HIT also has an assignment duration, which is the amount of time a Worker has to complete a HIT after accepting it.
Reward: A reward is the money a Requester pay Workers for satisfactory work they do on HITs.
Working in Mturk is simple. After signing in you directly reaches HITs page, where you can search interesting tasks and apply for it. Withdrawal options can be found in the account setting under “Your account” tab.

Make money from home in India


It Is No More A Difficult Task To Find Out The Real Ways How To Make Money Only, Which Are Of Course Scam-Free Ways. Below Are Just a few Of The Suggestions, Out Of Many.

Mturk.com
The Mechanical Turk of Amazon is one of the best ways to earn some extra money online. The earning may not be much but surely there will be few dollars an hour. The sign up is absolutely free here and it takes just a few minutes.
Learn More:

oDesk.com
oDesk is the largest among a number of companies, including Elance and Freelance that intend to hire and manage remote workers. Based in Redwood City, CA, oDesk was founded in 2003.

Learn more:

Freelancer.com
Freelancer.com is an outsourcing marketplace for small business. The platform connects over 3 million employers and freelancers globally from over 234 countries & regions. Through its website, employers can hire freelancers to do work in areas such as software, writing, data entry and design right through to engineering and the sciences, sales and marketing, and accounting & legal services. The average job is under $200.


Learn more:

Elance.com
Elance is one of the many internet virtual marketplaces that allows freelancers and outsourcing companies to come together to work on projects. It is based in California and has been on the web since 1999.


Learn more:

Scam free ways to make money online
There are hundreds of ways to make money online. These 7 top work at home jobs are fast ways to earn money on the Internet.


Learn more:



Code Challenge Solutions 4


1. Hanyu’s Kung Fu Match

Hanyu is glad as his academy of martial arts is chosen to present a warm-up match of Kung Fu at the inaugural ceremony of the Rio Olympics. 
There are 'n' Kung Fu fighters in Hanyu’s academy. 

Hanyu is very particular in selecting two fierce Kung Fu fighters from his academy who are going to put up a thrilling close competitive performance at the ceremony. 
  
For this purpose, he fetches the details of the winning points of all 'n' fighters in his academy and stores it in an array. 
He should now select the two fighters who have scored almost the same win percentages so far, as they would make the audience exhilarating till the end.  
  
Your aim is to help Hanyu find the difference in win percentages between two fighters chosen for the warm-up match. 
                                
Examples: 
Input  :  If n = 4 and winPoints[] = {30,5,20,9} 
Output :  4 

Input Format: 
The first line of the input consists of an integer n, which corresponds to the number of fighters in Hanyu’s academy. Assume that the maximum number of input elements in the array is 50. 
The next 'n' lines in the input corresponding to the winning points of each of the fighter. 
Output Format: 
The output is an integer – difference between two fighters chosen for the warm-up match. 

Refer sample input and output for formatting specifications. 

Sample Input1: 
19 
18 
25 
Sample Output1: 


Program


#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,j,n,diff,d;
int a[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
diff=abs(a[0]-a[1]);
for(i=0;i<n-1;i++)

for(j=i+1;j<n;j++)
{
d=abs(a[i]-a[j]);
if(d<diff)
diff=d;
}

printf("%d",diff);
return 0;
}


2. Bhageera And Mowgli


Mowgli Bagheera is teaching mathematics to Mowgli. He has given N integer numbers to Mowgli and asked him “What is the sum of these N numbers?”Mowgli told him that he is not good in numbers yet and he can’t perform this addition operation but if Bagheera allow him to convert each integer into its nearest 10’s multiple, he can tell the sum of those given numbers. For e.g. if the last digit of the number is 5 or more than 5, he will convert it into nearest 10’s multiple that is greater than the given number. If last digit is less than 5, he will convert it into nearest 10’s multiple that is less than the number. After that he will count the sum of all these numbers and tell Bagheera.  Input Format:  First input is an integer N>=0 which is number of elements given. Next input is an array which will hold N number.  Output Format:  Output is also an integer which will hold the sum.  [All text in bold corresponds to input and the rest corresponds to output] Sample Input and Output:  5 11   16   15   24   4 70


Program:

#include <Stdio.h>
#include <conio.h>
main()
{
   int n,u,i,arr[100];
   int sum=0,temp=0;
   scanf ("%d", &n) ;
   for(i=0;i<n;i++)
   {
       scanf("%d", &arr[i]);
   }

   for(i=0;i<n;i++)
   {
       u = arr[i] % 10;
       if(u>=5)
       {
           temp=arr[i]+(10-u);
       }
       else{
        temp=arr[i]-u;
       }
       sum+=temp;
   }
   printf("\n%d",sum);
   return 0;

}





Sunday 12 November 2017

Code Challenge Solutions 3

1. Mahirl and Educational Fair


To make her Event Management company “Amphi Events and Decors” popular among the younger generation, Mahirl planned to conduct “The Great India Education Fair’. This Fair has proved to be a strong and cost-effective marketing platform for the Universities, Colleges, Schools and Education Institutions to reach out very cost-effectively to a larger number of parents and students.

              
There are many popular magazines that review these kinds of educational fairs and rate them.
They rate the fair as “Good” if the total number of people attending the fair is greater than 7000.
They rate the fair as “Outstanding” if both the number of parents attending the fair and the number of students attending the fair is at least 5000. However, if the number of students attending the fair is at least double the number of parents attending the fair, they rate the fair as “Great”.
If the total number of people attending the fair is less than 7001, they rate the fair as “Bad”.
Can you please help them in rating the fair?
Input Format:
Input consists of integers. The first integer corresponds to the number of parents who have attended the fair. The second integer corresponds to the number of students who have attended the fair.
Output Format:
The output consists of a string --- “Bad” or “Good” or “Outstanding” or “Great” or “Invalid Input”.
If any of the 2 input integers are negative, print “Invalid Input”.
Sample Input :
6000
5600
Sample Output :
Outstanding


Program:

#include<stdio.h>
int main()
{
int s,p;
scanf("%d%d",&p,&s);
if((s>=0)&&(p>=0))
{
if(s>=(2*p))
printf("Great");
else if(s>=5000&&p>=5000)
printf("Outstanding");
else if((p+s)>=7000)
printf("Good");
else
printf("Bad");
}
else
printf("Invalid Input");
return 0;
}


2. Watermelon Problem

[A variation of Code Forces Problem]

 
One hot summer day Peter and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that, the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
 
Peter and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs the even number of kilos, at the same time it is not obligatory that the parts are equal. But the difference between the 2 parts should be minimal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out if they can divide the watermelon in the way they want. For sure, each of them should get a part of the positive weight.
 
Input Format
The first (and the only) input line contains integer number w (1 = w = 100) — the weight of the watermelon bought by the boys.
 
Output Format
If the input value is not within the range, print "Invalid Input".
In the first line of the output, print YES, if the boys can divide the watermelon into two parts, each of them weighing an even number of kilos; and NO in the opposite case.
If the first line of the output is YES, the next line of the output consists of 2 integers separated by a space. In case of distinct integers, the smallest number should appear first.
 
Sample Input 1
8
 
Sample Output 1
YES
4 4
 
Sample Input 2
11
 
Sample Output 2
NO
 
Sample Input 3
124
 
Sample Output 3
Invalid Input


Program:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int w,c;
    scanf("%d",&w);
    if((w>=1)&&(w<=100))
    {
        if(w%4==0)
        {

            c=w/2;
            printf("YES");
            printf("\n%d%d",c,c);
        }
        else if(w%2==0)
        {
            c=w/2;
            printf("YES");
            printf("\n%d%d",c+1,c-1);
        }
        else{printf("NO");}
    }
    else
    {
      printf("Invalid Input\n");
    }

    return 0;
}



Code Challenge Solutions 1:

Code Challenge Solutions 2

Code Challenge Solutions 2

1. Emily’s Lucky Awards

Madam Emily often conducts surprise tests for her ‘n’ kids. 
That day too it was a shocking surprise for the kids as Emily announced it no sooner the kids were back from their vacation. 
Evaluating the performances of the kids Emily found the overall result to be very inconsistent as there were positive as well negative scores from the kids. 

However Emily wished to give away lucky awards to the kids in a means to motivate them. She is much fond of number ‘f’. But she couldn’t find any student among ‘n’ students who has scored f marks. 

Hence she decided to give away the awards to the pair of students whose scores sum is f. 

Examples: 
Input  :  If n = 4, scores[] = {1, 5, 7, -1} and Emily’s fond number f = 6. 
Output :  2 
Pair with sum 6 are (1, 5) and (7, -1) 
Let us help Emily determine those pairs of scores.  
  
Input Format: 
The first line of the input consists of an integer, n that corresponds to the number of kids. Assume that the maximum number of input elements in the array is 50. 
The next 'n' lines in the input consists of an integer, which correspond to the scores of kids. 
The next line of the input consists of an integer f, which corresponds to Emily’s fond number. 

Output Format: 
Output is an integer – number of pairs whose sum is equal to fond number. 
Refer sample input and output for formatting specifications. 

Sample Input1: 
-1 
Sample Output1: 
  
Sample Input2: 
Sample Output2: 


Program

#include<string.h>
#include<stdio.h>
int main()
{
int n,f,a[100],c=0,i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&f);
for(i=1;i<n;i++)
{
for(j=1;j<n;j++)
{
if((a[i]+a[j])==f)
{
c++;
}
}}
printf("%d",c);
return 0;
}


2. Special Name Problem

Arvind believes in Numerology a lot and when his first child was born, he consulted the leading numerologist in the city about selecting a name for his child. The numerologist suggested that the name that would be lucky for his child should have the following characteristics --- It should not start with a vowel and it should not end with a vowel and it should contain exactly 1 vowel.
Can you help Arvind in shortlisting the names for his child?
Assume that the maximum length of the name is 30.
Input and Output Format:
Input consists of a string that corresponds to one of the names.
The output consists of a single string that is either yes or no. Output yes if the name can be shortlisted based on the suggested criteria.
Sample Input 1:
Sam
Sample Output 1:
yes
Sample Input 2:
Bame
Sample Output 2:
no

Program


#include<string.h>
#include<stdio.h>
int main()
{
int l,i,a=0;
char name[30];
scanf("%s",name);
l=strlen(name);
for(i=1;i<l-1;i++)
{
if((name[i]=='a')||(name[i]=='e')||(name[i]=='i')||(name[i]=='o')||(name[i]=='u'))
{
a++;
}
}
if((name[0]=='a')||(name[0]=='e')||(name[0]=='i')||(name[0]=='o')||(name[0]=='u'))
printf("\nno");
else if((name[l-1]=='a')||(name[l-1]=='e')||(name[l-1]=='i')||(name[l-1]=='o')||(name[l-1]=='u'))
printf("\nno");
else
if(a==1)
printf("\nyes");
else
printf("\nno");
return 0;
}




More Code challenge Problems and solutions: