donnemartin / donnemartin/interactive-coding-challenges

Issue on anagram check in java and python

Open
#244 0 comments 0 reactions 0 assignees View on GitHub
needs-review
Dominant language
Python
Stars
31.8k
Forks
4.7k
PR merge metrics
No merged PRs in 30d

Description

You are using sum of prime numbers logic for checking anagrams which might result in inconsistent results like for example aa and b are my inputs which are not anagram to each other . In your case of addition the result will come as both are anagrams to each other.

Hence please fix the logic to product than using sum.

For your reference —-
https://forum.cosmoquest.org/showthread.php?167873-Using-Prime-Numbers-to-Check-if-Two-Words-are-Anagrams
https://hastebin.com/adazekoyet.swift
https://stackoverflow.com/questions/13215789/comparing-anagrams-using-prime-numbers

Contributor guide

Open the contributing guide

Research direction

Locate the anagram-check implementations for Python and Java and inspect how the character primes are combined. Reproduce the reported collision with “aa” and “b”, then add or update a regression test and verify that the implementation distinguishes these inputs while preserving valid anagram checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
developer-experience
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.