You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Michele Sessa 43c2a6dedc docs(diamond_creation): improve code example clarity 2 years ago
..
README.md docs(diamond_creation): improve code example clarity 2 years ago

README.md

diamond_creation

Instructions

Build the function make_diamond which takes a letter as an input, and returns a diamond.

Rules:

  • The first and last row contain one 'A'.
  • The given letter has to be at the widest point.
  • All rows, except the first and last, have exactly two identical letters.
  • All rows have as many trailing spaces as leading spaces. This may be 0.
  • The diamond is vertically symmetrical, and horizontally symmetrical.
  • The width of the diamond equals its height.
  • The top half has letters in ascending order (abcd).
  • The bottom half has letters in descending order (dcba).

Expected functions

pub fn get_diamond(c: char) -> Vec<String> {

}

Usage

Here is a program to test your function.

use diamond_creation::*;

fn main() {
    println!("{:?}", get_diamond('A'));
    println!("{:?}", get_diamond('C'));
    for line in get_diamond('C') {
        println!("{}", line);
    }
}

And its output:

$ cargo run
["A"]
["  A  ", " B B ", "C   C", " B B ", "  A  "]
  A  
 B B 
C   C
 B B 
  A  
$

Notions