0% found this document useful (0 votes)
213 views4 pages

Questions For Codechef Contest

The document contains 20 questions for a CodeChef contest. The questions cover a range of programming challenges including: writing a number guessing game; subtracting numbers without the minus operator; sorting and manipulating lists; string manipulation problems including checking passwords, deleting characters, and swapping cases; FizzBuzz; checking if two strings are anagrams; multiplying NumPy matrices; printing combinations and patterns.

Uploaded by

Vsno Sngh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
213 views4 pages

Questions For Codechef Contest

The document contains 20 questions for a CodeChef contest. The questions cover a range of programming challenges including: writing a number guessing game; subtracting numbers without the minus operator; sorting and manipulating lists; string manipulation problems including checking passwords, deleting characters, and swapping cases; FizzBuzz; checking if two strings are anagrams; multiplying NumPy matrices; printing combinations and patterns.

Uploaded by

Vsno Sngh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

QUESTIONS FOR CODECHEF CONTEST

1) Write a program to create a number guessing game between a


particular range of numbers with maximum 4 attempts to
guess the correct number.

2) Write a program to subtract two numbers without using minus


(-) operator in whole program.

3) Write a program to first print all the outcomes obtained by


rolling two dice simultaneously in a matrix (two dimensional
list) format and then after extracting all the duplets from the
matrix print the sum of all the duplets in ascending order.

4) Write a program to print all the permutations that can be


formed by a string using iterative statements.

5) Write a program to solve the following problem :-

6) You are given an array prices where prices[i] is the price of a given stock
on the ith day.You want to maximize your profit by choosing a single day
to buy one stock and choosing a different day in the future to sell that
stock.Return the maximum profit you can achieve from this transaction.
If you cannot achieve any profit, return  0.

7) .Write a program that can convert a 4 by 4 2D list to 1D list and


then sort that 1D list.
8) Write a python program to find the max item from a list
without using the max function.

9) Write a python program to remove all the duplicates from a


list.

10) Write a program to check if a list is in ascending order or


not if it is in ascending order than convert it into descending
order if not than convert it into ascending order.

11) Write a program to make a new string with all the


consonents deleted from the string "Hello, have a good day".

12) Write a Python program to get a string from a given string


where all occurrences of its first char have been changed to '$',
except the first char itself.

13) Write a Python program to swap cases of a given string.


a. pYTHON
b. eXERCISES
c. jAVA
d. nUMpY

14) Write a Python program which iterates the integers from


1 to 50. For multiples of three print "Fizz" instead of the
number and for the multiples of five print "Buzz". For numbers
which are multiples of both three and five print "FizzBuzz".

15) Write a Python program to check the validity of a


password (input from users). Validation :
a. At least 1 letter between [a-z] and 1 letter between [A-Z].
b. At least 1 number between [0-9].
c. At least 1 character from [$#@].
d. Minimum length 6 characters.
e. Maximum length 16 characters.

16) Ask user to enter age, sex ( M or F ), marital status ( Y or N


) and then using following rules print their place of service.

a. If employee is female, then she will work only in urban areas.


b. If employee is a male and age is in between 20 to 40 then he may
work in anywhere.
c. If employee is male and age is in between 40 t0 60 then he will
work in urban areas only.
d. And any other input of age should print "ERROR".

17) Write a program to check if the two strings entered by


user are anagrams or not using sorted() function. Two words
are said to be anagrams if the letters of one word can be
rearranged to form the other word. For example, jaxa and ajax
are anagrams of each other.

18) Write a program to multiply 2 NumPy array matrices.

19) Write a program to print all possible combinations from


the three digits.

20) Write a Program to print the alphabet pattern “O”.

* * *
* *
* *
* *
* *
* * *

You might also like