Coder Social home page Coder Social logo

google-hashcode-template's Introduction

Google Hashcode Rust Template

Basic Rust template for Google Hashcode challenges.

Quickstart

  1. Clone this repository
  2. Change crate author in Cargo.toml ;-)

Parsing

  1. Add fields to InputData struct in data.rs
  2. Implement parse_input in data.rs
fn parse_input(s: &str) -> anyhow::Result<InputData> {}

Tip: utils.rs contains a few helper functions for parsing lists of integers or list of strings.

fn number_list_line(s: &str) -> Res<&str, Vec<N>> {}
fn number_list_line_exact(s: &str, expected_size: usize) -> Res<&str, Vec<N>> {}
// same as number_list_line excepts it logs errors if any
fn number_list_line_verbose(s: &str) -> Res<&str, Vec<N>> {}
// same as number_list_line_exact excepts it logs errors if any
fn number_list_line_exact_verbose(s: &str, expected_size: usize) -> Res<&str, Vec<N>> {}

fn str_list_line(s: &str) -> Res<&str, Vec<&str>> {}
fn str_list_line_exact(s: &str, expected_size: usize) -> Res<&str, Vec<&str>> {}
// same as str_list_line excepts it logs errors if any
fn str_list_line_verbose(s: &str) -> Res<&str, Vec<&str>> {}
// same as str_list_line_exact excepts it logs errors if any
fn str_list_line_exact_verbose(s: &str, expected_size: usize) -> Res<&str, Vec<&str>> {}

see tests in utils.rs for usage.

Solving

  1. Add fields to OutputData struct in data.rs.
  2. Implement solve in data.rs.
fn solve(input: &InputData) -> anyhow::Result<(OutputData, Option<usize>)> {}

Dumping

  1. Implement output_as_lines in data.rs.
fn output_as_lines(output: &OutputData) -> anyhow::Result<Vec<String>> {}

Run the solver

RUST_LOG=info cargo run --release -- res/input_0.txt res/input_1.txt

Generates ./output_0.out and ./output_1.out.

Enabling Logs

prefix command with RUST_LOG=<level> e.g.

RUST_LOG=info cargo run --release -- res/input_0.txt res/input_1.txt

google-hashcode-template's People

Contributors

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