title: Form Minimum Number From Given Sequence 1
signature: class Solution {
  
      public string FormMinimumNumberFromGivenSequence1(string seq) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(string actual, string expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(string seq, string expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                string pred_result = solution_cls.PLACEHOLDER_FN_NAME(seq); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  "D", 
                  "[2, 1]"
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  "I", 
                  "[1, 2]"
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  "DD", 
                  "[3, 2, 1]"
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  "II", 
                  "[1, 2, 3]"
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  "DIDI", 
                  "[2, 1, 4, 3, 5]"
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  "IIDDD", 
                  "[1, 2, 6, 5, 4, 3]"
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  "DDIDDIID", 
                  "[3, 2, 1, 6, 5, 4, 7, 9, 8]"
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  "176297", 
                  "[7, 6, 5, 4, 3, 2, 1]"
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  "1", 
                  "[2, 1]"
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  "XHkhZq", 
                  "[7, 6, 5, 4, 3, 2, 1]"
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
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;
  }