Code Monkey home page Code Monkey logo

aoc23's Introduction

aoc23

advent of code

aoc23's People

Contributors

aleeusgr avatar

Watchers

 avatar

aoc23's Issues

feature: withResources

I want to keep the code I write for historic purposes, and I would like to learn how to write tests.
Following this discussion I wrote the test as follows:

aoc23/test/Main.hs

Lines 1 to 15 in 25b7d16

import Test.Tasty
import Test.Tasty.HUnit
import qualified MyLib (getCalibrationValues)
tests :: IO String -> TestTree
tests lsIO = testGroup "tests"
[ testCase "task1: the sum of calibration numbers is correct" $
sum ( MyLib.getCalibrationValues $ lines lsIO) @?= 56397
]
main :: IO ()
main = defaultMain (withResource acquire tests)
acquire :: IO [String]
acquire = read <$> readFile "inputs/1"

However I get an errors:
on line 8,

lsIO 
 Couldn't match type: IO String
                 with: [Char]

and on line 12,

withResource acquire tests
 Couldn't match expected type TestTree
              with actual type (IO [String] -> TestTree) -> TestTree
 Probable cause: withResource is applied to too few arguments 

2

some of the digits are actually spelled out with letters: one, two, three, four, five, six, seven, eight, and nine also count as valid "digits".

debug:

  • integrate quickcheck and use PBT to find other inputs that are problematic
  • use debugger to investigate the fynction step by step
  • use regex to solve this problem

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.