Advent of Nim 2022

2022-12-20 Thread bg
You may already be aware of this, but if you don't want to use symbols, you can make a `max=` proc in nim: proc `max=`*(a: var int, b: int) = a = max(a,b) var x = 5 let y = 7 x.max= y assert x == 7 Run

Advent of Nim 2022

2022-12-20 Thread fxn
I have not been able to solve #19 yet, but I founded it to be perfect for arrays indexed by an enum. The code reads really nice, reads with problem names, but allows for genericity when you need it.

Advent of Nim 2022

2022-12-19 Thread fxn
I saw that [Noulith](https://github.com/betaveros/noulith) has x max= y Run as a (conceptual) shortcut for x = max(x, y) Run which is often handy for AoC in particular. And just realized you can write that in Nim, for example:

Advent of Nim 2022

2022-12-15 Thread shirleyquirk
so that hack for popping an item out of a `set[T]`.? someone asked how on [stackoverflow](https://stackoverflow.com/questions/74673080/pop-for-built-in-sets/74807180#74807180) and i got nerdsniped and wrote a simd-vectorized fully generic version. tldr: min timeavg time

Advent of Nim 2022

2022-12-11 Thread Hlaaftana
Wasn't backported because it's a breaking change IIRC but it theoretically could be

Advent of Nim 2022

2022-12-11 Thread lscrd
I suppose that the bug will be fixed in 1.6.12 version but I don’t know when this version will be released.

Advent of Nim 2022

2022-12-11 Thread dlesnoff
Did you propose to backport the relevant issue in the 1.6.x stable branch ?

Advent of Nim 2022

2022-12-11 Thread DestyNova
Just seeing this thread now, but I've been posting my solutions [in this repo](https://github.com/DestyNova/advent_of_code_2022). Most days I've used Nim but there are a few Crystal solutions too, especially in the earlier days before I got too lazy. A few times I used ChatGPT to translate my

Advent of Nim 2022

2022-12-07 Thread rockcavera
I never participated in Advent of Code, but this year I decided to do it and see how it works. I hope it's productive. My solutions will be [here](https://github.com/rockcavera/nim-adventofcode).

Advent of Nim 2022

2022-12-06 Thread lscrd
My solutions are available here: When solving day 06, I encountered a bug in Nim 1.6.10 "strutils" library. In "s.find(sub, start, last)", if "last" is equal to 0, this is interpreted as "s.high" which is wrong. This bug has been fixed in the

Advent of Nim 2022

2022-12-05 Thread fxn
> The converter from input string to Shape is called toShape. After reading more Nim, I believe this was not idiomatically a coverter. Got renamed to `parseShape`, which may be a better choice.

Advent of Nim 2022

2022-12-05 Thread miran
> Even some of the mods here use other languages. I don't know who that guy might be, but he must be a real jerk. The worst _human_ ever!! * * * I'm in 7 private leaderboards, and some of those are Advent of , because one (or multiple) year(s) I've solved (primarily) in that language. And

Advent of Nim 2022

2022-12-05 Thread dlesnoff
I finally shared mine: The solutions so far are exactly in the state where I finally solved the problem.

Advent of Nim 2022

2022-12-05 Thread Zoom
By this day it's pretty obvious that the current two Leaderboards do not really represent the Nim community. From what I can tell, ATM, the only persons in both top10s Awho are provably using Nim is Michal Maršálek (although there's no link so you need to know [his

Advent of Nim 2022

2022-12-04 Thread jasonfi
Related: [Placing #1 in Advent of Code with GPT-3](https://news.ycombinator.com/item?id=33850999) I asked ChatGPT to write a web framework for Nim. It wrote a a small program that looked like it could work, but was very minimal.

Advent of Nim 2022

2022-12-04 Thread SolitudeSF
> but nobody writes their api to accept openArray[char] damn shame

Advent of Nim 2022

2022-12-04 Thread Yardanico
> but nobody writes their api to accept openArray[char] This is changing though, thanks to Beef we have this in devel (and it'll be in 2.0): "Added openArray[char] overloads for std/parseutils allowing more code reuse. Added openArray[char] overloads for std/unicode allowing more code reuse."

Advent of Nim 2022

2022-12-04 Thread shirleyquirk
Does mmap.lines allocate too many strings for your liking? sure, you could iterate over memslices, but nobody writes their api to accept openArray[char], do they now. why not mmap the file directly into memory as a nim string literal? import

Advent of Nim 2022

2022-12-03 Thread shirleyquirk
shirleyquirk's horrifying hack for day3: Want dubious micro-optimized performance gains, AND the possibility of undefined behaviour? Access the lowest member of a set in O(1)! import std/bitops type Priority = range[1..52] func lowest(s:set[Priority]):Priority =

Advent of Nim 2022

2022-12-02 Thread bg
It is really clever! Nim is so flexible that the input can be interpreted as valid Nim code and run! That said, I don't prefer that approach in my own solutions. When I clean up my solutions I tend to want to make them run faster, and for those purposes I consider baking the input into the

Advent of Nim 2022

2022-12-02 Thread pietroppeter
There was a fix made in May to allow moderators to edit posts but I guess it is not in production: Admins should always be able to edit posts, even not their own, from what I can tell (it would be nice to have somewhere accessible a ref to

Advent of Nim 2022

2022-12-02 Thread Zoom
> I feel like compared to last year, not many people are posting their Nim > solutions to the megathread. Maybe reasonable and forward-thinking people are just steadily leaving Reddit ;) Here's my repo for this year, although, I don't think I'll stick to updating it for long due to other

Advent of Nim 2022

2022-12-02 Thread firq
I'll post my solutions at

Advent of Nim 2022

2022-12-02 Thread pietroppeter
indeed, when I posted my solution yesterday I found only two other people. haven't yet the chance to post mine today... unfortunately also the website that was able to show you all solutions in megathread by language is not active anymore:

Advent of Nim 2022

2022-12-02 Thread MichalMarsalek
Hmm, I feel like compared to last year, not many people are posting their Nim solutions to the megathread.

Advent of Nim 2022

2022-12-02 Thread miran
Since my second post here is "too old and can no longer be edited", here are our repos: * @al1ranger: * @auxym: * @bg: * @ElegantBeef:

Advent of Nim 2022

2022-12-02 Thread shirleyquirk
i think i saw PMunch use this hack last? year, today's problem looked like a nail for that particular hammer, so:

Advent of Nim 2022

2022-12-02 Thread fxn
Solutions for day 2: Trying to be idiomatic: * All procs are `func` to indicate they are pure functions. * Usage of an enum for the shapes which results in type safety and much improved readability, because `Rock` obviously

Advent of Nim 2022

2022-12-01 Thread remix
https://github.com/remigijusj/aoc-2021/tree/main/2022

Advent of Nim 2022

2022-12-01 Thread mishankov
Here are mine solutions for this year AoC: Hope I'll finish it this year

Advent of Nim 2022

2022-12-01 Thread fuddlesworth
Decided to learn nim. Here's day 01.

Advent of Nim 2022

2022-12-01 Thread ElegantBeef
My solutions will be [here](https://github.com/beef331/nimtrest/tree/master/aoc2022). _When my solutions do not appear it means my solution for the first part was too specialised and I am off to kick rocks_ :P

Advent of Nim 2022

2022-12-01 Thread fxn
Day 1 was the warmup, but I am learning so here my solution . I've seen a few solutions to the first part that built sequences (in other programming languages), but to compute a max you do not need to store them all.

Advent of Nim 2022

2022-12-01 Thread moigagoo
Oof, let's see for how many days I'll be able to handle this :-)

Advent of Nim 2022

2022-11-30 Thread MichalMarsalek
I'm doing AoC in Nim again:

Advent of Nim 2022

2022-11-30 Thread hamidrb80
https://github.com/hamidb80/problem-solving/tree/main/advent-of-code/2022

Advent of Nim 2022

2022-11-30 Thread bg
I'm in a similar situation as some others: I probably won't have time to do all the days as they come. I plan to share my answers here:

Advent of Nim 2022

2022-11-30 Thread al1ranger
I will be uploading my solutions here. Most likely I will not be able to complete all the challenges during the event, but I plan to do the unsolved ones afterwards.

Advent of Nim 2022

2022-11-30 Thread auxym
I'm in for sure, AOC is always good fun, especially in Nim. Young kids mean programming time is limited. I'll probably get the first couple days in time, and finish it up after christmas. Still managed to solve all days except 24 last year!

Advent of Nim 2022

2022-11-30 Thread pietroppeter
ye, it's advent of nim time! that time of the year where I am miraculously excited to get out of a bed at 6 am!  I plan to blog about my solutions in nim in my usual repo here: I also plan to share the link to my solutions in reddit daily

Advent of Nim 2022

2022-11-30 Thread miran
## Advent of Code 2022 Thursday December 1st at 5 a.m. UTC will mark the start of the eight incarnation of [Advent of Code](https://adventofcode.com/), popular programming contest started back in 2015. The author describes Advent of Code (AoC) as " _a series of small programming puzzles for a

Advent of Nim 2022

2022-11-30 Thread miran
Previous Advent of Nim threads: * [AoC 2018](https://forum.nim-lang.org/t/4416) * [AoC 2019](https://forum.nim-lang.org/t/5588) * [Aoc 2020](https://forum.nim-lang.org/t/7162) * [AoC 2021](https://forum.nim-lang.org/t/8657) * * * Our repositories and solutions: TBA

Advent of Nim 2022

2022-11-30 Thread PMunch
I was thinking of streaming my solutions again this year. Hopefully people will still find that interesting :)