After playing around with Project Euler for a while, I determined I wanted to challenge my coding skills even more, but stay firmly planted in the mathematical realm in which I’m familiar. So, I’ve begun writing some code that can be used for certain mathematical objects. In particular, I’ve written a fraction class, a 2D vector class, and a complex number class. You can find the code on GitHub.
Continue reading “Some New Code”Project Euler
As part of my year of focus, I’ve been trying to spend more consistent chunks of time working on programming. In particular, right now I’m focusing on doubling down on my Python knowledge, and exploring some other aspects of computer science that interest me. After checking out a few books and tutorials, I’ve made my way back to a website that I found a number of years ago, which is the most intriguing to me: Project Euler.
The gist of Project Euler is to give a wide range of mathematically-oriented programming puzzles for people to solve. You can always just go on there for ideas of small programs to write, whether it’s to learn some math or to try out a new computer language. In my case, I’m trying to write the most efficient programs possible, making use both of clever algorithms I spend time figuring out or researching, and making use of Python syntax to make particularly elegant solutions. If you make a simple account, you can keep track of your progress and access message boards about each problem.
It has been very engaging so far. They are more bite-sized, but give ideas for more complex programs that can be written which are more general purpose. Rather than writing a script that solves a problem, I can focus on writing broad functions that may be helpful.
A fun problem I worked on today involved triangular numbers. These are just numbers you get from adding together all the positive integers before it. So, the seventh triangular number is just 1+2+3+4+5+6+7=28.
The goal was to find the smallest triangular number with more than 500 divisors. Here’s the Python code I wrote for it. (I apologize, I can’t figure out how to make syntax highlighting work right now.
import math
def getTriangular(n): ## Generates a list of triangular numbers up to n
triangularList = [sum(i for i in range(1,k+1)) for k in range(1, n+1)]
return triangularList
def getNumberDivisors(n): ## Generates number of divisors
numDivisors = 2 ## We don't care about n=1, so assume it has 1 and n
for divisor in range(2,int(math.sqrt(n))+1): ## Only check to sqrt(n)
if n % divisor == 0: ## Needs to be a divisor
if divisor * divisor == n: ## If square root
numDivisors += 1
else:
numDivisors += 2 ## Otherwise, divisor has a factor
## pair larger than n//2
return numDivisors
def main():
triangleList = getTriangular(25000) ## Hopefully big enough
is500 = False
triangleIndex = 7 ## It's certainly larger than seventh number
while not is500:
triangleIndex += 1
#print(triangleIndex)
if getNumberDivisors(triangleList[triangleIndex]) > 500:
is500 = True
print(triangleList[triangleIndex]) ## Tell me the number
main()
The code runs reasonably quickly, which is always the goal. The standard view on Project Euler problems (and I believe it is their official stance) is that well-optimized solutions should run for no longer than a minute on nearly any computer. The first few problems should take substantially less time than that.
I recommend giving them a try if you have an itch for some challenges, and either want to work on optimizing your code in a certain language, or try out the functions in a new language. For example, the fact that Python supports arbitrarily large integer addition (compared to C or Java) makes some problems pretty trivial. Thinking about how to deal with other languages becomes rather interesting.
No Keyboard for Old Men
As I come to the realization that a significant part of both my work and personal hobbies involve sitting at a computer, I have become increasingly wary of the stories I hear about things such as repetitive stress injuries (RSI), and what will likely be the impending damage to my eyes. In an effort to avoid, or at least delay, the former issue I have tentatively purchased an ergonomic keyboard. Specifically, the Surface Ergonomic Keyboard from Microsoft. I say tentatively because it’s not cheap. I may return it, but so far I’ve put a few thousand keystrokes on it and it’s feeling pretty good. This review is meant to get as in-depth as a keyboard review can be when written by someone who has never written a keyboard review. I’ll briefly explain my rough, but sufficient, testing procedure and what I found out. Then I’ll get into some details and comparisons I noted to other keyboards I’ve used.
Continue reading “No Keyboard for Old Men”New WordPress Editor
WordPress (both the .org and .com versions) is rolling out a new native editor. It is a “block” system, and I am entirely unsure how I feel about it. I figured I would give them the benefit of the doubt and try to write a somewhat complete post using the WordPress.org back-end, with this new block system, and see how it goes.
Continue reading “New WordPress Editor”Why Linux? Part 1: Free As In…
During sophomore year of college, I embarked on a project to put a Linux operating system on my laptop. I had been interested ever since using a computer in one of the engineering labs which ran Ubuntu, one of the most mainstream, user-friendly distributions out there. I was intrigued both by the visual design, and the ease with which complex programs could be run. There was also the intrigue of feeling like a cool hacker, using a terminal and typing commands to get around a file system. I was hooked, and since then I’ve had a Linux distribution running on every computer I’ve owned over the past three years.
I want to spend a good chunk of time explaining my growing passion for Linux, and why I think more people should seriously consider it as an option for the computers in their lives. This first post will focus on two of the oft-repeated phrases in the Linux community, and its main inspiration: Linux is free.
Continue reading “Why Linux? Part 1: Free As In…”
New Blog
Yesterday I switched over from using WordPress.com to hosting my blog on Bluehost and using the official WordPress blogging environment. The main difference here is when you are using WordPress.com, there is some gray area about who really has control over the content. You are ultimately at the whims of their hosting structure, and also you must pay through the nose to access the various features of the actual WordPress blogging platform it claims to deal with.
WordPress is an open-source blogging platform, and is very widely used. Wonderful plug-ins are created to increase its functionality and customizability, and I have enjoyed dealing with it. WordPress.com, on the other hand, is a company run by one of the people who created the WordPress platform in the first place, but has various hosting options built in. For people who just want to get things going and keep things simple, that’s fine. I still run OHAC on WordPress.com, and things are going fine. But, I wanted more ability to be in control of my personal blog, and not have to worry about something going wrong that I didn’t have control over.
This is in large part influenced by the post I have written which will be published this upcoming week, the first part in a long series about why I use Linux. As you will understand once you read it, one main part of using Linux is freedom to customize the software you’re using, as well as software being actually free. WordPress.com provides neither of these; WordPress as a platform allows both. So, I switched things over, created a simplified dark template, and I’m loving it. Hopefully you’ll enjoy it a bit as well.
Notes On Future Mathematics Posts
Updated November 23, 2022
I’m going back through my posts and recategorizing them, and noticed this one. My plan for having a secondary spot for math posts didn’t take off after I moved my blog to WordPress properly, and discovered the excellent \KaTeX plugin for rendering math.
Original Post
I recently remembered my company, AoPS supports blog creation for their users. In particular, it has the full functionality I’m used to on their message board. In particular, they have native support, in addition to support for the Asymptote vector graphics language. This makes writing math significantly easier on my end, and significantly easier to interact with on the reader’s end.
Here is my first post, a rewrite of Introduction to Sets. This shows how much more functionality there is, such as the option for “discovery based” definitions and problems, by using the native option to “hide” text for users to click on. There is also support for python code, which I am excited to play around with.
Moving forward, I’ll be porting the current math-related posts of significance to that blog. Any future posts will have an introduction on this blog, so you know what’s going on, and then a link to the AoPS blog post.
Dull Edge
The cutting edge of technology is particularly awesome these days. Cars are doing more on their own, phones are surpassing some current computers in their performance, and VR is coming into its own finally. I listen to a lot of tech podcasts, and love messing around with technology, but due to my status as a recent college graduate, I am definitely not maintaining a collection of cutting-edge devices. And that’s okay.
First, let’s talk about cars. I recently purchased a post-lease 2015 Honda Civic, LX trim (in other words, the only model more basic comes with a manual instead of a CVT.) The disparity between that car and other higher-end cars from the same year is rather shocking. Sitting in it, I feel super cool. It’s a big upgrade from the 1998 EX-L Honda Accord I had been driving. There’s a “cockpit” feeling to it, good Bluetooth connectivity, and a back-up camera. It’s relatively zippy for a cheap car, and the gas mileage gained by the CVT cannot be beat.
Then, I read a Golf R Review by Casey Liss. He is one of three car enthusiasts on the Accidental Tech Podcast. Not surprisingly, the only one I can identify with is John Siracusa, who to my knowledge has mostly driven manual Civics and Accords for his entire life. Casey though, he complained about the lack of assisted driving and automatic parking. The car needs to be fast, it needs a sunroof, and of course Carplay! This was absolutely baffling to me. I just cannot get my head wrapped around why some of these things are important. These three men have attempted to address it on their podcast, but it still does not click with me. Cars can be purchased only so often to be at all reasonable, and so one cannot even stay on the cutting edge.
The other issue is that he recently began working from home exclusively, yet sounded very hesitant to become a one-car family. Oh well, to each their own.
Now, obviously cars are a very special case of not staying on the cutting edge. I’ve only owned my own car for a few months, and it’ll be a number of years before I can even begin to think about getting another. But phones: now that’s another matter.
I’ve had my Galaxy S7 for two years now. Previously, I had a Galaxy S4 for two years, and then some random LG (I think) phone for 4 years throughout high school. In my mind, until I can afford the “every year” phone upgrade, two years is a reasonable time in these days of mostly non-replaceable phone batteries. So, with my S7 really slowing down and the battery life starting to tank, it was time to figure out what to do. Was the newest Galaxy S9 worth the incredible price tag? Did I want to save some money and get a Pixel XL or a new LG phone, each containing last year’s processors, despite them being the newest in the lineup?
I ended up choosing a Galaxy S8+. Due to the release of the S9, I got a very good deal on it, and the processing difference (and battery life) between the S7 and S8+ is much larger than the S8+ to a comparable newest generation phone. Once again, I opted to stay on the duller edge of technology. And I am happy with that decision. I tried the S9 in stores, and it truly did not impress me anymore than the S8 does. The S8 was the revolutionary phone (just like the iPhone X, and whatever comes out next will not be quite as lauded).
This is what is interesting about technology. So many people are excited to get the newest and best thing. The hype is always there, but the price-to-performance normally isn’t. I spent all of last year in school working on a 4-year old Ideapad and a 5-year old refurbished Thinkpad. They performed admirably for me, because like most people, I’m not doing much heavy-lifting.
Being on the dull edge, and looking out at what is available and what others have, can be fun. I don’t think there is anything wrong with living life on some sort of delay with technology. Perhaps as I grow older and make a bit more money, that will change. But for now, I am happy with scouring the internet for good deals, and getting what I actually need for the best price.