## My 3D Printing Adventures

Hello all!

So in May this year, I received a Monoprice MP Select 3D Printer. So far it has been an interesting experience, and I’d like to take this post to reflect upon what I’ve learned and struggled with. I’d also like to note that my experiences and solutions are my own and that if you want to try them, follow them at your own risk.

So over the past few months, I’ve run into only a few issues, but they have been very repetitive and hard to fix. The worst of these so far include print bed adhesion, nozzle jamming, and severe retraction problems.

### Retraction

By far retraction has been the most challenging problem I’ve faced with my printer. Retraction is when your printer will pull back filament inside the extruder slightly to retrieve pressure from the print head. This help reduce stringing in prints wh en the printer is making non-print moves. My issue arises from the stepper motor that drives the filament; I don’t quite know what is wrong with the motor yet (I’m waiting to get a new one before I disassemble the old one to diagnose it) but I know that it makes an uncomfortable whining noise and doesn’t push or pull the filament enough. This results in prints that have missing sections, very pool infill, separated layers, and many other issues. The only way I’ve found to fix this that actually works is to just turn off retraction when slicing my prints, and use a razor blade to cut off the strings and sand it down later. Hopefully, in the future, I can update and diagnose this feature

### Nozzle Jamming

Another issue I have encountered is nozzle jamming, and this was far easier to fix than my last issue. So, my method to fix this issue was to turn up the temperature of my extruder by 10 degrees Celsius. Another option is to drill out the nozzle, my printer came with a small drill bit to clear the opening, but I didn’t want to use this for fear of damaging the printer. And another method is to attach a cleaning piece to your filament as it runs to the extruder, but this only works if your problem is debris jamming the nozzle.

And finally, the easiest to fix issue I’ve had is bed adhesion. Now albeit my solution doesn’t replace the actual BuildTak, but it does fix the issue, and maybe a little too well. The solution to this that I chose was to put rough blue painters tape over my BuildTak to provide a better surface, and then use a glue stick to coat the tape and provide very good adhesion to the print surface. Overall I think that doing this has been the best solution for me rather than modding the printer and adding a removable build surface.

These have just been the issues that I have faced so far. I definitely think that 3D Printing is something more people should get involved in, as this technology is amazing and it has been an absolute blast printing out everything from D&D Miniatures to trumpet mouthpieces or part.

Thanks for reading and have a wonderful day!
~ Corbin

## Where I’ve been…

Hello all!

I’ve been a bit absent lately, well more for like a few months, but I’ve learned a lot and I’m ready to get back on my blogroll! Over the past few months, I’ve done a bunch of cool things that I’m gonna be putting posts up about, and I want to talk about what my new plan is here.

So the first thing you’ll notice is I have a new blog. My blog was transferred over to a docker container with WordPress and it’s all fresh and shiny now. (It’s also making me get involved with Docker a bit, but that’s a whole other topic.)

Over the past few months, I have…
– Attended MIT Splash and took a TON of really cool courses (And explored the gorgeous campus with my friends!)
– Contacted a professor and secured a research opportunity
– Taught myself some new cool stuff, such as Java and OOP basics
– Started a CS Independent Study where I’ve been learning new material for the AP CSA exam
– Gave a talk at HOPE 2018 and met a bunch of really cool humans
– Got a 3D Printer and have been having tons of fun making things

There have been other smaller events that have been cool, but that’s what I can quickly remember at the moment. Overall it’s been an amazing few months and I’m very happy to get back. I also would like to make a change to my blog, I want to be more personal and show my struggles on problems, show how I’m getting stuck and how I’m trying to solve new problems. And I’d love some input from you wonderful humans too! I’m going to attempt weekly posts again, I’m also gonna be showcasing more basic things I do and my projects rather than just Project Euler problems.

It’s great to be back!

Thanks for reading and have a wonderful day!
~ Corbin

## Mindsets and Prime Factorization

Hello all!

It’s been a while since I last posted, apologies. I’ll be doing another Project Euler problem today.

Problem 3:

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

I’d like to begin by saying that I spent way too long on this problem improving my code after I had already solved it. But this is a very good mindset to have when you are trying to become better at something. Due to the increased complexity of this problem, it is a good idea to write an algorithm for it, and I will likely do this for all future problems.

def largest_prime(n)
Iterate through each number up until the square root of n
If the iterable is prime and the modulo of the base and iterable is 0:
Append the iterable to some empty list
print the [-1] element of the list, and this is the largest prime

I decided on an algorithm where I will check every number’s divisibility and ‘prime-ness’ up until the square root of the original number. This works because you can have no prime factor larger than the square root of the number. Next, I add every valid number to some list, and then I go back and pick out the largest one from the list and this is the answer’s problem. Now I need to turn this into working code, and then from there, I can improve it.

def largest_prime(base):
primes = []
root = math.sqrt(base)
for i in range(int(root+1)):
if is_prime(i) == True and base%i == 0:
primes.append(i)
prime = primes[-1]
print(prime)
print(primes)

In theory, this code should work but now I need to make a function is_prime(n) that allows me to check if a number is prime for some boolean value. I’ll do this by checking every number up until the square root for divisibility, and if I find no divisibility other than 1 and the number itself then I will declare the number as prime.

def is_prime(n):
if n <= 1:
return False
for i in range(2, (int(math.sqrt(n))+1)):
if n%i == 0:
return False
return True

Although all of this code works, it is very inefficient. If I insert a timer using from time import * my code takes an average of roughly 7 seconds to run. I would like to cut this down to 1 second or less in any way I can. One way I can optimize the code is by removing my use of lists, but this only saves me ~1 second. This is where I’ll introduce recursion into my programming repertoire. Recursion is when you have a function that calls on itself repeatedly until the task is done. When the task is done the look breaks and returns your answer.

In order to do this problem using recursion, I have to redefine my algorithm. Instead of using another function is_prime(n) I’ll be taking each number, finding the lowest common divisor. I will then take this new number, (n/lcd), and perform the same method on it until I can no longer be divided and this final number is our largest prime factor.

def largest_prime(base):
start = clock()
for i in range(2, int(math.sqrt(base)+1)):
if base % i == 0:
return largest_prime(base/i)
print(base)
end = clock()
print(end-start)

This is my final piece of code and it takes ~0.0008 seconds to run. I am very happy with the results as the code is simple and condensed. I’d like to end this post by talking about mindsets and why they matter. When you’re trying to get better at something you should realize that your abilities are not as fixed as you think they are. I see this problem a lot in my high school, kids in my Pre-Calculus class often complain that they are bad at math but then when they like a topic we are learning in the class they do extremely well at it because they enjoy it and put effort into it. A good analogy of this is someone learning to play an instrument. When you’re practicing hitting higher notes on a trumpet you don’t squeak a note and say “I’m bad at this and I should just give up trumpet” you instead say “Okay, I need to put faster air through the trumpet” and you try again, so why not do this with other things you are trying to get good at? If you would like to know some more about mindsets I highly recommend Mindset: The New Psychology of Success by Carol Dweck. It details lots of information and research about growth mindsets and how they can improve your life.

Thanks for reading and have a wonderful day!
~ Corbin

## Functions in Programming, List Comprehension, and Even Fibonacci Numbers

Hello all!

Today I’ll be doing another Project Euler problem.

Problem 2:

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

There are many ways to do this problem, but I’ve chosen to create a series of functions that I can run to get Fibonacci numbers until some upper bound, and then the sum of even numbers in a list. I find that abstracting calculations like these into functions is a very easy way to make programs feel and look more organized as well as increasing reusability and convenience. A good example would be that I may need a Fibonacci sequence in a future problem, and using a function like this allows me to just paste this code into a future program and I can recall on it using fib(max) when needed. I’m going to begin by creating a function to find the Fibonacci numbers up to some upper bound. I’ll create the function fib(max) where max is the upper bound of the number we’ll be getting from the Fibonacci sequence. The best way I can come up with to create a Fibonacci sequence is to create a list and use fib[-1] and fib[-2] to grab the latest two numbers in the sequence. Next, I’ll add in a while loop that iterates through the Fibonacci sequence and places the numbers into the list fib[ ], to create the next Fibonacci number. This loop then breaks when we hit the upper bound we placed earlier. After this the function will return the newly filled list fib[ ].

def fib(max):
fib = [1, 2]
while(int(fib[-1] + fib[-2]) <= max):
fib.append(int(fib[-1]+fib[-2]))
return fib

Next, I need to create a function that will add the even numbers of a list together. I’ll call this function even_sum(list) and to create it I’m going to use something new I learned called List Comprehension. You can learn more about List Comprehension here but I’ll provide a quick overview. List Comprehension allows a smaller and more efficient way to create a list by placing a for loop inside of square brackets. We can also place operators such as if statements inside the brackets. Using this new tool my next function will look like this:

def even_sum(list):
return sum([i for i in list if i%2==0])

Now that we have both of our functions we can just combine the two and run them through each other like so:

even_sum(fib(4000000))

This now returns us with the sum of all even Fibonacci numbers up until 4 million!

Thanks for reading and have a wonderful day!
~ Corbin

I would like to give special thanks to Christian Ferko for teaching me about List Comprehension.

## Intro and Multiples of 3 and 5

Hello all!

I’ll insert a small introduction here. Welcome to my blog, my name is Corbin Frisvold and I’m a student interested in furthering my passions for Computer Science, Mathematics, and several other fields. Here my posts will primarily consist of my exploration into becoming a better programmer, but I will likely post other things around on the blog. Anyways, onto my first post!

Today I’m going to be doing a problem from Project Euler.
Problem 1:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

I find it useful to just dive into the code for a small problem like this. We know we want a for loop iterating through 1000 and checking each number’s divisibility by 3 or 5. What I come out with is this:


sum = 0
for i in range(1000):
if i % 3 == 0:
sum += i
elif i % 5 == 0:
sum += i
print(sum)


What this code does is it creates a variable sum that will be used to store the sum of all our valid multiples. Then we use a for loop increment through all numbers between 1 and 1000. After running the program will print the output. Running this we get sum = 233168. And now we have solved Problem 1! My intention with post frequency is to post as much as I can, but I will attempt to keep a minimum frequency of 1 or 2 posts a week.

Thanks for reading and have a wonderful day!
~ Corbin