Simple DTMF decoding: find the phone key!
JavaScript (ES6), 39 35 bytes
a=>b=>"310*58# 47269"[a%b%83%16%13]
Maps the two inputs into numbers in the range [0, 13)
by calculating:
col % row % 83 % 16 % 13
.
Takes input in currying syntax (f(col)(row)
) and returns a single-char string.
Test Cases
let f=
a=>b=>"310*58# 47269"[a%b%83%16%13]
console.log( f(1336)(941) )
console.log( f(1209)(697) )
console.log( f(1336)(697) )
console.log( f(1477)(697) )
console.log( f(1209)(770) )
console.log( f(1336)(770) )
console.log( f(1477)(770) )
console.log( f(1209)(852) )
console.log( f(1336)(852) )
console.log( f(1477)(852) )
console.log( f(1209)(941) )
console.log( f(1477)(941) )
.as-console-wrapper{max-height:100%!important}
History
Started with the range of [0, 20)
with calculation col % row % 29 % 20
, which required 8 wasted characters in the mapping.
Haskell, 42 37 bytes
x#y="_1425__#9__*70836"!!mod(2*x+y)18
Just some math to index a string. Input order is <column> # <row>
, e.g. 1336 # 697
.
Try it online!
Edit: @flawr found a formula that works on shorter string. Overall -5 bytes. Thanks!
MATL, 23 bytes
13*+79\'186#294*3750'w)
Inputs are: column frequency, then row frequency.
Try it online!
Explanation
Multiplying the column frequency by 13, adding the row frequency, and computing modulo 79 gives a different value for each of the 12 pairs of inputs.
13* % First input (implicit) times 13
+ % Add to second input (implicit)
79\ % Modulo 79
'186#294*3750' % Push this string
w % Swap
) % Index