Spookiel / British-Informatics-Olympiad-Solutions

Contains python solutions for the British Informatics olympiad
24 stars 9 forks source link

How to get better at these questions? #3

Closed macaquedev closed 1 year ago

macaquedev commented 2 years ago

Hi! I've been looking at your solutions for quite some time as I am practicing for BIO '22. However, I'm just struggling with BIO Q3's and don't know how to get better at them. I understand dynamic programming (memoization) and recursion, I just don't see the solutions when I do these problems. Could you please help me get out of this rut?

ron0studios commented 2 years ago

learn a bit of enumeration (perms and combinatorics). There are a lot of neat tricks for enumeration in python that make it way faster

Pararcana commented 1 year ago

learn classes for question 2s

macaquedev commented 1 year ago

I'm sure most who seriously study for BIO know classes. I was asking about the more algorithmic and "ad-hoc" Q3 which gets me every time.

Pararcana commented 1 year ago

permutations then? idrk

ron0studios commented 1 year ago

I'm sure most who seriously study for BIO know classes. I was asking about the more algorithmic and "ad-hoc" Q3 which gets me every time.

Start with usaco guide or hackerrank. A typical progression would be 'ad hoc' -> 'complete search' -> 'greedy' -> 'DP' The first two can be done at any point really. Once you're good with DP, given that you've worked your way up by doing the other 3 problem styles, you should be good to go. Practice is key, read this (https://codeforces.com/blog/entry/98806)

macaquedev commented 1 year ago

Thanks a lot for the replies, I've long since found usaco and learnt a lot of the algorithms. Would you like to add my solution for 2018 Q2 to your repo?

import string

if __name__ == "__main__":
    first_dial = list(string.ascii_uppercase)
    second_dial = []
    curr = 0
    n, s = input("Please enter a number then a string: ").strip().split()
    n = int(n)
    i = 0
    while len(second_dial) < 26:
        i = (i + n - 1) % len(first_dial)
        second_dial.append(first_dial.pop(i))

    print("".join(second_dial[:6]))

    first_dial = list(string.ascii_uppercase)
    output = ""
    for letter in s:
        output += second_dial[first_dial.index(letter)]
        second_dial = second_dial[1:] + [second_dial[0]]

    print(output)
ron0studios commented 1 year ago

That's an impressive solution @macaquedev ! I have one in c++ too (much more bloated than yours though), maybe we could both PR?

macaquedev commented 1 year ago

Sure, or maybe do you just want to PR both your and my solution?

On Tue, 30 Aug 2022 at 07:36, Ron0Studios @.***> wrote:

That's an impressive solution @macaquedev https://github.com/macaquedev ! I have one in c++ too (much more bloated than yours though), maybe we could both PR?

— Reply to this email directly, view it on GitHub https://github.com/Spookiel/British-Informatics-Olympiad-Solutions/issues/3#issuecomment-1231212252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQQDSQ73LQLXXFXA7LMJMMDV3WTW5ANCNFSM5LHBB6VQ . You are receiving this because you were mentioned.Message ID: <Spookiel/British-Informatics-Olympiad-Solutions/issues/3/1231212252@ github.com>

ron0studios commented 1 year ago

Sure, or maybe do you just want to PR both your and my solution? On Tue, 30 Aug 2022 at 07:36, Ron0Studios @.***> wrote: That's an impressive solution @macaquedev https://github.com/macaquedev ! I have one in c++ too (much more bloated than yours though), maybe we could both PR? — Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQQDSQ73LQLXXFXA7LMJMMDV3WTW5ANCNFSM5LHBB6VQ . You are receiving this because you were mentioned.Message ID: <Spookiel/British-Informatics-Olympiad-Solutions/issues/3/1231212252@ github.com>

I can't really fork an PR atm sorry. If you'd like some help on the BIO, you should join our unofficial BIO server here You can go and meet Spookiel, tmncollins, many of the other solution creators and BIO finalists there! :)

macaquedev commented 1 year ago

Sure, thanks a lot for letting me join this server!

macaquedev commented 1 year ago

Server looks completely dead and there’s no channels where I can send messages? Have I joined the right place?

On Tue, 30 Aug 2022 at 09:59, Ron0Studios @.***> wrote:

Sure, or maybe do you just want to PR both your and my solution? … <#m1360859899000459917> On Tue, 30 Aug 2022 at 07:36, Ron0Studios @.***> wrote: That's an impressive solution @macaquedev https://github.com/macaquedev https://github.com/macaquedev ! I have one in c++ too (much more bloated than yours though), maybe we could both PR? — Reply to this email directly, view it on GitHub <#3 (comment) https://github.com/Spookiel/British-Informatics-Olympiad-Solutions/issues/3#issuecomment-1231212252>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQQDSQ73LQLXXFXA7LMJMMDV3WTW5ANCNFSM5LHBB6VQ . You are receiving this because you were mentioned.Message ID: </issues/3 https://github.com/Spookiel/British-Informatics-Olympiad-Solutions/issues/3 /1231212252@ github.com>

I can't really fork an PR atm sorry. If you'd like some help on the BIO, you should join our unofficial BIO server here https://discord.gg/J68wQvYU You can go and meet Spookiel, tmncollins, many of the other solution creators and BIO finalists there! :)

— Reply to this email directly, view it on GitHub https://github.com/Spookiel/British-Informatics-Olympiad-Solutions/issues/3#issuecomment-1231374138, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQQDSQ57UTQ2FXDSX47FUA3V3XEO7ANCNFSM5LHBB6VQ . You are receiving this because you were mentioned.Message ID: <Spookiel/British-Informatics-Olympiad-Solutions/issues/3/1231374138@ github.com>

Spookiel commented 1 year ago

If you open a PR I will merge the branches.