GithubHelp home page GithubHelp logo

advent-of-code's Introduction

Advent of Code

I’m basing the structure of this repo (*.edn files, etc) off of tschady’s repo.

Introduction

My Clojure solutions to the Advent of Code challenge (to be reused over multiple years).

Structure

Babashka scripts

Handy scripts (thanks tschady) are in script.

bb.edn defines tasks that call them.

e.g. To create stub files for 2023 day 7, download the data to resources/day07.txt and open the websites for the problem and data, run:

bb go -y 2023 -d 7

Basic setup

Use deps.edn to define dependencies and paths.

Files in src and resources can be found during runtime.

Tests use file in test.

Tests

Tests are under tests.

Tests use kaocha (not sure how this works yet).

kaocha recommends setting up test configs in tests.edn.

Run with

bb test

Learnings

Transducers

https://clojure.org/reference/transducers

Reducing function

The kind of function you’d pass to reduce Takes an accumulated result and a new input and returns a new accumulated result.

Transducer (xform or xf)

A transformation from one reducing function to another.

Examples

(filter odd?) ;; returns a transducer that filters odd
(map inc)     ;; returns a mapping transducer for incrementing
(take 5)      ;; returns a transducer that will take the first 5 values

Compose with comp

Use the existing comp function. comp applies the rightmost function to the parameters, then the next rightmost function to the result, and so on.

(def xf
  (comp
   (filter odd?)
   (map inc)
   (take 5)))

The transformation above is equivalent to the sequence transformation

(->> coll
     (filter odd?)
     (map inc)
     (take 5))

advent-of-code's People

Contributors

bartev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.