Repl.it Problem Of The Week #4 (POTW) - Pyramids
I am making the problem pyramid themed. The first 2 (A-B) are pretty easy, you need to think for Part C, and D - F are challenging.
Ask the user for input, and print out a simple, left-aligned pyramid, with that many rows of *.
This is easy for people using python :)
Now, do the exact same thing, but print out out right-aligned.
You should be able to do this with some simple math. Now you need to think about the next one.
Oddify (make odd) the number of * in the rows, and then center it.
Part 1 Example Output:
Now just center align it. It may take some time, and if you want to quickly move on to the next section you can read this: String Center Method
Now comes the harder parts. Make the pyramid full of random numbers instead of *, and then print out how many of each number there are. Make sure the numbers are only 1 - 9.
Now for the part leading to most challenging one. Make it so that the lowest numbers are the replaced by *.
Note: If there are two numbers, replace both.
Now, calculate the shortest route to go from the top and bottom. You start at the top, in this case 1, and move down. You can go straight down, diagonal left, or diagonal right. By the shortest route, I mean the route that will get you the lowest sum. When you go over a number, add it to the total. Make sure to print out what the sum is, replace the route with *. (Do not do Part E), and print out the total time it took. If you don't know how to find out how long something took, you can look at this: time.time() Python Method.
Sorry for people using other languages, all tutorials are in python :(
I hope you have fun solving this problem!!! (Or Trying!) :)
Post your answers here: Answers - POTW #4