We post one challenging problem here every week. Solution due is 11:59 PM every Friday. We offer awards to two responders. 1. The first one with the right solution. 2. The correct solution with fewest code statements.
If we get only one correct solution, we will skip the award for the fewest code statements.
You need to create an account in this club in order to participate in this competition. The solution can use one of these three languages: Java, Python, JavaScript. You can submit your solution to this topic. Make sure your name and email account are in the end of the solution.
If you want that we indent your code correctly, please submit your code to this challenge along with a screenshot of your code in your IDE or your code file as an attachment. Remember you still need to submit your code as text here. Thanks for your participation.
Problem: When you play pool game, you use one ball to hit a group ball and then that group ball is scattered over the pool table. Think about this game using letters. Ask the user to input a variant length string of letters (length is no more than 30 but must be lower case letters). Find the letter that occurs the most times in the string (if more than one letter, using the one that appears before the other one) and use it as the hit ball. You use the hit ball to split the string. Find out how many small groups you have. Also find out the smallest group and the biggest group (Both in number of letters. If multiple, using the one with smaller sum of Unicode values for the smallest and the one with bigger sum of Unicode values for the biggest) . Get the difference of the number of letter in the biggest and the smallest group. Divide this number by the number of the total groups. Print the result out.
Here is the link to the Google Drive:
https://docs.google.com/document/d/1lz2ZT1BiwLQo84LgAcWb3QMn84M-hi_KiUbSECn5s_0/edit?usp=sharing
If doesn’t work, use attached file.
Ivan’s Java Challenge Code
Link to the Google Doc: https://docs.google.com/document/d/18XylmyOuz9sHwz3V6iWwVR6vRRKHX3SptsxlNIgKv30/edit?usp=sharing
The only issue your code had was that you did not take care if there are two groups that have the same number of characters.
https://docs.google.com/document/d/1tD7ZFJmWU6sq0-zYSR0Na_k6QfIFSJIqOZCDFP5TO4s/edit
I input hgdtjkltasfmtuvwz, the result you gave is 0. It is actually 0.25.
https://docs.google.com/document/d/1opucPFxWXFszA6kzMUa9DxDUE4DA4KsFdBIBWM6N2cM/edit?usp=sharing
Challenge-61720 (1)
Copy and paste the code into python to run the challenge homework.
You almost got there but the final step was wrong. It shall be divided by 4 because you have 4 groups.
Here is the output.
E:\Python\python.exe C:/Users/yangx/PycharmProjects/AOE/com/aoe/stem/codeflow1.py
Please input a string that has less than 30 characters and is all lowercase letters.hgdtjkltasfmtuvwz
The lettered that occurred the most (or is a hit ball is) t
There are 4 small groups.
The biggest group is uvwz
The smallest group is hgd
The difference between the number of letters in the biggest group and the number of letters in the smallest group is 1
After dividing the difference the final result is 3.25
Process finished with exit code 0
Ivan Zhang is the winner for this week. We only have one winner so based on the rule Ivan is only awarded as the Quickest Problem Solver (Most Efficient Coder is skipped)