I know what you’re thinking- “Jes, what are you talking about? This blog is supposed to be about the STP!”
Well, it all started a couple of weeks ago, on a rainy Friday at the pub after work. Dreaming of better days with better weather, someone piped up “Do you know what would be great? When the weather is good we should have a rounders game!”
Ah yes, I couldn’t agree more. I expressed my delight at the idea and within minutes I had somehow “volunteered” myself to organise this activity. I suppose this wasn’t too big a deal- I’ll just pick a date and send out an invite, not a lot to do, it’s fine.
A good response, enough for 2 decent sized teams. Teams. It hit me. Oh no. How are we going to organise the teams? Cue flashbacks to Year 9 P.E: getting picked last to be part of a team. We couldn’t have that.
Well, it’s a good job I’m a problem solver- a key skill in the role of bioinformatics, as Adriana explained so well in her last post. Randomly generated teams- the perfect solution! But, because I’m training to be a bioinformatician I couldn’t possibly use a program on the internet, so I decided to write my own using Python as a mini project to improve my coding skills. Now, I want to put it out there that we don’t officially get taught any programming until our 2nd year and I’m not from a computer science background, so this is mostly self-taught and I know there’s room for improvements.
I’m not going to share all of the code on here but I’ll give a quick overview. If anyone is interested we are thinking about setting up a Github repository to share any code that we might talk about on this blog (let us know what you think!).
So it takes an input of a file containing a list of names that are your players and uses the choice function from the random module to select one player from that list for each team, removing them from the list of players after they’ve been selected until there are no players left. It then prints out the two lists and voila! Two randomly generated teams! Quite happy with my little script, I let everyone know this was how the teams were going to be chosen. But was this enough? Apparently not… “Can we have team names too please?” Back to work… I didn’t want to make things too complicated so I decided to stick to the classic combination of colour + animal. I just made a list of all your common colours and the list of animals was collated by asking colleagues for their favourite animals without telling them why. Clearly, imaginary animals were not ruled out. This made for a list of several animals you probably traditionally wouldn’t want your sports team named after, including sloths and guinea pigs. However, in the interest of fair representation, I went ahead with all the suggested animals and the outcome was team 1 being the Blue Badgers and team 2: the Pink Unicorns.
Satisfied that the code worked successfully I decided to add a tiny little function to the end of the script, just for my own enjoyment. This code printed out:
“Accurate computational future prediction algorithms predict that team X will win”. The fact that team X always turned out to be the team that I was in… what can I say? The computer must know something!
I thought I would share this because it’s an example of how I try to use fun challenges to develop my coding skills outside of the required competencies. Even though it is basic it enabled me to practice using lists, while loops and the random module. To develop this script further, I would modularise the code into functions to deal with more than two teams.
Oops, I haven’t even told you what I know you all want to know! Which team won?! Funny story actually… we somehow ended up breaking the wooden bat in half, mid-game so we never got to finish (though I’m pretty sure my team would’ve won anyway…). Re-match is pending while we source a sturdy rounders bat.
Thanks for reading everyone! Until next time.