A word, phrase, or name formed by rearranging the letters of another, such as cinema, formed from iceman.
Questions tagged [anagram]
531 questions
50
votes
37 answers
How to check if two words are anagrams
I have a program that shows you whether two words are anagrams of one another. There are a few examples that will not work properly and I would appreciate any help, although if it were not advanced that would be great, as I am a 1st year programmer.…

Chilli
- 603
- 1
- 6
- 8
50
votes
13 answers
Finding anagrams for a given word
Two words are anagrams if one of them has exactly same characters as that of the another word.
Example : Anagram & Nagaram are anagrams (case-insensitive).
Now there are many questions similar to this . A couple of approaches to find whether two…

h4ck3d
- 6,134
- 15
- 51
- 74
31
votes
23 answers
Using Python, find anagrams for a list of words
Suppose I have a list of strings like ["car", "tree", "boy", "girl", "arc"] etc. I want to find groups of anagrams in that list - in this case, (car, arc).
I tried writing code to loop over the list and compare pairs of strings, but how do I…

user1040563
- 5,121
- 9
- 34
- 36
29
votes
7 answers
Optimizing very often used anagram function
I have written a function that determines whether two words are anagrams. Word
A is an anagram of word B if you can build word B out of A just by rearranging
the letters, e.g.:
lead is anagram of deal
This is my function:
bool…

mel-
- 533
- 4
- 11
27
votes
37 answers
Anagrams finder in javascript
I am supposed to write a program in JavaScript to find all the anagrams within a series of words provided. e.g.:
monk, konm, nkom, bbc, cbb, dell, ledl, llde
The output should be categorised into rows:
1. monk konm, nkom;
2. bbc cbb;
3. dell ledl,…

jiaoziren
- 1,309
- 4
- 14
- 16
19
votes
14 answers
Algorithm for grouping anagram words
Given a set of words, we need to find the anagram words and display each category alone using the best algorithm.
input:
man car kile arc none like
output:
man
car arc
kile like
none
The best solution I am developing now is based on an hashtable,…

Ahmed
- 7,148
- 12
- 57
- 96
17
votes
7 answers
Ruby anagram solver
I am wanting to write a anagram type solver in Ruby but it will work against a list of words, like so.
List of words is:
the
these
one
owner
I would allow the user to input some letters, e.g noe, and it would search the word list for words that it…

RailsSon
- 19,897
- 31
- 82
- 105
16
votes
8 answers
Code golf: find all anagrams
A word is an anagram if the letters in that word can be re-arranged to form a different word.
Task:
The shortest source code by character count to find all sets of anagrams given a word list.
Spaces and new lines should be counted as…

Charles Ma
- 47,141
- 22
- 87
- 101
14
votes
1 answer
How to use the 'in' operator in guard clauses?
I am trying to write an anagram checker in Elixir. It takes 2 words, the first one is a reference, the second is to be tested as a possible anagram of the first.
I am trying to write it with recursion and pattern matching. I get an error about using…

svarlet
- 595
- 5
- 14
14
votes
27 answers
How can I check if two strings are anagrams of each other?
I am trying to write a program that accepts two strings from the user:
s1 = input("Please enter a word:")
s2 = input("Please enter another word:")
How can I output True if the two are anagrams and False otherwise?
If you found this question from a…

Kyle
- 151
- 1
- 1
- 5
12
votes
8 answers
Algorithm to get a list of all words that are anagrams of all substrings (scrabble)?
Eg if input string is helloworld I want the output to be like:
do
he
we
low
hell
hold
roll
well
word
hello
lower
world
...
all the way up to the longest word that is an anagram of a substring of helloworld. Like in Scrabble for example.
The input…

PowerApp101
- 1,798
- 1
- 18
- 25
11
votes
1 answer
Why am i getting " Duplicate modifier for the type Test" and how to fix it
I was trying to make a method that returns true if given "Strings" are anagrams. unfortunately i cant even test it and i don know what is wrong. The markers at left says:
Multiple markers at this line
- Breakpoint:Test
- Duplicate…

EvilDumplings
- 301
- 1
- 3
- 9
10
votes
2 answers
Java 8 Stream function to group a List of anagrams into a Map of Lists
Java 8 is about to be released... While learning about Streams, I got into a scenario about grouping anagrams using one of the new ways. The problem I'm facing is that I can't find a way to group Strings objects using the map/reduce functions.…

Marcello DeSales
- 21,361
- 14
- 77
- 80
10
votes
38 answers
Anagram algorithm in java
I would like to make anagram algorithm but
This code doesn't work. Where is my fault ?
For example des and sed is anagram but output is not anagram
Meanwhile I have to use string method. not array. :)
public static boolean isAnagram(String s1 ,…

SemihY
- 249
- 1
- 4
- 14
10
votes
6 answers
Algorithm to remove a character from a word such that the reduced word is still a word in dictionary
Here is the scenario, Given a word remove a single character from a word in every step such that the reduced word is still a word in dictionary. Continue till no characters are left.
Here is the catch:
You need to remove the right character, for eg.…

nmd
- 823
- 1
- 7
- 17