# Armstrong Numbers

I gave the final for my CSCI 1302 class earlier today, and for one of the questions I asked them to write a program, in Java, that prints out all the Armstrong numbers without using any String methods. An Armstrong number is a 3 digit number for which the sum of the cubes of its digits is equal to the number. An example of an Armstrong number is 153 as 153 = 1 + 125 + 27 = 1^3 + 5^3 + 3^3. The final was supposed to be cumulative (and it was), and this just screamed 1301 material (Sorry for the UGA rhetoric. CSCI 1301 is the prerequisite for my class.). Here is the solution that I came up with when I encountered this question in an interview one time.

Since the definition of a 3 digit number seems to depend on who you're talking too, I always make sure to mention that the code can be easily modified to only work with true 3 digit numbers. Also, since Scala is my favorite language, here is the same code converted to Scala.

Another interesting approach is to enumerate all 3 digit numbers and use what I call the modulus technique to get the digits for each (mod 10 to get the last digit, divide by 10 to decrease the number by one digit, repeat). I suspected (correctly) that some of my students would think of this method because it's very similar to a lab in the prerequisite course.

If you know any other method to enumerate Armstrong numbers then please post it in the comments.

# Printing Boolean Input Combinations in Scala

Someone at school recently asked me to help him write some code in Scala to print out the $2^n$ Boolean input combinations that are possible with $n$ variables. I decided to start off with $n=4$ variables to keep things simple and verifiable. After a couple of minutes of hacking around, I came up with the following code:The cool part is the shifting modulus check. I'm actually kind of proud of it. It enabled me to write the code using only two loops! Here is the result: -a -b -c -d +a -b -c -d -a +b -c -d +a +b -c -d -a -b +c -d +a -b +c -d -a +b +c -d +a +b +c -d -a -b -c +d +a -b -c +d -a +b -c +d +a +b -c +d -a -b +c +d +a -b +c +d -a +b +c +d +a +b +c +d Also, please note that this is probably, by no means, the most functional way to do this. It was merely an attempt at hacking together some code that just gets the job done. If I have time, I will write up some posts on functional ways to produce both combinations and permutations in Scala.

# First Semester Completed

My first semester of Graduate School is completed! Grades are back (4.0) and the stress level is diminishing. Now I'm enjoying some much-needed family time with at my Aunt and Uncle's house in South Carolina.

# Spring Research Assistantship Accepted!

I got an offer for a 1/6th time Research Assistantship in the Spring, working with Dr. Miller in the Computer Science Department and Dr. Kissinger in the Institute of Bioinformatics. According to the letter, recipients are selected through a competitive process, and assistantships are awarded only to the University's most qualified individuals to aid them in their pursuit of study or research. Anyway, I accepted the offer. So, I'll be on both a Teaching Assistantship and Research Assistantship in the Spring!