Advertisement
roronoa

ts boom bing ding

Jul 8th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. class Solution {
  6.  
  7.     public static void main(String args[])
  8.     {
  9.         Scanner in = new Scanner(System.in);
  10.         String s = in.nextLine();
  11.         int x=0, y=0;
  12.         for(String word : s.split(" "))
  13.         {
  14.             String step = move(word, x, y);
  15.             x = Integer.parseInt(step.split(" ")[0]);
  16.             y = Integer.parseInt(step.split(" ")[1]);
  17.         }
  18.         System.out.println(x+" "+y);
  19.     }
  20.     public static String move(String word, int x, int y)
  21.     {
  22.         String res = "";
  23.         switch(word)
  24.         {
  25.             case "ts":
  26.                 if(x>0)
  27.                     x--;
  28.                 break;
  29.             case "boom":
  30.                 if(x<=29)
  31.                     x++;
  32.                 break;
  33.             case "ding":
  34.                 if(y>0)
  35.                     y--;
  36.                 break;
  37.             case "bing":
  38.                 if(y<=9)
  39.                     y++;
  40.                 break;
  41.         }
  42.         res += x + " " + y;
  43.         return res;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement