{"id":"2b109cef-df3c-448a-af91-fc39f275bc25","name":"Queens Permutations - 2d As 2d - Box Chooses","description":"1. You are given a number n, representing the size of a n * n chess board.\r\n2. You are required to calculate and print the permutations in which n queens can be placed on the \r\n n * n chess-board. \r\n\r\nNote -> Use the code snippet and follow the algorithm discussed in question video. The judge can't \r\n force you but the intention is to teach a concept. Play in spirit of the question.","inputFormat":"A number n","outputFormat":"Check the sample output and question video","constraints":"1 <= n <= 5","sampleCode":{"cpp":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void queensPermutations(int qpsf, int tq, int row, int col, String asf, boolean[] queens) {\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 n = Integer.parseInt(br.readLine());\r\n boolean[] queens = new boolean[n];\r\n\r\n queensPermutations(0, n, 0, 0, \"\", queens);\r\n }\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void queensPermutations(int qpsf, int tq, int row, int col, String asf, boolean[] queens) {\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 n = Integer.parseInt(br.readLine());\r\n boolean[] queens = new boolean[n];\r\n\r\n queensPermutations(0, n, 0, 0, \"\", queens);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"2","sampleOutput":"q1\tq2\r\n-\t-\r\n\r\n\r\nq1\t-\r\nq2\t-\r\n\r\n\r\nq1\t-\r\n-\tq2\r\n\r\n\r\nq2\tq1\r\n-\t-\r\n\r\n\r\nq2\t-\r\nq1\t-\r\n\r\n\r\nq2\t-\r\n-\tq1\r\n\r\n\r\n-\tq1\r\nq2\t-\r\n\r\n\r\n-\tq1\r\n-\tq2\r\n\r\n\r\n-\tq2\r\nq1\t-\r\n\r\n\r\n-\tq2\r\n-\tq1\r\n\r\n\r\n-\t-\r\nq1\tq2\r\n\r\n\r\n-\t-\r\nq2\tq1\r\n\r\n\r\n","questionVideo":"https://www.youtube.com/embed/5ujm7QQUwhs?end=215","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":"085def4c-926e-4fce-b10e-6f76ce8516b9","name":"Queens Permutations - 2d As 2d - Box Chooses","slug":"queens-permutations-2d-as-2d-box-chooses","type":1}],"next":{"id":"af526979-c20a-4e27-9908-f0443236d71e","name":"Queens Permutations - 2d As 2d - Box Chooses MCQ","type":0,"slug":"queens-permutations-2d-as-2d-box-chooses-mcq"},"prev":{"id":"d5ad26af-3afe-44f1-9074-3941ac474487","name":"Queens Permutations - 2d As 2d - Queen Chooses MCQ","type":0,"slug":"queens-permutations-2d-as-2d-queen-chooses-mcq"}}}

Queens Permutations - 2d As 2d - Box Chooses

1. You are given a number n, representing the size of a n * n chess board. 2. You are required to calculate and print the permutations in which n queens can be placed on the n * n chess-board. Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.

{"id":"2b109cef-df3c-448a-af91-fc39f275bc25","name":"Queens Permutations - 2d As 2d - Box Chooses","description":"1. You are given a number n, representing the size of a n * n chess board.\r\n2. You are required to calculate and print the permutations in which n queens can be placed on the \r\n n * n chess-board. \r\n\r\nNote -> Use the code snippet and follow the algorithm discussed in question video. The judge can't \r\n force you but the intention is to teach a concept. Play in spirit of the question.","inputFormat":"A number n","outputFormat":"Check the sample output and question video","constraints":"1 <= n <= 5","sampleCode":{"cpp":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void queensPermutations(int qpsf, int tq, int row, int col, String asf, boolean[] queens) {\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 n = Integer.parseInt(br.readLine());\r\n boolean[] queens = new boolean[n];\r\n\r\n queensPermutations(0, n, 0, 0, \"\", queens);\r\n }\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void queensPermutations(int qpsf, int tq, int row, int col, String asf, boolean[] queens) {\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 n = Integer.parseInt(br.readLine());\r\n boolean[] queens = new boolean[n];\r\n\r\n queensPermutations(0, n, 0, 0, \"\", queens);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"2","sampleOutput":"q1\tq2\r\n-\t-\r\n\r\n\r\nq1\t-\r\nq2\t-\r\n\r\n\r\nq1\t-\r\n-\tq2\r\n\r\n\r\nq2\tq1\r\n-\t-\r\n\r\n\r\nq2\t-\r\nq1\t-\r\n\r\n\r\nq2\t-\r\n-\tq1\r\n\r\n\r\n-\tq1\r\nq2\t-\r\n\r\n\r\n-\tq1\r\n-\tq2\r\n\r\n\r\n-\tq2\r\nq1\t-\r\n\r\n\r\n-\tq2\r\n-\tq1\r\n\r\n\r\n-\t-\r\nq1\tq2\r\n\r\n\r\n-\t-\r\nq2\tq1\r\n\r\n\r\n","questionVideo":"https://www.youtube.com/embed/5ujm7QQUwhs?end=215","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":"085def4c-926e-4fce-b10e-6f76ce8516b9","name":"Queens Permutations - 2d As 2d - Box Chooses","slug":"queens-permutations-2d-as-2d-box-chooses","type":1}],"next":{"id":"af526979-c20a-4e27-9908-f0443236d71e","name":"Queens Permutations - 2d As 2d - Box Chooses MCQ","type":0,"slug":"queens-permutations-2d-as-2d-box-chooses-mcq"},"prev":{"id":"d5ad26af-3afe-44f1-9074-3941ac474487","name":"Queens Permutations - 2d As 2d - Queen Chooses MCQ","type":0,"slug":"queens-permutations-2d-as-2d-queen-chooses-mcq"}}}
plane

Editor


Loading...

Queens Permutations - 2d As 2d - Box Chooses

medium

1. You are given a number n, representing the size of a n * n chess board. 2. You are required to calculate and print the permutations in which n queens can be placed on the n * n chess-board. Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.

Constraints

1 <= n <= 5

Format

Input

A number n

Output

Check the sample output and question video

Example

Sample Input

2

Sample Output

q1 q2 - - q1 - q2 - q1 - - q2 q2 q1 - - q2 - q1 - q2 - - q1 - q1 q2 - - q1 - q2 - q2 q1 - - q2 - q1 - - q1 q2 - - q2 q1

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode