You work for a bank, which has recently purchased an ingenious machine to assist in reading letters and faxes sent in by branch offices.
The machine scans the paper documents, and produces a string with a bank account that looks like this:
_ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_| ||_ _| | _||_| ||_| _|
... why did we buy this machine?
Anyway, your task is to write a function that can take bank account string and parse it into actual account numbers.
_ _ _ _ _ _ _ _ _ | | _| _|| ||_ |_ ||_||_| => 23056789 |_||_ _||_| _||_| ||_| _|
_ _ _ _ _ _ _ _ _ |_| _| _||_||_ |_ |_||_||_| |_||_ _||_| _||_| _||_| _| _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_| ||_ _| | _||_| ||_| _|
This challenge comes from arhigod on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email email@example.com with your suggestions!
Top comments (4)
Rust. Who needs error checking when you can support multiline instead?
Look at it go
This is a rather hacky Python solution that relies on a dictionary of strings mapping to digits. I made the assumption that input would come as an array of strings, one for each level of the digits.