<commit_before>#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0

# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/

# Additional basic list exercises

# D. Given a list of numbers, return a list where
# all adjacent == elements have been reduced to a single element,
# so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or
# modify the passed in list.
def remove_adjacent(nums):
  # +++your code here+++
  idx_to_del = []
  
  i = 0
  while i < len(nums) - 1:
  	  if nums[i] == nums[i + 1]:
  	  	  idx_to_del.append(i + 1)
  	  i += 1
  	  
  idx_to_del.reverse() # avoid trying to delete shifted elements
  
  for idx in idx_to_del:
  	  nums.remove(nums[idx])
  
  return nums

<commit_msg>Improve list2.py's remove_adjacent exercise<commit_after>#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0

# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/

# Additional basic list exercises

# D. Given a list of numbers, return a list where
# all adjacent == elements have been reduced to a single element,
# so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or
# modify the passed in list.
def remove_adjacent(nums):
  # +++your code here+++
  result = []
  
  for num in nums:
  	  if num not in result:
  	  	  result.append(num)
  
  return result


{'fraction_non_alphanumeric': 0.11830065359477124, 'fraction_numerical': 0.023529411764705882, 'mean_word_length': 3.1945205479452055, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2703381', 'n_tokens_mistral': 561, 'n_tokens_neox': 528, 'n_words': 181}