(6, 'JKphobic', 'Take a Ten Minute Walk', '["FUNDAMENTALS","ARRAYS"]', '["Javascript","Java","Haskell","F#","Python","Ruby"]', 'function isValidWalk(walk) {\n \n}', 'You live in the city of Cartesia where all roads are laid out in a perfect grid. You arrived ten minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its citizens with a Walk Generating App on their phones -- everytime you press the button it sends you an array of one-letter strings representing directions to walk (eg. [''n'', ''s'', ''w'', ''e'']). You know it takes you one minute to traverse one city block, so create a function that will return true if the walk the app gives you will take you exactly ten minutes (you don''t want to be early or late!) and will, of course, return you to your starting point. Return false otherwise. \n\nNote: you will always receive a valid array containing a random assortment of direction letters (''n'', ''s'', ''e'', or ''w'' only). It will never give you an empty array (that''s not a walk, that''s standing still!)', '[{"test":"//some test cases for you... \nTest.expect(isValidWalk([''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s'']), ''should return true''); \nTest.expect(!isValidWalk([''w'',''e'',''w'',''e'',''w'',''e'',''w'',''e'',''w'',''e'',''w'',''e'']), ''should return false''); \nTest.expect(!isValidWalk([''w'']), ''should return false''); \nTest.expect(!isValidWalk([''n'',''n'',''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s'']), ''should return false''); \n"}]', '[{"test":"var fail = [ [''n''], [''n'',''s''], [''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s''], [''n'',''s'',''e'',''w'',''n'',''s'',''e'',''w'',''n'',''s'',''e'',''w'',''n'',''s'',''e'',''w''], [''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s'',''n'',''n''], [''e'',''e'',''e'',''w'',''n'',''s'',''n'',''s'',''e'',''w''] ]; var pass = [ [''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s'',''n'',''s''], [''e'',''w'',''e'',''w'',''n'',''s'',''n'',''s'',''e'',''w''], [''n'',''s'',''e'',''w'',''n'',''s'',''e'',''w'',''n'',''s''] ]; describe(''Walk Validator'', function(){ it (''should return false if walk is too short'', function(){ Test.expect(!isValidWalk(fail[0])); Test.expect(!isValidWalk(fail[1])); }); it (''should return false if walk is too long'', function(){ Test.expect(!isValidWalk(fail[2])); Test.expect(!isValidWalk(fail[3])); }); it (''should return false if walk does not bring you back to start'', function(){ Test.expect(!isValidWalk(fail[4])); Test.expect(!isValidWalk(fail[5])); }); it (''should return true for a valid walk'', function(){ Test.expect(isValidWalk(pass[0])); Test.expect(isValidWalk(pass[1])); Test.expect(isValidWalk(pass[2])); }); });"}]'),
0 commit comments