I’ve made a Python script that (for now at least) plots the number of times each package on my system was installed + upgraded. That is, if the y-axis reads “2”, it means the package was installed and upgraded once. If the y-axis reads “1” it means the package was installed once and never upgraded.
As my system is rather new (about 2 months old), most packages were not upgraded. The package that was most upgraded was Linux (10 times), followed by youtube-dl and python-setuptools. I decided to only show the name of these 3 packages as they were the most upgraded and the x-axis would contain 531 package’s names if I were to show them all.
I seek to post the code soon on github so you can use it and modify it as you wish.
Below is a Python code for a very simple bot that logs in into FICS, ask for a username and password that one must manually enter and then the bot will chat in channel 53, a channel for general discussion where guests can participate.
The code assume that you have a file called “random-words.txt” in /path-to/ directory. You can edit those according to your needs. The bot will randomly pick lines in the text file and send them in the 53th channel. It will do so at a rate of 1 line every 30 seconds by default, but this is adjustable.
Have fun editing and using this bot!
HOST = "freechess.org"
# user = raw_input("Enter your user name account: ")
user = input("Enter your user name account: ")
password = input("Enter your password: ")
user_bytes = user.encode('utf-8')
password_bytes = password.encode('utf-8')
tn = telnetlib.Telnet(HOST)
tn.write(user_bytes + b"\n")
tn.write(password_bytes + b"\n")
tn.write(b"set tell 1\n")
tn.write(b"set pin 1\n")
tn.write(b"tell 53 Hello, I am a robot!\n")
word_file = "/path-to/random-words.txt"
WORDS = open(word_file).read().splitlines()
word = random.choice(WORDS)
word_bytes = word.encode('utf-8')
tn.write(b"t 53 " + word_bytes + b"\n")
This time what caught my attention was the average number of stones ramdomly placed on a 19×19 goban required such that 2 stones are adjacent.
So I’ve written a python program (https://github.com/arbolis/pythonstuff/blob/master/goproblem_random/gorandom_1.py) and a R script for the plotting part (https://github.com/arbolis/personalscripts/blob/master/goban_random.R) to solve the problem numerically. It turns out that the number is around 13.1 which, in my opinion, is counter intuitive in the sense that most go players expect that number to be much higher (scarce are the go players who predicted a number below 30).
Anyway here is a summary of the data after 1,000,000 simulations of placing stones on a 19×19 goban until 2 stones are adjacent:
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.00 8.00 12.00 12.97 17.00 49.00
And there comes a bar plot:
I find that plot interesting and the summary of the data interesting.
Now I could get similar data for the 8×8 chessboard. Out of my memory the number of pieces randomly placed on a chessboard until 2 are adjacent is around 6.1. I expect a similar histogram than the one for the game of go somehow, except that the width of the distribution should be much smaller.
The Euler project (https://projecteuler.net/) is a collection of currently over 400 mathematics/programming problems. The problems are generally meant to be solved via both mathematical and programming “tricks” or skills and only a small fraction of them are solvable via brute force. There’s a ranking of problem’s difficulty based on the number of people who successfully managed to solve the problems so that gives you an idea about what to expect about the difficulty of any particular problem once you’ve solved a few of them.
I think it’s a very nice project to spark interest in programming for “math people” and also to learn some programming.
You basically look for an interesting Euler project problem, i.e. a problem you read and really want to know the answer to, then you pick any programming language you feel comfortable with and you start to think of ways to solve the problem. You try out stuffs and check whether that works or not. The program should not take more than about 1 minute of running time to solve the problem so it’s easy to check whether your method is not well suited.
I think this project should be mentioned in high schools even though it shouldn’t be hard to find the answer to all of the problems on the web. If someone is serious about it, he wouldn’t look for the solution and that’s what matters most.
The only downside I’ve found so far is that it can get pretty addictive and can make one spend way too much time thinking about a particular problem and that could have a bad impact on one’s life. You’ve been warned. 🙂