title: Basic And Extended Euclidean Algorithms
signature: function basicAndExtendedEuclideanAlgorithms(a: number, b: number): number {
source_py: def basic_and_extended_euclidean_algorithms(a, b):
      if (a == 0):
          return b
      return basic_and_extended_euclidean_algorithms((b % a), a)
source_cpp: int basic_and_extended_euclidean_algorithms(int a, int b) {
    if ( a == 0 ) return b;
    return basic_and_extended_euclidean_algorithms ( b % a, a );
  }
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"a": 46, "b": 89}}, {"idx": 1, "outputs": 2, "inputs": {"a": 26, "b": 82}}, {"idx": 2, "outputs": 4, "inputs": {"a": 40, "b": 12}}, {"idx": 3, "outputs": 2, "inputs": {"a": 58, "b": 4}}, {"idx": 4, "outputs": 1, "inputs": {"a": 25, "b": 44}}, {"idx": 5, "outputs": 1, "inputs": {"a": 2, "b": 87}}, {"idx": 6, "outputs": 1, "inputs": {"a": 8, "b": 65}}, {"idx": 7, "outputs": 3, "inputs": {"a": 21, "b": 87}}, {"idx": 8, "outputs": 2, "inputs": {"a": 82, "b": 10}}, {"idx": 9, "outputs": 1, "inputs": {"a": 17, "b": 61}}]
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(a: number, b: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(a, b),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(46, 89, 1);
    console.log(`TEST-0...${result}`);
  
    result = driver(26, 82, 2);
    console.log(`TEST-1...${result}`);
  
    result = driver(40, 12, 4);
    console.log(`TEST-2...${result}`);
  
    result = driver(58, 4, 2);
    console.log(`TEST-3...${result}`);
  
    result = driver(25, 44, 1);
    console.log(`TEST-4...${result}`);
  
    result = driver(2, 87, 1);
    console.log(`TEST-5...${result}`);
  
    result = driver(8, 65, 1);
    console.log(`TEST-6...${result}`);
  
    result = driver(21, 87, 3);
    console.log(`TEST-7...${result}`);
  
    result = driver(82, 10, 2);
    console.log(`TEST-8...${result}`);
  
    result = driver(17, 61, 1);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: basicAndExtendedEuclideanAlgorithms
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js