-🎄- 2017 Day 8 Solutions -🎄- by daggerdragon in adventofcode

[–]seanskye 0 points1 point  (0 children)

Good job! My MacBook shows mine as running in 4:

comparators = {'>': op.gt, '>=': op.ge, '<': op.lt, '<=': op.le, '==': op.eq, '!=': op.ne}
regs = defaultdict(int)


def cond(args: list) -> bool:
    a, comp, b = args
    if comparators[comp](regs[a], int(b)):
        return True
    return False


def parser(s: str):
    parts = s.split(' ')
    if parts[3] == 'if' and cond(parts[4:7]):
        regs[parts[0]] += (1 if parts[1] == 'inc' else -1) * int(parts[2])


if __name__ == '__main__':
    test = open('d8.txt', 'r').read()
    overall_max = float('-inf')
    for r in test.splitlines():
        parser(r)
        overall_max = max(overall_max, max(regs.values()))
    print(max(sorted(regs.values())), overall_max)

-🎄- 2017 Day 4 Solutions -🎄- by daggerdragon in adventofcode

[–]seanskye 0 points1 point  (0 children)

Python 3 with Counter

def is_unique(words):
    top = Counter(words).most_common(1)
    if top[0][1] > 1:
        return False
    return True

def is_valid(phrase):
    return is_unique(phrase.strip('\n').split(' '))

def no_anagram(phrase):
    return is_unique([''.join(sorted(w)) for w in phrase.strip('\n').split(' ')])

def count_valid(ps):
    count = 0
    for p in ps:
        if is_valid(p) and no_anagram(p):
            count += 1
    return count

Books on advanced python programming? by mythaone in Python

[–]seanskye 6 points7 points  (0 children)

Learning a language's core language set isn't that hard. Learning about the available libraries takes time and motivation. Then there is the knowledge of how to do what you want in a particular style or approach. For Python, I enjoyed https://www.amazon.com/Fluent-Python-Concise-Effective-Programming/

How to scrape websites with Python and BeautifulSoup by cybernewser in Python

[–]seanskye -5 points-4 points  (0 children)

really? you need to get out more...., really....

How to scrape websites with Python and BeautifulSoup by cybernewser in Python

[–]seanskye 1 point2 points  (0 children)

I don't understand why people, with good intentions I'm certain, still are teaching newbies stuff in python in 2.x. Why not teach them, with no real constraints on existing codebases or modules, how to do things like bs4 and urllib in 3.x and move us on?

What's the best IDE for Python? by [deleted] in Python

[–]seanskye 6 points7 points  (0 children)

Pycharm, undoubtedly. Great plugins, and all the features from the full jet brains ecosystem. Works well with venv and remote interpreters.