6 kyu

Unique In Order

6,436 of 195,080pinelopi

Description:

Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements.

For example:

uniqueInOrder("AAAABBBCCDAABBB") == {'A', 'B', 'C', 'D', 'A', 'B'}
uniqueInOrder("ABBCcAD")         == {'A', 'B', 'C', 'c', 'A', 'D'}
uniqueInOrder([1,2,2,3,3])       == {1,2,3}
uniqueInOrder('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B']
uniqueInOrder('ABBCcAD')         == ['A', 'B', 'C', 'c', 'A', 'D']
uniqueInOrder([1,2,2,3,3])       == [1,2,3]
uniqueInOrder('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B']
uniqueInOrder('ABBCcAD')         == ['A', 'B', 'C', 'c', 'A', 'D']
uniqueInOrder([1,2,2,3,3])       == [1,2,3]
unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B']
unique_in_order('ABBCcAD')         == ['A', 'B', 'C', 'c', 'A', 'D']
unique_in_order([1, 2, 2, 3, 3])   == [1, 2, 3]
unique_in_order((1, 2, 2, 3, 3))   == [1, 2, 3]
unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B']
unique_in_order('ABBCcAD')         == ['A', 'B', 'C', 'c', 'A', 'D']
unique_in_order([1,2,2,3,3])       == [1,2,3]
uniqueInOrder "AAAABBBCCDAABBB" == "ABCDAB"
uniqueInOrder "ABBCcAD"         == "ABCcAD"
uniqueInOrder [1,2,2,3,3]       == [1,2,3]
unique_in_order("AAAABBBCCDAABBB") == ['A', 'B', 'C', 'D', 'A', 'B']
unique_in_order("ABBCcAD")         == ['A', 'B', 'C', 'c', 'A', 'D']
unique_in_order([1,2,2,3,3])       == [1,2,3]
uniqueInOrder("AAAABBBCCDAABBB")   == List('A', 'B', 'C', 'D', 'A', 'B')
uniqueInOrder("ABBCcAD")           == List('A', 'B', 'C', 'c', 'A', 'D')
uniqueInOrder(List(1, 2, 2, 3, 3)) == List(1, 2, 3)
Algorithms
Fundamentals

More By Author:

Check out these other kata created by pinelopi

Stats:

CreatedFeb 19, 2015
PublishedFeb 19, 2015
Warriors Trained379294
Total Skips50343
Total Code Submissions879269
Total Times Completed195080
Python Completions85112
Ruby Completions6436
JavaScript Completions83763
C# Completions7478
PHP Completions4225
Clojure Completions448
Haskell Completions1535
Crystal Completions23
Rust Completions1732
C++ Completions5105
Scala Completions270
BF Completions14
TypeScript Completions837
CoffeeScript Completions7
Total Stars3288
% of votes with a positive feedback rating89% of 15079
Total "Very Satisfied" Votes12011
Total "Somewhat Satisfied" Votes2766
Total "Not Satisfied" Votes302
Ad
Contributors
  • pinelopi Avatar
  • jhoffner Avatar
  • bkaes Avatar
  • Unnamed Avatar
  • GiacomoSorbi Avatar
  • Songbird0 Avatar
  • Chrono79 Avatar
  • Cristian006 Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • jbristow Avatar
  • junthecoder Avatar
  • Voile Avatar
  • Souzooka Avatar
  • rowcased Avatar
  • dinomight Avatar
  • FArekkusu Avatar
  • tootis Avatar
  • hobovsky Avatar
  • xavierguihot Avatar
  • user8436785 Avatar
  • Kacarott Avatar
  • Wei-Ting Yang Avatar
  • Just4FunCoder Avatar
  • TheWoodenMan Avatar
  • KayleighWasTaken Avatar
  • JavaScripts Avatar
Ad