title: Form Minimum Number From Given Sequence 1
signature: pub fn form_minimum_number_from_given_sequence_1(seq: String) -> String {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: String, expected: String)->bool{
  return actual==expected
  }
  pub fn driver(seq: String, expected: String)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(seq), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        "D".to_string(), 
        "[2, 1]".to_string()
      ));
      
      println!("TEST-1...{}", driver(
        "I".to_string(), 
        "[1, 2]".to_string()
      ));
      
      println!("TEST-2...{}", driver(
        "DD".to_string(), 
        "[3, 2, 1]".to_string()
      ));
      
      println!("TEST-3...{}", driver(
        "II".to_string(), 
        "[1, 2, 3]".to_string()
      ));
      
      println!("TEST-4...{}", driver(
        "DIDI".to_string(), 
        "[2, 1, 4, 3, 5]".to_string()
      ));
      
      println!("TEST-5...{}", driver(
        "IIDDD".to_string(), 
        "[1, 2, 6, 5, 4, 3]".to_string()
      ));
      
      println!("TEST-6...{}", driver(
        "DDIDDIID".to_string(), 
        "[3, 2, 1, 6, 5, 4, 7, 9, 8]".to_string()
      ));
      
      println!("TEST-7...{}", driver(
        "176297".to_string(), 
        "[7, 6, 5, 4, 3, 2, 1]".to_string()
      ));
      
      println!("TEST-8...{}", driver(
        "1".to_string(), 
        "[2, 1]".to_string()
      ));
      
      println!("TEST-9...{}", driver(
        "XHkhZq".to_string(), 
        "[7, 6, 5, 4, 3, 2, 1]".to_string()
      ));
      
  }
source_py: def form_minimum_number_from_given_sequence_1(seq):
      n = len(seq)
      if (n >= 9):
          return '-1'
      result = ([None] * (n + 1))
      count = 1
      for i in range((n + 1)):
          if ((i == n) or (seq[i] == 'I')):
              for j in range((i - 1), (- 2), (- 1)):
                  result[(j + 1)] = int(('0' + str(count)))
                  count += 1
                  if ((j >= 0) and (seq[j] == 'I')):
                      break
      return result
source_cpp: string form_minimum_number_from_given_sequence_1(string seq) {
    int n = seq . length ( );
    if ( n >= 9 ) return "-1";
    string result ( n + 1, ' ' );
    int count = 1;
    for ( int i = 0;
    i <= n;
    i ++ ) {
      if ( i == n || seq [ i ] == 'I' ) {
        for ( int j = i - 1;
        j >= - 1;
        j -- ) {
          result [ j + 1 ] = '0' + count ++;
          if ( j >= 0 && seq [ j ] == 'I' ) break;
        }
      }
    }
    return result;
  }