{"id":"61220281-1806-4b94-a87b-6cd7f710a0f1","name":"Cryptarithmetic","description":"1. You are given three strings s1, s2 and s3.\r\n2. First two are supposed to add and form third. s1 + s2 = s3\r\n3. You have to map each individual character to a digit, so that the above equation holds true.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing the signature. The judge can't force you but intends you to teach a concept.","inputFormat":"Three strings\r\ns1\r\ns2\r\ns3","outputFormat":"Check the sample output and question video","constraints":"1 &lt;= length of s1,s2,s3 &lt;= 10","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 main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String s1 = scn.nextLine();\r\n String s2 = scn.nextLine();\r\n String s3 = scn.nextLine();\r\n\r\n HashMap<Character, Integer> charIntMap = new HashMap<>();\r\n String unique = \"\";\r\n for (int i = 0; i < s1.length(); i++) {\r\n if (!charIntMap.containsKey(s1.charAt(i))) {\r\n charIntMap.put(s1.charAt(i), -1);\r\n unique += s1.charAt(i);\r\n }\r\n }\r\n\r\n for (int i = 0; i < s2.length(); i++) {\r\n if (!charIntMap.containsKey(s2.charAt(i))) {\r\n charIntMap.put(s2.charAt(i), -1);\r\n unique += s2.charAt(i);\r\n }\r\n }\r\n\r\n for (int i = 0; i < s3.length(); i++) {\r\n if (!charIntMap.containsKey(s3.charAt(i))) {\r\n charIntMap.put(s3.charAt(i), -1);\r\n unique += s3.charAt(i);\r\n }\r\n }\r\n\r\n boolean[] usedNumbers = new boolean[10];\r\n solution(unique, 0, charIntMap, usedNumbers, s1, s2, s3);\r\n }\r\n\r\n \r\n public static void solution(String unique, int idx, \r\n\t\t\t\t\t\t\t HashMap<Character, Integer> charIntMap, boolean[] usedNumbers, \r\n\t\t\t\t\t\t\t String s1, String s2, String s3) {\r\n\t // write your code here\r\n }\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"team\r\npep\r\ntoppr","sampleOutput":"a-3 e-9 m-4 o-1 p-2 r-6 t-0 \r\na-3 e-9 m-5 o-1 p-2 r-7 t-0 \r\na-3 e-9 m-6 o-1 p-2 r-8 t-0 \r\na-4 e-9 m-2 o-1 p-3 r-5 t-0 \r\na-4 e-9 m-5 o-1 p-3 r-8 t-0 \r\na-5 e-9 m-2 o-1 p-4 r-6 t-0 \r\na-5 e-9 m-3 o-1 p-4 r-7 t-0 \r\na-6 e-9 m-2 o-1 p-5 r-7 t-0 \r\na-6 e-9 m-3 o-1 p-5 r-8 t-0 \r\na-7 e-9 m-2 o-1 p-6 r-8 t-0 ","questionVideo":"https://www.youtube.com/embed/RG5rWV6in38?end=136","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":"290727ae-80e8-47e6-ae68-d519960bc20b","name":"Cryptarithmetic","slug":"cryptarithmetic","type":1}],"next":{"id":"b5d0a796-2e3d-4d65-bf91-eec3f50cebad","name":"Cryptarithmetic MCQ","type":0,"slug":"cryptarithmetic-mcq"},"prev":{"id":"8a49d858-7d84-475a-98fa-7d469d2c05f8","name":"Crossword Puzzle MCQ","type":0,"slug":"crossword-puzzle-mcq"}}}

Cryptarithmetic

1. You are given three strings s1, s2 and s3. 2. First two are supposed to add and form third. s1 + s2 = s3 3. You have to map each individual character to a digit, so that the above equation holds true. Note -> Check out the question video and write the recursive code as it is intended without changing the signature. The judge can't force you but intends you to teach a concept.

{"id":"61220281-1806-4b94-a87b-6cd7f710a0f1","name":"Cryptarithmetic","description":"1. You are given three strings s1, s2 and s3.\r\n2. First two are supposed to add and form third. s1 + s2 = s3\r\n3. You have to map each individual character to a digit, so that the above equation holds true.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing the signature. The judge can't force you but intends you to teach a concept.","inputFormat":"Three strings\r\ns1\r\ns2\r\ns3","outputFormat":"Check the sample output and question video","constraints":"1 &lt;= length of s1,s2,s3 &lt;= 10","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 main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String s1 = scn.nextLine();\r\n String s2 = scn.nextLine();\r\n String s3 = scn.nextLine();\r\n\r\n HashMap<Character, Integer> charIntMap = new HashMap<>();\r\n String unique = \"\";\r\n for (int i = 0; i < s1.length(); i++) {\r\n if (!charIntMap.containsKey(s1.charAt(i))) {\r\n charIntMap.put(s1.charAt(i), -1);\r\n unique += s1.charAt(i);\r\n }\r\n }\r\n\r\n for (int i = 0; i < s2.length(); i++) {\r\n if (!charIntMap.containsKey(s2.charAt(i))) {\r\n charIntMap.put(s2.charAt(i), -1);\r\n unique += s2.charAt(i);\r\n }\r\n }\r\n\r\n for (int i = 0; i < s3.length(); i++) {\r\n if (!charIntMap.containsKey(s3.charAt(i))) {\r\n charIntMap.put(s3.charAt(i), -1);\r\n unique += s3.charAt(i);\r\n }\r\n }\r\n\r\n boolean[] usedNumbers = new boolean[10];\r\n solution(unique, 0, charIntMap, usedNumbers, s1, s2, s3);\r\n }\r\n\r\n \r\n public static void solution(String unique, int idx, \r\n\t\t\t\t\t\t\t HashMap<Character, Integer> charIntMap, boolean[] usedNumbers, \r\n\t\t\t\t\t\t\t String s1, String s2, String s3) {\r\n\t // write your code here\r\n }\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"team\r\npep\r\ntoppr","sampleOutput":"a-3 e-9 m-4 o-1 p-2 r-6 t-0 \r\na-3 e-9 m-5 o-1 p-2 r-7 t-0 \r\na-3 e-9 m-6 o-1 p-2 r-8 t-0 \r\na-4 e-9 m-2 o-1 p-3 r-5 t-0 \r\na-4 e-9 m-5 o-1 p-3 r-8 t-0 \r\na-5 e-9 m-2 o-1 p-4 r-6 t-0 \r\na-5 e-9 m-3 o-1 p-4 r-7 t-0 \r\na-6 e-9 m-2 o-1 p-5 r-7 t-0 \r\na-6 e-9 m-3 o-1 p-5 r-8 t-0 \r\na-7 e-9 m-2 o-1 p-6 r-8 t-0 ","questionVideo":"https://www.youtube.com/embed/RG5rWV6in38?end=136","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":"290727ae-80e8-47e6-ae68-d519960bc20b","name":"Cryptarithmetic","slug":"cryptarithmetic","type":1}],"next":{"id":"b5d0a796-2e3d-4d65-bf91-eec3f50cebad","name":"Cryptarithmetic MCQ","type":0,"slug":"cryptarithmetic-mcq"},"prev":{"id":"8a49d858-7d84-475a-98fa-7d469d2c05f8","name":"Crossword Puzzle MCQ","type":0,"slug":"crossword-puzzle-mcq"}}}
plane

Editor


Loading...

Cryptarithmetic

easy

1. You are given three strings s1, s2 and s3. 2. First two are supposed to add and form third. s1 + s2 = s3 3. You have to map each individual character to a digit, so that the above equation holds true. Note -> Check out the question video and write the recursive code as it is intended without changing the signature. The judge can't force you but intends you to teach a concept.

Constraints

1 <= length of s1,s2,s3 <= 10

Format

Input

Three strings s1 s2 s3

Output

Check the sample output and question video

Example

Sample Input

team pep toppr

Sample Output

a-3 e-9 m-4 o-1 p-2 r-6 t-0 a-3 e-9 m-5 o-1 p-2 r-7 t-0 a-3 e-9 m-6 o-1 p-2 r-8 t-0 a-4 e-9 m-2 o-1 p-3 r-5 t-0 a-4 e-9 m-5 o-1 p-3 r-8 t-0 a-5 e-9 m-2 o-1 p-4 r-6 t-0 a-5 e-9 m-3 o-1 p-4 r-7 t-0 a-6 e-9 m-2 o-1 p-5 r-7 t-0 a-6 e-9 m-3 o-1 p-5 r-8 t-0 a-7 e-9 m-2 o-1 p-6 r-8 t-0

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode