{"id":"5ff9cd42-db24-432f-ac9e-464f01f35892","name":"Pattern 15","description":"1. You are given a number n.\r\n2. You've to write code to print the pattern given in output format below.","inputFormat":"A number n","outputFormat":"<img src=\"http://pepcoding.com/resources/ojquestionresource/images/pat151.JPG\" alt=\"pat151\">","constraints":"1 &lt;= n &lt;= 10\r\n Also, n is odd.","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\nint main(int argc, char**argv){\r\n int n;\r\n cin >> n;\r\n\r\n //write your code here\r\n \r\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n\r\n // write ur code here\r\n\r\n }\r\n}"},"python":{"code":"def pattern15(n):\n #write your code here\n \nn = int(input())\npattern15(n)"}},"points":10,"difficulty":"easy","sampleInput":"5\r\n","sampleOutput":"\t\t1\t\r\n\t2\t3\t2\t\r\n3\t4\t5\t4\t3\t\r\n\t2\t3\t2\t\r\n\t\t1\t\r\n","questionVideo":"https://www.youtube.com/embed/TFfzfdGNsV0","hints":[],"associated":[{"id":"2bb1ef0f-af00-4790-aebc-16f3255bf918","name":"(Pattern 15) For n=7 (n stands for input taken from user) how will you denote the middle coloumn?","slug":"pattern-15-for-n-7-n-stands-for-input-taken-from-user-how-will-you-denote-the-middle-coloumn","type":4},{"id":"4ba7aed0-3cad-42cc-bac7-f049999aaa3a","name":"(Pattern 15) In this particular question, what will be the value of spaces while initialising ?","slug":"pattern-15-in-this-particular-question-what-will-be-the-value-of-spaces-while-initialising","type":4},{"id":"a4a4525a-e73d-438b-ac55-3985f94b5986","name":"(Pattern 15) Will the pattern look similar if value of input \"n\" is even ?","slug":"pattern-15-will-the-pattern-look-similar-if-value-of-input-n-is-even","type":4},{"id":"bf3211ba-9ad9-41a5-a354-546a9e1daa12","name":"(Pattern 15) While printing the entities which value should we print ? Assuming variable \"cval\" works on coloumns and variable \"val\" works on rows.","slug":"pattern-15-while-printing-the-entities-which-value-should-we-print-assuming-variable-cval-works-on-coloumns-and-variable-val-works-on-rows","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ca241a91-e685-4c63-9d83-892cf12c5576","name":"Patterns","slug":"patterns-9997","type":0},{"id":"bf608e58-9485-4533-a5ab-643b06e3ceee","name":"Pattern 15","slug":"pattern-15","type":1}],"next":{"id":"5aa3c02e-735d-4b8e-88df-18dc0a334988","name":"Pattern 15","type":3,"slug":"pattern-15"},"prev":{"id":"a7495587-ee4c-484c-9a71-fb266f96a04a","name":"Pattern 14","type":3,"slug":"pattern-14"}}}

Pattern 15

1. You are given a number n. 2. You've to write code to print the pattern given in output format below.

{"id":"5ff9cd42-db24-432f-ac9e-464f01f35892","name":"Pattern 15","description":"1. You are given a number n.\r\n2. You've to write code to print the pattern given in output format below.","inputFormat":"A number n","outputFormat":"<img src=\"http://pepcoding.com/resources/ojquestionresource/images/pat151.JPG\" alt=\"pat151\">","constraints":"1 &lt;= n &lt;= 10\r\n Also, n is odd.","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\nint main(int argc, char**argv){\r\n int n;\r\n cin >> n;\r\n\r\n //write your code here\r\n \r\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n\r\n // write ur code here\r\n\r\n }\r\n}"},"python":{"code":"def pattern15(n):\n #write your code here\n \nn = int(input())\npattern15(n)"}},"points":10,"difficulty":"easy","sampleInput":"5\r\n","sampleOutput":"\t\t1\t\r\n\t2\t3\t2\t\r\n3\t4\t5\t4\t3\t\r\n\t2\t3\t2\t\r\n\t\t1\t\r\n","questionVideo":"https://www.youtube.com/embed/TFfzfdGNsV0","hints":[],"associated":[{"id":"2bb1ef0f-af00-4790-aebc-16f3255bf918","name":"(Pattern 15) For n=7 (n stands for input taken from user) how will you denote the middle coloumn?","slug":"pattern-15-for-n-7-n-stands-for-input-taken-from-user-how-will-you-denote-the-middle-coloumn","type":4},{"id":"4ba7aed0-3cad-42cc-bac7-f049999aaa3a","name":"(Pattern 15) In this particular question, what will be the value of spaces while initialising ?","slug":"pattern-15-in-this-particular-question-what-will-be-the-value-of-spaces-while-initialising","type":4},{"id":"a4a4525a-e73d-438b-ac55-3985f94b5986","name":"(Pattern 15) Will the pattern look similar if value of input \"n\" is even ?","slug":"pattern-15-will-the-pattern-look-similar-if-value-of-input-n-is-even","type":4},{"id":"bf3211ba-9ad9-41a5-a354-546a9e1daa12","name":"(Pattern 15) While printing the entities which value should we print ? Assuming variable \"cval\" works on coloumns and variable \"val\" works on rows.","slug":"pattern-15-while-printing-the-entities-which-value-should-we-print-assuming-variable-cval-works-on-coloumns-and-variable-val-works-on-rows","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ca241a91-e685-4c63-9d83-892cf12c5576","name":"Patterns","slug":"patterns-9997","type":0},{"id":"bf608e58-9485-4533-a5ab-643b06e3ceee","name":"Pattern 15","slug":"pattern-15","type":1}],"next":{"id":"5aa3c02e-735d-4b8e-88df-18dc0a334988","name":"Pattern 15","type":3,"slug":"pattern-15"},"prev":{"id":"a7495587-ee4c-484c-9a71-fb266f96a04a","name":"Pattern 14","type":3,"slug":"pattern-14"}}}
plane

Editor


Loading...

Pattern 15

easy

1. You are given a number n. 2. You've to write code to print the pattern given in output format below.

Constraints

1 <= n <= 10 Also, n is odd.

Format

Input

A number n

Output

pat151

Example

Sample Input

5

Sample Output

1 2 3 2 3 4 5 4 3 2 3 2 1

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode