Paint The Tiles

Sort by

recency

|

11 Discussions

|

  • + 0 comments

    Hey here is my code in python 3!! All test cases passes with just tiny code below:

    import sys N = int(input().strip()) C = input().strip() count=1 for i in range(len(C)-1):
    if len(set(C))==1: break else: if C[i]!=C[i+1]: count+=1 print(count)

  • + 1 comment

    using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.Serialization; using System.Text.RegularExpressions; using System.Text; using System;

    class Solution {

    static int StrokesToPaint(int N,string[] C)
    {
       //C = new string[N];
       int count=1;
    
    
      for(int i=0; i<=(N-1); i++)
       {
          if(i!=4)
           {
               if(C[i] != C[i+1])
               {
                   count = count+1;
               }               
            }           
       }
    
        return count;
    
    }
    
    static void Main(string[] args) {
    
         TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
    
        int N = Convert.ToInt32(Console.ReadLine());
    
        //string[] C = new string[N];
    
       string[] C = Array.ConvertAll(Console.ReadLine().Split(' '), aTemp => 
       Convert.ToString(aTemp));      
    
        //string C = Console.ReadLine();       
    
        int count=StrokesToPaint(N,C);  
    
        //Console.WriteLine(count);
    
        textWriter.WriteLine(count);
    
        textWriter.Flush();
        textWriter.Close();  
    
    }
        }
    

    }

  • + 0 comments

    int main(){ int N; scanf("%d",&N); char a[N]; int count=0; scanf("%s",a);

    for(int i=0;i<strlen(a);i++)
    {
        if(a[i]!=a[i+1])
        count++;
    }
    printf("%d",count);
    return 0;
    

    }

  • + 0 comments
    n=int(input())
    s=input()
    if len(set(s))==1:
        print(1)
    else:
        c=0
        for i in range(len(s)-1):
            if s[i]!=s[i+1]:
                c+=1
            else:
                continue
    
        print(c+1)
    
  • + 0 comments
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String C = in.next();
    
        char[] arr = new char[N];
        arr = C.toCharArray();
        int count = 1;
        for(int i=0; i<N-1; i++)
        {
            if(arr[i] != arr[i+1])
                count++;
    
        }
        System.out.println(count);
    }