This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import combinations, permutations, product | |
from operator import add, sub, mul, truediv | |
def find_solution(numbers, target): | |
operations = [add, sub, mul, truediv] | |
for r in range(1, len(numbers) + 1): | |
for num_subset in combinations(numbers, r): | |
for num_permutation in permutations(num_subset): | |
for op_permutation in product(operations, repeat=r-1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.SneakyThrows; | |
import lombok.extern.slf4j.Slf4j; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.Map; | |
import java.util.Set; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.SneakyThrows; | |
import lombok.extern.slf4j.Slf4j; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.Map; | |
import java.util.Set; |