6 kyu

Unique In Order

84,570 of 193,990pinelopi

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 Trained377578
Total Skips50221
Total Code Submissions876592
Total Times Completed193990
Python Completions84570
Ruby Completions6427
JavaScript Completions83382
C# Completions7438
PHP Completions4206
Clojure Completions448
Haskell Completions1530
Crystal Completions23
Rust Completions1722
C++ Completions5065
Scala Completions269
BF Completions14
TypeScript Completions783
CoffeeScript Completions7
Total Stars3276
% of votes with a positive feedback rating89% of 15055
Total "Very Satisfied" Votes11992
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