1
\$\begingroup\$

Background:

Okay, i dropped my android smartphone and damaged the touchscreen
The lower half (yeah, exact half!) is spider-webbed and does not work (potrait-mode)
Fortunately for me, the display itself is working

My phone is already rooted and adb enabled, so i have managed to enable 360 degree display rotation

Using this phone almost appeared to be an excercise in frustration, having to rotate the phone this way and that, in order to touch/tap/swipe the inaccessible screen estate
But I've gotten pretty good at it now

  T O P
 _ _^_ _
|       |
|       |
|_ _ _ _|
| / / / |
|/ / / /|
|_/_/_/_|

 _ _ _ _ _ _
|/ / /|     |  T
| / / |     |\ O
|/ / /|     |/ P
|_/_/_|_ _ _|



Code Golf Challenge:
Given the current screen orientation and the desired (Row,Column) coordinate to touch, find the optimal rotation to access the point - direction and count

Assumptions:

  • This challenge is only for the App icons in the App Drawer, assume that the screen always shows the full grid of Apps and nothing else
  • Size of the grid is 6 Rows X 4 Columns in portait mode
  • Apps fill only one page in the App drawer - total number of apps is 24
  • Screen orientation can have four possible values - 0,90,180,270
      0 - Normal Potrait
      90 - Landscape achieved by turning the phone counter-clock-wise
      180 - Reverse Potrait achieved by turning the phone counter-clock-wise
      270 - Reverse Landscape achieved by turning the phone counter-clock-wise
  • Input will always be in the format (Row,Column,Current Orientation), including parantheses and commas with no spaces

    Counting starts from 1 Note that the coordinates are WYSIWYG - meaning, the Row number and column number are with respect to the current orientation
      Ex: (2,5,270)
      Which is Row 2, Column 5 while in Landscape


    _ _ _ _ _ _ 
 T |     |/ / /|
 O/|     | /?/ |
 P\|     |/ / /|
   |_ _ _|_/_/_|

Rules:

  • Standard Loopholes apply
  • Output may contain newlines
  • If the there are two equally optimal outcomes for a given input, both must be output by the code, sorted by clock-wise outcome first
  • Output should be in the format (Direction of rotation,Number of 90 degree turns), including parantheses and commas with no spaces
        Ex: (C,2)
            (CC,1)
  • If the current orientation is the optimal choice for a given input, the code should output 0
  • Shortest code wins!

Test cases:

#1
Input: (2,3,270)
Output: 0

#2
Input: (3,3,90)
Output: (C,1)

Will add more when i get time!

This is my first code-golf challenge, questions and suggestions welcome Happy golfing!

\$\endgroup\$
9
  • 3
    \$\begingroup\$ Oh Oh, formatting is all messed up, trying to fix now! \$\endgroup\$ Commented Apr 22, 2017 at 10:35
  • \$\begingroup\$ Help! Someone fix my ASCII art! Please! \$\endgroup\$ Commented Apr 22, 2017 at 10:52
  • \$\begingroup\$ Is there any reason you are specifying an input format for this challenge and requiring string output? \$\endgroup\$ Commented Apr 22, 2017 at 10:59
  • \$\begingroup\$ @JonathanAllan Thanks, fixed. Also, not specific reason for the input/output formats other than introducing some variety and a bit of challenge \$\endgroup\$ Commented Apr 22, 2017 at 11:03
  • \$\begingroup\$ @JonathanAllan Many apologies, i made a mistake in copy-pasting. Fixed again \$\endgroup\$ Commented Apr 22, 2017 at 11:15

0

Browse other questions tagged or ask your own question.