Code Monkey home page Code Monkey logo

euler's Introduction

Project Euler in Clojure

Project Euler (http://projecteuler.net) is an addictive and fun way to learn a new language and practice your craft. This repository is a scaffold for solving Euler problems using Clojure. It generates specs and solution stubs in an organized structure, making life just a little bit better.

Install

  1. If you don't have Leiningen installed, download this script and add it to you path.

  2. Check out this project:

     $ git clone [email protected]:slagyr/euler.git
    
  3. Download dependencies:

     $ lein deps
    
  4. Run the specs:

     $ lein spec
     F
     1)
     'Euler Problem #1 Solves #1' FAILED
     Expected: <-1>
          got: nil (using =)
     /Users/micahmartin/Projects/clojure/euler/problem001_spec.clj:11
     Finished in 0.00288 seconds
     1 examples, 1 failures
    

Usage

Problem #1

Euler Problem #1 is ready to go with two files pre-generated:

  1. spec file: spec/euler/level1/problem001_spec.clj
  2. source file: src/euler/level1/problem001.clj

In the source file you'll fine a link to the problem on the Project Euler web site. Plan your solution then write a test, make it pass, repeat. Each generated spec file contains one example (or test), that you'll need to edit. Feel free to add more.

Starting the Next Problem

When you're ready for a new problem, generate stubs. A Leiningen task has been provided to do this for you. Simple provide the problem number.

$ lein euler 2
writing 247 bytes to spec/euler/level1/problem002_spec.clj
writing 52 bytes to src/euler/level1/problem002.clj

Running Specs

Run all the specs:

$ lein spec

Run one spec or one directory

$ lein spec spec/euler/<file or dir name>

My favorite way to run the spec is to use the auto runner. Start her up and she'll run specs every time you touch a file.

$ lein spec -a

or for nicer output (for reasons we won't go into, commands run using Leiningen get whitespace stripped)

$ java -cp `lein classpath` speclj.main -a -c

Have Fun

Remember this is a learning exercise. There's plenty of stuff to practice:

  • Clojure
  • Writing Clean Code
  • TDD/BDD
  • Good Design
  • Refactoring
  • Organization

Contribute

Contributions are welcome. Just submit a pull request.

License

Copyright (C) 2011 Micah Martin

Distributed under the MIT License.

euler's People

Contributors

jhirn avatar slagyr avatar

Stargazers

 avatar

Watchers

 avatar  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.