Recently, I've been teaching my friend programming in the Ruby language. I'm doing this for a few reasons. One being so that I can deepen my understanding of concepts and to fill in any holes of my understanding so that I can teach them to my friend, another being that I just wanted someone to talk to about exciting things going on in my technology stack. ^^;

A huge caveat though is that my friend is Japanese. English is not her first language and while she understands English way better than most Japanese people as an English language learner, I don't consider her English ability to be amazing by my standards. Teaching her abstract concepts is, by itself, a huge challenge especially since when you start out, it's very hard to see why some concepts and ideas are important such as why using global variables frequently is not a good idea. In order to get to that point, I need to teach her other things as well so that those various concepts become more relevant. Currently she understands basic Ruby syntax so in order to teach her problem-solving, algorithms, and debugging, I create folders with Minitest specs and a corresponding Ruby file which gives her instructions and tips on how to go about certain things.

Here is what that looks like. The commented out version that you see above is my naive implementation of it and the uncommented version is my friend's solution with improvements that I added. This is important for me because I wanted to see if I could do it again (I did this problem once during my time at DevBootcamp) but its also important to show my friend a different way of solving a problem as well as exposing her to useful methods that Ruby has. For example, before the screenshot you see above, the way that she determined whether or not the index of an element is odd was by doing the index modulus three

```
doubled_numbers = numbers.map.with_index {|number,index| index % 3 == 0 ? number*=2 : number}
```

which I explained to her could be more aptly expressed as:

```
doubled_numbers = numbers.map.with_index {|number,index| index.odd? ? number*=2 : number}
```

What was interesting with my friend's solution was that one of the steps in implementing the Luhn algorithm is that after you double the numbers with an odd index, if that number has 2 digits, you break up the digits and then take the sum of that. I was impressed that she came up with this solution without referencing other solutions online.

```
number > 9 ? 1 + (number - 10) : number
```

The way this works is that when you double any single digit or any number lower than 10, the highest it can go up to is 18 and when you add the digits of 18, 1 and 8, you get 9. What you can do is subtract the number by 10 times the number in the tens place (in this case 1) and then add whatever the result is by the number in the tens place.

This solution is definitely cleaner and more well thought out than mine where I just convert the number back and forth as Strings or Fixnums. What I also found interesting is that I learned about the #with_index method which you can chain with other methods on Arrays or Hashes to get the index of the current element.

My friend definitely did a good job on this one. Not only was I able to show her new stuff, but she also ended up showing me new cool stuff as well. It's only a matter of time before she kills me and becomes a Sith Master.