6 kyu

Unique In Order

84,544 of 193,938pinelopi

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 Trained377525
Total Skips50217
Total Code Submissions876478
Total Times Completed193938
Python Completions84544
Ruby Completions6427
JavaScript Completions83368
C# Completions7433
PHP Completions4205
Clojure Completions448
Haskell Completions1530
Crystal Completions23
Rust Completions1722
C++ Completions5061
Scala Completions269
BF Completions14
TypeScript Completions781
CoffeeScript Completions7
Total Stars3275
% of votes with a positive feedback rating89% of 15053
Total "Very Satisfied" Votes11990
Total "Somewhat Satisfied" Votes2762
Total "Not Satisfied" Votes301
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