GS coding round: SSE
Anonymous User
642
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>

using namespace std;

// == Instructions ==
//
// A description of the expected behaviour is given below

// Given two words returns the shortest distance between their two midpoints in number of characters
// Words can appear multiple times in any order and should be case insensitive.
//
// E.g. for the document="This is a sample document we just made up"
//   shortestDistance( document, "we", "just" ) == 4
//   shortestDistance( document, "is", "a" ) == 2.5
//   shortestDistance( document, "is", "not" ) == -1

double shortestDistance(const string& document, const string& word1, const string& word2) {
 
}

const string document =
    "In publishing and graphic design, lorem ipsum is a filler text commonly used to demonstrate the graphic elements"
    " of a document or visual presentation. Replacing meaningful content that could be distracting with placeholder text"
    " may allow viewers to focus on graphic aspects such as font, typography, and page layout. It also reduces the need"
    " for the designer to come up with meaningful text, as they can instead use hastily generated lorem ipsum text. The"
    " lorem ipsum text is typically a scrambled section of De finibus bonorum et malorum, a 1st-century BC Latin text by"
    " Cicero, with words altered, added, and removed to make it nonsensical, improper Latin. A variation of the ordinary"
    " lorem ipsum text has been used in typesetting since the 1960s or earlier, when it was popularized by advertisements"
    " for Letraset transfer sheets. It was introduced to the Information Age in the mid-1980s by Aldus Corporation, which"
    " employed it in graphics and word processing templates for its desktop publishing program, PageMaker, for the Apple"
    " Macintosh. A common form of lorem ipsum reads: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do"
    " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation"
    " ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit"
    " esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui"
    " officia deserunt mollit anim id est laborum.";

// Returns true if the tests pass. Otherwise, false.
bool doTestsPass() {
  // todo: implement more tests if you'd like
  return shortestDistance(document, "and", "graphic") == 6.0 &&
    shortestDistance(document, "transfer", "it") == 14.0 &&
    shortestDistance(document, "layout", "It" ) == 6.0 &&
    shortestDistance(document, "Design", "filler" ) == 25.0 &&
    shortestDistance(document, "It", "transfer") == 14.0;
}

int main() {
  if (doTestsPass()) {
    cout << "All tests pass" << endl;
  } else {
    cout << "There are test failures" << endl;
  }
  return 0;
}
Comments (3)