{"id":"24de9609-a6d6-4403-9619-c052d302d569","name":"Permutation - 1","description":"1. You are give a number of boxes (nboxes) and number of non-identical items (ritems).\r\n2. You are required to place the items in those boxes and print all such configurations possible.\r\n\r\nItems are numbered from 1 to ritems.\r\nNote 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain empty.\r\nNote 2 -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't \r\n force you but intends you to teach a concept.","inputFormat":"Input is managed for you","outputFormat":"Check the sample ouput and question video. 0 means empty box.","constraints":"0 < nboxes <= 10\r\n0 <= ritems <= nboxes","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void permutations(int[] boxes, int ci, int ti){\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int nboxes = Integer.parseInt(br.readLine());\r\n int ritems = Integer.parseInt(br.readLine());\r\n permutations(new int[nboxes], 1, ritems);\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n3","sampleOutput":"12300\r\n12030\r\n12003\r\n13200\r\n10230\r\n10203\r\n13020\r\n10320\r\n10023\r\n13002\r\n10302\r\n10032\r\n21300\r\n21030\r\n21003\r\n31200\r\n01230\r\n01203\r\n31020\r\n01320\r\n01023\r\n31002\r\n01302\r\n01032\r\n23100\r\n20130\r\n20103\r\n32100\r\n02130\r\n02103\r\n30120\r\n03120\r\n00123\r\n30102\r\n03102\r\n00132\r\n23010\r\n20310\r\n20013\r\n32010\r\n02310\r\n02013\r\n30210\r\n03210\r\n00213\r\n30012\r\n03012\r\n00312\r\n23001\r\n20301\r\n20031\r\n32001\r\n02301\r\n02031\r\n30201\r\n03201\r\n00231\r\n30021\r\n03021\r\n00321\r\n","questionVideo":"https://www.youtube.com/embed/QKkHCS5bq0I?end=343","hints":[],"associated":[],"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":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"2cac43ad-2b8f-403e-a23c-3a08d267c58a","name":"Permutation - 1","slug":"permutation-1","type":1}],"next":{"id":"5ef6d01a-cf44-4715-99bc-f21abc2068b3","name":"Permutation -1 MCQ","type":0,"slug":"permutation-1-mcq"},"prev":{"id":"77df6048-2bda-4964-848a-54951d4e10d8","name":"Tug Of War MCQ","type":0,"slug":"tug-of-war-mcq"}}}

Permutation - 1

1. You are give a number of boxes (nboxes) and number of non-identical items (ritems). 2. You are required to place the items in those boxes and print all such configurations possible. Items are numbered from 1 to ritems. Note 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain empty. Note 2 -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

{"id":"24de9609-a6d6-4403-9619-c052d302d569","name":"Permutation - 1","description":"1. You are give a number of boxes (nboxes) and number of non-identical items (ritems).\r\n2. You are required to place the items in those boxes and print all such configurations possible.\r\n\r\nItems are numbered from 1 to ritems.\r\nNote 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain empty.\r\nNote 2 -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't \r\n force you but intends you to teach a concept.","inputFormat":"Input is managed for you","outputFormat":"Check the sample ouput and question video. 0 means empty box.","constraints":"0 < nboxes <= 10\r\n0 <= ritems <= nboxes","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void permutations(int[] boxes, int ci, int ti){\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int nboxes = Integer.parseInt(br.readLine());\r\n int ritems = Integer.parseInt(br.readLine());\r\n permutations(new int[nboxes], 1, ritems);\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n3","sampleOutput":"12300\r\n12030\r\n12003\r\n13200\r\n10230\r\n10203\r\n13020\r\n10320\r\n10023\r\n13002\r\n10302\r\n10032\r\n21300\r\n21030\r\n21003\r\n31200\r\n01230\r\n01203\r\n31020\r\n01320\r\n01023\r\n31002\r\n01302\r\n01032\r\n23100\r\n20130\r\n20103\r\n32100\r\n02130\r\n02103\r\n30120\r\n03120\r\n00123\r\n30102\r\n03102\r\n00132\r\n23010\r\n20310\r\n20013\r\n32010\r\n02310\r\n02013\r\n30210\r\n03210\r\n00213\r\n30012\r\n03012\r\n00312\r\n23001\r\n20301\r\n20031\r\n32001\r\n02301\r\n02031\r\n30201\r\n03201\r\n00231\r\n30021\r\n03021\r\n00321\r\n","questionVideo":"https://www.youtube.com/embed/QKkHCS5bq0I?end=343","hints":[],"associated":[],"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":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"2cac43ad-2b8f-403e-a23c-3a08d267c58a","name":"Permutation - 1","slug":"permutation-1","type":1}],"next":{"id":"5ef6d01a-cf44-4715-99bc-f21abc2068b3","name":"Permutation -1 MCQ","type":0,"slug":"permutation-1-mcq"},"prev":{"id":"77df6048-2bda-4964-848a-54951d4e10d8","name":"Tug Of War MCQ","type":0,"slug":"tug-of-war-mcq"}}}
plane

Editor


Loading...

Permutation - 1

easy

1. You are give a number of boxes (nboxes) and number of non-identical items (ritems). 2. You are required to place the items in those boxes and print all such configurations possible. Items are numbered from 1 to ritems. Note 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain empty. Note 2 -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

Constraints

0 < nboxes <= 10 0 <= ritems <= nboxes

Format

Input

Input is managed for you

Output

Check the sample ouput and question video. 0 means empty box.

Example

Sample Input

5 3

Sample Output

12300 12030 12003 13200 10230 10203 13020 10320 10023 13002 10302 10032 21300 21030 21003 31200 01230 01203 31020 01320 01023 31002 01302 01032 23100 20130 20103 32100 02130 02103 30120 03120 00123 30102 03102 00132 23010 20310 20013 32010 02310 02013 30210 03210 00213 30012 03012 00312 23001 20301 20031 32001 02301 02031 30201 03201 00231 30021 03021 00321

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode