Sha256: 8abbbff932baf5d416fe67b159db21a48dd57fb4c8fbee9271b2d3c91390d548
Contents?: true
Size: 807 Bytes
Versions: 62
Compression:
Stored size: 807 Bytes
Contents
class List { list: number[] constructor(...list: number[]) { this.list = list } compare(other: List) { switch (this.lengthDiff(this, other)) { case '-1': return this.isSublist(other.list, this.list) ? 'sublist' : 'unequal' case '0': return this.isSublist(other.list, this.list) ? 'equal' : 'unequal' case '1': return this.isSublist(this.list, other.list) ? 'superlist' : 'unequal' } return 'unequal' } lengthDiff(listOne: List, listTwo: List) { return String(Math.sign(listOne.list.length - listTwo.list.length)) } isSublist(listOne: number[], listTwo: number[]) { return listOne.join().match(listTwo.join()) } } export default List
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
trackler-2.2.1.119 | tracks/typescript/exercises/sublist/sublist.example.ts |
trackler-2.2.1.118 | tracks/typescript/exercises/sublist/sublist.example.ts |