This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#* Write a Ruby method group_anagrams that takes an array of strings as input | |
#* and groups the anagrams together. | |
#* Anagrams are words or phrases formed by rearranging the letters of another. | |
def group_anagrams(words) | |
groups = {} | |
words.each_with_index do |word, index| | |
sorted_word = word.chars.sort.join | |
if groups[sorted_word].nil? | |
groups[sorted_word] = [word] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def main(): | |
#Read Arguments | |
arch = sys.argv[1] | |
#print("Nombre archivo",arch) | |
#Read file | |
file = open(arch, "r").read() | |
#replace \n to whitespace | |
file = file.replace('\n',' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def main(): | |
#Read Arguments | |
arch = sys.argv[1] | |
#print("Nombre archivo",arch) | |
#Read file | |
file = open(arch, "r").read() | |
#replace \n to whitespace | |
file = file.replace('\n',' ') |