pub fn sequence_matcher(
    keys: &mut Vec<i32>,
    targets: &mut Vec<i32>,
    max_key_length: usize,
    max_target_length: usize,
    n_candidates: usize
) -> Vec<Vec<(Vec<i32>, Vec<i32>)>>
Expand description

Finds the integers from two vectors that sum to the same value. This method assumes that the two vectors have Many-to-Many relationships. Each integer of the keys vector corresponds to the multiple integers of the targets vector. With this method, we can find combinations of the integers.

Arguments

  • keys - An array.
  • targets - An array.
  • max_key_length - An integer.
  • max_target_length - An integer.
  • n_candidates - An integer.

Example


use dpss::dp::sequence_matcher;
let answer = sequence_matcher(&mut vec![1980, 2980, 3500, 4000, 1050], &mut vec![1950, 2900, 30, 80, 3300, 200, 3980, 1050, 20], 10, 10, 100);
assert_eq!(answer[0], vec![
   (vec![1050],
    vec![1050]),

    (vec![1980],
    vec![30, 1950]),

    (vec![2980],
    vec![80, 2900]),

    (vec![3500],
    vec![200, 3300]),

    (vec![4000],
    vec![20, 3980]),

   ]);
assert_eq!(answer[1], vec![
   (vec![1050],
    vec![1050]),

    (vec![1980],
    vec![30, 1950]),

    (vec![2980],
    vec![80, 2900]),

    (vec![3500, 4000],
    vec![20, 200, 3300, 3980]),

   ]);