Jump to content

99 Elm Problems/Problem 93

From Wikibooks, open books for an open world

Given a list of integer numbers, find a correct way of inserting arithmetic signs (operators) such that the result is a correct equation, if possible. Example: [2,3,5,7,11] we can form the equations 2-3+5+7 = 11 or 2 = (3*5+7)/11 (and ten others).

Division should be interpreted as operating on rationals, and division by zero should be avoided.

# # # THIS IS A STUB # # #

Example in Elm:
import Html exposing (text)
import List

f : Int -> Int
-- your implementation goes here

main = text (toString (f 0))

Result:

4

Solutions