Advertisement
MonsterScripter

CodinGame_2023_09_05__20_08_40__min_pos_sharp.java

Sep 5th, 2023
1,074
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * 01 Test 1
  5.  * Entrée
  6.  * Sortie attendue
  7.  * ***#***
  8.  * 3
  9.  *
  10.  * 02 Test 2
  11.  * Entrée
  12.  * Sortie attendue
  13.  * **#**********
  14.  * 2
  15.  *
  16.  * 03 Test 3
  17.  * Entrée
  18.  * Sortie attendue
  19.  * ****#*
  20.  * 1
  21.  *
  22.  * 04 Test 4
  23.  * Entrée
  24.  * Sortie attendue
  25.  * #*****
  26.  * 0
  27.  *
  28.  * 05 Test 5
  29.  * Entrée
  30.  * Sortie attendue
  31.  * *#*
  32.  * 1
  33.  */
  34. class Solution {
  35.  
  36.     public static void main(String args[]) {
  37.         final Scanner in = new Scanner(System.in);
  38.         final String T = in.nextLine();
  39.         final int i = T.indexOf('#');
  40.         final int r = (T.length() - 1) - i;
  41.        
  42.         // Trouver la position du '#' dans la chaîne et calculer la réponse
  43.         System.out.println(i < r ? i : r);
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement