Skip to content

Sublist

Clock in Rust on Exercism

概要

  • A,Bのリストが与えられるので部分集合かどうかを確認する
  • 順序も考慮する問題である。
  • If A = [1, 2, 3, 4, 5] and B = [2, 3, 4], then A is a superlist of B
  • If A = [1, 2, 4] and B = [1, 2, 3, 4, 5], then A and B are unequal
  • If A = [1, 2, 3] and B = [1, 3, 2], then A and B are unequal

初期コード

#[derive(Debug, PartialEq, Eq)]
pub enum Comparison {
Equal,
Sublist,
Superlist,
Unequal,
}
pub fn sublist<T: PartialEq>(_first_list: &[T], _second_list: &[T]) -> Comparison {
todo!("Determine if the first list is equal to, sublist of, superlist of or unequal to the second list.");
}

考察

学んだこと

  • windownsの引数に 0を渡すとpanicする

参考記事