Well, if you have branching in your algorithm, but you do not want to write the branching it means that you have to either find equivalent algorithm or wrap this branching into something to replace the branching with something else (like maps with defaults replace
map.getOrNull(key) ?: default
). IMO, replacing branching in this case is just making your life harder and your code less readable.
As for equivalent algorithm you can use
(min(a, x) - min(a-1, x) + min(b, x) - min(b-1, x) + 2 * (min(c, x) - min(c-1, x)) + min(d-1, x) - min(d, x)).let { if (it != 4) return it }
As for wrapping I can not come up with any idea.