From One End to the Other in Ruby
A while back I tackled the following programming challenge: From One End to the Other: Find the smallest possible (positive) integer that ends in a six such that if that six is removed and placed in front of the remaining digits of the number, the resulting number will be four times as large as the original. My solution is below, and here: https://gist.github.com/jwworth/5a5b3647a44b9a782896 I like that this solution is relatively fast, at 0.36 seconds. I like that it doesn’t imply what the answer might be by having a ceiling to the search— the code will run forever if my conditional is wrong. I like that it uses the rotate method, something I didn’t know existed until I tried to solve this problem. ...