From 91825867f6d5af5bc1f1ab3e9eb4b97b89a1691e Mon Sep 17 00:00:00 2001 From: Mari Wahl Date: Tue, 6 Jan 2015 21:55:53 -0500 Subject: [PATCH] bitwise scripts fixed --- src/bitwise/{bit_operations => }/bit_array.py | 18 +++----- src/bitwise/bit_operations/clear_bits.py | 40 ----------------- src/bitwise/bit_operations/find_bit_len.py | 28 ------------ src/bitwise/bit_operations/get_bit.py | 41 ----------------- .../num_bits_to_convert_2_nums.py | 45 ------------------- src/bitwise/bit_operations/set_bit.py | 38 ---------------- src/bitwise/bit_operations/update_bit.py | 26 ----------- src/bitwise/find_bit_len.py | 4 +- .../find_how_many_1_binary.py | 22 +++++---- .../{bit_operations => }/get_float_rep_bin.py | 16 ++++--- .../insert_small_bin_into_big_bin.py | 21 ++++----- .../next_with_same_num_1s.py | 41 ++++++++--------- src/bitwise/set_bit.py | 4 -- src/bitwise/swap_in_place.py | 10 +++-- .../{bit_operations => }/swap_odd_even.py | 23 +++++----- .../sorting/bubble_sort.py | 6 +-- .../sorting/count_sort.py | 5 +-- .../sorting/gnome_sort.py | 6 +-- src/searching_and_sorting/sorting/heap.py | 5 +-- .../sorting/heap_sort.py | 5 +-- .../sorting/insertion_sort.py | 5 +-- .../sorting/merge_sort.py | 6 +-- .../sorting/quick_sort.py | 5 +-- .../sorting/selection_sort.py | 5 +-- .../sorting/sort_anagrams_together.py | 6 +-- 25 files changed, 96 insertions(+), 335 deletions(-) rename src/bitwise/{bit_operations => }/bit_array.py (82%) mode change 100644 => 100755 delete mode 100644 src/bitwise/bit_operations/clear_bits.py delete mode 100644 src/bitwise/bit_operations/find_bit_len.py delete mode 100644 src/bitwise/bit_operations/get_bit.py delete mode 100644 src/bitwise/bit_operations/num_bits_to_convert_2_nums.py delete mode 100644 src/bitwise/bit_operations/set_bit.py delete mode 100644 src/bitwise/bit_operations/update_bit.py rename src/bitwise/{bit_operations => }/find_how_many_1_binary.py (69%) mode change 100644 => 100755 rename src/bitwise/{bit_operations => }/get_float_rep_bin.py (90%) mode change 100644 => 100755 rename src/bitwise/{bit_operations => }/insert_small_bin_into_big_bin.py (88%) mode change 100644 => 100755 rename src/bitwise/{bit_operations => }/next_with_same_num_1s.py (67%) mode change 100644 => 100755 rename src/bitwise/{bit_operations => }/swap_odd_even.py (87%) mode change 100644 => 100755 diff --git a/src/bitwise/bit_operations/bit_array.py b/src/bitwise/bit_array.py old mode 100644 new mode 100755 similarity index 82% rename from src/bitwise/bit_operations/bit_array.py rename to src/bitwise/bit_array.py index c5f8366..9e5aa46 --- a/src/bitwise/bit_operations/bit_array.py +++ b/src/bitwise/bit_array.py @@ -1,17 +1,16 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python -''' Example of how to use a bit array in python as a "counter" dict: +__author__ = "bt3" +''' Example of how to use a bit array in python as a "counter" dict''' + +def print_dupl_ba(l1): + ''' >>> l1 = [0, 1, 2, 3, 4, 2, 6, 7, 8, 9] >>> print_dupl_ba(l1) 2 -''' + ''' - - -def print_dupl_ba(l1): bs = bytearray(10) for i in range(len(l1)): if i == l1[i]: @@ -22,9 +21,6 @@ def print_dupl_ba(l1): return None - - - if __name__ == '__main__': import doctest diff --git a/src/bitwise/bit_operations/clear_bits.py b/src/bitwise/bit_operations/clear_bits.py deleted file mode 100644 index e5802cd..0000000 --- a/src/bitwise/bit_operations/clear_bits.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Clear a bit in a binary number. It is almost like the reverse of set bit: - 1) first create a number filled of 1s, with 0 at i (can create 0001000 and ~) - 2) AND the number so it clears the ith bit - - >>> num = int('10010000', 2) - >>> clear_bit(num, 4) - '0b10000000' - >>> num = int('10010011', 2) - >>> clear_all_bits_from_i_to_0(num, 2) - '0b10010000' - >>> num = int('1110011', 2) - >>> clear_all_bits_from_most_sig_to_1(num, 2) - '0b11' -''' - - - -def clear_bit(num, i): - mask = ~ (1 << i) # -0b10001 - return bin(num & mask) - - -def clear_all_bits_from_i_to_0(num, i): - mask = ~ ( (1 << (i+1)) - 1) - return bin(num & mask) - - -def clear_all_bits_from_most_sig_to_1(num, i): - mask = ( 1 << i) -1 - return bin(num & mask) - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/bitwise/bit_operations/find_bit_len.py b/src/bitwise/bit_operations/find_bit_len.py deleted file mode 100644 index d061435..0000000 --- a/src/bitwise/bit_operations/find_bit_len.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Find how many bits a int has: - 1) Start with a mask of 1 - 2) Mask with AND - 3) if result (if true): count += 1 - (obs: to find the int of a bin do int('1001', 2)) and to show in bin do bin(int)) - - >>> for i in range(17): print(find_bit_len(i)) -''' - - - -def find_bit_len(int_num): - lenght = 0 - while int_num: - int_num >>= 1 - lenght += 1 - return lenght - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/bitwise/bit_operations/get_bit.py b/src/bitwise/bit_operations/get_bit.py deleted file mode 100644 index a32c71e..0000000 --- a/src/bitwise/bit_operations/get_bit.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Get a bit in a binary number: - 1) Shifts 1 over by i bits - 2) make an AND with the number - 3) all the other than the bit at i are clean, now compare to 0 - 4) if the new value is not 0, bit i is 1 - >>> num = int('0100100', 2) - >>> get_bit(num, 0) - 0 - >>> get_bit(num, 1) - 0 - >>> get_bit(num, 2) - 1 - >>> get_bit(num, 3) - 0 - >>> get_bit(num, 4) - 0 - >>> get_bit(num, 5) - 1 - >>> get_bit(num, 6) - 0 -''' - - - -def get_bit(num, i): - mask = 1 << i - return num & mask != 0 - - - - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/bitwise/bit_operations/num_bits_to_convert_2_nums.py b/src/bitwise/bit_operations/num_bits_to_convert_2_nums.py deleted file mode 100644 index 90054de..0000000 --- a/src/bitwise/bit_operations/num_bits_to_convert_2_nums.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' This method returns the number of bits that are necessary to change to convert two - numbers A and B: - 1) XOR - 2) count 1s - - >>> a = int('10010000', 2) - >>> b = int('01011010', 2) - >>> count_bits_swap(a, b) - 4 - >>> count_bits_swap2(a, b) - 4 -''' - -def count_bits_swap2(a, b): - count = 0 - m = a^b - while m: - count +=1 - m = m & (m-1) - return count - - - -def count_bits_swap(a, b): - m = a^b - return count_1s(m) - - -def count_1s(m): - count = 0 - while m: - if m& 1 : - count +=1 - m >>= 1 - return count - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/bitwise/bit_operations/set_bit.py b/src/bitwise/bit_operations/set_bit.py deleted file mode 100644 index 3f98336..0000000 --- a/src/bitwise/bit_operations/set_bit.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' Set a bit in a binary number: - 1) Shifts 1 over by i bits - 2) make an OR with the number, only the value at bit i will change and all the others bit - of the mask are zero so will not affect the num - >>> num = int('0100100', 2) - >>> set_bit(num, 0) - '0b100101' - >>> set_bit(num, 1) - '0b100110' - >>> set_bit(num, 2) # nothing change - '0b100100' - >>> set_bit(num, 3) - '0b101100' - >>> set_bit(num, 4) - '0b110100' - >>> set_bit(num, 5) # nothing change - '0b100100' -''' - - - -def set_bit(num, i): - mask = 1 << i - return bin( num | mask ) - - - - - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/bitwise/bit_operations/update_bit.py b/src/bitwise/bit_operations/update_bit.py deleted file mode 100644 index 61422c8..0000000 --- a/src/bitwise/bit_operations/update_bit.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail - -''' This method merges set bit and clean bit: - 1) first clear the bit at i using a mask such as 1110111 - 2) then shift the intended value v by i bits - 3) this will create a number with bit i to v and all other to 0 - 4) finally update the ith bit with or - - >>> num = int('10010000', 2) - >>> update_bit(num, 2, 1) - '0b10010100' -''' - - - -def update_bit(num, i, v): - mask = ~ (1 << i) - return bin( (num & mask) | (v << i) ) - - -if __name__ == '__main__': - import doctest - doctest.testmod() - diff --git a/src/bitwise/find_bit_len.py b/src/bitwise/find_bit_len.py index 9961241..81d90f0 100755 --- a/src/bitwise/find_bit_len.py +++ b/src/bitwise/find_bit_len.py @@ -6,7 +6,8 @@ __author__ = "bt3" 1) Start with a mask of 1 2) Mask with AND 3) if result (if true): count += 1 - (obs: to find the int of a bin do int('1001', 2)) and to show in bin do bin(int)) + (obs: to find the int of a bin do int('1001', 2)) and to show in bin + do bin(int)) ''' @@ -22,4 +23,3 @@ if __name__ == '__main__': for i in range(17): print(find_bit_len(i)) print i.bit_length() - print diff --git a/src/bitwise/bit_operations/find_how_many_1_binary.py b/src/bitwise/find_how_many_1_binary.py old mode 100644 new mode 100755 similarity index 69% rename from src/bitwise/bit_operations/find_how_many_1_binary.py rename to src/bitwise/find_how_many_1_binary.py index 26a10f7..89fc44c --- a/src/bitwise/bit_operations/find_how_many_1_binary.py +++ b/src/bitwise/find_how_many_1_binary.py @@ -1,21 +1,22 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" ''' Find how many 1s in the binary: 1) Start with a mask of 1 2) Mask with AND 3) if result (if true): count += 1 - (obs: to find the int of a bin do int('1001', 2)) and to show in bin do bin(int)) - - >>> find_how_many_1_in_a_binary(9) - 2 - + (obs: to find the int of a bin do int('1001', + 2)) and to show in bin do bin(int)) ''' - def find_how_many_1_in_a_binary(n): + ''' + >>> find_how_many_1_in_a_binary(9) + 2 + ''' + counter = 0 while n: if n & 1: @@ -24,9 +25,6 @@ def find_how_many_1_in_a_binary(n): return counter - - - if __name__ == '__main__': import doctest diff --git a/src/bitwise/bit_operations/get_float_rep_bin.py b/src/bitwise/get_float_rep_bin.py old mode 100644 new mode 100755 similarity index 90% rename from src/bitwise/bit_operations/get_float_rep_bin.py rename to src/bitwise/get_float_rep_bin.py index e8f7bd4..fb3814d --- a/src/bitwise/bit_operations/get_float_rep_bin.py +++ b/src/bitwise/get_float_rep_bin.py @@ -1,20 +1,22 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" ''' Given a real number between 0 and 1 (eg: 0.72), this method print the binary representation. If the Number cannot be represented accurately in binary, with at most 32 chars, print error: - +''' + +def get_float_rep(num): + ''' >>> get_float_rep(0.72) ('Error 2', '.1011100001010001111010111000010') >>> get_float_rep(0.1) ('Error 2', '.0001100110011001100110011001100') >>> get_float_rep(0.5) '.1' -''' + ''' -def get_float_rep(num): if num >= 1 or num <= 0: return 'Error 1' result = '.' while num: @@ -27,7 +29,7 @@ def get_float_rep(num): result += '0' num = r return result - + if __name__ == '__main__': import doctest diff --git a/src/bitwise/bit_operations/insert_small_bin_into_big_bin.py b/src/bitwise/insert_small_bin_into_big_bin.py old mode 100644 new mode 100755 similarity index 88% rename from src/bitwise/bit_operations/insert_small_bin_into_big_bin.py rename to src/bitwise/insert_small_bin_into_big_bin.py index 03257b8..292b169 --- a/src/bitwise/bit_operations/insert_small_bin_into_big_bin.py +++ b/src/bitwise/insert_small_bin_into_big_bin.py @@ -1,33 +1,34 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + ''' Given two 32-bit numbers, N and M, and two bit positions, i and j, this - method insert M into N such that M starts at bit j and ends at bit i: + method insert M into N such that M starts at bit j and ends at bit i: 1) clear the bits j thru i in N' 2) shift M so that it lines up with bits j thru i 3) merge M and N +''' +def insert_small_bin_into_big_bin(M, N, i, j): + ''' >>> N = 0b10000000000 >>> M = 0b10011 >>> j = 6 >>> i = 2 >>> insert_small_bin_into_big_bin(M, N, i, j) '0b10001001100' -''' + ''' -def insert_small_bin_into_big_bin(M, N, i, j): allOnes = ~0 left = allOnes << (j+1) # 1110000 right = ( (1 << i) - 1) # 0000111 mask = left | right # 1110111 N_cleared = N & mask M_shifted = M << i - + return bin( N_cleared | M_shifted) - - - + if __name__ == '__main__': import doctest diff --git a/src/bitwise/bit_operations/next_with_same_num_1s.py b/src/bitwise/next_with_same_num_1s.py old mode 100644 new mode 100755 similarity index 67% rename from src/bitwise/bit_operations/next_with_same_num_1s.py rename to src/bitwise/next_with_same_num_1s.py index 47ba953..6c2617e --- a/src/bitwise/bit_operations/next_with_same_num_1s.py +++ b/src/bitwise/next_with_same_num_1s.py @@ -1,27 +1,19 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + ''' Give a positive int, print the next smallest and next largest ints with same number of 1 bits. The brute force is: 1) find number of 1 bits 2) loop above and down until find same, checking for each - - >>> num = 0b1001 - >>> next = '0b1010' - >>> prev = '0b110' - >>> print_prev_same_1s(num) == prev - True - >>> print_next_same_1s(num) == next - True - ''' def print_prev_same_1s(num): - n1s = find_num_1s(num) + n1s = find_num_1s(num) # find prev i = num-1 while True: @@ -31,10 +23,10 @@ def print_prev_same_1s(num): i -= 1 if i < 0: return None - + def print_next_same_1s(num): - n1s = find_num_1s(num) - # find next + n1s = find_num_1s(num) + # find next i = num+1 while True: n1s_here = find_num_1s(i) @@ -43,8 +35,8 @@ def print_next_same_1s(num): i += 1 if i < 0: return None - - + + def find_num_1s(num): counter = 0 @@ -54,11 +46,14 @@ def find_num_1s(num): num >>= 1 return counter - - - + + + if __name__ == '__main__': - import doctest - doctest.testmod() + num = 0b1001 + n = '0b1010' + p = '0b110' + print_prev_same_1s(num) == p + print_next_same_1s(num) == n diff --git a/src/bitwise/set_bit.py b/src/bitwise/set_bit.py index 0e78852..eeb73fb 100755 --- a/src/bitwise/set_bit.py +++ b/src/bitwise/set_bit.py @@ -8,18 +8,14 @@ __author__ = "bt3" 1) Shifts 1 over by i bits 2) make an OR with the number, only the value at bit i will change and all the others bit of the mask are zero so will not affect the num - ''' - def set_bit(num, i): mask = 1 << i return bin( num | mask ) - - if __name__ == '__main__': num = int('0100100', 2) print set_bit(num, 0) #'0b100101' diff --git a/src/bitwise/swap_in_place.py b/src/bitwise/swap_in_place.py index 6745132..5aee66a 100755 --- a/src/bitwise/swap_in_place.py +++ b/src/bitwise/swap_in_place.py @@ -8,6 +8,10 @@ __author__ = "bt3" def swap_bit(a, b): + ''' + >>> swap_bit(14, 73) + (73, 14) + ''' a = a^b b = a^b a = a^b @@ -15,7 +19,5 @@ def swap_bit(a, b): if __name__ == '__main__': - a = 14 - b = 73 - a2, b2 = swap_bit(a, b) - print "a was {0}, now it is {1}. \nb was {2}, now it is {3}".format(a, a2, b, b2) + import doctest + doctest.testmod() \ No newline at end of file diff --git a/src/bitwise/bit_operations/swap_odd_even.py b/src/bitwise/swap_odd_even.py old mode 100644 new mode 100755 similarity index 87% rename from src/bitwise/bit_operations/swap_odd_even.py rename to src/bitwise/swap_odd_even.py index d640262..386627d --- a/src/bitwise/bit_operations/swap_odd_even.py +++ b/src/bitwise/swap_odd_even.py @@ -1,6 +1,7 @@ -#!/usr/bin/python3 -# mari von steinkirch @2013 -# steinkirch at gmail +#!/usr/bin/env python + +__author__ = "bt3" + ''' Swap odd and even bits in a smart way in a binary: 1) first for odds, take n and move the odd: @@ -8,17 +9,18 @@ (b) shift by right by 1 2) do the same to ints with 01010101 3) merge - - >>> num = 0b11011101 - >>> result = '0b1101110' - >>> swap_odd_even(num) == result - True - ''' def swap_odd_even(num): + ''' + >>> num = 0b11011101 + >>> result = '0b1101110' + >>> swap_odd_even(num) == result + True + ''' + mask_odd = 0xAA # 0b10101010 mask_even = 0x55 # 0b1010101 odd = num & mask_odd @@ -28,9 +30,6 @@ def swap_odd_even(num): return bin(odd | even) - - - if __name__ == '__main__': import doctest diff --git a/src/searching_and_sorting/sorting/bubble_sort.py b/src/searching_and_sorting/sorting/bubble_sort.py index d156a22..4c12870 100644 --- a/src/searching_and_sorting/sorting/bubble_sort.py +++ b/src/searching_and_sorting/sorting/bubble_sort.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" def bubble_sort(seq): diff --git a/src/searching_and_sorting/sorting/count_sort.py b/src/searching_and_sorting/sorting/count_sort.py index 2ee6ea6..7030a7a 100644 --- a/src/searching_and_sorting/sorting/count_sort.py +++ b/src/searching_and_sorting/sorting/count_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" diff --git a/src/searching_and_sorting/sorting/gnome_sort.py b/src/searching_and_sorting/sorting/gnome_sort.py index 435a9f2..6d6fccb 100644 --- a/src/searching_and_sorting/sorting/gnome_sort.py +++ b/src/searching_and_sorting/sorting/gnome_sort.py @@ -1,8 +1,6 @@ -#!/usr/bin/python - -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +#!/usr/bin/env python +__author__ = "bt3" def gnome_sort(seq): diff --git a/src/searching_and_sorting/sorting/heap.py b/src/searching_and_sorting/sorting/heap.py index 72a809e..b22326c 100644 --- a/src/searching_and_sorting/sorting/heap.py +++ b/src/searching_and_sorting/sorting/heap.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" class Heap(object): diff --git a/src/searching_and_sorting/sorting/heap_sort.py b/src/searching_and_sorting/sorting/heap_sort.py index 38c2ff5..bcbf639 100644 --- a/src/searching_and_sorting/sorting/heap_sort.py +++ b/src/searching_and_sorting/sorting/heap_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' Heapsort using Pythons libraries''' diff --git a/src/searching_and_sorting/sorting/insertion_sort.py b/src/searching_and_sorting/sorting/insertion_sort.py index e67130c..ae71368 100644 --- a/src/searching_and_sorting/sorting/insertion_sort.py +++ b/src/searching_and_sorting/sorting/insertion_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" diff --git a/src/searching_and_sorting/sorting/merge_sort.py b/src/searching_and_sorting/sorting/merge_sort.py index 5a099c0..4ab04b1 100644 --- a/src/searching_and_sorting/sorting/merge_sort.py +++ b/src/searching_and_sorting/sorting/merge_sort.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" diff --git a/src/searching_and_sorting/sorting/quick_sort.py b/src/searching_and_sorting/sorting/quick_sort.py index 39d1d90..1c283a3 100644 --- a/src/searching_and_sorting/sorting/quick_sort.py +++ b/src/searching_and_sorting/sorting/quick_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" ''' Some examples of how to implement Quick Sort in Python diff --git a/src/searching_and_sorting/sorting/selection_sort.py b/src/searching_and_sorting/sorting/selection_sort.py index 72478c4..a198041 100644 --- a/src/searching_and_sorting/sorting/selection_sort.py +++ b/src/searching_and_sorting/sorting/selection_sort.py @@ -1,7 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" +__author__ = "bt3" def selection_sort(seq): diff --git a/src/searching_and_sorting/sorting/sort_anagrams_together.py b/src/searching_and_sorting/sorting/sort_anagrams_together.py index 890a7b8..7e41c11 100644 --- a/src/searching_and_sorting/sorting/sort_anagrams_together.py +++ b/src/searching_and_sorting/sorting/sort_anagrams_together.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python + +__author__ = "bt3" -__author__ = "Mari Wahl" -__email__ = "marina.w4hl@gmail.com" ''' A method to sort an array so that all the anagrams are together. Since we only want the anagrams to be grouped, we can use a dictionary for this task. This