Vulwsztyn

joined 2 years ago
[–] Vulwsztyn@programming.dev 2 points 8 months ago* (last edited 8 months ago)

I know it's not the point of this comment, but I'll check harlequin out

[–] Vulwsztyn@programming.dev 1 points 8 months ago* (last edited 8 months ago)

Stop using ~~floats and cents for money~~ medium ffs

[–] Vulwsztyn@programming.dev 1 points 8 months ago

"stop using medium"

[–] Vulwsztyn@programming.dev 4 points 8 months ago

my boring python solution:

from pathlib import Path


def main():
    input = Path('input.txt').read_text().split('\n')
    names = input[0].split(',')
    instructions = input[-1].split(',')
    print(names,instructions)
    index = 0
    for instruction in instructions:
        dir = instruction[0]
        number = int(instruction[1:])
        if dir == 'L':
            index -= number
            if index < 0:
                index = 0
        else:
            index += number
            if index > len(names) - 1:
                index = len(names) - 1
    print(names[index])
    index = 0
    for instruction in instructions:
        dir = instruction[0]
        number = int(instruction[1:])
        if dir == 'L':
            index -= number
        else:
            index += number
    print(names[index%(len(names))])
    indexes = list(range(len(names)))
    for instruction in instructions:
        dir = instruction[0]
        number = (int(instruction[1:]) if dir == 'R' else -int(instruction[1:])) % len(names)
        indexes[0], indexes[number] = indexes[number], indexes[0]
    print(names[indexes[0]])

if __name__ == "__main__":
    main()

I probably should read all 3 files though. I'll hone it out later.

[–] Vulwsztyn@programming.dev 1 points 9 months ago* (last edited 9 months ago)

it's as easy as the code you're maintaining is.

it has fewer guardrails than most languages, that would prevent you from writing shit code

[–] Vulwsztyn@programming.dev 1 points 9 months ago

syntax is bad for list operations, also there are situations where you need to count the number of parentheses you closed, which wouldn't happen of you were able to use fluent interfaces

[–] Vulwsztyn@programming.dev 1 points 9 months ago

I mean mainly list manipulation, with explicit filter, map, reduce mathods.

I've also never had a problem with not knowing if I closed enough parentheses in Ruby.

[–] Vulwsztyn@programming.dev 2 points 9 months ago (2 children)

it has more sane syntax than python and is great for e. g. webscrapping

[–] Vulwsztyn@programming.dev 3 points 11 months ago

This is only a Draft for now though

[–] Vulwsztyn@programming.dev 1 points 11 months ago

Yeah, but you can also write it like I proposed which is less boilerplaty and gives the same advantages

view more: ‹ prev next ›