Anagram is a word or phrase can be formed by rearranging the letters of another word or phrase. For example, carthorse is anagram of horsecars. Blanks within a phrase will be ignored. orchestra and horse cart are also anagrams.
Write a program that reads a list of phrases and print all pairs of anagram is demonstrated as follow (it will not work for upper case and lower case checking , "A" is different from "a" in the current program):
Sample input:
carthorse
horse
horse cart
I do not know u
ok i now donut
orchestra
Sample output:
carthorse = horse cart
carthorse = orchestra
horse cart = orchestra
i do not know u = ok i now donut
Please get the code and sample input file as below (there are both python and c++ version):
Is Anagram Problem
Sunday, September 30, 2018
Sunday, September 16, 2018
AIO Sample question with answer 2: Sitting or Standing?
Please click on the link to get the full question. Sitting or Standing ?
Input File: sitin.txt
Output File: sitout.txtTime Limit: 1 secondInput
Output
A local musician is putting on a concert to raise money for charity. The concert will be held in the town hall, a spacious venue perfectly suited for such an event. There are r rows of seats, each containing exactly s seats. At most one person can sit on a single seat (that is, two people cannot share a seat).
There is a problem - the concert may have been overbooked! This means that if everybody who bought tickets comes to the concert, some of them might have to stand. Now the musician has aproached you, not for advice, but for the answer to the following question: if everybody who bought tickets arrives and tries to find a seat, how many people will end up sitting, and how many people will be standing?
The first line of the input file will consist of the two integers r and s: the number of rows and the number of seats per row in that order. It is guaranteed that 0 <= r, s <= 10,000. The second line will contain a single integer between 0 and 1,000,000,000: the number of tickets that have been bought.
Your output file should consist of two integers separated by a space: the number of people sitting and standing respectively.
Remember, everybody tries to sit if they can. If the concert has been overbooked, you will not be able to seat them all.
I had try the question using Python.
The logic of program should be as below:
- get input data (number of seats per rows, number of rows and number of tickets sold)
- calculate the number of seats in total provided, number of tickets sold, get the number of standing people, number of sitting people
- output the result to file
You may get the code from here python code
or
viewing the python code as follows:
#################################################################################
# open the input file to obtain the number of rows and seats
with open('sitin.txt', 'r') as inputFile1:
mylist = list(inputFile1) # assign the row to list
inputFile1.close() # remember that always close the file
# the input data is optained row by row and is assigned to list
# first list is first line of input file (no.of.rows and seats)
# second list is second line of input file (no.of.tickets sold)
row, seats = mylist[0].split(' ', 1) # split the first element of list to get row and seats per row
tickets = mylist[1] # second row is only have the no.of.tickets sold
# calculate the total number of seats provided
# need to type casting the row and seats to integer datatype
# if number of seats is smaller or equal to number of tickets sold, number of people sitting = number of sets, the rest will be standing
# if number of seats is larger than the tickets solds, number of people sitting equal to number of tickets sold , and no people is standing
noOfSeats = int(row) * int(seats)
noOfTickets = int(tickets)
if noOfSeats <= noOfTickets:
standing = noOfTickets - noOfSeats
seatNo = noOfSeats
else:
seatNo = noOfTickets
standing = 0
# open output file, and write the result into it
# must close the file
outputFile = open('sitout.txt','w')
outputFile.write(str(seatNo) + ' ' + str(standing));
outputFile.close()
Thursday, September 6, 2018
Extra question - whole number
Extra question regarding whole number.
How to do calculation faster and more efficient ?
Download the file and try it!
Whole Number question
How to do calculation faster and more efficient ?
Download the file and try it!
Whole Number question
Sunday, September 2, 2018
AMC 2018 - Shortest distance
The pdf include some basic regarding Eulerian path and Eulerian circuit.
You need the basic knowledge in order to solve the question.
You may also solve it by trial and error method.
Shortest distance
You need the basic knowledge in order to solve the question.
You may also solve it by trial and error method.
Shortest distance
Saturday, September 1, 2018
AMC 2018 - Number Puzzle
Head scratching number puzzle.
What is across? Horizontal
What is down? Vertical
Download and try!
Number Puzzle
What is across? Horizontal
What is down? Vertical
Download and try!
Number Puzzle
How I check my answer ?
Well.
That is quite challenging to do mathematics questions.
There might be many solutions for one one mathematic question.
Sometimes, you may need more time to study the question to get optimal solutions.
However it might quite frustating if you do not know whether that is correct answer or solutions after you trying the questions for more than half an hour.
To ensure the "accuracy", I will normally checking my answer using computer.
It is not encouraging to do exhaustive method to do checking on hand, but we might use it by the help of computer.
Recently, I find out it is quite challenging to solve question regarding of disibility question.
You may check on the question in my other posts.
Extra questions: How many positive integers not exceeding 2001 are multiples of 3 or 4 but not 5?
Answer for revision book 5
I would like to introduce another method if you wish to check how accurate is your answer.
I will do some coding, in language C++ for this question.
I know you may ask what is C++ ? It is a programming language you may use to do a program.
Simply you may find some C++ online compiler and paste the code and run it.
Steps:
1. Please download the code file. If you cant view the file, you may right click the file, and click on open with then choose notepad to open the code
Divisible question code
2. Please click on this link to open the online compiler
C++ online compiler i am using
3. Copy and paste the code in C++ online compiler. Then click run.
You may get your answer.
You may modify the code when you have to check your answer for similar question but different value.
Have fun!
That is quite challenging to do mathematics questions.
There might be many solutions for one one mathematic question.
Sometimes, you may need more time to study the question to get optimal solutions.
However it might quite frustating if you do not know whether that is correct answer or solutions after you trying the questions for more than half an hour.
To ensure the "accuracy", I will normally checking my answer using computer.
It is not encouraging to do exhaustive method to do checking on hand, but we might use it by the help of computer.
Recently, I find out it is quite challenging to solve question regarding of disibility question.
You may check on the question in my other posts.
Extra questions: How many positive integers not exceeding 2001 are multiples of 3 or 4 but not 5?
Answer for revision book 5
I would like to introduce another method if you wish to check how accurate is your answer.
I will do some coding, in language C++ for this question.
I know you may ask what is C++ ? It is a programming language you may use to do a program.
Simply you may find some C++ online compiler and paste the code and run it.
Steps:
1. Please download the code file. If you cant view the file, you may right click the file, and click on open with then choose notepad to open the code
Divisible question code
2. Please click on this link to open the online compiler
C++ online compiler i am using
3. Copy and paste the code in C++ online compiler. Then click run.
You may get your answer.
You may modify the code when you have to check your answer for similar question but different value.
Have fun!
Answer for rivision book 5
Please feel free to respond if there is any doubt or you may disagree with the answer given.
Thanks
Please click the link to download the answer for revision book 5
Thanks
Please click the link to download the answer for revision book 5
Subscribe to:
Posts (Atom)
Superior of partial fraction
What is complex fraction? Complex fraction is a fraction whereby its numerator or denominator or both consists of fractions. Partial frac...
-
What is fraction? Imagining you have one whole cake and you need to share the cake among you and your friends. Here come the problems, t...
-
This is a question that challenge your understand skill and programming skill. The Tremendous Tak-Tak Tree Output File: taktakout.txt T...
-
After a quite a long and challenging journey, we finally finish the training on Intermediate level book 1 to book 8. What a relieve huh ? ...