id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > minerideTwistsAndTurns
prev  |  next  |  chance

Write a method that accepts your initial direction from a choice of 'N', 'S', 'E', or 'W' representing each of the cardinal compass directions. The method also accepts a string made up of the characters 'L' and 'R' in any order and any amount. Each 'L' represents a 90 degree turn to the left and each 'R' represents a 90 degree turn to the right. Return a string that indicates, in words, which cardinal compass direction you will be facing at the end of the sequence of turns. The result can only be "North", "South", "East", or "West". For example, if your initial direction is 'N' and your string representing turns is "LLLL" your result will be "North" because you have turned completely around 360 degrees. Look at the test data for additional examples.


minerideTwistsAndTurns("E", "RRRLRL") → "West"
minerideTwistsAndTurns("S", "RLRLRRRLLL") → "South"
minerideTwistsAndTurns("E", "RRRLRLLRLRLLLLLRLRL") → "South"

...Save, Compile, Run (ctrl-enter)

public String minerideTwistsAndTurns(char initDir, String turns) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy