How to design an algorithm to calculate countdown style maths number puzzle

Very quick and dirty solution in Java: public class JavaApplication1 { public static void main(String[] args) { List<Integer> list = Arrays.asList(1, 3, 7, 6, 8, 3); for (Integer integer : list) { List<Integer> runList = new ArrayList<>(list); runList.remove(integer); Result result = getOperations(runList, integer, 348); if (result.success) { System.out.println(integer + result.output); return; } } } public … Read more

all combinations of k elements out of n

In C++ given the following routine: template <typename Iterator> inline bool next_combination(const Iterator first, Iterator k, const Iterator last) { /* Credits: Thomas Draper */ if ((first == last) || (first == k) || (last == k)) return false; Iterator itr1 = first; Iterator itr2 = last; ++itr1; if (last == itr1) return false; itr1 … Read more