TimDumol / rust-rosetta

Implementing Rosetta Code problems in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rust-rosetta

Build Status

A repository for completing this issue on mozilla/rust. This repository contains minimal working code for many simple (and not so simple) tasks. New contributors and learners of the language are welcome. We will try to work with you to make the code more idiomatic over time.

Working on a problem, need some help? Drop by #rust-rosetta on irc.mozilla.org. Get in touch with @Hoverbear if you need help setting up.

Tasks Remaining

List of Tasks Remaining

Tasks Complete

Rosetta Code Source Link
9 billion names of God the integer 9 billion names of God the integer
24 game 24_game.rs
24 game/solve 24_game_solve.rs
99 bottles of beer 99_bottles_of_beer.rs
100 doors 100_doors.rs, 100_doors_unoptimized.rs
A+B a_plus_b.rs
ABC Problem abc_problem.rs
Ackermann function ackermann_function.rs
AKS test for primes aks_test_for_primes.rs
Almost prime almost_prime.rs
Anagrams anagrams.rs
Apply a callback to an array callback_to_array.rs
Arithmetic mean arithmetic_integers.rs
Arithmetic/Rational arithmetic_rational.rs
Arrays arrays.rs
Assertions assertions.rs
Averages/Arithmetic mean arithmetic_mean.rs
Averages/Mean angle averages_mean_angle.rs
Balanced brackets balanced_brackets.rs
Binary digits Binary_digits.rs
Binary search binary_search.rs
Bitwise operations bitwise_operations.rs
Bubble sort bubble_sort.rs
Call a foreign-language function call_foreign_function.rs
Check input device is a terminal input_is_terminal.rs
Check output device is a terminal output_is_terminal.rs
Check that file exists check_file.rs
Complex complex.rs
Concurrent computing concurrent_computing.rs
Count in octal count_in_octal.rs
Create a file create_file.rs
Dot product dot_product.rs
Empty program empty.rs
Entropy entropy.rs
Equilibrium index equilibrium_index.rs
Evaluate binomial coefficients binomial_coefficients.rs
Factorial factorial.rs
FASTA format fasta.rs
Fibonacci sequence fibonacci.rs
Fibonacci word fibonacci_word.rs
File size filesize.rs
Find limit of recursion recursion_depth.rs
Four bit adder four_bit_adder.rs
Function composition function_composition.rs
Function Definition function_def.rs
Generic swap swap.rs
Gray code gray_code.rs
Greatest element of a list greater_element_list.rs
Guess the number guess_number.rs
Hailstone sequence hailstone.rs
Hamming numbers hamming_numbers.rs, hamming_numbers_alt.rs
Happy numbers happy_numbers.rs
Harshad or Niven series harshad_or_niven_series.rs
HTTP http.rs
Huffman encoding huffman_coding.rs
IBAN iban.rs
Infinity infinity.rs
Input Loop input_loop.rs
Integer sequence integer_sequence.rs
JSON json.rs
Knapsack 01 knapsack_0-1.rs
Letter frequency letter_frequency.rs
Look-and-say sequence look-and-say_sequence.rs
Loops/For loops-for.rs
Loops/Foreach loops-foreach.rs
Loops/Infinite loops-infinite.rs
Loops/N plus one half loops-n-plus-one-half.rs
Loops/While loops-while.rs
LZW compression lwz.rs
Markov algorithm markov_algorithm.rs
MD5 implementation md5-implementation.rs
Modular exponentiation modular_exponentation.rs
Mutual recursion mutual_recursion.rs
N-queens problem n_queens.rs
Palindrome detection palindrome.rs
Parallel calculations parallel_calculations.rs
Perfect numbers perfect_numbers.rs
Power Set power_set.rs
Primality by Trial Division primality_trial_div.rs
Prime decomposition prime_decomposition.rs
Pythagorean triples pythagorean_triples.rs
Quick Sort quick_sort.rs
Range Expansion range_expansion.rs
Read a file line by line read_file_line.rs
Rename a file rename_a_file.rs
Repeat a string repeat_str.rs
Reverse words in a string reverse_words_str.rs
Roots of unity roots_of_unity.rs
Rot-13 rot13.rs
Run-length encoding run_length_encoding.rs
Self-describing numbers self-describing_numbers.rs
Sequence of non-squares sequence_of_non-squares.rs
Set set.rs
Sha-1 sha1.rs
Sha-256 sha256.rs
Short Circuit Evaluation short_circuit_evaluation.rs
Sierpinski triangle sierpinski_triangle.rs
Sieve of Eratosthenes sieve_eratosthenes.rs
Sort an integer array sort_int.rs
Stack stack.rs
Standard error stderr.rs
String_concatenation string_concatenation.rs
String matching string_matching.rs
Synchronous Concurrency synchronous_concurrency.rs
Webserver webserver.rs
Zig-zag matrix zig-zag_matrix.rs

Contributing

Looking to help out? Great, thanks! We have a few guidelines:

  • The code you contribute is public domain.
  • Your code should build cleanly on the master branch of Rust.
  • Keep your code as simple as possible, please avoid Dead Code warnings.
  • Don't be afraid of comments, the code is going to be written once, read hundreds of times, and maintained until past the 1.0 release of Rust.
  • Include a link to the Rosetta Code Problem at the top of the code sample.
  • Add a line to the Readme section below. (It's alphabetical!)
  • Unit tests are strongly encouraged. Having troubles getting the build to work? Check about Not Test Flags

If you have unit-tests, you will need to mark fn main, and possibly some other fns with #[cfg(not(test))] to avoid dead-code warnings. The reason dead-code warnings appear is because main is never called during a test.

#[cfg(not(test))]
fn main() {
    println!("I need to be not compiled during tests");
}

#[test]
fn test_me() {
    assert!(true);
}

If you are unable to test your program then mark the entire file with // not_tested. This will disable testing completely for that file.

// not_tested

fn main(){
    println!("Please add unit-tests later.");
}

The top of your code should look like this:

// http://rosettacode.org/wiki/foo

If you'd like, you're welcome to add your contact details, name, or other information as well.

Contributors

Beginners Guide to Contributing

If you look here you can see how most contributions "merge" over time with the main tree. People will create multiple branches off the same main repo. So you see your long one? Instead of multiple branches coming and going off the main repo, it's one long one.

Here's an idea of what a workflow would look like (in general-ish):

If it's your first time

  • Choose a problem off Rosetta Code.
  • Fork this repo on Github. (Help here!)
  • Clone your resulting repo onto your machine.

Every other time

  • Navigate to your rust-rosetta directory.
  • Make sure you're on master branch.
  • Update your fork (Details)
  • Create a branch that is reasonably unique Ein06-func-impl is a good example.
  • Make your changes for this problem.
    • Add the new definition to the README.md
    • Add one code file with the appropriate name to the src/ directory. If you need any data there is a separate folder for that.
    • Make sure to include unit tests for us, and comments! :)
  • Check git status to make sure you don't mangle anything else.
  • Commit your changes (git commit -a -m "Implement blah blah blah")
  • Submit a Pull request here.

After it's accepted

  • Delete the branch.

If this is unclear or you're having difficulties, just open an issue, we'd love to help.

About

Implementing Rosetta Code problems in Rust.

License:The Unlicense