News

Days 06, 07, 08 and Feedback on Repos

Written on 08.12.2022 10:35 by Sven Rahmann

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.

 

 

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