Number of Proper Links
All submissions for this problem are available.
John is a new web developer. He is not very good in programming languages so he makes some mistakes in writing the code. He does not take proper cautions for whitespaces. Also sometimes he inserts some extra characters at some places on the page. Because of this his page does not view correctly and also does not behave correctly. He wants to count the number of proper links in a given portion of his web pages.
A proper link is a link that starts with a “<” (opening angle bracket without quotes) followed character “a” (so in total becomes the opening of ‘a’ tag ) and then followed by string “href” with at least one white space before it. After this we can have an equal sign (“=”) and then followed by a link within double quotation. At last we have a “>” (closing angle bracket). Any numbers of white spaces are allowed in between the above characters or strings.(Note that some pairs must have more than one white space between them and no white space will be there in between the letters of string 'href')
Note : Closing of ‘a’ tag (“</a>”) is not considered.
Eg : < a href=”abc.com” > and <a href= ”xyz.com”> etc. are valid links.
< a . href=”abc.com” > and <a href = “xyz.com > etc. are not valid links.
The first line of the input contains an integer T denoting the number of test cases and then followed by t strings that to be processes for proper links.
For each test string you need to output the no of proper links in a new line. So your output will contain t lines and each line will have a single positive integer.
- 1 ≤ T ≤ 100
Input: 3 <a href = "abc.com" >This is sample. <b href="png.com"> <a. href = "abc.com" >Code Chef<b href="png.com"> <a href = "abc.com > Output: 1 0 0
First test string has only one proper link because second link is in "b" tag.
Second test string has no proper link because in first link there is a dot (" . ") after " a " and second link is in "b" tag.
Third test string also has no proper link because double quotes are not closed in the link.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.