GithubHelp home page GithubHelp logo

gj2014's Introduction

2014 Google Code Jam

This is my Haskell code for this year's GCJ, where I hope I can get some coding practice.

Contest page

All parsing done using Attoparsec, trying to stick with bytestring/vectors whenever possible.

A

Easy problem, pick row g1 from grid 1, pick row g2 from grid 2. Find the intersection. If: it's empty -> Volunteer cheated; a single element -> Volunteer card; Multiple cards -> baaad magician.

Had some initial trouble with attoparsec learning that Space \= string " " since it includes white space.

B

Trick here is to get a piece of paper, find a formula to determine at which rate it's better to wait out. ie

    X/rate < C/rate + X/(rate+F)

Having the rate you can find the index it happens (rate=2+n*F), then calculate the time.

Straightforward code, with output formating from Text.Printf

Piece of cookie

C

Couldn't figure out a way to solve this one. Tried filling the smaller side that can be filled with mines, if not possible, fill the largest.

Must think more.

D

For War, Naomi hasn't much of a say on how the game is played. Ken always get the best of his blocks; he can use the worst block that wins, or the worst block that loses.

For Deceitful War, Naomi has to make Ken waste his blocks. Since she knows his blocks, Naomi can force him to use the best block to win against her worst block, or use her worst block to win against his worst block.

Since there is many comparisons between best block and worst block and drops, I decided to sort the list of blocks first and use a deque - called Sequence in Haskell.

This way the relevant elements are easy to access.

gj2014's People

Contributors

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