Submit | All submissions | Best solutions | Back to list |
BFSTR1 - Strchr in BF |
Wonder if string functions are possible in brainf**k? Well, as Rivu says, "Impossible is nothing!!!".
Given a character (lower or upper case letter) and a character string, your task is to find the first occurance of the given character in this string and print its index. For a string of length N, the index numbering starts from 1 to N. Simple, Isn't it? Only 256 bytes allowed. Still simple? Well, try and minimize it.
Input
First line of the input contains T , which comprises of 2 digits, representing the number of test cases. The next T lines of the input contain a test case each.
Each of these lines start with a character, say C, followed by a space and then a string of characters, say STR. Each line of the input ends with a newline character.
Contraints:
0 < T < 10
0 < length of STR < 10
Output
For every test case, output the INDEX of the first occurence of C in STR. If the character C is NOT found in STR, output 0.
Example
Input:
03
F BrianFuck
c strcmp
m mama
Output:
6
4
1
SCORE is your source length.
NOTE: This question does NOT use exact judge. So, you can print any space character between the test cases.
Added by: | [theMighty] Deathsurgeon |
Date: | 2014-05-26 |
Time limit: | 1s |
Source limit: | 256B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | BF |
Resource: | Own problem |
hide comments
2014-05-28 19:18:39 Sandeep Garhwar
I am hoping t!=10 in the new test file,my 210 byte code isn't getting accepted,could you help me know where i am going wrong? Reply -> I've checked my test files again and again. But, I didn't find any mistakes in them. Surprisingly, I couldn't find any problem with your code too! I checked it on ideone and found it running correctly for all the given test files. I wonder what is the problem. Maybe you are printing some non printable character or some forbidden character. I think that would give a wrong answer too. All I can say for sure is your code is giving wrong answer for test file number 3 which has 9 test cases. (Sandeep Garhwar)->Never mind,i will keep trying and thanks for the effort Last edit: 2014-05-28 20:05:40 |