Problem:
Score : 200 points

Problem Statement

Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?

Constraints

1 \leq a \leq 9

1 \leq b \leq 9

a and b are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

Print the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)

Sample Input 1

4 3

Sample Output 1

3333

We have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.

Sample Input 2

7 7

Sample Output 2

7777777

Solution in Rust (1.42.0) (judge verdict: Accepted)

use std::error::Error;
use std::io::{self, BufRead, BufWriter, Write};

type AppResult<T> = Result<T, Box<dyn Error>>;

fn solve<R, W>(reader: R, mut writer: W) -> AppResult<()>
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().ok_or("no lines")??;
    let mut splited = a_line.trim().split_whitespace();
    let mut a: u32 = splited.next().ok_or("a not found")?.parse()?;
    let mut b: u32 = splited.next().ok_or("b not found")?.parse()?;
    // let b: u32 = splited.next().ok_or("b not found")?.parse()?;

    let (a, b) = if a < b { (a, b) } else { (b, a) };

    for _ in 1..=b {
        write!(&mut writer, "{}", a)?;
    }
    writeln!(&mut writer, "")?;

    Ok(())
}

fn main() -> AppResult<()> {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output)
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"4 3
", br"3333
",
        ),
        (
            br"7 7
",
            br"7777777
",
        ),
        // (br"", br""),
    ];

    #[test]
    fn test_b() -> AppResult<()> {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output)?;
            let expected_str = String::from_utf8(expected.to_vec())?;
            let output_str = String::from_utf8(output)?;
            assert_eq!(expected_str, output_str);
        }
        Ok(())
    }
}