Skip to content

Instantly share code, notes, and snippets.

@kohlikohl
Last active December 17, 2015 06:58

Revisions

  1. Matthias Knoll renamed this gist May 13, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Matthias Knoll created this gist May 13, 2013.
    41 changes: 41 additions & 0 deletions Challange.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    # Coding Challenge 4

    This weeks challenge is to write a so called "Pattern Chaser".

    ## Instructions

    #### Language
    JavaScript

    Expose a function called `bnt.patternChaser(str)` to the global namespace which takes one `string` as a parameter and returns `"yes [found pattern]"` or `"no null"`.

    The found pattern should be the longest pattern which can be found in the string.

    A pattern for this challenge will be defined as:

    * If at least 2 or more adjacent characters within the string repeat at least twice. So for example `"aabecaa"` contains the pattern `"aa"`, on the other hand `"abbbaac"` doesn't contain any pattern.
    * If str were `"aabejiabkfabed"` the output should be `"yes abe"`.
    * If str were `"123224"` the output should return `"no null"`.
    * The string may either contain all characters (a through z only), integers, or both. But the parameter will always be a string type.
    * The maximum length for the string being passed in will be 20 characters.
    * If a string for example is `"aa2bbbaacbbb"` the pattern is `"bbb"` and not `"aa"`. You must always return the longest pattern possible.

    ## Judging Criteria

    * ***Coding Style***:
    * Does the code lint in [JSLint](http://www.jslint.com/) with following settings: `/*jslint browser: true, plusplus: true, sloppy: true, stupid: false, indent: 4 */`
    * Use of language features

    * ***Execution Time***
    * ***Lines of code***
    * ***Elegance of solution***

    #### BONUS!!
    Use the Google Closure Library.

    If you choose to use the library please create the module in the `goog.provide('bnt.PatternChaser');` namespace and make sure it still exposes the `bnt.patternChaser(str)` function.


    ## Deadline

    19:00 - Tuesday 28th May