Giter Site home page Giter Site logo

hartl3y94 / follow-the-white-rabbit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abdelkrimdev/follow-the-white-rabbit

0.0 0.0 0.0 249 KB

Trustpilot backend developer coding challenge done in C#. The goal is to find 3 anagrams from a list of 99175 words in a specific order which matches the given MD5 hash values.

License: MIT License

C# 100.00%

follow-the-white-rabbit's Introduction

Follow The White Rabbit

Solution to the TrustPilot "follow the white rabbit" coding challenge done in C#.

Performance

The easy one could be found in just 2 secs, the medium one took 50 secs and the hard one should be resolved in about 30 mins.

Usage

$ dotnet run
Please type the key phrase: trustpilot wants you
Minimum word length: 2
Number of words per anagram: 4
Loading file...
Excluding impossible words...
Building words tree...
Jumping into the hole...
+------------------------------------------------+
|                                                |
         - printout stout yawls
         - ty outlaws printouts
         - wu lisp not statutory
|                                                |
+------------------------------------------------+
Saving results...
DONE!!!

Strategy

  • Filter down the wordlist to only contain words that could be part of the secret phrase.
  • Store the wordlist into a prefix tree, so we can group words with the same prefix.
                             '^'
                            /   \
                           /     \
                         'h'     'w'
                          |       |
                          |       |
                         'e'     'o'
                          |        \
                          |         \
                         'l'        'r'
                          |        / | \
                          |       /  |  \
                         'l*'   'd*''k*''l'
                          |              |
                          |              |
                         'o*'           'd*'
  • Iterate over all characters from the key phrase.
  • Going through the Trie and try to build an anagram for the key phrase.
  • Each time it consumes all characters from the key phrase, it adds a new candidate to the list.
  • Hash each of the anagrams and check if it matches.

follow-the-white-rabbit's People

Contributors

abdelkrimdev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.