Posts

Showing posts from April, 2020

String

S8P1-ALTERNATING CODE Alternating Code It is IPL Season and the first league match of Dhilip’s favorite team, "Chennai Super Kings". The CSK team is playing at the IPL after 2 years and like all Dhoni lovers, Dhilip is also eagerly awaiting to see Dhoni back in action. After waiting in long queues, Dhilip succeeded in getting the tickets for the big match. On the ticket, there is a letter-code that can be represented as a string of upper-case Latin letters. Dhilip believes that the CSK Team will win the match in case exactly two different letters in the code alternate. Otherwise, he believes that the team might lose. Please see note section for formal definition of alternating code. You are given a ticket code. Please determine, whether CSK Team will win the match or not based on Dhilip’sconviction. Print "YES" or "NO" (without quotes) corresponding to the situation. Note: Two letters   x, y   where   x != y   are said to be alternating in a co...

2-D Arrays

Image
S7P1 - VALID INITIAL CONFIGURATION Valid Initial Configuration   Nurikabe logical game (sometimes called Islands in the Stream) is a binary determination puzzle. The puzzle is played on a typically rectangular grid of cells, some of which contain numbers. You must decide for each cell if it is white or black (by clicking on them) according to the following rules: All of the black cells must be connected. Each numbered cell must be part of a white island of connected white cells. Each island must have the same number of white cells as the number it contains (including the numbered cell). Two islands may not be connected. There cannot be any 2x2 blocks of black cells. Unnumbered cells start out grey and cycle through white and black when clicked. Initially numbered cells are white in color. Problem Statement: Write a program to check whether the given board configuration is a valid initial configuration. Below figure is the sample valid initial configuration.   I...