We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make it equal by filling each digit [1 ... 9] once in the block: a b * c ---------- d e + f g ---------- = h i
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9}; helper(nums, new ArrayList()); return; } public static void helper(int[] nums, List<Integer> tempPerm) { if (nums.length == tempPerm.size()) { int ab = tempPerm.get(0) * 10 + tempPerm.get(1); int c = tempPerm.get(2); int de = tempPerm.get(3) * 10 + tempPerm.get(4); int fg = tempPerm.get(5) * 10 + tempPerm.get(6); int hi = tempPerm.get(7) * 10 + tempPerm.get(8); if (ab * c == de && de + fg == hi) System.out.println(tempPerm); } for (int n: nums) { if (tempPerm.contains(n)) continue; tempPerm.add(n); helper(nums, tempPerm); tempPerm.remove(tempPerm.size() - 1); } } }
>> [1, 7, 4, 6, 8, 2, 5, 9, 3]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: