Skip to content

TomParfitt/aoc2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent Of Code

https://adventofcode.com/2023

Recepie Book

Some common snippets ...

Unbounded GoRoutines

func unboundedExample() int {

	var wg sync.WaitGroup
	resultChan := make(chan int)

	for i := 0; i < 10; i++ {
		wg.Add(1)
		go process(i, &wg, resultChan)
	}

	go func() {
		wg.Wait()
		close(resultChan)
	}()

	sum := 0
	for r := range resultChan {
		sum += r
	}

	return sum
}

func process(i int, wg *sync.WaitGroup, resultChan chan<- int) {
	defer wg.Done()

	resultChan <- i
}

About

Advent of code 2023

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages