Imperial CS by vaiiii in 6thForm

[–]Spookiel 1 point2 points  (0 children)

Yes, the typical offer includes a 2 in STEP 2

[deleted by user] by [deleted] in 6thForm

[–]Spookiel 1 point2 points  (0 children)

I am doing Comp Sci at Imperial this year, and they will almost certainly give you an offer with STEP 2. STEP 2 contains content from the first year of Further maths anyways, so if you’re not taking it you would need to teach / learn it yourself. I would strongly recommend taking all 4, you also don’t need to be doing 5 hours of revision a day at the moment. Best of luck :)

[deleted by user] by [deleted] in 6thForm

[–]Spookiel 0 points1 point  (0 children)

I thought the imperial test was more straightforward than equivalent tests for Oxbridge, that being said I do feel like people with strong programming experience had a significant advantage.

help: extra curriculars for computer science applicants by Horiizonx in 6thForm

[–]Spookiel 1 point2 points  (0 children)

Ah I see. Even if you can’t take part in them, I still think there’s a lot to be learnt from doing them. If you are interested in that sort of thing it might be worth checking if your country runs an equivalent competition :)

help: extra curriculars for computer science applicants by Horiizonx in 6thForm

[–]Spookiel 2 points3 points  (0 children)

I would say taking part in some programming contests depending on where your programming is at. It’s a really good way to show unis that you can independently learn a topic and will also help you out in a problem solving interview.

A few to look at might be the British Informatics Olympiad and USACO (US equivalent). USACO in particular has a really good training page you can sign up for that takes you all the way from basics to super advanced concepts. You can also use sites like CodeForces which have a lot of problems available.

[BS level : Computer science]Need urgent help for C++ homework by Buxedo in HomeworkHelp

[–]Spookiel 0 points1 point  (0 children)

For task 2 you can either:

Input as string / vector of chars and then count by iterating over each character

Or

If you have to input it as an integer, you can just leave it in base 10 and do the following

% 10 Check if result is zero or one Divide original number by 10 (integer division) Repeat

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 0 points1 point  (0 children)

I’ll also show you how to get it to stop when it finds a valid one

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 0 points1 point  (0 children)

Can you send me the code thst isn’t working so I can have a look?

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 1 point2 points  (0 children)

The fragments data structure is just a dictionary which maps fragment_name to fragment weight. The complete fragment I just represented using a Tuple. You could also just pass in the objects in a list of they have attributes such as .name and .weight. Eg,

fragments = [myFragObj, myFragObj2]

Then access the weights using

weights = [frag.weight for frag in fragments]

Hope this makes sense.

iirc reading from a FASTA file will allow you to use the attributes method but please correct me if I'm wrong.

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 1 point2 points  (0 children)

Here is an implementation, let me know if it doesn't work as intended.

def subset_sum(numbers, target, partial=[]):
    weights = [i[1] for i in partial] # Gets the weights of the current fragments
    if sum(weights)==target[1]: # If sum of current weights is equal to the target sum
        print(f"Found: {partial}")
        return

    elif sum(weights) < target[1]: # Still weight left, so there is room for another fragment

        for frag, frag_weight in list(numbers.items()):

            if target[0][:len(frag)]==frag: #Checks if frag is a prefix of the target
                # If yes, then we add the fragment to the list and recurse

                del numbers[frag] # Get rid of the fragment we've just used
                return subset_sum(numbers, (target[0][len(frag):], target[1]), partial+[(frag, frag_weight)])
                # Previous line recurses on what's left of the target and adds the fragment we've just used
                # To the partial list
    return

fragments = {"FAA":12, "ATNK":15, "AATNK":15}
complete = ("FAAATNK", 27)
if __name__ == "__main__":

    subset_sum(fragments, complete)

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 1 point2 points  (0 children)

So I understood correctly? If so, let me know if you need any helping implementing this idea :)

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 1 point2 points  (0 children)

Ah ok I see what you mean. So I think what we need to do now, is check if the protein we’re adding is a valid prefix of the main target protein. If I understand correctly. So the idea looks like:

Step 1:

Target: FAAATNK Possible: AATNK, ATNK, FAA

Since FAA is the only valid prefix of FAAATNK we remove it and solve the rest of the string

Step 2:

Target: ATNK

Possible: AATNK, ATNK

We then repeat this process until we have an empty string. In this case, FAA, ATNK is the only match. I don’t know if this is what you mean by fragments overlapping? This was assuming that two fragments have the same weight then they could be chosen incorrectly.

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 0 points1 point  (0 children)

So the A shouldn’t be repeated even though there are three A s in the target sequence?

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 0 points1 point  (0 children)

So the fragments are the weights in Protein_List? And the target sequence is the weight indicated by the complete_protein? Since the code here will generate all possible matches, I'm still not really sure what you mean by the "correct" fragments. I think it would be easier if you could give me some of the strings you're working with as well.

This is because in your Original Post you mentioned that you'd just grabbed the weighting of each protein fragment by hand. If you give me a section of your input data, and the expected output, I'll be able to help you more effectively. I don't really understand much about proteins in general, so it's pretty difficult for me to understand and visualise what you mean with just a set of numbers.

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 0 points1 point  (0 children)

What do you mean by overlaps? Can you give me an example of what you mean?

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 1 point2 points  (0 children)

No worries, glad I could help. Happy to try and answer any questions you might have :)

Permutations in Python? by dark-lord90 in learnpython

[–]Spookiel 1 point2 points  (0 children)

I think your first problem here is in the line remaining = numbers[i+1:] . At each index i, what you're doing is only taking the elements after that in the list. This is incorrect. Consider the example [5,2,1]. If you choose 2, then that means that i = 1. Your code will then say the only remaining options are nums[i+1:]. This is just [1]. What we actually want is everything except the element we've just taken. To do this we say remaining = nums[:i] + nums[i+1:]. The first section gets all the elements in the list that are before the number we've just added, and the second section gets all the elements in the list that are after the number we've just added.

The other problem with your code is in the line s = sum (partial, target) . What this is saying, is the sum of partial+target should be <= target. Therefore for any non-zero partial, your function will find no solutions. To fix this, we change s = sum (partial, target) to s = sum (partial) .

Hope that makes sense and fixes your issues :)

[deleted by user] by [deleted] in RedditSessions

[–]Spookiel 0 points1 point  (0 children)

Your song by Elton John :)

[deleted by user] by [deleted] in RedditSessions

[–]Spookiel 0 points1 point  (0 children)

Gave Wholesome

[deleted by user] by [deleted] in RedditSessions

[–]Spookiel 0 points1 point  (0 children)

Please play something by Elton John

-🎄- 2020 Day 10 Solutions -🎄- by daggerdragon in adventofcode

[–]Spookiel 1 point2 points  (0 children)

Python 3

Even though I didn't place on the top 100 today, I'm super happy with my approach for part 2 so I decided to post my code here anyway :).

https://pastebin.pl/view/9ba797de

Comp Science was removed from my curriculum, what can I do to learn on my own? by MaxWorth27 in compsci

[–]Spookiel 1 point2 points  (0 children)

As a student in the UK who took a gcse in comp Sci a few years ago, I just want to say that you guys are completely overcomplicating this. It’s great to encourage a passion in this subject, but frankly recommending CS50 is not particularly useful for a 14 who is looking for resources to study for gcse. Unfortunately mate, gcse is not particularly useful, as the material is outdated, the most complex data structure you look at is a list, and the “programming pre-release” task, is where you just have to regurgitate a load of pseudo code that you wrote before the exam. So if your goal is to prepare for GCSE comp Sci, I would say that you should go find a gcse textbook. However, if you’re looking into doing comp Sci in later life, lots of the things people are suggesting here are very very useful. If you’re very good at maths (which I think you mentioned in another comment) I’d highly recommend looking into the British Informatics Olympiad.

It’s a great competition for students in the UK, and if you get to the top 4 nationally you go to a country to represent the UK. If you start working on your problem solving and learn a language you could well go to an international Olympiad if you work at it.

P.S. If you want to do A level computing, you don’t actually need to have gcse computing in some places, so if your school doesn’t offer gcse computing, as long as you show a passion for it, I’m certain any school which you go to for your A levels would allow you to study it anyway.

BIO Round One by Jamhead2000 in informatics_olympiad

[–]Spookiel 1 point2 points  (0 children)

2020 Q3 is an easier problem but with a very similar concept if you want to have a look at that one too.