
C# is a programming language developed by Microsoft. C# has power of C++ since it's derived from C and C++. It is simpler than Visual Basic. Besides that, C# is a Java like language for web programming. Microsoft says, that C# is the best language to develop its .NET Framework applications.
Here's what you need:
Visual Studio Express 2015 or greater
WinRAR
Course Demos
Here is what you are going to learn... lots of practical applications.. here is a sampling
In this Lecture we will
In this Lecture we will
Create your first Windows Applications using various user interface controls
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In the Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
Problem solving has been described as the process of finding certain information that is not known, from a set of information that is known. In other words, problem solving is not an end result but rather a process. The end result is only worthwhile if the process is followed.
Problem solving is also an activity based on logic and, as such, requires some kind of structure to be present to aid us in our quest.
In this Lecture we will
It would be unfair to ask anyone to solve problems without effective tools to help along the way. The nature of programming requires programmers to first solve the problem at hand, then create an ordered set of instructions that will teach the computer how to solve the problem. There are a variety of problem solving models that assist the programmer in the problem solving stage.
In this Lecture we will
Why do software companies keep sending you updates, patches and fixes?
Computer programs that fail are common. By fail, we mean that a tiny error can cause a program to misbehave or crash. Most users are familiar with "crashing", from our own experience with computers. We have all heard amazing stories about software glitches that cause banks to lose millions or spacecraft to crash.
It may be impossible to guarantee that programs are error-free, but careful programming can help.
A program may encounter problems as it executes. It may have trouble reading data, there might be illegal characters in the data, or an array index might go out of bounds. C# has built in error and exception handling that enables programs to deal with such problems. Programs can recover from errors and keep on running.
In this Lecture we will
In this Lecture we will
In this Lecture we will
To this point, all the data that we have used when executing our programs has been entered from the keyboard. Similarly, all the output that has been produced from our programs has been to the screen. We must realize that not all input and output occurs this way, in fact, the majority of input for a computer program comes from data files that are stored on a disk or hard drive. When we create a document in a word processor, we see it on the screen; however, if we want to store that information, so that we can use or edit it at a later date, we must output the data to some secure storage medium. In the next few lessons, we will see how data storage and retrieval works.
Data produced from a program as the result of successful processing, can be output to a file for storage, rather than simply to the screen. Once stored, the data can be accessed for further processing, used as input for programs, searched for specific information, sorted, updated ... you get the idea!
Everyone using a computer deals with files. When you turn on your computer, the computer loads files. When you start a piece of software, the computer loads files. When you type solutions to the questions in this unit and save them (hopefully), the computer is saving or writing to a file. We use files to store information that is not being used by the computer at the present time.
Can you think of any useful program that doesn't use files? Files are a very important concept to understand, because any really useful piece of software uses files. Even your video games store your high scores.
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
As our programming experience becomes more complex and detailed, are you taking the time to help others? Do you visit the discussion area regularly to see if you can support those experiencing difficulty? By working and learning together, we can share the challenges as well as the successes.
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In the Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
In this Lecture we will
Recap course content
Discuss appropriate content for future learning
In this Lecture we will:
In the Lecture we will challenge you with the: "Four In A Row" Problem
Background
Given a positive integer, tell whether it is equal to the sum of four consecutive integers.
In the Lecture we will challenge you with the: "Anything you can do , I can do better" Problem
Background
You have a colleague that is extremely competitive and always tries to “top” one of your stories. If you say your car is fast, your colleague will say his or her car is faster. If you say your car is faster, your colleague will say his or her car is fastest. After a few such conversations, you realize that you can always predict what your colleague will say next.
To demonstrate how annoying this is, you decide to write a program that can accurately predict the responses of your colleague. Your task is to write this program. Specifically, given any adjective, your program will return its comparative form by appending “er” to it. Note that if the adjective already ends in “e”, you should only append “r”. If your program is given an adjective already in its comparative form, your program should return the superlative form of the adjective created by simply replacing the “er” with “est”. Your program should consider any string that ends in “er” to be an adjective in comparative form.
In the Lecture we will challenge you with the: "Crashing Words" Problem
Background
Two words of the same length, which have the same letter in the same position are said to crash. For example, the words CRUSH and BURST have length five and have S in the fourth position. Write a program to read two words at a time from a data file called words.txt. You may assume the words are the same length and are in upper case. If the words do not crash, a message is printed out in the top left hand corner of the screen. If, however, the words crash, the word, which comes first in alphabetical order, will be printed vertically starting on the first row of the screen and the other word will be printed horizontally starting in the first column of the screen so that the words intersect at the first crash location.
In the Lecture we will challenge you with the: "Add Times" Problem
Background
In this problem we are going to represent time in the format days hours minutes. So, using a 24hr clock , 3 15 45 would mean 3 days 15 hours and 45 minutes.
You are to write a program that reads in pairs of times in this format then outputs the sum of the times.
For example: Let's say the first time is 3 15 45 and the second time is 2 12 35. Then the required sum is 6 4 20 ( 6 days 4 hours 20 minutes).
In the Lecture we will challenge you with the: "Waiting Long" Problem
Background
Do you ever get tired of waiting for something to happen? The Gotta-Have-It Gadget Company thinks there is a market for a small device that can tell you how long you have been waiting. In its normal mode, it simply counts the minutes from start to stop. In the advanced mode, you can enter a start time and a stop time and it will tell you how many minutes have elapsed.
The Gotta-Have-It Gadget Company has hired you to program the advanced option. You are to write a program that will accept two times and determine how much time has transpired between them. Times will be entered in a 24-hour format. The first time will always be before the second time (but it may be larger - from 21:01 to 7:11 is 590 minutes). Your input will be the times in hours and minutes (HHMM - 21:01 would be 2101 for input). Your program should stop when the start time is 0. One minute after midnight would be represented as 1 (0 hours).
In the Lecture we will challenge you with the: "It's All Good " Problem
Background
Jimmie Flowers, known as Agent 13 is back!. However, he has a secret that until now nobody has noticed (although we aren't sure how we missed it!). Jimmie can't stand to have objects that are not properly aligned. If any object is slanted, he feels compelled to adjust that object.
Jimmie needs your help, though! He wants you to take bricks (which we will represent by just one of their edges) and determine if they are slanted or not.
The Problem:
Given two unique points on a line, determine if the line is a horizontal or vertical line.
In the Lecture we will challenge you with the: "Primitive Typewriters" Problem
In the Lecture we will challenge you with the "Tipping Point" Problem
Background
You are given a common die sitting on a table in a specific orientation. It sits on the table in front of you with a 1 showing on its top face, a 2 showing on its front face, and a 3 showing on its right face. Because the die is ordinary you should know that the total of the numbers on opposite sides of the die add up to 7. Thus the die has a 4 on its left face, a 5 on its back face, and a 6 hidden on its bottom face resting on the table. The die can tip over to reveal a new number based upon the direction of tipping. You can tip the die AWAY, TOWARD, LEFT or RIGHT.
Given the initial die configuration and a sequence of tip instructions, you must determine the number that remains on the top face of the die after all tips have been completed.
In the Lecture we will challenge you with the "Square The Word" Problem
Background
Read a word and create a square pattern as follows:
a) From the top left corner the word reads left to right
b) From the top left corner the word reads top to bottom
c) From the bottom right corner the word reads from bottom to top
d) From the bottom right corner the word reads right to left
In the Lecture we will challenge you with the Credit Card Problem
Background
The Luhn algorithm, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers. The formula verifies a number using its included check digit, which is usually appended to a partial account number to generate the full account number. This account number must pass the following test:
1. Counting from the rightmost digit (which is the check digit) and moving left, double the value of every even-positioned digit (note: The first position/digit is considered in
position 0 a even position) . For any digits that are doubled and become 10 or more, take the two numbers and add them together. For example, 1111 becomes 2121, while 8763 becomes 7733 (from 2×6=12 → 1+2=3 and 2×8=16 → 1+6=7).
2. Add all these digits together. For example, if 1111 becomes 2121, then 2+1+2+1 is 6; and 8763 becomes 7733, so 7+7+3+3 is 20.
3. If the total ends in 0 (put another way, if the total modulus 10 is congruent to 0), then the number is valid according to the Luhn formula; else it is not valid. So, 1111 is not valid (as shown above, it comes out to 6), while 8763 is valid (as shown above, it comes out to 20).
Create a program that takes its input from a data file called credit.txt which will consist of a list of credit card numbers. Determine if the number is correct according to the Luhn algorithm.
In this Lecture we will challenge you with the Time Clock Problem
Background
You need to compute the total time a worker has worked on a single calendar day given two time stamps of the form “HH:MM”. The numbers MM can be in the range of “00” to “59” while HH is in the range “01” through “12”. This is an archaic time stamp clock that doesn’t even record AM or PM values. The system has worked well in the past because no-one has ever worked longer than an 8 hour shift.
You can be assured that the two times are different and represent an employee checking in to work (on a calendar day) and checking out from work later on the exact same calendar day. You are to output the total time as “HH:MM”. If the accumulated work time is greater than 8 hours (in other words, 481 minutes or longer), then you are ordered to output “08:00” because this is the maximum time that the employee would be paid.
For example, given time stamps of “09:13” and “04:42” the total reported working time is reported as “07:29”.
In this Lecture we will challenge you with the QWERTY Problem
Background
The Dvorak Simplified Keyboard is a keyboard layout patented in 1936 by Dr. August Dvorak, an educational psychologist and professor of education at the University of Washington in Seattle as an alternative to the more common QWERTY layout.
If someone was to have Dvorak enabled on their computer, and a guest was to start typing, expecting the standard QWERTY layout - text will come out as nonsense. You are to write a program to de-scramble any such message.
In this Lecture we will challenge you with the iProfit Problem
Background
Having decided to capitalize on your awesome programming skills, you've set out to create and sell a mobile application at $0.99 per copy. Since the application is hosted and distributed through a managed platform, the store gets to keep 30% from each sale.
Given that you have an idea of how much profit you want to make off your hard work, at least how many 1000s of copies must be sold? (That is, the answer is rounded to the next 1000).
In this Lecture we will challenge you with the Craps Game Problem
Background
The game of craps uses a standard pair of dice, with the rules: The user rolls the dice. They win if the total
value of their first roll is 7 or 11. They lose if the value is 2, 3, or 12. If they neither win nor lose, the value of their first roll is called the point. They continue rolling until they get another roll matching the point (they win), or a 7 appears (they lose)
Some over-zealous players like to roll the dice and ignore whether the game is over (at which point security is called to escort the player from the premises). Your program is to determine if the player has won the game or not, in addition to determining whether or not they have continued to roll after the game is over. There are five possibilities:
• The player stopped exactly when the game was over, and they won.
• The player stopped exactly when the game was over, and they lost.
• The player continued rolling after they won.
• The player continued rolling after they lost.
• The player stopped rolling when the game was not finished.
In this Lecture we will challenge you with the Decoding Problem
Background
People have used letters, digits, and other punctuation symbols to represent information for hundreds, if not thousands, of years. To transmit such symbols via a computer line, however, we must encode the symbols using a binary (two-symbol) code, since computers only process information represented by strings of zeroes and ones.
A code is a set of binary strings. In the program you are to write for this problem the letters a, b, d, e, h, l, o, r and w will be encoded as follows:
a -> 1
b -> 01
d -> 001
e -> 0001
h -> 00001
l -> 000001
o -> 0000001
r -> 00000001
w -> 000000001
For example, the word "bed" will be encoded as 010001001. Your program must decode binary messages that have been encoded using the above code. The input file decode.txt will contain several words encoded as above, one per line. The first line will contain a single positive integer indicating the number of encoded lines to follow.
The output will consist of one decoded word per line, with each decoded word corresponding to an encoded word in the input file.
In this Lecture we will challenge you with the Palindrome Problem
Background
Your program is to read a data file (palindromes.txt) consisting of single lines of text and output
whether that text is a palindrome or not.
A palindrome is a string that read from left to right or right to left looks the same. For instance
"abcba" is identical whether we read it from left to right or from right to left.
Your program is expected to be case-sensitive.
On top of this definition we will consider the following pairs of characters to be reversible:
( ) , [ ] , { } , < >
This means that when reading from left to right we encounter the character '(' we should
encounter instead the character ')' when reading from right to left.
For instance the string "ab(c)ba" will be considered to be a palindrome while "ab(c(ba" will not.
Here are some examples of palindromes:
aabbcbbaa
aa
a{}a
( )
(a)
ver{(aga)}rev
and some examples of non-palindromes:
ab
(a(b(a
a(aa{b>c
Sample Input (palidromes.txt)
aabbcbaa
(a)
Sample Output
This is not a palindrome.
This is a palindrome.
In this Lecture we will challenge you with the Alphabetic Average Problem
Background
A numerologist might compute a number from a word as follows: assign the letter A a value of 1, the letter B a value of 2, …, and the letter Z has a value of 26. Now sum up the values of each letter in a word. For example, the word CAB has three letters and its numerological total is 3+1+2 = 6.
However, instead of computing the sum, what if you were asked to compute the Alphabetic Average. That is, compute the sum as shown above, then divide by the total number of letters in the word. Since this average might not be a proper integer, you need to round it to the nearest integer, whose value (as before) determines a letter, which is the alphabetic average of the original word.
When rounding use the following rule:
To round to the nearest integer a positive number x whose fractional value is 0.5 or higher, choose the smallest integer greater than x, otherwise choose the largest integer smaller than x
For example, 1.4999 rounds (down) to the integer 1, while 13.5 rounds (up) to 14.
For CAB, the average (3+1+2)/3 = 2 which corresponds to B being the alphabetic average.
In this Lecture we will challenge you with the Title Problem.
Background
A software company has hired you to write software to help grade school children learn grammar. Your first project, and the objective of this problem, is to ensure that a title is presented in its proper case. As you may recall, the first word of a title always begins with a capital letter, and all other words begin with a capital, except “small words”. For this program, the set of small words are restricted to:
a an and the or for on is of
For example the title
“the rise and fall of western civilization”
should have the first letter of the first word capitalized, in addition to all other words that are not small.
Thus, the proper title should be:
“The Rise and Fall of Western Civilization”.
Write a program to convert a title into its proper case.
In this Lecture we will challenge you with the Parity Bit Problem.
Background
A parity bit is a binary digit that is added to ensure that the number of bits with value of 1 in a given set of bits is always even or odd. Parity bits are used as a simple validation code, for example to test that all the data has arrived correctly in a transmission. For this question we'll be using even parity bit -- that is, we want to add a bit (1 or 0) so that the total number of high bits (1) is even.
For example, consider integer 13. Binary representation of 13 is 1101. Number of high bits in 1101 is 3, which is odd. To make it even, the parity bit must also be high, so 1.
In this Lecture we will challenge you with the Digital Key Problem
Background
My Shiny Digital Key
A house key, is essentially a physical encoding of a digital key, where different heights of teeth represent different digits. If one could read this digital equivalent (lets say from a to-scale photograph), then the physical key itself is not needed to create a copy. Lets
imagine that we are not lock-picking our way into some place we shouldn't be at, but instead are running a legitimate locksmith business, maintaining a machine that cuts new copies of keys. We need to write some software that will scan the image of a key, and extract the heights of the teeth.
The input file digitalkey.txt will contain 2 sets of input. Each line is 5 characters long, and there are 7 lines per set. There is an additional whitespace line separating each set. Dot . will be the empty space character in the "image", number sign # is a part of the key. Each set of #s is continuous, but there could be a line of input with no #s at all.
The output contain 2 lines, each a 7 digit number, where each digit matches the height of the tooth on the corresponding line in the key. The top-most line of input is the leftmost digit in the output. There are no spaces between the digits, and each digit is in the 0-5 range.
Note: Make sure to print any leading zeros, if such are present.
Sample Input :
.....
#....
##...
###..
####.
#####
#....
#....
##...
###..
##...
###..
###..
##...
Sample Output:
0123451
1232332
In this Lecture we will challenge you with the Enraged Fowl Problem.
Background
Brandon is playing the latest game sensation, Enraged Fowl! His favorite fowl to use in this game is the one that “flies” in a straight line and then drops a bomb straight down on a target. Unfortunately, he is not very good at dropping the bomb so he wants to practice outside of the game. He wants you to help him! For his practice, he will consider only games where the target is in the same place (at the same height) as himself. He will provide you the distance that the target is from his position, the straight-line distance that he will fling his fowl through the air and the distance the bomb will drop. You need to determine whether that combination will work and hit the target!
The Problem:
Given three values representing the target distance, the flying distance, and the bomb drop
length, determine whether Brandon can hit the target.
In this Lecture we will challenge you with the Penny Lane Problem.
Background
Given a dollar amount between $0.01 and $9.99 you are to compute the fewest number of standard American coins needed to produce that sum. The standard coins are:
• dollar ($1.00)
• half-dollar ($0.50)
• quarter ($0.25)
• dime ($0.10)
• nickel ($0.05)
• penny ($0.01)
You must output the number of coins in descending order of value, being careful to use plurals when a specific coin is represented more than once. Note that the plural of “penny” is “pennies”.
Sample Results
$1.47
1 dollar
1 quarter
2 dimes
2 pennies
In this Lecture we will challenge you with the Rectangle Problem.
Background
You are to write a program to determine if two rectangles overlap, one surrounds the other, or they have no overlap at all. One rectangle surrounds another if the other rectangle lies entirely inside the first (their edges may lie on top of each other). Rectangles are said to overlap if both rectangles have some area in common and some are not in common. Lastly, two rectangles have no overlap if they do not share any area in common
In this Lecture we will challenge you with the Card Shark Problem.
Background
A new card game is sweeping the nation. It has become the game of choice with weekly card games being held at the Arts Centre. This game is similar to Poker, but no attention is paid to suits, and we don’t care about straights. The idea is that the person with the worst hand wins. Therefore you do not want any pairs. David is a very conservative player. He only wants to bet if he is really sure that he will win. So you are to write a program to tell him if he has the worst hand possible. Each hand, seven cards are dealt to each player. They may then discard 2 cards. A guaranteed winning hand will have no pairs, and the lowest possible “high” card.
In this Lecture we will challenge you with the Vowel Palindrome Problem.
Background
A palindrome is a sequence of letters that reads the same forwards and backwards. You are given a word phrase containing just capital letters and spaces. If you consider just the vowels in the word – A, E, I, O, U, or Y – do they form a palindromic sequence?
For example, the phrase "WHAT IS THAT" contains three vowels, which when read from left to right in the phrase are "AIA"; this forms a vowel palindrome.
Here’s another example, “ONE TO HIT ON ELBOW" contains the vowels (in this order) “OEOIOEO” which is a vowel palindrome.
In this Lecture we will challenge you with the Word Swap Problem.
Background
Agnes has heard that the carnival is going to have a new game next year. The carnival guy chooses a word and writes it down on a piece of paper, and only tells you the length of the word (lets call it Word 1). You have to guess a word of the same length (lets call it Word 2), and you earn or lose coins depending on how different are the two words (i.e., based on how much effort is required to swap the two words). Agnes, having just turned 6, has barely started reading and can't do math yet, so she wants your help to play this game.
The carnival provided the following rules for earning or paying coins.In this Lecture we will challenge you with the Double Dice Problem.
Background
Antonia and David are playing a game. Each player starts with 100 points.
The game uses standard six-sided dice and is played in rounds. During one round, each player rolls one die. The player with the lower roll loses the number of points shown on the higher die. If both players roll the same number, no points are lost by either player.
Write a program to determine the final scores.
In this Lecture we will challenge you with the Metric to Imperial Units Conversion Problem.
Background
For this problem , you will be asked to convert a distance, in centimetres, to its equivalent distance in miles, yards, feet and inches, to the nearest inch.
For example, 425 cm is 0 mile(s), 4 yard(s), 1 foo(ee)t, 11 inch(es)
In this Lecture we will challenge you with the Single Digit Problem.
Background
This problem requires you to take a positive integer and add up all of the digits in that integer. If the answer is a single digit, you're finished. If it isn't, you do it again, and you keep doing it until your answer does become a single digit.
In this Lecture we will challenge you with the Hour Clock Problem.
Background
Given the time on a 24 hour clock, convert it to the time on a 12 hour clock (AM/PM). The input file clock.txt will contain up to 100 lines of data. Each line will contain the time on a 24 hour clock, in the format HH:MM, where 00<=HH<=23 and 00<=MM<=59.
The output will contain the time in a 12 hour clock, in the format HH:MM XM, where 0<=HH<=12, 00<=MM<=59, and X in [‘A’,’P’].
In this Lecture we will challenge you with the Greeting In A Box Problem.
Background
This problem requires you to display a greeting within a box frame on the screen. The input data file, which must be called greeting.txt , will contain four lines of data, with the data on each line beginning in the first column of that line.
Line 1 contains the number of spaces the box frame is to be indented from the left margin.
Line 2 contains the number of blank spaces that must surround the greeting on all four sides.
Line 3 contains the character to be used to draw the box frame.
Line 4 contains the name of the person to whom the greeting is to be addressed, and you should note that the person's name need not be just a single word.
Your program must read all of this information from the file and then display a greeting to the person named in the file. The displayed greeting must have the exact form illustrated in the sample output, and it must be positioned properly within the box frame. The box frame must itself be drawn using the correct character from the input data, and must be positioned properly on the screen.
Your program must also display a "digit ruler" of length 80 digits immediately above the box frame so that the judges (and you) may more easily determine the precise location of your output. This ruler is also shown in the sample output, since it is in fact part of the output.
Sample input data (greeting.txt)
4
2
*
George W. Bush
Sample Output:
123456789012345678901234567890123456789012345678901234567890123456
*************************************
* *
* *
* Hello there, George W. Bush! *
* *
* *
*************************************
In this Lecture we will challenge you with the Odd Sum Problem.
Background
Given a range [a, b], you are to find the summation of all the odd integers in this range. For example, the summation of all the odd integers in the range [3, 9] is 3 + 5 + 7 + 9 = 24.
Input (oddsum.txt)
There can be multiple test cases. The first line of input gives you the number of test cases, T ( 1 ≤ T ≤ 100) . Next, T test cases follow. Each test case consists of two integers a and b ( 0 ≤ a ≤ b ≤ 100) on separate lines.
For each test case you are to print one line of output the serial number of the test case followed by the summation of the odd integers in the range [a, b].
Sample Input
3
1
5
3
5
20
30
Sample Output
Case 1: 9
Case 2: 8
Case 3:125
In this Lecture we will challenge you with the Happy Sad Problem.
Background
We often include emoticons in our text messages to indicate how we are feeling. The three consecutive characters :-) indicate a happy face and the three consecutive characters :-( indicate a sad face.
Write a program to determine the overall mood of a message.
There will be several lines of input that contain between 1 and 255 characters.
The output is determined by the following rules:
If the input line does not contain any happy or sad emoticons, output NONE.
Otherwise, if the input line contains an equal number of happy an sad emoticons, output UNSURE
Otherwise, if the input line contains more happy than sad emoticons, output HAPPY
Otherwise, if the input line contains more sad than happy emoticons, output SAD
Sample Input:
How are you :-) doing :-( today :-)?
:)
This:-(is str:-(:-(ange te:-)xt.
Sample Output:
Happy
None
Sad
In this Lecture we will challenge you with the Robbers Language Problem.
Background
In Sweden, there is a simple child’s game similar to Pig Latin called Rovarspraket (Robbers Language)
In this version every consonant is replaced by three letters, in the following order:
The consonant itself;
The vowel closet to the consonant in the alphabet eg. If the consonant is d, then the closet vowel is e, with the rule that if the consonant falls exactly between two vowels, then the vowel closer to the start of the alphabet will be chosen eg., if the consonant is c, then the closet vowel is a ;
The next consonant in the alphabet following the original consonant eg. If the consonant is d, then the next consonant is f except if the original consonant is z, in which case the next consonant is z as well.
Vowels in the word remain the same. (Vowels are a, e i o u and all other letters are consonants)
Write a program that translates a word from English into Rovarspraket.
In this Lecture we will challenge you with the Making The Grade Problem.
Background
You are getting ready to take a final exam for your Basket Weaving 101 class and you need to know the minimum score you must get on the final exam in order to obtain an average of at least 90 for the course. A weighted average consists of a number of scores along with their respective weights. For this course, there are four parts to the grade, a project that is worth 15% of the grade, a term paper that is worth 20% of the grade, a midterm exam that is worth 25% of the grade, and a final exam that worth 40% of the grade. Given scores for the project, the term paper, and the midterm exam, compute and display the minimum integer final exam score that will result in a grade of at least 90 for the course. Possible final exam scores range from 0 to 100, inclusive. If it is impossible to obtain at least 90 your program should display the appropriate message.
In this Lecture we will challenge you with the Magic Square Problem.
Background
Magic Squares are square arrays of numbers that have the interesting property that the numbers in each column, and in each row, all add up to the same total.
Given a 4 x 4 square of numbers, determine if it is magic square. The input consists of two sets of four lines, each line having 4 space-separated integers. Output either magic if the input is a magic square, or not magic if the input is not a magic square.
In this Lecture we will challenge you with the Shifty Sum Problem.
Background
Suppose we have a number like 12. Let’s define shifting a number to mean adding a zero at the end. For example, if we shift that number once, we get the number 120. If we shift the number again we get the number 1200. We can shift the number as many times as we want.
In this problem you will be calculating a shifty sum, which is the sum of a number and the numbers we get by shifting. Specifically, you will be given the starting number N and a nonnegative integer k. You must add together N and all the numbers you get by shifting a total of k times.
For example, the shifty sum when N is 12 and k is 1 is: 12 + 120 = 132. As another example, the shifty sum when N is 12 and k is 3 is 12 + 120 + 1200 + 12000 = 13332.
In this Lecture we will challenge you with the Telemarketers Problem.
Background
Here at the Concerned Citizens of Commerce (CCC), we have noted that telemarketers like to use seven-digit phone numbers where the last four digits have three properties. Looking just at the last four digits, these properties are:
the first of these four digits is an 8 or 9;
the last digit is an 8 or 9;
the second and third digits are the same.
For example, if the last four digits of the telephone number are 8229, 8338, or 9008, these are telemarketer numbers.
Write a program to decide if a telephone number is a telemarketer number or not, based on the last four digits. If the number is not a telemarketer number, we should answer the phone, and otherwise, we should ignore it.
In this Lecture we will challenge you with the Occupied Parking Problem.
Background
You supervise a number of small parking lots across the city. Yesterday you had the individual lot supervisors record which parking spaces were occupied by cars and which were empty. Today, you recorded the same information. How many of the same parking spaces were occupied both yesterday and today?
The data will consist of pairs of two lines. The first line of input records the information about yesterday’s parking spaces, and the second line of input records the information about today’s parking spaces. Each of these records will either be C to indicate an occupied space or. to indicate it was an empty parking space.
Output the number of parking spaces which were occupied yesterday and today for an undetermined number of parking lots.
In this Lecture we will challenge you with the Word Counting Problem.
Background
You’ve been tasked with building a major component of a word processing program. Given a line and a word you are to determine the number of occurrences of that word in the line.
If the word is embedded inside of some other word, it counts as an occurrence. Two words are considered equal if they contain the same characters in the same order regardless of case.
In this Lecture we will challenge you with the Counting Swann's Coin Problem.
Background
Governor Weatherby Swann orders you to count the number of coins in the government treasury. To make the job more interesting you decide to say” Good” for all numbers that are a multiple of 3 and ” Man” for all numbers that are a multiple of 5. For numbers that are multiples of both 3 and 5 you say” Goodman”.
Input/Output Format:
The input will be a list of the number of coins you need to count. The output will be a display of each separate case where the numbers and words in sequence, separated by spaces are displayed. Start a new line after each word.
In this Lecture we will challenge you with the Show Me The Money Problem.
Background
The task is to create a small application that will monitor financial transactions and keep a running total, displaying the balance at the end of each day. It should be assumed that the initial balance is zero, and balance is rolled over from one day to the next. Negative balance is a special event that will reset the balance to 0 at the end of that day.
The input file money.txt will contain five line, each no more than 255 characters long. Each line represents a stream of transactions with two possible characters + or - each representing addition and subtraction of one unit from the running balance.
The output will contain five lines. Each line will have an integer, representing a balance at the end of that day's datastream. In a case that balance drops below 0 during any particular stream, "OH NOES!" should be printed to that line instead, and have the balance be reset back to 0, regardless of what follows on that line.
In this Lecture we will challenge you with the Telephone Encryption Problem.
Background
A company wants to transmit data over the telephone line, but they are concerned that their lines are tapped. All of their data is transmitted as four-digit integers. They have asked you to write a program that encrypts their data so that it may be transmitted more securely.
Your program should read a four-digit integer from a data file (telephone.txt) and encrypt it as follows:
Replace each digit by ((digit + 7) mod 10).
Then, swap the first digit with the third, swap the second digit with the fourth, and print the encrypted integer.
In this Lecture we will challenge you with the Wheels of Glory Problem.
Background
Your crazy computer science teacher, Mr. Chiarelli, has run into a problem. He lost all the grades for all his students and there is only one day left in the school year. He decides to rent the skating rink for the day and determine the students' grades by how well they perform in an endurance test. You get to write a program that will determine your grade based on the grading requirements and how fast you can skate.
Input: (wheels.txt)
Input will begin with a number, N, that represents how many datasets will be inputed. Each dataset will be on one line containing first an integer, M, representing the number of minutes to skate, an integer S representing how many seconds it takes you to complete a lap, an integer, A, representing how many laps it takes to get an A, an integer, B, representing how many laps it takes to get a B, and lastly an integer, C, representing how many laps it takes to get a C.
In this Lecture we will challenge you with the Penny Game Problem.
Background
Extra change can be a big burden to carry around with you. So, you decide to leave your stacks of (identical) pennies you have at home. However, these stacks aren't of the same size, and look a little messy. You want to move pennies between these stacks so that all the stacks eventually have the same size; it is guaranteed that you are able to do this. You want to do this by making the smallest number of moves possible, where one move consists of taking one penny from a stack and adding it to another stack.
For example, if you have three stacks with 4, 5, and 6 pennies, you have to move one penny from the third stack to the first stack so that they all end up with 5 pennies each. Write a program that helps you out with this task.
The input file penny.txt will contain a set of input. The first line of the set is number 1 <= N <= 50, the number of stacks you have. The next *N* lines each contain a number 1 <= M <= 1000, the number of pennies in each stack.
The output will contain a single number: the minimum number of moves required to make every stack have equal number of pennies.
In this Lecture we will challenge you with the Terms of Office Problem.
Background
In CS City, a mathematical place to live, the mayor is elected every 4 years, the treasurer is appointed every 2 years, the chief programmer is elected every 3 years and the dogcatcher is replaced every 5 years.
This year, Year X, the newly elected mayor announced the appointment of the new treasurer, a new dog-catcher and congratulated the chief programmer for winning the recent election. That is, all positions were changed over. This is highly unusual. You will quantify how unusual this really is.
Write a program that inputs the year X and the future year Y and lists all years between X and Y inclusive when all positions change.
In this Lecture we will challenge you with the 24-hour clock problem.
Background
Given the time on a 24-hour clock, convert it to the time on a 12-hour clock (AM/PM).
The input file (clock.txt) will contain up to 100 lines of data. Each line will contain the time on a 24-hour clock, in the format HH:MM, where 00<=HH<=23 and 00<=MM<=59.
The output will contain the time in a 12-hour clock, in the format HH:MM XM, where 0<=HH<=12, 00<=MM<=59, and X in [‘A’,’P’].
In this Lecture we will challenge you with the Wind Chill problem.
Background
Here is Canada where I’m from , when the winter months come (Dec-Mar) the weather reports usually include the infamous “Wind Chill “. So the temperature outside might be -10 Celsius , but because there may be a strong wind blowing , it “feels” much colder. The wind chill might be -20 Celsius.
The formula for the wind chill temperature (WCT) is calculated as follows:
WCT = 13.12 + 0.6215 x Tair - 11.37 x V10metre^0.16 +0.3965 x Tair x V10metre^0.16
Where: Tair - is the surface temp in Celsius
V10metre - is the standard surface wind speed in km/hr
Write a program that determines the rating for the wind chill given the surface temperature in Celsius (Tair) and the standard surface wind speed in km/hr (V10metre).
In this Lecture we will challenge you with the Area of Circle problem.
Background
Given the Cartesian plane coordinates for the centre of a circle (x1,y1) and a point on the circle’s circumference (x2,y2), calculate the area of the circle.
In this Lecture we will challenge you with the Smiles with Similes Problem.
Background
A simile is a combination of an adjective and noun that produces a phrase such as "Easy
as pie" or "Cold as ice".
Write a program to input n adjectives (1<= n<=5) and m nouns (1<= m<=5) and print out all possible similes. The first two lines of input will provide the values of n and m, in that order followed, one per line, by n adjectives and m nouns.
Your program may output the similes in any order.
In this Lecture we will challenge you with the Simple Continued Fraction Problem
Background
See pdf in resources for all the details
In this Lecture we will challenge you with the Jedi Crystals Problem
Background
A new Kyber crystal mine has been started on Dantooine. These are the crystals for lightsabers, and the mine owner has been mining red, blue, and green crystals. Periodically, the mine owner pauses the mining to put together all the crystals found till then, and ships them out to lightsaber factories (yes, they exist!). For reasons of superstition, he only does this when an equal number of crystals of each color has been collected from the mine (i.e., when there is “balance”).
However, since he has no control over which color crystal is found next, he wants your help to decide when balance is reached. The program will read in a list of letters representing the color of each crystal that comes out of the mine. When a balance (greater than 0,0,0) has been achieved, the program will stop reading and print "Balance achieved at " followed by the number of red crystals that came out (which of course would be the same as the number of blue and the number of green crystals).
In this Lecture we will challenge you with the Cold Compress Problem
Background
Your new cellphone plan charges you for every character you send from your phone. Since you tend to send sequences of symbols in your messages, you have come up with the following compression technique: For each symbol, write down the number of times it appears consecutively, followed by the symbol itself. This compression technique is called run-length encoding. More formally, a block is a substring of identical symbols that is as long as possible. A block will be represented in compressed form as the length of the block followed by the symbol in that block. The encoding of a string is the representation of each block in the string in the order in which they appear
In this Lecture we will challenge you with the Turpentine Avenger Problem
Background
Of all the sucky powers to be born with, The Turpentine Avenger has one of the worst: he can generate turpentine from his fingers at will, up to 100 gallons per day. He found that this didn’t stop criminals nearly as well as he hoped, so he gave up crime-fighting and became a door-todoor used Turpentine Salesman. But one day, when he walked up the front porch of an unassuming suburban house and rang the doorbell, the door was answered by none other than Paint Man! Paint Man was his arch-nemesis, quite by default: Paint Man was the only supervillain that The Turpentine Avenger had any chance of defeating. When Paint Man saw who was at the door, he screamed and slammed it shut. Yet The Turpentine Avenger was not to be defeated so easily. He opened the door (since Paint Man had forgotten to lock it) and began a search for his hideous adversary. This turned out to be difficult. Paint Man’s house was completely coated in paint, and Paint Man himself looked just like a blob of paint, so there was no way to know where Paint Man was. He decided to just blast the whole house, or as much as he could, in the hopes that he would stumble upon the fiend.
The Problem:
Your job is to find the maximum number of rooms that The Turpentine Avenger can clear. He has 100 gallons of turpentine, and each gallon will clean 50 square feet of paint.
In this Lecture we will challenge you with the Armstrong Number Problem
Background
An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits.
For example:
9 is an Armstrong number, because 9 = 9^1 = 9
10 is not an Armstrong number, because 10 != 1^2 + 0^2 = 1
153 is an Armstrong number, because: 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
154 is not an Armstrong number, because: 154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190
Write some code to determine whether a number is an Armstrong number.
In this Lecture we will challenge you with the Atbash Cipher Problem
Background
Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.
The Atbash cipher is a simple substitution cipher that relies on transposing all the letters in the alphabet such that the resulting alphabet is backwards. The first letter is replaced with the last letter, the second with the second-last, and so on.
An Atbash cipher for the Latin alphabet would be as follows:
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: zyxwvutsrqponmlkjihgfedcba
It is a very weak cipher because it only has one possible key, and it is a simple monoalphabetic substitution cipher. However, this may not have been an issue in the cipher's time.
Ciphertext is written out in groups of fixed length, the traditional group size being 5 letters, and punctuation is excluded. This is to make it harder to guess things based on word boundaries.
In this Lecture we will challenge you with the Rain Drops Problem
Background
Convert a number to a string, the contents of which depend on the number's factors.
If the number has 3 as a factor, output 'Pling'.
If the number has 5 as a factor, output 'Plang'.
If the number has 7 as a factor, output 'Plong'.
If the number does not have 3, 5, or 7 as a factor, just pass the number's digits straight through.
Examples
28's factors are 1, 2, 4, 7, 14, 28.
o In raindrop-speak, this would be a simple "Plong".
30's factors are 1, 2, 3, 5, 6, 10, 15, 30.
o In raindrop-speak, this would be a "PlingPlang".
34 has four factors: 1, 2, 17, and 34.
o In raindrop-speak, this would be "34".
In this Lecture we will challenge you with the DNA Hamming Distance Problem
Background
Calculate the Hamming Distance between two DNA strands.
Your body is made up of cells that contain DNA. Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime!
When cells divide, their DNA replicates too. Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. This is known as the "Hamming Distance".
We read DNA using the letters C,A,G and T. Two strands might look like this:
GAGCCTACTAACGGGAT
CATCGTAATGACGGCCT
They have 7 differences, and therefore the Hamming Distance is 7.
The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :)
In this Lecture we will challenge you with the Perfect Numbers Problem
Background
Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for natural numbers.
The Greek mathematician Nicomachus devised a classification scheme for natural numbers, identifying each as belonging uniquely to the categories of perfect, abundant, or deficient based on their aliquot sum. The aliquot sum is defined as the sum of the factors of a number not including the number itself. For example, the aliquot sum of 15 is (1 + 3 + 5) = 9
Perfect: aliquot sum = number
o 6 is a perfect number because (1 + 2 + 3) = 6
o 28 is a perfect number because (1 + 2 + 4 + 7 + 14) = 28
Abundant: aliquot sum > number
o 12 is an abundant number because (1 + 2 + 3 + 4 + 6) = 16
o 24 is an abundant number because (1 + 2 + 3 + 4 + 6 + 8 + 12) = 36
Deficient: aliquot sum < number
o 8 is a deficient number because (1 + 2 + 4) = 7
o Prime numbers are deficient
Implement a way to determine whether a given number is perfect.
In this Lecture we will challenge you with the Pangram Problem
Background
Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma, "every letter") is a sentence using every letter of the alphabet at least once. The best-known English pangram is:
The quick brown fox jumps over the lazy dog.
The alphabet used consists of ASCII letters a to z, inclusive, and is case insensitive. Input will not contain non-ASCII symbols.
In this Lecture we will challenge you with the Scramble Problem
Background
Given a word, compute the scrabble score for that word.
Letter Values
A, E, I, O, U, L, N, R, S, T => 1
D, G => 2
B, C, M, P => 3
F, H, V, W, Y => 4
K => 5
J, X => 8
Q, Z =>10
Examples
"cabbage" should be scored as worth 14 points:
3 points for C
1 point for A, twice
3 points for B, twice
2 points for G
1 point for E
And to total:
3 + 2*1 + 2*3 + 2 + 1
= 3 + 2 + 6 + 3
= 5 + 9
= 14
In this Lecture we will challenge you with the Darts Problem
Background
Write a program that returns the earned points in a single toss of a Darts game. Darts is a game where players throw darts to a target.
In our particular instance of the game, the target rewards with 4 different amounts of points, depending on where the dart lands:
If the dart lands outside the target, player earns no points (0 points).
If the dart lands in the outer circle of the target, player earns 1 point.
If the dart lands in the middle circle of the target, player earns 5 points.
If the dart lands in the inner circle of the target, player earns 10 points.
The outer circle has a radius of 10 units (This is equivalent to the total radius for the entire target), the middle circle a radius of 5 units, and the inner circle a radius of 1. Of course, they are all centered to the same point (That is, the circles are concentric) defined by the coordinates (0, 0).
Write a application that given a point in the target (defined by its real cartesian coordinates x and y), returns the correct amount earned by a dart landing in that point.
In this Lecture we will challenge you with the Stanley Cup Problem
Background
This is it – the exciting finals of the Stanley Cup (Ice Hockey ) playoffs are about to begin! The format is a best-of-7 series, in which the first team to win 4 games will claim the Cup!
In each game, the team which scores more points than the other team wins (there are no ties). The series ends as soon as one team has won 4 games, and no further games are played after that point. This means that the series may last between 4 and 7 games, inclusive.
By collecting data on all hockey games which have ever been played, and performing some sophisticated data analysis, you've managed to predict all of the upcoming games' scores with absolute certainty. You know that, in the i-th game, Team A will score Ai points and Team B will scores Bi points (0 ≤ Ai, Bi ≤ 10, Ai ≠ Bi). In fact, you have these values for all 7 potential games in the series, even though the 5th, 6th, and/or 7th games may not actually get played, in which case their scores should be ignored.
All that's left is to place your bets on the winning team. You can rake in even more cash if you bet on the exact final game counts. As such, given your predicted scores, determine the number of games won by each of the teams when the series ends.
Input Format (stanley.txt)
The input consists of seven lines, the i-th of which consists of two space-separated integers, Ai and Bi (for i =1..7).
Output Format
Output two space-separated integers, the number of games won by Teams A and B respectively when the series ends.
In this Lecture we will challenge you with the Script Doctor Problem
Background
The Head Monkey has just completed her first draft of the film script, and has proudly passed it on to Bo Vine for a readthrough. Unfortunately, Bo has concerns that coarse language in the script might cause the movie to end up with an R rating, which would be a disaster! In order to secure exposure of the movie to younger audiences, he'd like to take a pass over the script himself to ensure that it contains no occurrences of a particularly offensive word: "bull".
The script is a non-empty string S consisting of at most 1000 characters, each of which is either a lowercase letter ("a".."z") or an underscore ("_"). Bo Vine would like to alter it as little as possible such that, once he's done, the string contains no occurrences of the substring "bull". Now, he's not a writer, so he doesn't feel qualified to add anything to the script to accomplish his goal — he'll only remove existing characters from it.
Help Bo Vine remove as few characters as possible from the Script to yield a string with no occurrences of the substring "bull". If there are multiple ways to do so, any will do. It's possible that no characters may need to be removed.
In this Lecture we will challenge you with the Telemarketing Problem
Background
Here at the Concerned Citizens of Commerce (CCC), we have noted that telemarketers like to use phone numbers where the last four digits have three properties. Looking just at the last four digits, these properties are:
_ the first of these four digits is an 8 or 9;
_ the last digit is an 8 or 9;
_ the second and third digits are the same.
For example, if the last four digits of the telephone number are 8229, 8338, or 9008, these are telemarketer numbers.
Write a program to decide if a telephone number is a telemarketer number or not, based on the last four digits. If the number is not a telemarketer number, we should answer the phone, and otherwise, we should ignore it.
In this Lecture we will challenge you with the Certified Fresh Problem
Background
A new science fiction psychological thriller action-comedy film, The Codefather, is being released this weekend! You'd love to go see it, but you'll first need to convince your friends that it'll be good.
Fortunately, trusted movie review websites such as Rotten Tomatoes exist for this purpose! Following its release in theatres, The Codefather will receive a series of N (1 ≤ N ≤ 100) reviews from certified Rotten Tomatoes critics, one after another. The i-th review will either be positive (if Ri = "P") or negative (if Ri = "N").
At any given point in time after its first review, each movie on Rotten Tomatoes is considered to have a certain Tomatometer score. This score is a real number, computed as the number of positive reviews received so far divided by the total number of reviews received so far.
You're concerned that The Codefather's final Tomatometer score may end up not being too high, as general audiences may not grasp its subtle competitive programming-driven writing. However, if you keep refreshing its Rotten Tomatoes page as new reviews come in, maybe you can catch a point in time at which it has a higher score, and take a screenshot of it to show to your friends! Determine the maximum Tomatometer score which The Codefather will reach at any point after its first review.
In this Lecture we will challenge you with the Canuck Detection Problem
Background
Nice, you've just landed your first software engineering internship at a popular blog site! Your first task is to collect data about which countries all of the site's bloggers live in, for further analysis. Now, you don't exactly have the most experience with such things, but it's important that you get it done somehow. Asking for help would make you look weak! As a first step, it shouldn't be too hard to figure out whether or not a given user is Canadian, right?
You've already gotten a script together to load the text from a single blog post and strip it down into a more convenient format – a non-empty string S consisting of at most 50,000 lowercase letters. Unfortunately, from there, your algorithm is questionable at best. You know that a characteristic of words written by Canadians is that they sometimes end in "our" rather an "or" (colour instead of color).
However, due to faulty programming, your script will decide that the blogger is Canadian if their text contains at least one instance of the subsequence "our". A string subsequence is an ordered but possibly non-consecutive set of characters in it. For example, the string "abac" contains subsequences "ab", "ac", "bc", and "abc", among others. However, it does not contain the subsequence "ca", as an "a" never appears anywhere after a "c".
Things aren't looking great for your internship, but might as well at least test out your approach. Given a string S, output "Y" if your script would determine that the blogger is Canadian, or "N" otherwise.
In this Lecture we will challenge you with the Uncrackable Problem
Background
You'd like to register an account on an extremely entertaining website. You've already selected a username, but it seems that the requirements for choosing a password are quite strict, in order to completely protect your account from being hacked into.
The password must be a string between 8 and 12 characters long (inclusive), such that every character is either a lowercase letter ("a".."z"), uppercase letter ("A".."Z"), or digit ("0".."9"). Furthermore, it must contain at least three lowercase letters, at least two uppercase letters, and at least one digit.
You've got a potential password in mind, a non-empty string made up of at most 100 characters, each of which is a lowercase letter, uppercase letter, or digit. Rather than entering the password into the site and risking rejection, you'd like to determine for yourself whether or not your password would validly satisfy all of the rules.
In this Lecture we will challenge you with the Occupy Parking Problem
Background
You supervise a small parking lot which has N parking spaces. Yesterday, you recorded which parking spaces were occupied by cars and which were empty. Today, you recorded the same information. How many of the parking spaces were occupied both yesterday and today?
Input Specification (parking.txt)
The first line of input contains the integer N (1 - 100). The second and third lines of input contain N characters each. The second line of input records the information about yesterday’s parking spaces, and the third line of input records the information about today’s parking spaces.
Each of these 2N characters will either be C to indicate an occupied space or . to indicate it was an empty parking space.
Output Specification
Output the number of parking spaces which were occupied yesterday and today.
Sample Input 1 (parking.txt)
5
CC..C
.CC..
Output for Sample Input 1
1
Explanation of Output for Sample Input 1
Only the second parking space from the left was occupied yesterday and today.
In this Lecture we will challenge you with the Vampire Problem
Background
Your mom just landed her dream job in California, suddenly uprooting you from your home on the east coast and moving to Sunnydale. You soon become friends with Buffy the Vampire Slayer and realize that knowing how to spot a vampire from a distance is actually very important. While Buffy never worries about knowing who is a vampire and who isn't, you find yourself quite concerned. There are, of course, physical cues that can lead you to know who is a vampire, but sometimes that just is not enough.
After you help Buffy, Willow, and Xander slay a few of the creeps, you start to notice that all the vampire names follow a pattern they have 3 consonants for every 2 vowels in their first name ('y' is considered a consonant). This means that Buffy, Willow, and Xander can't be vampires (you find this soothing), but that Angel and Spike certainly are vampires. For a moment you become fearful of Giles, but you quickly remember that his first name is Rupert, so he also must be a human.
Using your programming skills, you decide to write a program to recognize vampires by name so that you can distribute your new knowledge to the rest of the town. When the program starts up, it should read a number of names from a data file and should print out whether or not the person is a vampire or not, based on the name.
In this Lecture we will challenge you with the Space Age Problem
Background
Given an age in seconds, calculate how old someone would be on:
Earth: orbital period 365.25 Earth days, or 31557600 seconds
Mercury: orbital period 0.2408467 Earth years
Venus: orbital period 0.61519726 Earth years
Mars: orbital period 1.8808158 Earth years
Jupiter: orbital period 11.862615 Earth years
Saturn: orbital period 29.447498 Earth years
Uranus: orbital period 84.016846 Earth years
Neptune: orbital period 164.79132 Earth years
So if you were told someone were 1,000,000,000 seconds old, you should be able to say that they're 31.69 Earth-years old.
In this Lecture we will challenge you with the Reflections Problem
Background
In this problem, you are given two parallel lines of length L, running horizontally that are a distance D apart. Imagine a person standing at a point marked P holding a laser. Note that P is at the very left end point of the lines . At some time, the person standing there fires a shot from his laser at some angle x, from the horizontal. You are to find the number of times the laser is reflected off the two parallel lines before exiting at the other end.
The input file is called (reflections.txt) will contain three sets of data. Each set of data will contain three lines. Each line will contain a floating point value. The first line of each set will contain L, the length of the lines. The second line of each set will contain D, the distance between the two lines. The third line of each set will contain x, the angle from the horizontal, in degrees, at which the laser is shot, 0 <= x < 90.
The output will contain three lines of data, corresponding to each set in the input file. It will display the number of reflections made.
In this Lecture we will challenge you with the Epidemiology Problem
Background
People who study epidemiology use models to analyze the spread of disease. In this problem, we use a simple model. When a person has a disease, they infect exactly R other people but only on the very next day. No person is infected more than once. We want to determine when a total of more than P people have had the disease.
I hope that including this problem at this time highlights the important roles that computer science and mathematics play in solving real-world problems.
Input Specification (virus.txt)
There are three lines of input. Each line contains one positive integer. The first line contains the value of P. The second line contains N, the number of people who have the disease on Day 0. The third line contains the value of R.
Output Specification
Output the number of the first day on which the total number of people who have had the disease is greater than P.
Sample Input
750
1
5
10
2
1
Output for Sample Input
4
5
In this Lecture we will challenge you with the Secret Instructions Problem
Background
Professor Santos has decided to hide a secret formula for a new type of biofuel. She has, however, left a sequence of coded instructions for her assistant.
Each instruction is a sequence of five digits which represents a direction to turn and the number of steps to take.
The first two digits represent the direction to turn:
• If their sum is odd, then the direction to turn is left.
• If their sum is even and not zero, then the direction to turn is right.
• If their sum is zero, then the direction to turn is the same as the previous instruction.
The remaining three digits represent the number of steps to take which will always be at
least 100.
Your job is to decode the instructions so the assistant can use them to find the secret formula.
In this Lecture we will challenge you with the Morsican Navigation Problem
Background
One day, while you're sitting at your desk working on your latest programming project, you hear a strange whirring sound. You spin around quickly, looking for the source of the noise as it grows louder and see the TARDIS appear in your living room. You hold your breath as the door opens and the Doctor leans out. "Well, what are you waiting for?", he says, "Get in! We haven't got all day!" You jump up, leaving your project behind without a thought, and enter the time ands pace traveling box.
On your first journey, you travel to the Morsican System, home of the Morsicus race. The Morsicans are threatening an invasion of Earth to feast on the hopes and dreams of aspiring programmers, which is their main source of food. Unfortunately, the TARDIS’ navigational system is down… again. You successfully made it to the edge of the planetary system, but there’s no good way to get to the Morsican home planet while the navigation system is still down. Luckily for you, this system contains mostly empty space and the only object of any legitimate size is the Morsican planet. You simply need to get close so that you can see it. The Doctor goes below the console to try and repair the system, but you decide to take matters into your own hands and write a program to navigate to the planet yourself.
First, ask the user for the row and column of the planet. Then, read in a path (a path is a string of characters symbolizing up (u), down (d), left (l), and right(r)). Starting in the upper left hand square of the map (which is the space (1,1)), you should test the path to see if it will succeed in getting you to the planet.
You may assume the path will never go off the edge of the map. If you end on a space marked by a *, your journey is successful and you will be able to meet the Morsicans (so you should print a statement letting you know)! Otherwise, your journey fails and you should print out that you didn’t make it to the planet. If you pass over the planet but don't finish on it, you do not find the planet.
In this Lecture we will challenge you with the Space Ship Problem
Background
The year is 2114. The evil Phil Bates, leader of the Blooscrein Empire, is trying to destroy the human race to make room for his own species. The Earth division of the United Network of Intergalactic Transmissions (UNITs) selected you to deliver a distress signal to neighboring star systems. You must get this message through to avoid the extermination of mankind and the further domination of the Blooscreins. They have provided you with an old computer system, much like the one in front of you, and a cloaking spaceship. However, the Blooscrein warships have superior technology. If you fly too close to them, their more advanced radar systems will be able to find you. You have managed to escape Earth, but will you save mankind?
The Problem:
You are currently in the middle of a galaxy called MicroStars, surrounded by Blooscrein Empire’s star fleet. Fortunately, your spaceship knows the range of each enemy warship’s radar. So, you decide to write a program that will tell you how many Blooscrein warships can “see” you. Given your location, and the location and effective range of each enemy’s radar, determine how many warships will pick you up. The Blooscrein radar systems will detect you even if you are at the very edge of the radar’s range. Assume the radar signals emit from the location of the ship and that the sizes of all ships are negligible.
The Input: (space.txt)
The first line of the file will consist of the number of data sets, n. The first line of each data set contains four integers, x, y, z, and e; (x, y, z) is your position in 3D space and e is the number of Blooscreins in your vicinity. The following e lines each contain four integers, xi, yi, zi, di. These represent the position and effective radius of each warship’s radar.
The Output:
For each data set, print the line “You will be picked up by x radars.” where x is the number of enemy ships that will detect your spaceship.
In this Lecture we will challenge you with the Craps Problem
Description
The game of craps uses a standard pair of dice, with the rules: The user rolls the dice. They win if the total value of their first roll is 7 or 11. They lose if the value is 2, 3, or 12. If they neither win nor lose, the value of their first roll is called the point. They continue rolling until they get another roll matching the point (they win), or a 7 appears (they lose). Here are some example games:
• The user rolls 7 on their first roll. They win.
• The user rolls 11 on their first roll. They win.
• The user rolls 2 on their first roll. They lose.
• The user rolls 3 on their first roll. They lose.
• The user rolls 12 on their first roll. They lose.
• The user rolls 5. The game continues, with the point being 5. If they next roll 4, the game continues. If they then roll 3, the game continues. If they then roll 5 (matches the point), they win and the game is over.
• The user rolls 5. The game continues, with the point being 5. If they next roll 4, the game continues. If they then roll 7, the game is over and they lose.
Some over-zealous players like to roll the dice and ignore whether the game is over (at which point security is called to escort the player from the premises). Your program is to determine if the player has won the game or not, in addition to determining whether or not they have continued to roll after the game is over. There are five possibilities:
• The player stopped exactly when the game was over, and they won.
• The player stopped exactly when the game was over, and they lost.
• The player continued rolling after they won.
• The player continued rolling after they lost.
• The player stopped rolling when the game was not finished.
Input File:craps.txt
Input Format: Each line will contain a series of integers. The first integer specifies the number of times the user throws the dice, N, which will have a maximum value of 20. Following that number will be N integers, each having a value between 2 and 12. These are the consecutive rolls made by the user.
Output Format: Print out a single line of text for each game. The text should contain one of the following messages: Won! Lost! Won, stop rolling! Lost, stop rolling! Keep rolling!
In this Lecture we will challenge you with the Continued Fraction Problem
Background
See pdf file below in resources for all the details
In this Lecture we will challenge you with the UPC Check Digit Problem
Background
The final digit of a Universal Product Code is a check digit computed so that summing the even numbered digits, plus 3 times the sum of the odd-numbered digits, modulo 10, is 0.
For example, take the UPC 070617006092. The sum of even numbered digits is 7+6+7+0+0+2 = 22, and the sum of the odd-numbered digits is 0+0+1+0+6+9 = 16. The total sum is 22+3×16 = 70 = 0 modulo 10. So the code is valid.
You are to read in the file (upc.txt). It will contain a number of lines of data. Each line will contain a 12 digit UPC code that has an invalid check digit.
The output will contain the UPC codes with the correct check digit.
In this Lecture we will challenge you with the Zellers Congruence Problem
Background
Zeller’s Congruence determines the day of the week for any date since October 15, 1582 of the Gregorian Calendar. For example, January 21, 2005 is a Friday.
The formula for Zeller’s Congruence is:
DW =(INT((26 * (M + 1)) / 10) + K + Y + INT(Y / 4) + INT(C / 4) - (2 * C )) MOD 7
IF DW < 0 THEN DW=DW+7
Where M is the month as you would expect (March = 3, April = 5, May = 5, etc.) EXCEPT January and February are considered the 13th and 14th month of the PREVIOUS year, K is the day of the month, C is the century, Y is the year in the century, and DW is the day of the week ( 0 = Saturday, 1 = Sunday, 2 = Monday, ... 6 = Friday )
Write a program that determines the day of the week given a date.
In this Lecture we will challenge you with the Dvorak Keyboard Problem
Background
The Dvorak Simplified Keyboard is a keyboard layout patented in 1936 by Dr. August Dvorak, an educational psychologist and professor of education at the University of Washington in Seattle, as an alternative to the more common QWERTY layout.
If someone were to have Dvorak enabled on their computer, and a guest were to start typing while expecting the standard QWERTY layout, then the text would come out as nonsense. You are to write a program to de-scramble any such message.
In this Lecture we will challenge you with the Semi-Prime Problem
Background
In mathematics, a semiprime number is a natural number that is the product of exactly two prime numbers. For example: 4, 6, 9, 10, 14, 15, 21, 22 are the first eight semiprime numbers.
Given a set of numbers, one should be able to identify semiprime numbers contained in that set. The input file semi.txt will contain five integers, one per line. 1 <= N <= 1000.
The output will contain five lines, stating if the supplied integers were "semiprime" or "not".
In this Lecture we will challenge you with the Football Scoring Problem
Background
We wish to determine the number of ways of achieving a given score in American football. For the purposes of this
program, we assume that there are only two ways of scoring:
• A field goal: 3 points
• A touchdown: 7 points
For example, there are 3 ways to score 45 points:
• 15 field goals
• 8 field goals and 3 touchdowns
• 1 field goal and 6 touchdowns
Your program should take as input a list of nonnegative integer scores no greater than 100, and it should output
the number of ways of achieving each of the scores.
In this Lecture we will challenge you with the Favourite Digit Problem
Background
Simply speaking, you need to know how to handle your numbers well. Given an integer, what is the largest digit present in that number?
The input file digits.txt will contain 5 or more lines, integers 0 <= N <= 1,000,000.
The output will display a single integer 0 <= n <= 9 -- the largest digit present in the corresponding input number.
Sample Input (digits.txt)
1
10
102
1025
9999
Sample Output:
1
1
2
5
9
In this Lecture we will challenge you with the ROT13 Encryption Problem
Background
ROT13 as in "rotate by 13" is a really simple cipher algorithm, that just advances every letter by 13 places, wrapping around from Z to A. Since applying the algorithm twice would advance each letter by 26 places, it has a really neat property that encryption and decryption are the same function.
The input file rot.txt will contain at least 5 lines, strings 1 <= N <= 250 characters long.
The output will display the corresponding strings that were run through ROT13 function once.
Note: The character rotation should apply only to alphabetic characters. Spaces, digits, and punctuation should stay as is.
Sample Input (rot.txt … first two shown):
EBG13 FNZCYR.
ROT13 SAMPLE.
Sample Output (first two shown):
ROT13 SAMPLE.
EBG13 FNZCYR.
In this Lecture we will challenge you with the Roman Numeral Problem
Background
What is this Roman Numeral .
Although today's use of Roman numerals is typically limited to movie titles or the pages preceding the main part of a book (and thus are typically small), let's build a Roman-to-decimal converter anyway. Just for the LOLs.
The input file roman.txt will contain 5 lines, Roman numerals with values 1 <= N <= 2000.
The output will contain 5 lines, the decimal values of the input numbers.
For your reference, the symbols are as follows: I 1 V 5 X 10 L 50 C 100 D 500 M 1000 .
Numbers in between the symbols are constructed by adding the symbols together (e.g. II for 2) - or by subtracting, which is done by placing a smaller symbol in front of a larger one (e.g. IV for 4).
Note: Be cautious that the numbers are slightly more complicated than simply adding the values of symbols in order. While XI (11), XII (12), XIII (13) are simple enough, XIV (14) breaks the pattern (that is, it is not 10 + 1 + 5, but 10 + (5 - 1)).
In this Lecture we will challenge you with the Simple Checksum Problem
Background
A checksum is a type of simple error detection scheme, meant to catch incorrectly entered data such as typos. Credit cards, for example, use the Luhn algorithm to generate account numbers. Alternatively, a checksum could be a digit appended to the end of a number that needs to be later validated.
A super-simple scheme used to validate 6-digit student numbers is as follows:
Break the number up into 6 digits.
Add up all the digits together to get a new number.
Repeat the process until the result is only a single digit.
Match the resulting digit to the capital letter of alphabet, in that position.
Example
123456
1+2+3+4+5+6 = 21
2+1 = 3
3 = C
The input file numbers.txt will contain 5 lines, each being a 6-digit positive integer followed by a space and a capital letter. Numbers will not have leading zeros, and thus digits will never add up to 0.
The output will contain 5 lines, stating match or error, depending if the number generates the same checksum letter as supplied or not.
Sample Input:
123456 C
123456 A
100000 A
111111 F
111114 I
Sample Output:
match
error
match
match
match
In this Lecture we will challenge you with the Fergusonball Rating Problem
Background
Fergusonball players (Basketball) are given a star rating based on the number of points that they score and the number of fouls that they commit.
Specifically, they are awarded 5 stars for each point scored, and 3 stars are taken away for each foul committed. For every player, the number of points that they score is greater than the number of fouls that they commit. Your job is to determine how many players on a team have a star rating greater than 40. You also need to determine if the team is considered a gold team which means that all the players have a star rating greater than 40.
Input Specification (ferguson.txt)
The first line of input consists of a positive integer N representing the total number of players on the team. This is followed by a pair of consecutive lines for each player. The first line in a pair is the number of points that the player scored. The second line in a pair is the number of fouls that the player committed. Both the number of points and the number of fouls, are non-negative integers.
Output Specification
Output the number of players that have a star rating greater than 40, immediately followed by a plus sign if the team is considered a gold team.
In this Lecture we will challenge you with the Bob Problem
Background
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question.
He answers 'Whoa, chill out!' if you yell at him.
He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
He says 'Fine. Be that way!' if you address him without actually saying anything.
He answers 'Whatever.' to anything else.
Bob's conversational partner is a purist when it comes to written communication and
always follows normal rules regarding sentence punctuation in English.
Assume there exists a data file called bob.txt with an undetermined number of
statements which Bob will respond to.
Input (bob.txt)
How are you today?
WHAT ARE YOU DOING
I just returned from shopping.
WHAT’S YOUR NAME?
Output
Sure
Fine. Be that way!
Whoa, chill out
Whatever
Calm down, I know what I’m doing!
In this Lecture we will challenge you with the Muddy Paws Problem
Background
There have been a few rain storms the last couple of days, but the puppies still had to go outside to play. Coming back inside, the puppies left muddy paw prints all over the house.
You are tasked with trying to clean as many rooms of the house as you can, but you only have so much cleaner. Write a program to determine how many of the rooms in the house you can clean if you have 10 gallons of cleaner. Each gallon of cleaner can clean a maximum of 500 square feet.
Your program should read in the square footage (given as a whole number) of each room.
The data inputs (paws.txt) are given in ascending order of size.
Finally, your program should output the number of rooms you can clean.
Sample 1 Input (paws.txt)
500
3000
4000
Sample Output
2 room(s) were cleaned.
In this Lecture we will challenge you with the Difference of Squares Problem
Background
Find the difference between the square of the sum of the digits and the sum of the squares of each digit
for a given number.
Take the number 12345
The square of the sum of the digits is (1 + 2 + 3 + 4 + 5)² = 15² = 225.
The sum of the squares of the digits 1² + 2² + 32 + 42 + 52 = 55
Hence the difference 225 - 55 = 170.
Assume you will need to read in a series of numbers which indicate a range (lower-upper) and determine
for each of these ranges which numbers in the range have “Difference of Squares” greater than 150
Input (numbers.txt)
123 197
86 98
352 380
Output
Range -> 123 197
--------------------------------------------------------------
179 has a difference of 158
188 has a difference of 160
189 has a difference of 178
197 has a difference of 158
--------------------------------------------------------------
Range -> 86 98
--------------------------------------------------------------
No differences greater than 150 for this range
--------------------------------------------------------------
Range -> 352 380
--------------------------------------------------------------
358 has a difference of 158
359 has a difference of 174
367 has a difference of 162
368 has a difference of 180
369 has a difference of 198
376 has a difference of 162
377 has a difference of 182
378 has a difference of 202
379 has a difference of 222
---------------------------------------------------------------
In this Lecture we will challenge you with the Silent Auction Problem
Background
A charity is having a silent auction where people place bids on a prize without knowing anyone else’s bid. Each bid includes a person’s name and the amount of their bid. After the silent auction is over, the winner is the person who has placed the highest bid. If there is a tie, the person whose bid was placed first wins. Your job is to determine the winner of the silent auction.
In this Lecture we will challenge you with the Diff Text Utility Problem
Background
While diff is a useful text processing utility that finds the difference between contents of files, this baby diff will start out as a simplistic check, counting how many of the leading characters of two lines of text are the same. The hopes and dreams of this program is to grow up into a fullfledged utility, but for now, it starts small.
The input file diff.txt will start off with a number representing the number of sets of two lines .
Each line will be a non-empty string less than 255 characters long.
The output will contain integers 0<=i<=255 where i is the number of leading characters that are the same between the two lines, up to the first difference.
Note: the two lines could be of different length. The counter stops before the first character that doesn't match, so two strings that start differently would be a result of 0.
In this Lecture we will challenge you with the Secret Instruction Problem
Problem Description
Professor Santos has decided to hide a secret formula for a new type of biofuel. She has, however, left a sequence of coded instructions for her assistant.
Each instruction is a sequence of five digits which represents a direction to turn and the number of steps to take.
The first two digits represent the direction to turn:
• If their sum is odd, then the direction to turn is left.
• If their sum is even and not zero, then the direction to turn is right.
• If their sum is zero, then the direction to turn is the same as the previous instruction.
The remaining three digits represent the number of steps to take which will always be at least 100. Your job is to decode the instructions so the assistant can use them to find the secret formula.
Input Specification (secret.txt)
There will be at least two lines of input. Each line except the last line will contain exactly five digits representing an instruction.
Output Specification
There must be one line of output for each line of input . These output lines correspond to the input lines (in order). Each output line gives the decoding of the corresponding instruction: either right or left, followed by a single space, followed by the number of steps to be taken in that direction.
In this Lecture we will challenge you with the Backyard Overhaul Problem
Problem Statement
This summer, the Griswald family would like to host the bi-weekly neighborhood barbeque. In order to prepare, they want to install brand new two-toned brick edging around their flower bed, but they aren't sure what will look best. They tell the construction company that whatever design they pick will be fine as long as it adheres to the following rules:
The design must use a different number of red bricks and tan bricks.
The design cannot use 3 or more consecutive bricks of the same color.
Given a sequence of colored bricks, output whether or not the sequence conforms to the Griswald family's design rules.
Input (backyard.txt)
Your program should take the following input:
A string containing the colors of each brick (R for red and T for tan)
Output
Your program should output "True" or "False" indicating that the given grid of bricks conforms or does not conform to the specified rules.
Input(backyard.txt)
RRTTR
TRRTTRTR
TRRR
Output
RRTTR Conforms
TRRTTRTR Does Not Conform
TRRR Does Not Conform
In this Lecture we will challenge you with the Dice Roll Combinations Problem
Problem Statement
There are several games and puzzles that are done using dice. This problem will use standard dice that
have six sides, numbered 1, 2, 3, 4, 5, and 6. If we roll some dice, the total sum is the sum of values on
the top face of the dice. Given the total sum of three dice that were rolled, output all the combina?ons
of rolls that are equal to the total sum. Your program should also output the total number of
combinations found.
Input Format(roll.txt)
The input format is the total as a whole number.
Output Format
All of the dice combinations should be outputted first, one per line. Finally, the total number of dice
combinations should be outputted on its own line.
Sample Input
15
Sample Output
(3, 6, 6)
(4, 5, 6)
(4, 6, 5)
(5, 4, 6)
(5, 5, 5)
(5, 6, 4)
(6, 3, 6)
(6, 4, 5)
(6, 5, 4)
(6, 6, 3)
10
In this Lecture we will challenge you with the Out of Order Orders Problem
Problem Statement
Frieda's First Come, First Served FroYo prides itself on serving customers in the exact order that they place their orders. Unfortunately, frozen yogurt machines are constantly in need of repair, so sometimes a customer's order is delayed and they have to wait while others who placed their order later receive their FroYo first. Frieda especially doesn't like it when an earlier order is picked up after one placed later.
Each order is assigned a number that is a positive integer, where each order number is always bigger than the last order issued. For example, if a customer places an order and receives order number 42, the very next order placed may be number 45 (their order system is a little glitchy).
Frieda uses a tracking system to determine when customers receive their food. The tracking system records a list of integers representing order numbers, which are listed in the order that the customers received their FroYo. Write a program to determine how many customers received their order directly after a larger order number than their own.
Input
Your program should take the following input:
Sets of order numbers as integers, each falling between 0 and 100 up to possibly 50 orders. per set. There may be more than one set You may assume all customers receive their food.
Output
Your program should output the number of customers who receive their food directly after a larger order number as a positive integer
Sample Input (orders.txt)
41 43 42 44 45 47
29 28 31 32 36 27 30 35 26
29 28 31 27 30 35 36
Output
Order Numbers 41 43 42 44 45 47
Number of orders out of order 1
Order Numbers 29 28 31 32 36 27 30 35 26
Number of orders out of order 3
Order Numbers 29 28 31 27 30 35 36
Number of orders out of order 2
In this Lecture we will challenge you with the Box Collisions Problem
Problem Statement
Two-dimensional (2D) video games often resolve multiple collisions every frame. If every collision was precise to the pixel, the game could quickly lose performance. One way to handle all these collisions is to use an AxisAligned Bounding Box (AABB). Every collidable object in a game utilizing AABBs is given a fixed (i.e. nonrotating) rectangle, and collision checks simply test if two rectangles intersect.
Write a program that implements AABBs This program should accept a constant width for all rectangles, a constant height for all rectangles, and the unique x/y coordinates for the bottom left corner of two different rectangles. The program should then print if there is a collision or not between the two rectangles. Note that a collision should only occur if the rectangles are overlapping and not just touching. You can assume that the values for width, height, x, and y are non-zero positive integers.
Input (box.txt)
4 6 2 3 4 7
2 2 4 2 6 2
Output
There is a collision
There is no collision
In this Lecture we will challenge you with the ROT13 Cipher Problem
Problem Statement
Substitution ciphers are simple encrypion algorithms where plaintext is replaced with ciphertext based off some fixed system. For example, we could shift or rotate the alphabet by some number of positions as the basis for encrypting a message. Rotating the alphabet by 13 places is known as a ROT13 cipher.
In ROT13, a letter is substituted with a letter that comes 13 places after it. For example, if we start with a normal English alphabet, letters 'a' through 'm' will be substituted with a letter that comes 13 letters after the letter and letters 'n' through 'z' will be substituted with a letter that comes 13 before the letter. Note that this works in both directions (i.e. encryption and decryption are the same operation)
Write a program that will encrypt and decrypt messages using the ROT13 cipher. The program should take as input a message to encode or decode. The message should be encrypted/decrypted, and the result should be printed out.
Input (message.txt)
A non-empty string that is the message to encode or decode. This message will only contain
lower case alpha characters.
Output
Your program should output the message from the user that is encrypted or decrypted based
off of the inputs.
Sample
Input (message.txt)
hello
cookie
tbpngf
Output
uryyb
pbbxvr
gocats
In this Lecture we will challenge you with the Figure Skating Scoring Problem
Problem Statement
In an effort to avoid scoring controversies, the International Olympic Committee (IOC) has recently adopted a new scoring system for Ice Skating. 12 judges will assign scores from 0.0 to 6.0 to each skater.Then the highest and lowest scores are dropped and the average of the remaining 10 scores is the skater’s final score.
Your job is to write a program that computes the final score for any number of skaters. Input will consist of sets of two lines. The first line is the skaters name and the second line contains the skaters 12 scores from the judges. Scores will be non-negative numbers between 0.0 and 6.0 inclusive. Scores will contain exactly one digit to the right of the decimal point.
Sample input data (skating.txt)
Tim
0.0 1.0 2.0 3.0 4.0 5.0 6.0 6.0 6.0 6.0 6.0 6.0
Bob
3.5 3.7 4.6 6.0 3.0 5.0 5.2 5.7 3.3 3.2 3.0 6.0
Sample Output: Final Ordered Results:
Skating Competition Results
Tim Scores : 0.0 1.0 2.0 3.0 4.0 5.0 6.0 6.0 6.0 6.0 6.0 6.0
Bob Scores : 3.5 3.7 4.6 6.0 3.0 5.0 5.2 5.7 3.3 3.2 3.0 6.0
Final Skating Results ... Sorted
-------------------------------------------------
Tim 4.50
Bob 4.32
In this Lecture we will challenge you with the Soccer Tournament Problem
Problem Statement
In a 4 team round-robin tournament, each team plays all the other teams. There will be six games.
We will input the games results from the first team’s view as “W” for win, “L” for loss, and “T” for tie.
We will list them: A vs B; A vs C; A vs D; B vs C; B vs D; C vs D.
A team’s score is determined by 3 points for each win and 1 point for ties. Losses are zero points.
Given the six letters giving the games results, output the teams’ names and scores in order from highest
to lowest.
Example:
Input (soccer.txt)
W W W L L T
Output:
Team Points
A 9
C 4
D 4
B 0
In this Lecture we will challenge you with the Secret Channels Problem
Problem Statement
A company uses public Internet to carry its phone service. The voice data will be encrypted before
sending to Internet. The encryption algorithm is as follows:
For each four-digit decimal integer,
(1) Add 5 to each digit, divide the sum by 10 and use the remainder to replace the digit,
(2) Swap 1st-digit with 4th-digit,
(3) Swap 2nd-digit with 3rd-digit.
Input (channels.txt)
A series of lines. Each line is a positive four-digit decimal integer.
Output
In each line, print the encrypted four-digit decimal integer.
Sample Input
0123
5890
9999
Sample Output
8765
5430
4444
In this Lecture we will challenge you with the Jenga Problem
Problem Statement
You are writing a computer program that will play Jenga, but first you need to figure out what boards are legal! Given a set of possible Jenga boards, determine if each board is standing or if it has fallen over. A board falls over
if any two consecutive blocks in a row (not column) are both missing, including within the top row. Assume that even two consecutive missing blocks on the top row makes the tower” Fallen.”
Input (tower.txt)
The first line of input is the number of test cases that follow. Each input case will start with a single integer representing the height of the Jenga tower. Each row in the tower appears on a single line and represents the blocks currently still in the board for that row. A ’1’ represents the block being present, a ’0’ represents a removed block. There will be between 1 and 100 test cases, each with one Jenga board of height between 1 and 20.
Output
For each case, output the line “Case x:” where x is the case number, on a single line followed by a single
space and either the word” Fallen” or” Standing”
Sample Input (tower.txt)
4
8
111
111
111
100
101
111
010
111
4
111
111
101
101
5
000
111
111
111
101
8
111
010
111
011
100
101
101
111
Sample Output
Case 1: Fallen
Case 2: Standing
Case 3: Fallen
Case 4: Fallen
In this Lecture we will challenge you with the Title Problem
Problem Statement
A software company has hired you to write software to help grade school children learn grammar. Your first project, and the objective of this problem, is to ensure that a title is presented in its proper case. As you may recall, the first word of a title always begins with a capital letter, and all other words begin with a capital, except “small words”. For this program, the set of small words are restricted to:
a an and the or for on is of
For example the title “the rise and fall of western civilization” should have the first letter of the first word capitalized, in addition to all other words that are not small. Thus, the proper title should be: “The Rise and Fall of Western Civilization”.
Write a program to convert a title into its proper case.
Input File:title.txt
Input Format:
Each line of the input will contain 1 to 7 words. The maximum length of a word is 20 lowercase characters. All characters will be only the lowercase letters a, b, c, … z, except the last word on the line will always be terminated with a period.
Sample Input
the rise and fall of western civilization.
war and peace.
principles of macroeconomics.
classic chess endings.
government.
Sample Output
#1: The Rise and Fall of Western Civilization.
#2: War and Peace.
#3: Principles of Macroeconomics.
#4: Classic Chess Endings.
#5: Government.
In this Lecture we will challenge you with the Exam Grading Problem
Problem Statement
Ms. Garrette needs help grading her multple-choice exams. To prevent cheating, she gave each student an individualized exam. She wants to write a program that, given an answer key and a particular student's responses, calculates the number of incorrect answers. Can you help her?
Input(responses.txt)
The input consists of 2 sets of lines of input. The first line contains the answer key, where each question is represented by a single letter (i.e. a, b, c, or d) corresponding to the correct answer. The following line contains the student's responses in the same format.
Output
For each case, output the line Case x:" where x is the case number, on a single line. This is followed by the number of student responses that did not match the answer key.
Sample Input
abadd
abada
cba
abc
Sample Output
Case 1: abadd – abada … answers not matching is 1
Case 2: cba - abc … answers not matching is 2
In this Lecture we will challenge you with the Roller Coaster Problem
Problem Statement
Richard Andree an American mathematician developed a neat algorithm for generating chains (or sequences) of numbers which he called roller coaster chains.
Here’s how it works:
Consider any natural number N > 1. If N is odd, multiply it by 3 and add 1. Since the number obtained is even, divide it by 2 and repeat the division by 2 as long as an even number is obtained. When an odd number occurs, repeat the initial step and so on, until the final number is 1. If N is even, divide by 2 in the first step and if necessary repeat until an odd number is obtained.
Here is a more mathematical presentation of the algorithm
T0 = N
Tn= 3tn-1 + 1 If Tn-1 is odd
Tn= tn-1/2 if Tn-1 is even
n=1,2,3,......
Interestingly enough the chains always sooner or later arrive at the number 1.
Below are 2 samples.
N=13
Step N
0 13
1 40
2 20
3 10
4 5
5 16
6 8
7 4
8 2
9 1
This one has a cycle length of 10
N=10
Step N
0 10
1 5
2 16
3 8
4 4
5 2
6 1
This one has a cycle length of 7
For any two numbers i and j (i < j, positive integers, 4 digits max) you are to determine the maximum cycle length over all numbers between i and j and the actual number which created the maximum cycle length. The output should contain the original numbers, the maximum cycle length and the actual number.
Sample Input Data: (rollercoaster.txt)
100 200
201 210
900 1000
Sample Output:
100 200 125 171
201 210 89 206
900 1000 174 937
In this Lecture we will challenge you with the Digi Eater Problem
Problem Statement
A Digi-eater is a monster that can be fed with numbers every once in a while. When a Digi-eater eats a number, it evolves multiple times. This particular digi-monster is unique because during evolution, the Digi-eater adds the digits of the number in his belly and eats the sum, evolving again and again until the number in his belly has only one digit. This final number is engraved on his digital belly.
For example, I fed the Digi-eater with the number 987 and saw that it evolved 2 times. Adding all the digits, 9 + 8 + 7, the Digi-eater changed the number to 24. It then ate this number, changed the number to 2 + 4 = 6, leaving his digi-eater 2 levels up in evolution and with a funny number 6 printed on his belly. Help me figure out the number that will be printed on his Digi-eater’s belly before he feeds it again.
Input (digi.txt)
The first line will have only one number T (1 ≤ T≤ 100), the number of test cases. Then T lines follow, each containing one integer N (1 ≤ N ≤ 1,000,000).
Output
For each test case, print the resulting number on its own line.
Sample Input
5
10
33
987
10000
123123
Sample Output
1
6
6
1
3
In this Lecture we will challenge you with the Sleeping Astronaut Problem
Problem Statement
NASA is finally sending astronauts to other planets, and you’re on the team to help develop programs for them to use. Since the astronauts have been training for a while, all of the missioncritical programs (like navigation) have been completed. There’s one small catch, however: not all planets in the galaxy have the same day length as Earth does. In fact, the planet they are traveling to has a 26-hour-long day. This might introduce problems with astronauts’ sleep schedules. So, since regular scheduling programs can’t be relied upon due to the difference in day lengths, NASA project managers have asked you to write a program to verify sleep schedules.
The Problem:
The flight surgeon is planning the sleep schedule for the astronauts, but he must run his plans through your program to verify that each astronaut is getting enough sleep during that week (seven nights) of the mission. So, given a weekly schedule, as well as the desired number of hours of sleep, your job is to see if the schedule for that astronaut is valid for one week (again, seven nights) of 26-hour-long days.
The Input:(sleep.txt)
The first line of the input file will consist of an integer, n, representing the number of sleep plans in the file. Each sleep plan will contain 8 lines each. The first line of the sleep plan will contain a single integer number, x, representing the minimum amount of total time (in hours) that that astronaut should sleep that week. The next seven lines will contain the times, in 26-hour format, for the sleep plan. The time the astronaut will go to sleep and the time the astronaut will wake up will be separated by a dash. The times will be in “HH:MM” format, where HH is the hour and MM is the minutes. All times will be in sequential order, meaning that the time the astronaut is scheduled to wake up will always be after the time the astronaut is scheduled to go to sleep. Also, the time the astronaut is planned to go to sleep the next night will always be after the time the astronaut is scheduled to wake up from the previous night. No astronaut will be scheduled to sleep more than 26 hours in a single sleep period. The last minute of the day will be represented as 25:59, and one minute after that would be 00:00 (midnight). So, an elapsed time from 24:00-02:00 would be precisely four hours (2 hours before midnight, plus 2 hours after midnight.)
The Output:
If the total time the astronaut is planned to sleep during the week is enough, print out “Astronaut #n will sleep enough!” On the other hand, if the astronaut wouldn’t be getting enough sleep, print out “Astronaut #n needs x hours and y minutes more sleep!”, where n is the number of the astronaut, (starting at 1), x is the number of whole hours that need to be added to the sleep schedule for that astronaut, and y is the number of whole minutes (0 < y < 60) that need to be added to the sleep schedule for that astronaut. If either x or y is one, you do not need to change the output to singular form (“hours” to “hour”).
Sample Input:
2
42
23:00-05:00
22:30-04:30
20:00-05:00
25:00-05:00
25:59-00:00
25:00-09:00
22:00-05:00
40
23:00-02:00
25:00-05:00
00:00-04:00
22:15-02:15
01:00-05:00
24:00-05:00
01:00-04:45
Sample Output:
Astronaut #1 will sleep enough!
Astronaut #2 needs 4 hours and 15 minutes more sleep
In this Lecture we will challenge you with the Box Bricks Problem
Problem Statement
Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. "Look, I've built a wall!'', he tells his older sister Alice. "Nah, you should make all stacks the same height. Then you would have a real wall.'', she retorts. After a little consideration, Bob sees that she is right. So he sets out to rearrange the bricks, one by one, such that all stacks are the same height afterwards. But since Bob is lazy he wants to do this with the minimum number of bricks moved. Can you help?
Input (bricks.txt)
The input consists of several data sets. Each set begins with a line containing the number n of stacks Bob has built. The next line contains n numbers, the heights hi of the n stacks. You may assume 1 <= n <= 50 and 1 <= hi <= 100. The total number of bricks will be divisible by the number of stacks. Thus, it is always possible to rearrange the bricks such that all stacks have the same height.
Output
For each set, first print the number of the set, as shown in the sample output. Then print the line "The minimum number of moves is k.'', where k is the minimum number of bricks that have to be moved in order to make all the stacks the same height.
Sample Input
6
5 2 4 1 7 5
Sample Output
Set #1
The minimum number of moves is 5
In this Lecture we will challenge you with the Reducing Improper Fractions Problem
Problem Statement
You were invited to a St. Patrick’s Day party, but you aren’t allowed to leave until you finish your fraction reduction homework. You want to go to the party as soon as possible so you decide to write a program to do your homework for you. Given an improper fraction, calculate its reduced form.
Input
The first line of input is the number of test cases that follow. Each test case is a line containing two integer values. The first integer value will be the numerator n (0 ≤ n ≤ 109 ), the second integer is the denominator d (0 < d≤ 109 ).
Output
For each case output the line “Case x:” where x is the case number, on a single line, followed by a space, and then proper fraction. Each fraction will be of the form “I N/D”, where I is the integer part, N is the numerator of the fractional part, and D is the denominator of the fractional part. If the integer value is less than than 0, only output “N/D”. If both the integer value and the reduced numerator are zero, output “0”. If there is no fractional part, only output “I”.
Sample Input (fractions.txt)
301 100
12 0
89 39
50 25
0 3
25 50
Sample Output
Fraction Results
Case # 1: 301 100 Reduced Fraction: 3 1/100
Case # 2: 12 0 Reduced Fraction: undefined ... zero denominator
Case # 3: 89 39 Reduced Fraction: 2 11/39
Case # 4: 50 25 Reduced Fraction: 2
Case # 5: 0 3 Reduced Fraction: 0
Case # 6: 25 50 Reduced Fraction: 25/50
In this Lecture we will challenge you with the Launch Code Problem
Problem Statement
A country has threatened the world with destruction by using its nuclear weapons. You have been tasked with stopping the launch from happening. It has been discovered that the designer of the launching mechanism had a poor memory so he left hints for himself to remember all of the launch cancellation codes. The hints are just numbers, and the code can be determined by breaking the numbers down into the prime numbers that multiply together to get them (also known as prime factorization).
Your task is to implement a program that will help crack his hints and prevent the world from being destroyed. The input will always be a positive integer and not be greater than 32767. Display each factor separately, even if it appears multiple times.
Input(launch.txt)
16384
35694
2233
Output
2*2*2*2*2*2*2*2*2*2*2*2*2*2
2*3*3*3*661
7*11*29
In this Lecture we will challenge you with the Postive Negative Sum Problem
Problem Statement
Write a C# Sharp program to compute the sum of the positive and negative numbers of an array of integers and display the largest sum, regardless of the sign of the number.
Input (numbers.txt)
-10 -11 -12 -13 -14 15 16 17 18 19 20
-11 -22 -44 0 3 4 5 9
Expected Output:
Original array elements: -10 -11 -12 -13 -14 15 16 17 18 19 20
Largest sum - Positive/Negative numbers of the said array: 105
Original array elements: -11 -22 -44 0 3 4 5 9
Largest sum - Positive/Negative numbers of the said array: -77
In this Lecture we will challenge you with the Harp Tuning Problem
Problem Description
The CCC harp is a stringed instrument with strings labelled A, B, . . . , T. Like other instruments, it can be out of tune. A musically inclined computer science student has written a clever computer program to help tune the harp. The program analyzes the sounds produced by the harp and provides instructions to fix each string that is out of tune. Each instruction includes a group of strings, whether they should be tightened or loosened, and by how many turns. Unfortunately, the output of the program is not very user friendly.
It outputs all the tuning instructions on a single line. For example, the single line AFB+8HC-4 actually contains two tuning instructions: AFB+8 and HC-4. The first instruction indicates that harp strings A, F, and B should be tightened 8 turns, and the second instruction indicates that harp strings H and C should be loosened 4 turns.
Your job is to take a single line of tuning instructions and make them easier to read.
Input Specification (harps.txt)
There will be one line of input which is a sequence of tuning instructions. Each tuning instruction will be a sequence of uppercase letters, followed by a plus sign (+) or minus sign (-), followed by a positive integer. There will be at least one instruction and at least one letter per instruction. Also, each uppercase letter will appear at most once.
Output Specification
There will be one line of output for each tuning instruction. Each line of output will consist of three parts, each separated by a single space: the uppercase letters referring to the strings, tighten if the instruction contained a plus sign or loosen if the instruction contained a minus sign, and the number of turns.
In this Lecture we will challenge you with the Go Fish Problem
Problem Description
My daughters love to play the card game “Go Fish.” The object of the game is to guess what cards your opponent has so you can match cards in your hand. You start with seven cards. If you guess a card correctly, they hand you that card and you go again. If they do not have the card, they say, “Go fish,” and you draw a card from the pile. If you draw the card you guessed, you get to ask again. Otherwise, it’s your opponent’s turn. Write a program for a SIMPLIFIED game of “Go Fish”!
In this simplified version, there will be only 5 turns (10 guesses total). For each guess, output either “HERE’S MY CARD” or “GO FISH”. A player will not go again if they guess the card. Assume you will not take all the cards from your opponent. You will not “draw a card” if you guess incorrectly, so your hand will only get smaller with each correct guess.
Input: (fish.txt)
There will be 12 lines of data. The first 2 lines contain seven cards (2-10, J, Q, K, A) for the 2 hands. The next 10 lines indicate 5 turns of each player guessing a card, the first player guessing from the 2nd players hand, etc.
Output:
For each guess, show either “HERE’S MY CARD” or “GO FISH”.
Example Input
2 4 6 8 J Q K
3 4 5 6 9 10 A
2
6
8
9
J
A
4
5
Q
3
Output to screen:
GO FISH
HERE’S MY CARD
GO FISH
GO FISH
GO FISH
GO FISH
HERE’S MY CARD
GO FISH
GO FISH
GO FISH
In this Lecture we will challenge you with the Divisibility Problem
Problem Description
A positive integer k is a proper factor of an integer n if:
• k does not equal n and
• k divides n; i.e., there is an integer i such that ik = n.
A positive integer n is:
• deficient if the sum of its proper factors is less than n;
• perfect if the sum of its proper factors is equal to n;
• abundant if the sum of its proper factors is greater than n.
Examples:
• 4 is deficient because 1 + 2 < 4.
• 6 is perfect because 1 + 2 + 3 = 6.
• 12 is abundant because 1 + 2 + 3 + 4 + 6 > 12.
Write a program that takes as input a positive integer n and outputs whether n is deficient, perfect, or
abundant.
Input (numbers.txt)
4
6
12
Output
4 is deficient.
6 is perfect.
12 is abundant.
In this Lecture we will challenge you with the Sorted Skating Scores Problem
Problem Description
In an effort to avoid scoring controversies, the International Olympic Committee (IOC) has recently adopted a new scoring system for Ice Skating. 12 judges will assign scores from 0.0 to
6.0 to each skater. Then the highest and lowest scores are dropped and the average of the remaining 10 scores is the skater’s final score. Your job is to write a program that computes the final score for any number of skaters and displays the results in sorted order (highest to lowest)
Input will consist of sets of scores. In every set, the first line is the skaters name and the remaining lines contain the skater’s 12 scores from the judges.. Scores will be non-negative numbers between 0.0 and 6.0 inclusive. Scores will contain exactly one digit to the right of the decimal point.
In the data below, the first number is the number of sets of data to be processed (skaters competing). This number could be up to 100.
Sample input data (skating.txt)
6
Jan
0.0
1.0
2.0
3.0
4.0
5.0
6.0
6.0
6.0
6.0
6.0
6.0
Kevin
3.5
3.7
4.6
6.0
3.0
5.0
5.2
5.7
3.3
3.2
3.0
6.0
Tim
0.0
1.0
2.0
3.0
4.4
5.7
6.0
6.0
6.0
6.0
6.0
6.0
Bob
3.5
3.7
4.6
6.0
3.6
5.3
5.2
5.7
3.8
3.2
3.0
6.0
Jim
0.0
1.5
2.2
3.0
4.3
5.3
6.5
6.0
6.0
6.0
6.0
6.0
Ben
3.5
3.9
4.6
6.0
3.9
5.9
5.9
5.9
3.3
3.2
3.0
6.0
Output
Final Results Sorted
Jim 4.63
Ben 4.61
Tim 4.61
Jan 4.50
Bob 4.46
Kevin 4.32
In this Lecture we will challenge you with the Gremlin Lift Problem
Problem Statement
Gremlin Lifts, a division of CBG Inc (Cheap But Glitchy Incorporated), has installed an elevator in a seven-story building. Due to their upbringing, Gremlin Lifts has numbered the floors 0 – 6 and refuse to re-number them, claiming that the request is “out of scope”. Gremlin Lifts, having been built by actual gremlins, don’t necessarily work the way one might hope.
The Gremlin Lift elevator has the same four 4 buttons in the elevator and on each floor: Up, Down, eXpress and Off. Using a proprietary technology, the elevator only responds to a button if it is already at a floor. Buttons pressed while the elevator is in motion are ignored.
Their transition from floor to floor is governed by the following rules
Pushing any button in the Off state has no effect—there is no on button. At installation the elevator was in the “0” state.
The up button always causes the elevator to go up 2 floors, if it cannot go up 2 floors it does nothing.
Pushing the down button causes the elevator to go down the half the number of floors it is on (rounded up). For example, if the elevator is on floor 5 and down is pressed, the elevator goes to floor 2 (5/2 rounded up is 3 , so the elevator goes down 3 floors and ends stops on floor 2)
The express button causes the elevator to go to the ground (0) floor, except a system glitch means the button does not work when on floor “4”.
The off button only works if on the ground (0) floor. Any button pressed while the elevator is off will not work. Please note that Off is really the ground floor with the elevator turned off.
Input consists of a string that contains any number of the following characters representing each button press : D for Down, U for Up, X for eXpress and O for Off
The output should be the final floor that the elevator is at once all the button presses have been processed as well as the number of invalid button presses (button presses that caused nothing to happen) that were made.
Input(elevator.txt)
UUDUXUDO
UUUDUDUX
OUDU
Output
Stopped on floor 3 … Invalid button presses: 2
Stopped on floor 4 … Invalid button presses: 1
Stopped on floor 0 … Invalid button presses: 3
In this Lecture we will challenge you with Sam's Secret Problem
Description
Sam builds forts with super secret security. To enter Sam’s forts, guests must type a secret passphrase.
The passphrase must contain 3 separate strings, and each string must begin or end with the letter “s”.
Given an input that contains a secret passphrase, your program should output the string “welcome” if the passphrase is valid or output the string “denied” if the passphrase is invalid.
Input(sam.txt)
Sam invites guests
Sam requests cookies
Sam sent me
Sam requests sugar cookies
Output
sam invites guests
Valid number of words in line ... Checking for locations of s
Welcome
sam requests cookies
Valid number of words in line ... Checking for locations of s
Welcome
sam sent me
Valid number of words in line ... Checking for locations of s
Denied
sam requests sugar cookies
Invalid number of words in line ... must be 3
In this Lecture we will challenge you with the Balanced Letters Problem
Description
Given a string, does the string contain an equal number of uppercase and lowercase letters? Ignore whitespace, numbers, and punctuation. Return the string “true” if balanced or the string “false” if not balanced.
Sample Input (balanced.txt)
AaBbCc
Go! Go! Go! Go! Go!
TWO plus TWO equals FIVE
The quick brown fox jumps over the lazy dog
Sample Output
AaBbCc ---> balanced
Go! Go! Go! Go! Go! ---> balanced
TWO plus TWO equals FIVE ---> balanced
The quick brown fox jumps over the lazy dog ---> not balanced
Consider These Edge Cases
Does your program properly handle a string with numbers only?
In this Lecture we will challenge you with the Vanity Number Search Problem
Description
Some companies like to cite an 800 number that has a special connection to something about their business (e.g., 1-800-FLO-WERS). Create a program that reads in a series of phone numbers in the format of 1-XXX-XXX-XXXX, where “X” is an alphanumeric character. All parts of the phone number that are alphabetic characters should be converted to a number based on the following standard mapping found on most phone keypads:
You may assume that the input is perfectly formed (dashed separators always provided, number starts with 1, and no illegal characters are given). Thus, you do not need to perform any specific validation checks on the input, in order to make your program simpler.
Your input and output should resemble the following examples.
Example Input: phone.txt
1-800-FLO-WERS
1-205-GOU-ABGO
Example Output:
The real phone number is 1-800-356-9377
The real phone number is 1-205-468-2246
In this Lecture we will challenge you with the Boat Float Problem
Description
How buoyant your boat is depends, in part, on how large it is. Buoyancy is a balancing act between buoyant force, which pushes your boat out of the water, and weight, which sinks your boat into the water. The lighter your boat -- just you and a fishing pole -- the lower the buoyant force required to keep your boat above the water and the more buoyant the boat. As you add things --- a cooler full of food and drink, a stereo, tackle boxes and fishing buddies --- the boat becomes heavier, rides lower in the water and is less buoyant.
Formulas
Volume of Boat in Cubic Feet
V = Length (feet) x Width (feet) x Height (feet)
Desired Positive Buoyancy (%)
B = Decide how much of the boat, also called the amount of positive buoyancy, you want your boat to have out of the water. If you want to have 50 percent of your boat's sides out of the water, use 0.50. If you want 75 percent of your boat's sides out of the water, use 0.75.
Weight of 1 Cubic Foot of Fresh Water
C = 62.4 pounds
Number of pounds of buoyant force keeping half of your boat out of the water.
F = V x B x C
Given the boats volume (V) in cubic feet, the boats weight in pounds, and the boats desired positive buoyancy percentage (B), determine if the boats actual buoyancy is same or greater than the desired buoyancy. If so, return the string “safe” if same or greater, else return the string “heavy”.
Sample Input (boat.txt)
54 1500 0.50
54 2000 0.50
Sample Output
Safe
heavy
Sample Calculation
54 x 0.50 x 62.4 = 1684.8 weight supported at 50%, 1500 is less than 1684.8 so actual buoyancy is greater than desired buoyancy of 50%, which means the boat is “safe”.
In this Lecture we will challenge you with the Chili Peppers Problem
Problem Description
Ron is cooking chili using an assortment of peppers.
The spiciness of a pepper is measured in Scolville Heat Units (SHU). Ron's chili is currently not spicy at all, but each time Ron adds a pepper, the total spiciness of the chili increases by the SHU value of that pepper.
The SHU values of the peppers available to Ron are shown in the following table:
Pepper Name Scolville Heat Units
Poblano 1500
Mirasol 6000
Serrano 15500
Cayenne 40000
Thai 75000
Habanero 125000
Your job is to determine the total spiciness of Ron's chili after he has finished adding peppers.
Input Specification
The first line of input will contain a positive integer N, representing the number of peppers Ron adds to his chili. The next N lines will each contain the name of a pepper Ron has added. Each pepper name will exactly match a name that appears in the table above. Note that more than one pepper of the same name can be added.
Output Specification
The output will consist of a positive integer T, representing the total spiciness of Ron's chili.
Sample Input (chili.txt)
4
Poblano
Cayenne
Thai
Poblano
Output for Sample Input
118000
Explanation of Output for Sample Input
A Poblano pepper has an SHU value of 1500. A Cayenne pepper has an SHU value of 40000.
A Thai pepper has an SHU value of 75000. The total spiciness of Ron's chili is therefore
1500 + 40000 + 75000 + 1500 = 118000.
In this Lecture we will challenge you with the Caesar WebPage Encryption Problem
Problem Description
After successfully completing your search engine, you are put on a new job. It turns out a rival company is trying to steal your customers by providing direct links to your customer database from their web site. Your job is to encrypt your web pages so that only your web server can access them.
You remember that the ancient Romans used a Caesar cipher, where each letter is replaced by a letter k later in the alphabet (shifting it by k positions). Shifts occur in alphabetical order, between the letters ``a'' and ``z''. If a letter is shifted past ``z'', it starts back at ``a'' and continues shifting. For example, using a caesar cipher where k = 2, the word ``car'' is transformed into ``ect'', while the word ``yaz'' is shifted to ``zcb''.
You decide to go one better. Instead of shifting all letters by the same distance, you will shift each letter by a different amount, based on a code word. Each letter in the code word is converted into a shift amount, based on how many letters it is after ``a''. Text to be encrypted is then shifted by the amount of each letter in the keyword, repeating as necessary.
For instance, suppose your keyword is ``bad''. The shift amounts for the letters are then 1, 0, and 3, respectively. You would encrypt the string ``carrot'' as ``dausow'', shifting ``c'' by one, ``a'' by zero, and ``r'' by three letters, then repeating for ``r'', ``o'', and ``t''.
Input Format (web.txt)
The input will begin with your keyword on a single line. It will then consist of a series of words to be encrypted using the keyword, each on a separate line. You may assume that the keyword and all input will be in lowercase.
Output Format
For each word to be encrypted, output a line containing the encrypted word.
Example
Input:(web.txt)
bad
carrot
aaaaa
Output:
dausow
badba
In this Lecture we will challenge you with the Comparing Grades Problem
As grades from the school year's first science test are being handed back, the students of H.S. High School begin to peer at their marks with dread. With the exception of two particularly competitive friends, that is: Alice and Bob are eager to compare their grades against one another, and see who did better this time around!
Alice received a percentage grade of A (0 ≤ A ≤ 100) on the test, while Bob received a percentage grade of B (0 ≤ B ≤ 100). However, they don't like to compare these exact percentage grades against one another—instead, they think it's more fun to compare their more approximate letter grades. Each percentage grade corresponds to a letter grade according to the following table:
90..100 A
80.. 89 B
70.. 79 C
60.. 69 D
0.. 59 F
According to Alice and Bob's rules, whichever of them receives a worse letter grade than the other will have to do something embarrassing in front of the class. However, if they both receive the same letter grade, then neither of them will be subjected to this punishment.
As one of their fellow classmates, you'd like to find out if anything embarrassing is going to occur, so that you can have your phone at the ready. In other words, you'd like to determine whether or not Alice and Bob received the same letter grade as one another. Output "Same" (without quotes) if their letter grades are the same, or "Different" if they're different.
Input Format (grades.txt)
The first and only line of input consists of two space-separated integers, A and B.
Output Format
Output a single string, either "It’s a tie " if Alice and Bob received the same letter grade, or name of winner otherwise.
Sample Input
84 89
60 59
Sample Output
Alice's Grade 84 Letter Grade B
Bob's Grade 89 Letter Grade B
--->It's a tie!
---------------------------------------------------------
Alice's Grade 60 Letter Grade D
Bob's Grade 59 Letter Grade F
--->Alice wins
---------------------------------------------------------
Sample Explanation
In the first case, both Alice and Bob received a letter grade of B.
In the second case, Alice received a letter grade of D while Bob received a letter grade of F.
In this Lecture we will challenge you with the Special Events Problem
Problem Description:
You are trying to schedule a special event on one of five possible days.
Your job is to determine on which day you should schedule the event, so that the largest number of interested people are able to attend.
Input (special.txt)
The first line of input will contain a positive integer N, representing the number of people interested in attending your event. The next N lines will each contain one person's availability using one character for each of Day 1, Day 2, Day 3, Day 4, and Day 5 (in that order).
The character Y means the person is able to attend and a period (.) means the person is not able to attend.
Output Specification
The output will consist of one line listing the day number(s) on which the largest number of interested people are able to attend.
If there is more than one day on which the largest number of people are able to attend output all of these day numbers in increasing order
Sample Input 1
3
YY.Y.
...Y.
.YYY.
Output for Sample Input 1
4
Explanation of Output for Sample Input 1
All three people are able to attend on Day 4, and they are not all available on any other day.
Sample Input 2 (Extra Challenge)
5
YY..Y
.YY.Y
.Y.Y.
.YY.Y
Y...Y
Output for Sample Input 2
2,5
Explanation of Output for Sample Input 2
There is no day on which all five people are able to attend. Four people are able to attend
on both Day 2 and Day 5.
In this Lecture we will challenge you with the Yobi Problem
Problem Description
Dusa eats Yobis, but only Yobis of a certain size.
If Dusa encounters a Yobi that is smaller than itself, it eats the Yobi, and absorbs its size. For example, if Dusa is of size 10 and it encounters a Yobi of size 6, Dusa eats the Yobi and expands to size 10 + 6 = 16.
If Dusa encounters a Yobi that is the same size as itself or larger, Dusa runs away without eating the Yobi. Dusa is currently facing a line of Yobis and will encounter them in order. Dusa is guaranteed to eventually encounter a Yobi that causes it to run away. Your job is to determine Dusa’s size when this happens.
Input Specification (yobi.txt)
The first line of input contains a positive integer, D, representing Dusa’s starting size. The remaining lines of input contain positive integers representing the sizes of the Yobis in order.
Output Specification
Output the positive integer, R, which is Dusa’s size when it eventually runs away.
Sample Input
5
3
2
9
20
22
14
Sample Output
Dusa's initial size 5
Dusa encounters a Yobi of size 3
Dusa eats the Yobi and grows to size 8
Dusa encounters a Yobi of size 2
Dusa eats the Yobi and grows to size 10
Dusa encounters a Yobi of size 9
Dusa eats the Yobi and grows to size 19
Dusa encounters a Yobi of size 20
Dusa cannot eat the Yobi and must run away!
Final size of Dusa was 19
Size of Yobi that caused Dusa to run away was 20
In this Lecture we will challenge you with the Bronze Count Problem
Problem Description
After completing a competition, you are struck with curiosity. How many participants were awarded bronze level?
Gold level is awarded to all participants who achieve the highest score. Silver level is awarded to all participants who achieve the second highest score. Bronze level is awarded to all participants who achieve the third highest score.
Given a list of all the scores, your job is to determine the score required for bronze level and how many participants achieved this score.
Input Specification
Each line of input contain a single integer representing a participant’s score.Each score is between 0 and 75 (inclusive) and there will be at least three distinct scores.
Output Specification
Output a non-negative integer, S, and a positive integer, P, separated by a single space, where S is the score required for bronze level and P is how many participants achieved this score.
Sample Input 1 (bronze.txt)
70
62
58
73
Output for Sample Input 1
62 1
Explanation of Output for Sample Input 1
The score required for bronze level is 62 and one participant achieved this score.
Sample Input 2
75
70
60
70
70
60
75
70
Output for Sample Input 2
60 2
Explanation of Output for Sample Input 2
The score required for bronze level is 60 and two participants achieved this score.
In this Lecture we will Challenge you with the Ovoo Problem
Problem Description
An Ovoo(oh-voo) is a sacred stone heap that serves as an altar or shrine in Mongolian folk religion. (Fictional information starts here). Each Mongolian clan constructs their own Ovoos. Every day is either a work day or a worship day. During a workday, a new Ovoo is built; during a worship day, the favor of the gods towards a clan (initially zero) increases by the total amount of Ovoos constructed up to that day. The favor of each clan only depends on the amount of Ovoos they constructed, and no Ovoos of other clans are considered.
The Problem:
Given a clan’s schedule, determine the favor of the gods on each worship day.
The Input: (ovoo.txt)
The first line of input will contain a single, positive integer, c, representing the number of clans. For each clan, several input lines follow. The first line of input contains a single integer, n (2 ≤ n ≤ 100), representing the number of days. Then, n lines follow, each containing a single string: WORK or WORSHIP, depending on whether the day is a work day or a worship day. It is guaranteed that the input for each clan begins with a workday and ends with a worship day.
The Output:
For each clan, output a single line containing “Clan #i:” where i is the number of the clan in the input (starting at 1). Then for each worship day, output the favor of the gods on its own line. Leave a blank line after the output for each clan.
Sample Input: (ovoo.txt)
2
10
WORK
WORSHIP
WORK
WORSHIP
WORK
WORSHIP
WORK
WORSHIP
WORK
WORSHIP
4
WORK
WORK
WORSHIP
WORSHIP
Sample Output:
Clan #1:
1
3
6
10
15
Clan #2:
2
4
In this Lecture we will Challenge you with the Anagram Problem
In the adventurous land of Super Mario Brothers, Mario and Luigi have stumbled upon a peculiar puzzle left behind by the ancient Koopa sages. The brothers discovered that certain magical words hold the key to unlocking hidden power-ups, and these words are anagrams of each other, woven with the same letters but in a different order.
To harness these mystical power-ups and gain an edge in their quest against Bowser, the brothers need to quickly determine if two given words are magical anagrams. They have enlisted your help to create a program that can solve this riddle.
Specifically, you need to implement the function:
static Boolean are Anagrams(String word1, String word2) which returns a Boolean Indicating whether word1 and word2 are anagrams or not.
Input: (anagram.txt)
Each line contains one test case, i.e., two words consisting of letters a-z (no capital letters or other symbols). You can assume that 1 <= N <= 10000.
Output:
For each test case, the program will output a single string “Yes” or “No”, indicating whether the two words are anagrams or not. Note that the words may contain repeated letters. For two words to be anagrams, they must contain the same number of repetitions if any.
Input:
listen silent
binary brainy
admirer maried
Yes
Yes
No
In this Lecture we will Challenge you with the Lorapians Palindrome Problem
While exploring their new habitat, Kiri discovered a new species of animals called Lorapians. Lorapians have their own language called Rar, with a unique system of phonemes that allow for palindromic words and sentences. In fact all the words that Kiri has heard so far appear to be palindromic, when written out in the script that Lorapians use.
To study this language further Kiri would like to create a program to check if a given word is a palindrome or not. She needs your help to implement this program.
Input
The data will consist of up to 100 possible test cases. Each test case will be one string, consisting of characters a-z and of a length between 1 and 100.
Output
For each test case output YES or NO
Input(pal.txt)
abracadabra
kayak
amanaplanacanalpanama
Output
No
Yes
Yes
In this Lecture we will Challenge you with the Space Invaders Problem
You are playing the classic video game Space Invaders! In this game, you move a laser cannon at the bottom of the screen left and right while attempting to shoot as many aliens as possible. You have three controls: move left one unit, move right one unit, and fire the cannon. After several hours of playing this game, you decide it is too easy and add a secondary challenge for yourself: finish with the cannon in the middle of the screen. Given a sequence of left and right moves you make and your starting position, you want to determine if you will successfully end in the middle of the screen. Note that the screen does not have bounds and the laser cannon can move left and right as much as desired.
The Problem:
Given a sequence of left and right moves and the starting position, determine if the cannon will end in the middle of the screen.
The Input: (invaders.txt)
The first line of input consists of two integers, n (1 ≤ n ≤ 100) and x (-100 ≤ x ≤ 100), representing the number of commands and the starting position of the laser cannon on the screen, respectively. The middle of the screen is represented by x = 0. The next line will contain a single string of n characters, composed of ‘L’s and ‘R’s. An ‘L’ represents a move left, decreasing the position by one, and an ‘R’ represents a move right, increasing the position by one.
The Output:
Output a single line. If you will successfully end in the middle of the screen, output “Challenge completed!” Otherwise, output “Better luck next time!”
Sample Input
3 1
LLR
5 -1
RRRRR
Sample Output
Challenge Completed!
Better luck next time!
In this Lecture we will Challenge you with the Navigation Problem
One day, while you're sittng at your desk working on your latest programming project, you hear a strange
whirring sound. You spin around quickly, looking for the source of the noise as it grows louder and see the TARDIS
appear in your living room. You hold your breath as the door opens and the Doctor leans out. "Well, what are you
waitng for?", he says, "Get in! We haven't got all day!" You jump up, leaving your project behind without a
thought, and enter the time and space traveling box.
On your first journey, you travel to the Morsican System, home of the Morsicus race. The Morsicans are
threatening an invasion of Earth to feast on the hopes and dreams of aspiring programmers, which is their main
source of food. Unfortunately, the TARDIS’ navigational system is down… again. You successfully made it to the
edge of the planetary system, but there’s no good way to get to the Morsican home planet while the navigation
system is still down. Luckily for you, this system contains mostly empty space and the only object of any legitimate
size is the Morsican planet. You simply need to get close so that you can see it. The Doctor goes below the
console to try and repair the system, but you decide to take matters into your own hands and write a program to
navigate to the planet yourself.
You can assume the Solar System grid can be envisioned as a 10 x 10 grid
Input(nav.txt)
4
3
rrrdlrllddrr
ddrurdd
The first two numbers are the exact row and column of the planet. Then, follows a path (a path is a string of
characters symbolizing up (u), down (d), left (l), and right(r)). Startng in the upper lefthand square of the map
(which is the space (1,1)), you should test the path to see if it will succeed in gettng you to the planet. You may
assume the path will never go off the edge of the map. If you end on a right space (in this case row 4, column 3) ,
your journey is successful and you will be able to meet the Morsicans (so you should print a statement lettng you
know)!
Otherwise, your journey fails and you should print out that you didn’t make it to the planet. If you pass over the
planet but don't finish on it, you do not find the planet. The program loops until no other paths, are read in . We
use the same map for every path.
Sample Run:
Final Row: 4 Final Column: 3
rrrdlrllddrr
You didn't get to the planet
-----------------------------
Final Row: 4 Final Column: 3
ddrurdd
You got to the planet!
-----------------------------
In this Lecture we will challenge you with the Tsunami Problem.
The recent Indian Ocean earthquake was an undersea earthquake that generated a tsunami that was among the most devastating in modern history. The resulting tsunami devastated the shores of Indonesia, Sri Lanka, South India, Thailand and other countries with waves of up to 15 m high. It caused serious damage and deaths as far as the east coast of Africa, 8 000 km away from the epicentre. This disaster has raised the awareness of tsunamis and their destructive powers to many people around the world.
The approximate speed of a tsunami, c, is given by the formula
c = sqrt(gxh)
where
g = 9.8 m/s 2 = acceleration due to gravity
h = water depth in metres
c = wave speed in metres per second
The input file tsunami.txt consists of 3 sets of data. Each set of data contains two lines. The first line contains, h, 500 <= h <= 7000, the average depth in metres of the water and the second line contains, d, 0 < d <= 10000, the distance in kilometres that the tsunami wave will travel. h and d will both be integer values.
The output will contain the time in hours, minutes and seconds (to the nearest second) that
the tsunami wave will take to travel the distance, d.
Sample Input
2500
225
3500
2020
4500
8000
Sample Output
Water depth: 2500 metres, Distance to shore: 225 kilometres Time for Tsunami to Reach Shore: 0 hours, 23 minutes, 57 seconds
Water depth: 3500 metres, Distance to shore: 2020 kilometres Time for Tsunami to Reach Shore: 3 hours, 1 minutes, 46 seconds
Water depth: 4500 metres, Distance to shore: 8000 kilometres Time for Tsunami to Reach Shore: 10 hours, 34 minutes, 55 seconds
In this Lecture we will
discuss future options for students interested in game development
Students will learn to create their own computer programs and video games using the C# programming language. No prior programming experience is assumed. This is a course for REAL BEGINNERS. We will introduce all the required programming skills from the ground up. This programming course is meant for ANYONE WHO WANTS TO LEARN TO CODE. We cover C# syntax but more importantly we introduce the PROBLEM SOLVING SKILLS necessary to convert practical problems to solutions in code. You get paid for solving problems everything else is just a technicality.
Our focus will be working with Visual Studio on WINDOWS machines . All coding examples are fully compatible with the LATEST Visual Studio Edition (As of 2026 Visual Studio Community 2022 and Visual Studio 2026 Insiders) for WINDOWS , Unfortunately they are not MAC compatible
A language like C# is typically learned "in a vacuum," and stripped of potentially distracting visual elements or front end graphical interfaces. This type of learning process - which is considered the standard approach is great for communicating the fundamentals. It allows you to focus on the most important and basic programming concepts you will need to understand, and is often presented through the output of a static, text-based console window. However, learning a language in this console vacuum can also be bland and boring, and can often lead to students becoming disengaged entirely.
Students are more likely to remain engaged by learning how to build Windows applications from day one in tandem with learning the C# programming language. Therefore, my lectures are designed to keep you engaged with the process of learning C# fundamentals by presenting them through a series of lessons aimed at creating simple, Windows Form based applications. This course, by jumping right into apps with a Graphical User Interface, allows the learner to feel like they are learning concepts that produce a tangible result.
I walk you carefully through every possible feature you can imagine, and I use hundreds of existing projects you can learn from, or expand on to make your own project. It's worth sifting through a dozen mediocre Udemy courses to find a gem like this. It's pretty close to a one stop shop for taking you from knowing nothing about WinForms, to building your own whole applications.
C# is a masterpiece in language design.
C# doesn’t have all the associated headaches of C++, nor the drudge work of Java—but contains almost all of their advantages.
C# is versatile: you can write web apps, games, desktop software, iOS and Android apps, and so forth. Probably the only area where Python beats C# is AI and Data Analytics , quite possibly due to the Python libraries and the established knowledge-user-base around it.
In modern web development, with C# you don’t even have to write client side Javascript. Blazor is a C# framework that enables you to build interactive client side applications with only HTML, CSS, and C#! Should you need to use Javascript, Blazor also supports interoperability with JavaScript libraries.
In game development, using C# (Monogame engine) you can get started in your programming journey by directly writing games which is more fun than dry exercises.
This course has more hours of video instruction (18 + hours) , lectures (90+) and exercises and supplemental resources (400+) than virtually any other Introductory C# course offered on Udemy. All for one low price.
Students will be exposed to all the stages in software development and develop problem-solving skills as well as learn the syntax of the C# language.
The challenges and applications are drawn from a variety of situations in the home, school and workplace. They address a wide spectrum of interests including business, science, math, art, music, and especially ANIMATION and GAMES (1/4 of the lectures).
My goal is not just to show you how to program, but to help you understand what you are doing, and why you are doing it. I am online daily to respond to any problems you may encounter.
Not only do the videos show you how to become a programmer in great detail, but each time an important concept is taught, I offer you a challenge that is designed to help you really understand what you have just learned.
You will go away and complete the challenge, and then come back and see the challenge answered and explained in detail in the video, allowing you to check your results!
Here's how I will help you to succeed:
o Each lecture starts with a list of objectives and speaking notes
o Every example covered in the lecture is available for download in the resources section including the objectives/speaking notes
o Almost every lecture has a set of Practice problems with full solutions provided
o My style of writing and teaching follows the KISS principle : Keep It Super Simple.
I try to stay away from fancy computer terminology and try to teach like am speaking to a brand new user with little to no previous knowledge on the subject matter, etc. and I am always available for help, replying most times within a day.
This is NOT a static course, updates are made several times a month, with new Lectures and Challenge Problems (114 + as of Apr 2026 fully solved) added on a continual basis.
And finally please do not judge a book by it's cover don't judge the course by the title or this small description section, if you want to know exactly all the topics covered please go to:
COURSE CONTENT
Sections
Lectures (press the down arrow) This will open up literally thousands of lines of very detailed lecture descriptions leaving no doubt what is and what is not covered.