You need to find the sum of minimum values of two list (same size) of small numbers. In a C like language, that could be expressed as:
v = min(a,b) + min(a,b)+ min(a,b) ...
The range of values is 0..7 and the 2 list can have up to 7 values. If you like, all the values in each list can be stored as a single 32 bit number.
My goal is avoiding branches in code, so the rules are
- Single line expression,
- No function calls or method calls (except for basic operations like sum, if your language mandate this),
- No if statements, including things that compile to if statements such as ternary operators or "greater than" operators
Edit 1 To clarify, what I want is 'no branches in code'. So, no if, no calls (function of methods). Loops with fixed ranges (0..7) could be OK because can be unrolled. Sorry if was not crystal clear about this.
All what your language can do inline is OK. So if a functional language has a strange syntax that resembles a function call but is inlined, that's OK.
Shortest code wins.
As a side note: this challenge is related to a quasi-real problem: a fast scoring function in mastermind game.