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.
Example
_ _ _ _ _ _ _ _ _ | | _| _|| ||_ |_ ||_||_| => 23056789 |_||_ _||_| _||_| ||_| _|
Tests
_ _ _ _ _ _ _ _ _ |_| _| _||_||_ |_ |_||_||_| |_||_ _||_| _||_| _||_| _| _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_| ||_ _| | _||_| ||_| _|
Good luck!
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 yo+challenge@dev.to with your suggestions!
Oldest comments (3)
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.
Code
Python solution
Output,
Rust. Who needs error checking when you can support multiline instead?
Look at it go