title: Bell Numbers Number Of Ways To Partition A Set
signature: function bellNumbersNumberOfWaysToPartitionASet(n: number): number {
source_py: def bell_numbers_number_of_ways_to_partition_a_set(n):
      bell = [[0 for i in range((n + 1))] for j in range((n + 1))]
      bell[0][0] = 1
      for i in range(1, (n + 1)):
          bell[i][0] = bell[(i - 1)][(i - 1)]
          for j in range(1, (i + 1)):
              bell[i][j] = (bell[(i - 1)][(j - 1)] + bell[i][(j - 1)])
      return bell[n][0]
source_cpp: int bell_numbers_number_of_ways_to_partition_a_set(int n) {
    int bell [ n + 1 ] [ n + 1 ];
    bell [ 0 ] [ 0 ] = 1;
    for ( int i = 1;
    i <= n;
    i ++ ) {
      bell [ i ] [ 0 ] = bell [ i - 1 ] [ i - 1 ];
      for ( int j = 1;
      j <= i;
      j ++ ) bell [ i ] [ j ] = bell [ i - 1 ] [ j - 1 ] + bell [ i ] [ j - 1 ];
    }
    return bell [ n ] [ 0 ];
  }
question_info.test_list: [{"idx": 0, "outputs": 21147, "inputs": {"n": 9}}, {"idx": 1, "outputs": 15, "inputs": {"n": 4}}, {"idx": 2, "outputs": 203, "inputs": {"n": 6}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(9, 21147);
    console.log(`TEST-0...${result}`);
  
    result = driver(4, 15);
    console.log(`TEST-1...${result}`);
  
    result = driver(6, 203);
    console.log(`TEST-2...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: bellNumbersNumberOfWaysToPartitionASet
question_info.test_case_ids: 0 1 2
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js