Questions tagged [anagram]

A word, phrase, or name formed by rearranging the letters of another, such as cinema, formed from iceman.

531 questions
4
votes
7 answers

Create lists of anagrams from a list of words

I want to find create lists of anagrams from a list of words. Should I use another loop in my code or recursion? some_list = ['bad', 'app', 'sad', 'mad', 'dab','pge', 'bda', 'ppa', 'das', 'dba'] new_list = [some_list[0]] i = 0 while i+1 <…
pk.
  • 99
  • 3
  • 12
4
votes
5 answers

Java Anagram Solver

I can work out how to create anagrams of a string but I don't know how I can compare them to a dictionary of real words to check if the anagram is a real word. Is there a class in the Java API that contains the entire English dictionary?
Alex
  • 5,364
  • 9
  • 54
  • 69
4
votes
5 answers

anagram algorithm is returning duplicate values

I've been developing an algorithm to calculate anagrams for a given (set of) word(s). I just got it to work, with ONE incredibly frustrating exception (no pun intended; there is no actual exception being thrown). Despite my attempts to utilize…
insomniac
  • 131
  • 14
4
votes
2 answers

Rearrange Letters from Array and check if arrangement is in array

I'm Making a an ios application where you input 9 lettes and it will output anagrams of those 9 letters. It is like the target word, or 9 letter word in the paper. Like this link: http://nineletterword.tompaton.com/ It doesn't just provide anagrams…
falky
  • 589
  • 2
  • 11
  • 27
4
votes
4 answers

Search a string for an anagram of another string?

I'm trying to find a substring from a string text that is an anagram to a string pattern. My Question: Could the Rabin-Karp algorithm be adjusted to this purpose? Or are there better algorithms? I have tried out a brute-force algorithm, which did…
Rami Jarrar
  • 4,523
  • 7
  • 36
  • 52
3
votes
2 answers

Quick way to jumble the order of an NSString?

Does anyone know of an existing way to change the order of an existing NSString or NSMutableString's characters? I have a workaround in mind anyway but it would be great if there was an existing method for it. For example, given the string @"HORSE",…
Bob-ob
  • 1,560
  • 4
  • 18
  • 34
3
votes
3 answers

Check whether two strings are anagrams

What is the most straightforward way to check whether two strings are anagrams? i.e. they share the same letters as well as number of occurrences of each these letters (and possibly other characters). Something like this: s1 = "elbow" s2 =…
Maël
  • 45,206
  • 3
  • 29
  • 67
3
votes
3 answers

Algorithm for finding amount of word anagrams?

So I know the theory behind finding anagrams, shown here. For my purposes I need to find the amount of anagrams that can be found from a word excluding duplicates. Allowing for duplicates, this is fairly simple. aab has the following…
Jake D
  • 31
  • 1
3
votes
3 answers

Objective-C jumbled letters solver

I am trying to create this app on the iphone that given 6 letters, it would output all the possible 3-6 letter english words. I already have a dictionary, I just want to know how to do it. I searched around and only found those scrabble solvers in…
kazuo
  • 297
  • 1
  • 6
  • 15
3
votes
3 answers

Python- Possible English one-word anagrams given input letters

I know variations of this have been asked before, but I was unable to understand any of the previous implementations because most of them involved using sets and the issubset method. Here is what I am trying to do: I have a set of words in a…
Parseltongue
  • 11,157
  • 30
  • 95
  • 160
3
votes
2 answers

Print the maximum occurence of the anagrams and the anagram words itself among the input anagrams

a = ['ab', 'absa', 'sbaa', 'basa', 'ba'] res = [] s = 0 for i in range(len(a)): b=a[i] c = ''.join(sorted(b)) res.append(c) res.sort(reverse=False) wordfreq = [res.count(p) for p in res] d = dict(zip(res, wordfreq)) all_values =…
3
votes
3 answers

Anagram Recursion Scala

This is the question that I tried to write a code for. Consider a recursive algorithm that takes two strings s1 and s2 as input and checks if these strings are the anagram of each other, hence if all the letters contained in the former appear in…
3
votes
3 answers

JavaScript algorithm to match words in a dictionary

I have an array that contains a few thousand words. I have an input field on my webpage that allows a user to enter in a couple of letters, and then hit search. When the user hits search, the application should look in the dictionary and see what…
juicejonjon
  • 31
  • 1
  • 2
3
votes
4 answers

Problem 98 - Project Euler

The problem is as follows: By replacing each of the letters in the word CARE with 1, 2, 9, and 6 respectively, we form a square number: 1296 = 36^(2). What is remarkable is that, by using the same digital substitutions, the anagram, RACE, also forms…
dominic
  • 468
  • 1
  • 5
  • 14
3
votes
4 answers

Python - Compare 2 words and check if they are anagram

I am trying to define a function that takes 2 strings, compare those two and returns True if they are anagram. I don't want to import collections. So, if string1 is python and string 2 is nohtyp, it should return True. Otherwise, obviously, return…
Auclown
  • 179
  • 1
  • 3
  • 20