Vulwsztyn

joined 2 years ago
[–] Vulwsztyn@programming.dev 1 points 4 days ago

there is basedpyright

 

I need to boast a bit and ask for "code review". I'm sorry if this doesn't constitute a good post.

I browse local communities more often than I should for my mental health.

I was checking out https://nim-lang.org/ and when I googled it one of the links was to rosettacode.org and I decided to check out the implementation of 2048.

I noticed that zig's implementation was a non-working auto translation of rust's, so I decided to rewrite it.

My repo: https://codeberg.org/Vulwsztyn/2048_zig

With the reader, writer, and arraylist api changes in 0.15 most of the sources were usless and if I hadn't found https://github.com/xyaman/mibu I guess I would have surrendered.

Feel free to roast the hell out of my code.

[–] Vulwsztyn@programming.dev 1 points 3 weeks ago

Your post is my introduction to gleam and I already love it. Thank you

[–] Vulwsztyn@programming.dev 6 points 4 weeks ago

coming from a language with consistent pronunciation I pronounce it "aur" like other comments said, like "aurum" or like in Portuguese - how it is written)

[–] Vulwsztyn@programming.dev 0 points 1 month ago

That's not a good idea

[–] Vulwsztyn@programming.dev 1 points 1 month ago

lower resource usage for users

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

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

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

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

[–] Vulwsztyn@programming.dev 1 points 1 month ago

"stop using medium"

[–] Vulwsztyn@programming.dev 4 points 1 month 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.

 

Hi, I recently realised one can use immutable default arguments to avoid a chain of:

def append_to(element, to=None):
    if to is None:
        to = []

at the beginning of each function with default argument for set, list, or dict.

view more: next ›