Programming with Python (MSc Bioinformatics) Prof. Dr. Sven Rahmann Required programming course for Bioinformatics Master program

News

01.02.2023

List of admitted students published

The list of matriculation numbers of the students admitted for the exam (35+ stars) has been published in the Materials section. Please verify if you are on the list. If there is a comment attached, please fix the issue until midnight. The files must be named... Read more

The list of matriculation numbers of the students admitted for the exam (35+ stars) has been published in the Materials section. Please verify if you are on the list. If there is a comment attached, please fix the issue until midnight. The files must be named day01.py, day02.py, ..., day25.py. We cannot process 25 files * 80 students manually. 

 

 

31.01.2023

Pre-Final Information

So, today is the last day (till 23:59) to collect stars! A few important comments:

  • While AoC will allow you to continue to collect stars, we will download the state shortly after midnight and keep it "frozen". So even if you gain any additional stars, we will... Read more

So, today is the last day (till 23:59) to collect stars! A few important comments:

  • While AoC will allow you to continue to collect stars, we will download the state shortly after midnight and keep it "frozen". So even if you gain any additional stars, we will see how many stars you had at 00:01 on 01.02.2023 (Berlin time zone).
  • Again (and again), we will only attribute the stars to you if your README file is correctly formatted. You know this is the case if and only if you appear in the "Verified AoC repository list" in the materials section. If not, fix it TODAY, because tomorrow, it is too late. For your convenience, the exact format is repeated below. DO NOT CHANGE the format. Just enter your data. No extra characters.
  • Currently, all time slots for exams are taken. We will offer additional slots after we have collected the information about who got 35 stars, because then we know the exact number of exams. We will then also publish a preliminary schedule. This schedule will still see some modifications and additions!
  • On 01. or 02. of February, it is time to register for the exam on LSF. No credits without LSF registration! No exceptions! (Some of you cannot register on LSF: Erasmus students, some students from non-CS programs -- please inform us about this in individual emails. You will get a written confirmation letter of a successful exam to give to your examination office).
  • This year, probably for the last time, the exam is pass/fail only. You will pass if we are convinced that you are able to solve problems with Python. We will start with your AoC solutions and ask you about it. Then we will ask about Python constructions in general, including the current material (numpy, scipy, numba, plotting, etc.). No topic is excluded. Of course, you are not expected to know all optional arguments of each matplotlib function. But you should know the big picture.

Your README.md file in your fork of the repository must start with these lines, including the lines with the three dashes, just replace the data with your information, and DO NOT CHANGE the spelling of the keys like name, mat, etc.

---
name: John Doe
mat: 00000000
aocname: BobTheBear
aocnumber: 0000000
---

 

Clearly, name refers to your full name (as a registered student), mat to your UdS matriculation number, aocname is the name shown in the AoC leaderboard, and as some of you use an anonymous name and to identify you uniquely, please also provide your AoC number. This number can be seen when you are logged into AoC and visit your setting page (https://adventofcode.com/2022/settings) "anonymous user #0000000". Please provide that number without the #.

Again, if your correct matriculation number appears in the verified list in the Materials section, your information is parsed correctly. If not, FIX IT TODAY!

 

23.01.2023

How to select a time slot

A surprising number of you has difficulties in selecting a time slot. So here are instructions.

1. DO NOT WRITE A COMMENT.

2. Select ONE AVAILABLE time slot in the matrix. If you do not see a checkmark and cannot select a slot, it is already TAKEN.

3. It is... Read more

A surprising number of you has difficulties in selecting a time slot. So here are instructions.

1. DO NOT WRITE A COMMENT.

2. Select ONE AVAILABLE time slot in the matrix. If you do not see a checkmark and cannot select a slot, it is already TAKEN.

3. It is possible that, after you click on the time slot, your browser moves the window MUCH TOO FAR to the right, and it will look like an empty page. In that case, SCROLL BACK TO THE LEFT.

4 Scroll left or right until you see the SAVE button in your row. Click on SAVE. That's it. If you do not click on SAVE, your choice is not registered. You know that your choice has been registered if you are shown an INDIVIDUAL LINK that can be used to modify your vote later.

5. NO, we can NOT modify your choice for you. You have a LINK to modify your choice. The link to modify your choice will be shown to you after you have clicked on SAVE. If you do not copy the link or lose it, it's gone. We cannot help you. You have to stick to your first choice. So think about your exam slot BEFORE you choose one. 

6. Again, a comment with your preferences does not help. We will ignore it. So, please, DO NOT WRITE A COMMENT. I spend a lot of time deleting your comments, and I could use that time much better for other things.

7. DO NOT WRITE COMMENTS. If you have to write a comment, DO NOT WRITE YOUR MATRICULATION NUMBER !!!

 

23.01.2023

Addtional exam slots

We have added a few more exam slots on the 14. and 15.02.

Also, please remember to evaluate the course; both the lectures and the tutorials (if applicable).

All links are on the Materials page; "Administrative" section.

18.01.2023

Course Evaluation

I have added two new links for the course evaluation (separately for lecture and tutorial).

Please evaluate the course and the tutorial until 02.02.2023! This is important to improve the course for the next edition.

An additional hint for the exam... Read more

I have added two new links for the course evaluation (separately for lecture and tutorial).

Please evaluate the course and the tutorial until 02.02.2023! This is important to improve the course for the next edition.

An additional hint for the exam registration: Please choose exactly one date and register for it. Do not enter a comment at all (unless you have to comment on something). The comments are pubilc! If you want a confirmation and/or a link, you have to specify it.  Otherwise, you are simply registered, even without further confirmation. We will send a summary after 02.02.2023, so you can verify your slot.

18.01.2023

Exam Time Slot Registration Now Open

Dear all,

in the Materials section, you can now find a link to reserve a 20-min exam time slot. Please only register if you can probably achieve the 35 stars. If necessary, we can offer more time slots later.

 

12.01.2023

Important Announcements: Exam, Next Courses

Dear all, as several questions have come up, here are some announcements:

1. Exam requirements and dates

We will check your number of stars on 01 February at 6am in the morning. The official deadline is still 31 January, 23:59, but to give you some grace... Read more

Dear all, as several questions have come up, here are some announcements:

1. Exam requirements and dates

We will check your number of stars on 01 February at 6am in the morning. The official deadline is still 31 January, 23:59, but to give you some grace period, we will collect the list of stars first thing in the morning at 6am. 35 stars are required. We know that this is hard, but this is the point. If you haven't really started by now, it is probably too late.

To take part in the exam, you must

a) have 35 stars by the cutoff date, and these stars must show up on our list. Please check carefully if your matriculation number appears on the list! Do this now, and do it again.

b) reserve a time slot for the exam. You can do this as soon as we open the registration (separate announcement soon). The first round of exam dates will be February 08-10 and February 13-15. A second round will be offered shortly before the summer term starts.

c) register for the exam on the LSF / HISPOS system. This needs to be done until one week before the exam date. Instructions will follow.

You can register before January 31 for b) and c), but if you do not achieve 35 stars, these registrations are void. We ask you to register only if you are relatively confident that you have 35 stars by the cutoff date.

The exam will take place in person on campus in E2_1, room 1.14. Only in very exceptional circumstances, the exam can be done online (quarantine order, visa problems; proof must be provided).

 

2. FAQ

a) Q: 35 stars are too much and too difficult. Can the requirement be lowered? A: No.

b) Q: Can someone help me set up my gitlab repository? A: This was a thing in the first week of the semester. Now, all tutors are busy helping with the hard problems. If you did not set up your gitlab in week 1 or 2, it is probably too late.

c) Q: I have lost some of my code (my laptop broke, my dog ate the USB drive, ...). A: Your code should be in your gitlab repository, from week 1. Then it cannot be "lost". If you didn't use gitlab and do not have daily backups, you have a problem. For the exam, we automatically download your code for random days (for which you have stars) from your gitlab and study it to ask you questions about it. If the code is not there for any day where you have a star, we suspect that you have cheated, and you fail the exam.

 

 

05.01.2023

Clarification on External Resources

Dear all,

we would like to re-emphasize the following: If you use external sources for your solutions, you must cite them. This includes AI bots. Failure to do so will result in failing the course. You must still understand the code in detail and be able to... Read more

Dear all,

we would like to re-emphasize the following: If you use external sources for your solutions, you must cite them. This includes AI bots. Failure to do so will result in failing the course. You must still understand the code in detail and be able to answer all questions about it. And you can be sure: We will ask about the details in the exam. The exam will be very strict in this regard. If you do not understand the code you submitted (even if you cite your resources), you will fail the exam.

So if you reach 35 stars only by using other people's solutions, I can assure you: you will fail the course. And you will be reported if you plagiarize. And you will have wasted the team's and my time, and this will be remembered. So don't do it. Work out the solutions on your own. If it is not possible or too hard in this semester, come back and try a different programming course next winter.

I hope that this is crystal clear now. We want you to learn programming and not how to cheat your way through the Master's program.

 

03.01.2023

No lecture today

A happy new year to all of you!

Unfortunately, due to unforeseen technical problems, today's lecture has to be cancelled. The next lecture will be on Tuesday, January 10. The tutorials will take place normally this week. We suggest you use this week to continue... Read more

A happy new year to all of you!

Unfortunately, due to unforeseen technical problems, today's lecture has to be cancelled. The next lecture will be on Tuesday, January 10. The tutorials will take place normally this week. We suggest you use this week to continue working on the AoC problems as far as possible. All the best!

25.12.2022

Days 24 and 25

Here are some short hints for the final two days. As usual, different approaches are possible.

Day 24

This can be nicely modelled as a graph problem, where the nodes are (i, j, t), with (i, j) being the grid coordinate and t the time step. For every t, you can... Read more

Here are some short hints for the final two days. As usual, different approaches are possible.

Day 24

This can be nicely modelled as a graph problem, where the nodes are (i, j, t), with (i, j) being the grid coordinate and t the time step. For every t, you can compute which nodes exist (i.e. which points are free). Then you can connect the graph through time. I found this problem long but not too hard if you have already solved some of the other shortest-path type problems. Part 2 is  a straightforward extension. Maybe we'll do some more graph problems (from older AoC problems) in January because a large number of problems this year was graph-based.

Day 25

This is a short problem to finish. As always, part 2 is solved automatically if you have all the other 49 stars, so there is only part 1, which is a conversion between decimal numbers and a signed base-5 number system. It is similar to the DNA k-mer representation (which is a base-4 system), but with the additional twist that we have negative digits. In the end, all you need is two small functions: to_decimal(s) and to_snafu(d).

 

23.12.2022

Hints for Day 22 and Day 23; Clarification on Input Files

Happy Holidays!

Yesterday (day 22) was relatively straightforward, at least part 1. However, part 2 is extremely annoying. It is likely that you will not have a general solution (that works for every layout), but just a solution that works for your specific... Read more

Happy Holidays!

Yesterday (day 22) was relatively straightforward, at least part 1. However, part 2 is extremely annoying. It is likely that you will not have a general solution (that works for every layout), but just a solution that works for your specific layout. This is ok. I still found it extremely annoying. If you want to skip any problem, it could be this one. 

Today (day 23) was also relatively straightforward; I found it advantageous to code the set of elves as a set of (i, j) coordinates. Note that there are 3 reasons for an elf not to move: (1) all adjacent spaces are empty; (2) no step in any direction is valid, hence none can be proposed; (3) a valid step is proposed but not executed.

A clarification because an earlier news was confusing: The input file should be named dayXY.txt for day XY, e.g. day01.txt for day 1 and day23.txt for day 23. Please commit these input files into your gitlab repository, together with your code file (dayXY.py). We may check you code on your input but also on our input files (day 22, part 2 being an exception; we do not expect it to run on input different from yours).

Hope this helps!

21.12.2022

Hints Day 20 and 21; Announcements & Happy Holidays

Dear all,

the snow is gone, so no White Christmas this year, but ever more AoC problems... At least you'll not be bored. To help you a little bit, here are some comments, but first some Announcements.

This week, the tutorials will take place regularly unless... Read more

Dear all,

the snow is gone, so no White Christmas this year, but ever more AoC problems... At least you'll not be bored. To help you a little bit, here are some comments, but first some Announcements.

This week, the tutorials will take place regularly unless your tutor explicitly invites you to an online tutorial.

The next regular lecture is on January 3 at the usual time and place (zoom). We will discuss numpy (for efficiently storing array data of a fixed type) and numba (for just-in-time compiling parts of your program to speed it up, up to 100x in some cases). There will be no further exercises for the material in January, but several examples, and they should also help further with the AoC problems.

In January, you should finish you AoC problems to get >= 35 stars, but also revise what you have done earlier, maybe comment your code, re-write some of your earlier solutions to make them shorter or more elegant and prepare to talk about them and explain them during the exam.

Hints for Day 20 (Tuesday)

The solution is not very long or complicated, if you use the right data structure. Unfortunately, we did not discuss singly or doubly linked lists yet, but you may want to have a look at them: https://en.wikipedia.org/wiki/Linked_list .  We will also talk about them in January. As you need to walk left and right, you may think you need a doubly linked list, but in fact, because it is circular, you can always walk right (just compute the number of steps correctly!) and get away with a singly linked list, which requires less coding (I did not try it, I used a doubly linked list, so no guarantees). Part 2 seems to take ridiculously long because of the huge shift sizes, but of course, there is a shortcut to figure out.

Hints for Day 21 (Wednesday, today)

Part 1 is a straightforward recursive problem. An relatively easy start to get for a day 21 problem. The second part, on the other hand, can be hard. You could try to implement your own little solver with limited capabilities, but enough to solve the problem. Or you can have a look at the sympy package. The latter needs less coding, but of course you need to figure out how the whole package works and how to turn the problem into something that sympy can solve. If you use external packages, make it very clear in a docstring at the top of your program that you do and why.

General hints

We will check some of your code in gitlab on OUR inputs (not yours!). So your code must parse the input file, not hard-code your input; otherwise it will not output the correct solution on our inputs. It can actually happen that your code is correct for your input but not in general (especially for day 19, where you might take shortcuts that are wrong in general, but worked for your input). If we find such a case, we will certainly ask you about that particular code, but of course, we will not (and cannot) take away the stars. Please ensure that we can just run (for example) python day19.py after getting your file and that it reads day19.txt. (In an earlier version, this mentioned input19.txt, but the input file for day 19 should be called day19.txt.)

Most repositories seem to be readable and identifiable now; a recent version of the star statistics has been uploaded to the Materials section; please see if your matriculation number appears in the list. If not, please read the instructions again (here in older news).

Happy holidays!

19.12.2022

Hints Days 17 - 19

Good morning,

it seems to get a bit colder at the university; but the ZBI building is still warm. Over the last few days, the AoC problems were getting quite demanding, so here are some comments.

Day 17 (Saturday):

Part 1 of this game of "Tetris without... Read more

Good morning,

it seems to get a bit colder at the university; but the ZBI building is still warm. Over the last few days, the AoC problems were getting quite demanding, so here are some comments.

Day 17 (Saturday):

Part 1 of this game of "Tetris without rotation" is in principle straightforward, although it is unfortunately easy to make off-by-1 errors when deciding where to start with a new falling rock and when it comes to rest. It is crucial to look at and to reproduce the examples. In terms of data structures, I just used a simple list to represent the tower. Each level is again a list of characters (so I can modify it). The cycle() function from itertools can be helpful to implement the infinitely cycling rocks and jets.

Part 2 is more demanding, since we must build the tower for a ridiculously large number of steps, so we cannot do it explicitly. Instead, we note that at some point, something repeats over and over again. Note that we can describe the current "state" of the system by: (a) where we are in the rock cycle, (b) where we are in the jet cycle, and (c) how the last few (how many?) topmost rows of the tower look like. If a state repeats after gaining some height dh after using dr rocks, we can use this information to take shortcuts.

Day 18 (Sunday):

This problem was relatively easy in comparison, especially part 1 is straightforward; you just check all neighbors of a cube.

For part 2, you need to be able to distinguish outside from inside. Again, a small variation of the "connected components" algorithm from the lecture can be helpful. Then, for every cube, you just count neighboring fields that belong to the outside.

Day 19 (Monday, today):

In principle, this is a straightforward recursion. In each minute, you can take one of several possible decisions and recursively solve the problem with the updated resources, number of robots, and remaining time. However, because there are many possible branches after each minute (you can buy a new robot of one of 4 types, or do nothing, so there are up to 5 possibilities), the total number of recursive calls might be close to 5**24, which is impossible to evaluate. Fortunately, in many situations, most of the branches are not possible (you cannot "buy" a new robot if you do not have the resources), but you will still need to find more clever ways to limit the recursion in order to have your program finish before the deadline. So think about it: When does it make sense (or no sense) to buy another robot of type X? When does it make sense (or not) to do nothing in one round?

This is even more important in part 2, where the time frame increases from 24 minutes to even more. Of course, you must make sure that your "shortcuts" do not cut away the actual optimal solution! On my laptop, I needed roughly 70 seconds to run both part 1 and part 2 in the end in pure Python, using just-in-time compilation of the recursive function, I could finish in 3 seconds. We will discuss compilation in January. Perhaps, if you think harder than I did, even your pure Python solution may be faster than 70 seconds.

 

16.12.2022

Day 16 Comments: re and DP ;-) and a note on next week

Good evening,

I just wanted to say that today's problem (already part 1) is not so easy. As you may read in the description, you have to figure out a path from your position ('AA') to every valve that can release pressure in open them in an optimal order. Usually... Read more

Good evening,

I just wanted to say that today's problem (already part 1) is not so easy. As you may read in the description, you have to figure out a path from your position ('AA') to every valve that can release pressure in open them in an optimal order. Usually part 1 can be brute-forced, but in my input, there were already 15 valves, so naively running all 15! = 1.3 * 1012 permutations is out of the question (at least in pure Python). It may work within a day or so with a reasonably efficient compiled C program. So the challenge is not only to write some good here, but also to come up with a better idea.

You could apply a technique called branch-and-bound: Clearly, some permutations already start so badly that they will never have a chance of beating another already known solution. Then all permutations which share such a bad prefix do not have to be evaluated. This can cut off a large fraction of the search space if you already know a good solution. It is not trivial to implement correctly, though.

Another approach will be discussed in class on Tuesday: dynamic programming (DP). This is also not trivial to get correct on the first attempt, but it also plays nicely with part 2 of today's problem. Of course, we will not discuss this particular problem in class, but other applications of DP. From bioinformatics, you should be familiar with edit distance (or alignment score) computation using DP: optimally solving a large problem by putting together optimal solutions of smaller subproblems, without repeatedly solving the same subproblem more than once.

Another useful module to use today (and on some previous days) is 're' for regular expressions to parse the input file. Unfortunately, regular expressions form their own little language, and there is a learning curve. However, once you know how to write patterns and how to extract the relevant information, parsing the input file becomes much simpler than splitting and piecing everything together. So we will also discuss regular expressions (also regexes, re_s) on Tuesday.

Classes next week

Unfortunately, we lack information about heating in the ZBI building next week. At the moment, we assume that the PC pool will be operational and due to the amount of PCs in the room, it will also be warm. Therefore, the tutorials will probably(!) be on campus. However, if you cannot or do not want to come, no problem: You can always use the alternative channels and/or if there is high demand, we can also offer a video tutorial 

Have a nice weekend!

 

15.12.2022

Days 14 and 15 (Hints)

Good morning,

fortunately, ChatGPT has some inspiration for us:

What would a wise woman do if she could not solve a problem immediately?

A wise woman, like a wise man, would likely take a step back and approach the problem from a different perspective if... Read more

Good morning,

fortunately, ChatGPT has some inspiration for us:

What would a wise woman do if she could not solve a problem immediately?

A wise woman, like a wise man, would likely take a step back and approach the problem from a different perspective if she couldn't solve it immediately. She might seek out additional information or resources to help her understand the problem better, or she might consult with others to get their input and advice. In any case, a wise woman would likely recognize that sometimes the best course of action is to take a break and come back to the problem later with a fresh perspective.

Day 14 is, in my personal opinion, one of the nicest problems so far. It is a simple physical model and can be implemented in a relatively straightforward way. You may wonder which data structure you should use to represent the (x,y) points. I recommend a dict (called "cave"), so you do not need to know the maximum and minimum x and y values beforehand. When a pair (x,y) is not a key in the dict, there is just air at (x,y). If there is a wall or sand, the corresponding symbol will be at cave[x,y]. For the second part, note that the new wall does not really have to be infinite. You can also not insert any new wall at all, but special-check the y coordinate.

Day 15 (today) can be a bit tricky. For part 1, carefully look at the example; why is the answer to the toy problem 26 and not 27? While part 1 can be solved by examining each position in the y-row, part 2 is on a much larger scale, so you'll need something much more efficient than working with single positions: In each row, each sensor covers a whole interval in the given limited range. The intervals of different sensors may overlap.

 

13.12.2022

Day 13 Hints; eval()

Good morning!

I hope you all have a wonderful day. Let's make the most of today and tackle whatever challenges come our way.

Today's problem (day 13) requires you to write a comparison(x1, x2) function. It will probably have to be recursive. Read the... Read more

Good morning!

I hope you all have a wonderful day. Let's make the most of today and tackle whatever challenges come our way.

Today's problem (day 13) requires you to write a comparison(x1, x2) function. It will probably have to be recursive. Read the instructions and the example very carefully! This is easy to get wrong.

One concrete hint for reading the input: You will have a string that represents a Python list, like "[1,2,3]". To get the actual list object, you can pass the string to the eval() function, which evaluates an arbitrary string as a Python expression. Careful! Never do this with untrusted user input ("eval is evil"):

L = eval("[1,2,3]") will give you the list [1,2,3]

Note that the same trick can also be applied on day 11, where you have strings like '  Operation: new = old + 6'. If you split this at '=', take the right part and prepend 'lambda old:' and eval this like f = eval('lambda old: old + 6'), then f will be an actual Python function that adds 6 to its input argument, and you can actuall call f(17) to get 23.

Remember to stay focused and stay positive, and you can accomplish anything. Have a great day!

 

12.12.2022

Days 09, 10, 11, 12 and Tomorrow's Lecture; Reminder on Repos

Good day everyone,

today is roughly half-time, and the problems get more complex and take longer to work on.

For day 09 (Friday), you may, of course, adapt the Point class shown in the lecture. You can adapt it to 2D (only x and y), and will need to implement... Read more

Good day everyone,

today is roughly half-time, and the problems get more complex and take longer to work on.

For day 09 (Friday), you may, of course, adapt the Point class shown in the lecture. You can adapt it to 2D (only x and y), and will need to implement subtraction (.__sub__(self, other) method). Being able to compute the maximum norm of a point is also helpful, max(abs(x), abs(y)). For part 2, you should implement part 1 in a way, such that you can just use a loop over different head-tail combinations. Consider re-writing part 1 if part 2 seems hard to do with your part 1 implementation.

Day 10 (Saturday) is straightforward in principle. However, you have to be careful to get the timing right. Note the careful wording of the problem: "during" a time step vs. "after" a time step. You may want to process the input file twice (separately for part 1 and part 2), because the two parts are doing quite different things. For part 2, you must actually print the screen contents of your 6 x 40 display and read off the letters by yourself; it makes no sense to do this programatically.

Day 11 (Sunday), part 1, is mainly a parsing challenge: You must correctly parse the information for each monkey from the text file. In principle, it can call be done with the split function. Remember that, for example line.split(":") splits at colons, while by default, just split() splits at whitespace. Otherwise, as always, it is recommended to verify that the example works with your code, as shown on the problem website.

Part 2, on the other hand, presents a completely new challenge. While Python supports arbitrary-size integers, the numbers will get so big that the computation will be extremely slow and not finish before the deadline (and/or exhaust all of your memory). However, it is not necessary to store the *exact* worry levels to get the correct test results for every monkey!

Day 12 (today, Monday) is a classical shortest-paths problem, which you can find in algorithms textbooks or on the internet. The first step is to build a directed graph from the input, G=(V,E) with a node set V and an edge set E. Edges connect nodes that can be reached from each other. Graphs will be covered in tomorrow's lecture, so it may help to wait until tomorrow after the lecture to get some basics.

IMPORTANT: We still have many repositories on gitlab that did not edit their README file according to the instructions. Remember:

  1. You must FORK Vu Lam's template repository (NOT request access to it)
  2. You must then edit the README according to instructions (here in the news). Use the EXACT provided format.
  3. You must be registered in the CMS here (you are if you are receiving news emails) AND your matriculation number in the CMS must match the number in the README.
  4. You must be registered on the course's private leaderboard in AoC.

If and only if ALL of these steps are followed, we can track your progress automatically.

 

09.12.2022

Can we read your gitlab repo?

We created table (Materials -> Administrative) that contains matriculation numbers and current stars (as of now) of EVERYONE who provided correctly formatted information in their README file, REGISTERED on the private leaderboard and is in the CMS. Please check your... Read more

We created table (Materials -> Administrative) that contains matriculation numbers and current stars (as of now) of EVERYONE who provided correctly formatted information in their README file, REGISTERED on the private leaderboard and is in the CMS. Please check your data (the information is sorted by matriculation number). If you do NOT FIND your matriculation number, please check that you have

1. forked your own repository from the correct template (otherwise we cannot find it; we process all forks of the template)

2. edited the README file as instructed and entetered each line formatted exactly as shown

3. registered on the private leaderboard (link in Materials)

If you see a problem, please fix it. If you cannot find the problem, please get in touch.

08.12.2022

Days 06, 07, 08 and Feedback on Repos

Good morning,

let me say some words about the past days.

Day 6 was quite simple, fortunately, just testing whether all of the characters in each length-k substring (k-mer) of a long string are distinct, and we have learned how to do that.

Day 7 was... Read more

Good morning,

let me say some words about the past days.

Day 6 was quite simple, fortunately, just testing whether all of the characters in each length-k substring (k-mer) of a long string are distinct, and we have learned how to do that.

Day 7 was (probably) quite difficult. The problem is all about a tree structure (a typical directory tree), but it is given in a complex "format" using unix commands, so parsing takes quite some code. In addition, such problems are best solved using recursion, and we have not discussed it yet. It can be solved without! You have two choices. Leave the problem be for now, and do it later. Other days will be easier. Or, you can use a global dict (call it D here) that will store, for each full directory name (like '/'. or '/abc/def/xyz') the size of the files contained in the directory directly AND the total size of the directory (including its own files and the sum of the total sizes of the directories below). The full directory path names must be constructed and updated as you interpret the '$ cd XXX' commands. Computing total sizes non-recursively can be done if you additionally determine each directory's level. The level is essentially the number of slashes (/) in its name, except the root ('/') alone, whose level is 0. You must compute the total size from high level numbers first down to zero. Using recursion makes it more elegant.

Today (day 8) is better again. I suggest to store the input map in a "list of lists" H. Then you can access the value at (i,j) by H[i][j]. Essentially H[i] is the i-th row (another list). If you want the values looking "north" from (i,j), you can use a "reversed" list comprehension (decreasing the i value) like this:
heights_north_from_ij = [ H[k][j] for k in range(i) ][::-1]. Similarly, heights_south_from_ij = [ H[k][j] for k in range(i+1,m) ] (no reversal; m the number of rows).

Hope this helps.

On another note, some of you asked for feedback on whether we can read you git repos. We will publish a list shortly. We wanted to wait for a few days so everyone who wants to has had a chance to start and finish at least one or two days. You will get another news about this.

 

 

05.12.2022

Hints for Day 04 and 05

Good morning,

yesterday's problem (day 04) was not too hard (it helps do draw pictures). Remember that you can use split with an argument, like line.split(','), which will split on comma instead of whitespace. Once you have extracted integer start end end... Read more

Good morning,

yesterday's problem (day 04) was not too hard (it helps do draw pictures). Remember that you can use split with an argument, like line.split(','), which will split on comma instead of whitespace. Once you have extracted integer start end end position of elf 1 and elf 2, you can just check whether containment holds (or another condition in part 2).

An elegant functional-style solution would be possible here for both parts, but of course is not required.

 

For today's problem (day 05), we should point out that you can use a list as a stack: The bottom is element 0, the top is the last element (-1). To push something on a stack/list S, use S.append(item). To remove (and remember) and item from the top, use item = S.pop().

There is one gotcha "between" parts 1 and 2. Part 2 requires you to re-start from the same configuration as given in the input file. Either you read the input file again (safe), or you make a deep copy (not a normal copy) of your list of stacks before you modify it in part 1. (You do not want to start part 2 with the modified stacks after part 1!). It can be done as follows:

from copy import deepcopy

# Let S0 be the original list of stacks

S = deepcopy(S0)  # create a copy for modification in part 1; S0 remains the original

 

03.12.2022

Hints for Day 03

Dear all,

for today's problem(s), we want to give a few hints because some things can be difficult to figure out.

  • Remember sets? If A and B are Python sets, their intersection is (A & B).
  • Assume you have a set S with a single element. How do you get the... Read more

Dear all,

for today's problem(s), we want to give a few hints because some things can be difficult to figure out.

  • Remember sets? If A and B are Python sets, their intersection is (A & B).
  • Assume you have a set S with a single element. How do you get the element? You cannot write S[0] because indexing does not work on sets. However, you can manually create an iterator over S and get its first element by e = next(iter(S)).
  • Since part 2 is structurally different from day 1, you may want to write different functions for part 1 and 2. It is ok to read the input file again for part 2. Or you initially store it in a list of strings from which you then do both part 1 and 2 (making sure that you never change the list in between).
  • If you have trouble getting a group of 3 lines (in part 2), take a look at the itertools module; they show example code how to implement a "batched" function (https://docs.python.org/3/library/itertools.html); alternatively read the whole input into a long list and then slice it.
  • Remember to move short (but slightly complex) calculations (like letter -> priority) to their own functions; you get much more readable code like that.

Addendum for day 02:

  • Or course, there are shorter and more elegant ways than enumerating all 9 combinations explicitly. But we would be happy to see a simple clean solution that treats all 9 cases correctly rather than a "clever" wrong solution.

Have fun with the problems!

02.12.2022

Short Hints on December 2

Good evening,

just a quick hint for today's problem. It's not particularly difficult but somewhat annoying. In essence, you are converting every line of the input file into a score value and add up all the score values. The meaning of the input changes between... Read more

Good evening,

just a quick hint for today's problem. It's not particularly difficult but somewhat annoying. In essence, you are converting every line of the input file into a score value and add up all the score values. The meaning of the input changes between part 1 and part 2, but in both parts, you have 9 possible inputs (combinations of letters) to convert into a score. As you have learned, you can do this in at least 3 ways: if/elif/.../else chains, match/case, or using a dict. All of them are fine. The nasty part is getting the score value correct.

Since AoC punishes you for wrong answers by blocking you for one minute (initially, more minutes if you repeatedly enter wrong answers on the same problem), it is recommended to run tests with the provided example first (as explained in a previous tutorial, "test driven development"). Good luck!

 

01.12.2022

Important Instructions for Repository Setup

Dear all,

we have tried to extract your personal information from the gitlab repositories and decided that we must take a more formal approach; currently it is impossible to parse the README files consistently. Here are detailed instructions. Please follow them... Read more

Dear all,

we have tried to extract your personal information from the gitlab repositories and decided that we must take a more formal approach; currently it is impossible to parse the README files consistently. Here are detailed instructions. Please follow them carefully.

1. Make sure you have forked the following repository: https://gitlab.com/lamdv1/programming-with-python-2022 (click on the "Fork" button somewhere in the upper right area)

2. Make sure you set the repository to "private", but give at least "reporter" access to us (guest access is not sufficient). Our usernames and detailed instructions can be found in a slide set (Materials) of week 03.

3. Now edit the README.md file as follows to insert your personal details as follows at the very top (before the heading) of the file.

---
name: Jens Zentgraf
mat: 1234567
aocname: Jens Zentgraf
aocnumber: 654321
---

# Programming with Python template


Here, "name" refers to your real name (as it appears in official university transcripts), "mat" is your matriculation number, "aocname" is the name you use in AoC (as shown in the private Leaderboard) and "aocnumber" is your AoC user number. You can find it in AoC by clicking on "Settings". You can show yourself by name (even with a picture) or as "(anonymous user #654321)". This number (here shown as 654321) is your user number in AoC.

Please make sure that there is no empty line before this header,  and the first line is exactly three (3) dashes (---).
Please make also sure that the header ends with the same three dashes (---) and that there is an empty line after it. The next line after the empty line should be the original heading (# Programming with Python template).

4. Please note that in the original README.md, some wrong information was given. Here is the correct information, and you can edit the file to reflect these corrections. We apologize for the confusion.

  • Input data files from AoC should be saved as day01.txt (not .inp)
  • Final deadline is 31.01.2023 !

If there are any remaining questions, please use the forum or ask the tutors in your tutorial.

 

01.12.2022

Welcome to Advent of Code

Good morning everyone,

today is the first day of December, so Advent of Code has started. Every day at 6:00 in the morning, a new two-part problem goes online at https://adventofcode.com/2022.

By today, you should have your (private) git repository (as... Read more

Good morning everyone,

today is the first day of December, so Advent of Code has started. Every day at 6:00 in the morning, a new two-part problem goes online at https://adventofcode.com/2022.

By today, you should have your (private) git repository (as described in the first week) on gitlab and have given us read access to it (as described in a later week). Please be sure to follow the naming conventions, so we can automatically check out and review your code periodically.

You should also have joined our AoC private leaderboard for the course (link and code in Materials). Otherwise we will not notice when you have achieved 35 stars, and you will not be admitted to the final exam.

So, the first problem today is "standard", and we will be publishing hints here in the news from time to time. Today, there is no need really. We have practiced this type of problem: Open the file, read line by line, test whether the current line is empty and if it is, re-start summing from zero. Maybe it is a good idea to append all elves' calories to one list, so you can in the end work conveniently with one list to make your life (code) simple.

All lecture recordings (and slides, sometimes corrected or slightly modified) are available in the Materials section, if you want to review something.

In general, please try to do each problem on the day it appears; otherwise you may fall too far behind. You still have until 31.01.2023 to collect at least 35 stars, but the later problems will be more difficult and require more time!

Have fun and good luck!

15.11.2022

Slides and Video of Lecture 4 online


Dear all,

the video recording of today's lecture 4 and the corresponding slides are online. The problems for this week will go online later this afternoon.

08.11.2022

Slides and Video of Lecture 3 online

Dear all,

the video recording of today's lecture 3 and the corresponding slides are online. May they be useful for this week's problem set (also online now).

01.11.2022

Lecture 02 Slides and Video online

Dear all,

slides and video of lecture 2 are now online. This important lecture covers most of the day-to-day basics of Python (assignments, function definitions, for, while, if/elif/else, sequence types). Sorry for the delay. Enjoy the video and see you at the... Read more

Dear all,

slides and video of lecture 2 are now online. This important lecture covers most of the day-to-day basics of Python (assignments, function definitions, for, while, if/elif/else, sequence types). Sorry for the delay. Enjoy the video and see you at the tutorials or in the forum.

28.10.2022

First Week Recap

Dear all,

we hope that you have had a good first week on campus. We also hope you got a quick start with our Python course, i.e., got conda installed, were able to set up your git repository, clone it and push your first commits, and that you were able to run... Read more

Dear all,

we hope that you have had a good first week on campus. We also hope you got a quick start with our Python course, i.e., got conda installed, were able to set up your git repository, clone it and push your first commits, and that you were able to run Python in the shell, and solved the first set of exercises.

Next week, the lecture would be on a holiday (Nov 1, All Saints Day). Because we need to cover a lot of basics before December starts, we unfortunately cannot skip the lecture. Instead, I will upload a pre-recorded lecture, so it won't be live on Tuesday morning. If you are awake after the Halloween party, you can already watch the video on Tuesday morning. Tutorials will take place as usual.

We noted that not everyone who was assigned to a tutorial was actually present. This creates the unfortunate situation that a large number of people who might want to come to a tutorial could not (because by counting, it was full), and there were some empty seats. So if you do not want your tutorial spot on Wednesday, Thursday, or Friday, let your tutor (Jens, Johanna, or Vu Lam) know! Conversely, if you do not have a tutorial assigned but would like one, please get in touch with the tutor of your preferred time slot (or tentatively come to the tutorial to see if there are empty seats). We will see what we can do.

What we plan for week 2 (this may change slightly, some topics may move to week 3, etc.):

- loops (for, while); conditional statements (if)

- basic types (list, tuple, range; str)

- sequence types

- function definitions

- Many short examples

For week 3 then, we plan to introduce all basic language elements that are still missing, so we can do two (easy) Advent of Code examples from previous years in detail; their code fill fit on a single slide.

Have a nice weekend!

25.10.2022

Welcome to the Python Programming Course!

Welcome, everyone.

The course is about to start in 7 hours (08:30 in the morning). The zoom link is in the Materials section. The first set of slides is online.

Please be aware that the course is heavily over-subscribed. Since the course is mandatory only for... Read more

Welcome, everyone.

The course is about to start in 7 hours (08:30 in the morning). The zoom link is in the Materials section. The first set of slides is online.

Please be aware that the course is heavily over-subscribed. Since the course is mandatory only for beginning MSc Bioinformatics students, only they are guaranteed a place in the tutorials. If you are a beginning MSc Bioinformatics students (1st or 2nd Master semester), please select your tutorial preference right after the lecture (before midnight in any case). If you are not one of these students, please select Tutorial #4 (None), which has unlimited capacity. You can always use the online forum to ask questions to all tutors.

Thank you and enjoy the course.

Show all
 

Programming with Python

This course is the required programming course for first semester students in the Bioinformatics Master program.

Students of other programs may take this course after consulting with their study coordinators. Since the course is ungraded this year, it can only be used for the ungraded credit section. In particular, the course can (only) be used for "freie Punkte" in the Bachelor or Master Informatik program.

We are in the process of changing the study regulations to upgrade the current ungraded 5 credits course to a graded 8 credits course in the future and to offer alternating courses between C++ and Python.

This year, for the last time, we will have the ungraded 5 credits course, but already in the Python version.

Schedule

Lecture: Tuesday 08:30 - 10:00, online only (Zoom); first lecture: 25.10.2022 at 08:30. Link in Materials section for registered students.

Tutorials: You will be assigned to one of three tutorials. It is optional to come to the tutorials. They offer the possibility to ask questions while you work on the problems. You may need more time to solve the problems than during the tutorial sessions. If you feel more confident, you can also work entirely from home and ask the occasional question in the forum. Participation in tutorials is restricted to beginning Master students in Bioinformatics (for whom the course is required), as the capacity is limited and the course is over-subscribed. All tutorials take place in the E2.1 computer pool (next to the entrance), so make sure you have access to it before the semester starts.

  • Tutorial 1: Wednesday 14-18
  • Tutorial 2: Thursday 09-13
  • Tutorial 3: Friday 12-16
  • "Tutorial" 4: None (you must choose this if you are not a beginning Bioinformatics MSc student for whom this course is mandatory)
     

Structure

The course will be structured into three phases. Each week during the lecture period (25.10. to 10.02.), there will be a 2h lecture (V2) and 4h of tutorials (Ü4), during which you are expected to do most of the programming work, i.e., there should be very little homework (in comparison to a V4+Ü2 course, for example, which usually yields 9 credits). You should expect to spend 150 h on the course in total (~10h/week, 6 of which are done in presence). Please consult the calendar page to review the exact times of lectures and tutorials.

Phase 1: Start of lecture period till end of November (6 lectures)

The basic elements of Python and how to write and run simple Python programs will be taught. Several assignments (ideally to be completed in presence) will be given each week. You should be able to write a short program that interacts with the outside world (e.g., file I/O) by the end of November. In this phase, the workload will be relatively low.

Phase 2: December: Algorithms and Advent of Code (4 lectures)

We will participate in "Advent of Code" as a group. Each day, December 1 - 25, an individualized two-part problem will be posted on Advent of Code. You get one star for solving each part for a possible maximum of 50 stars. You will need to get at least 35 stars until the deadline (see below) to be admitted to the exam. Lecture in December will explain necessary algorithms to solve some of the more difficult problems. The problems usually start out quite easy, but become more and more difficult as the month progresses.

Phase 3: Special topics (January till end of lecture period, 5 lectures)

After the holiday break, the lectures will introduce useful Python modules for bioinformaticians, such as different plotting libraries, workflow management using Snakemake, just-in-time compilation using numba, and others. There will be a small amount of assignments to work on some examples with these libraries. Otherwise, you have time to finish the Advent of Code assignments.

Exams

Short oral exams (~15-20 min) take place in the first week after the lecture period. You are qualified if you have 35 stars in Advent of Code until 31.01.2023, 23:59. In the exam, you have to explain your code for some of the more complex Advent of Code problems and answer questions about it.

Requirements

  • Before the lecture period, or in the first week: Register here in the CMS to access the Materials section. Unregister if you drop the course. If you do not have an account yet on the CMS, be sure to get one early.
  • During the lecture period, achieve at least 35 stars in the Advent of Code problems to qualify for the exam.
  • ONE WEEK BEFORE the exam (or earlier), register for
  1. a time slot for the oral exam using the provided scheduler
  2. the exam itself in LSF; this will be explained further in a News item when the time comes.

 

Ethics and Plagiarism Policy

You may ask for help, either the tutors or other students, or people on the internet, or even books. However, you may not use or copy their code directly. All implementations must be your own. In case you use other peoples' work beyond the Python standard library (e.g. numpy, scipy), this must be clearly stated up-from and properly cited. Violation of these rules will result in removal from the course and in reporting you to the examination office. If you get reported more than once, you may have to leave the university.



Privacy Policy | Legal Notice
If you encounter technical problems, please contact the administrators