Giter Site home page Giter Site logo

massimo-zaniboni / aoc-benchmarks Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 909 KB

Publish some Advent of Code benchmarks

Home Page: https://aoc-benchmarks.dokmelody.org/

Dockerfile 1.38% Python 26.62% Makefile 1.16% Haskell 8.23% Common Lisp 21.55% PHP 30.54% Shell 1.93% HTML 1.08% Hack 0.13% Clojure 7.38%

aoc-benchmarks's People

Contributors

massimo-zaniboni avatar

Watchers

 avatar  avatar

aoc-benchmarks's Issues

Day7

Prova per vedere che funzioni tutto

main = main2

main1 = sol1 <$> input >>= print
main2 = sol2 <$> input >>= print

input :: IO [Int]
input = read . ('[':) . (++"]") <$> getContents

cost :: (Int -> Int) -> [Int] -> Int
cost d ps = sum $ map d ps

median :: [Int] -> Int
median ps = last . take (quot (length ps) 2) $ L.sort ps

mean :: [Int] -> Int
mean ps = quot (sum ps) (length ps)

-- sol1 <$> input    344138
-- sol2 <$> input    94862124
sol1, sol2 :: [Int] -> Int
sol1 ps = cost (abs . subtract (median ps)) ps
sol2 ps = cost (\p -> sum [1..(abs $ (mean ps - p))]) ps

Legge da stdin

Navigation is not coherent

The name of the benchmark links sometime to the list of programs solving the problem, but in other cases to the source code.

There is a list of programs done in the same language, but it is not clear to select.

The link on a fail should jump to the section with the benchmark failing.

Clojure solutions (until day 15 as of now)

This is the link to all the solutions I wrote for this year in Clojure: jabberabbe/advent-of-code. Every problem is split into two separate independent files (part A and part B).
Each script takes the program input on stdin and writes the solution to stdout.
Some notes:

  • Leave out days 05 and 08 (they're example of bad coding practice; I will try to find some time to write them again from scratch).
  • Day 13 requires input preprocessing (at the moment). Feel free to leave it out; I put a short comment at the top of the file with some Ex-commands to create the required format. I will add some lines of code to parse the original input format.
  • Assuming you have already installed Clojure you can run the scripts from the shell with the following command: clj -M [clojure_file_containing_solution] < [input_file]. Keep the file deps.edn in the same directory of the scripts and run clj from that directory.
  • Alternatively, solutions that do not depend on external libraries (all except Day 15) can be run with the Babashka Clojure runtime, which uses GraalVM and has a much faster startup time (JVM clojure takes about 4s to start on my 2016 MacBook Pro). However, on big inputs the JVM may perform much better (we'll see). Assuming Babashka is installed: bb -f [clojure_file_containing_solution] < [input_file].

Thank you!

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.