Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python 3.x Purpose: To build a slightly more complex program and test it. To get warmed up with Python, in case you are using it
Python 3.x
Purpose: To build a slightly more complex program and test it. To get warmed up with Python, in case you are using it for the first time. Degree of Difficulty: Moderate. There many ways to complete this problem, but don't leave this to the last minute. The basic functionality is easy. There are aspects of the problem that you won't appreciate until you start testing. A mathematician named Blaise Pascal has been accused of murder, and Phoenix Wright, ace attorney. has taken the case as the defence attorney. A piece of paper with what appears to be a Pascal's Triangle written on it was found at the crime scene. If the paper does in deed have a correct Pascal Triangle on it (EvidenceTriangle.txt from moodle), then the defendent will be found guilty (Prosecutor: 1. Only Pascal could successfully write such a large Pascal's triangle. 2. The triangle is named after Pascal, which is pretty incriminating if you ask me). However if the found Pascal's Triangle turns out to be incorrectly constructed, Pascal will be found innocent (Phoenix Pascal would NEVER make a mistake creating his triangle!). Phoenix isn't great at math, and needs your help for this case! A Pascal's triangle is a triangular array of numbers. Typically, the top row is row O, and for each row there are (row number) + 1 numbers. Each number is the sum of the number above it and to the left, and the number above it and to right The top row is special, and contains only a 1. See https://en.wikipedia. org/wiki/Pascal%27s_triangle for more information. 1 1 1 2 1 3 1 4 6 1 5 10 1 1 3 1 4 10 5 1 1 In this question you will implement a program that checks whether a series of numbers constitutes of a Pascal's Triangle or not. Your program should work by reading input from the console, and sending an answer to the console, as in the following example: . It reads a number N on a line by itself. This will be the number of rows. The order must be a positive integer, e.g., N>O. It reads N lines of numbers, with each line needing (row number) + 1 positive numbers (Remember row numbers start at O). It checks whether the sequence of numbers is a Pascal Triangle or not. Your program should display the message yes' if it satisfies the above criteria, or 'no' if it does not. 11 | 11 | 121 1331 121 14 31 14 641 The example above shows input entered by the user, with each newline being a new row in the table. The input from the left table should output yes. The example above and to the right should output a no, as on row 3 there's a 4 instead of a 3 remember rows start at 0). There are many ways to solve this problem. Here is an example approach: Your program should first accept all input and then create a Pascal's triangle out of lists or arrays (or lists of lists, or arrays of arrays). Page 6
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started