BFMODULO - "a mod b" in BF

no tags 

your task is simple ..find the answer of a mod b as fast as you can.
a and b are integers
0<=a<1000 and 0<b<10

Input:


integer a with leading zeroes
then space ASCII(32)
then b .. and EndOfLine ASCII(10)
 

output:


the value of(a mod b)

 

Example1:
input:

999 2

output:

1 

 

Example2:
input:
005 6

output:

5


Example3:
input:
099 1

output:
0



Score:

 


Sometimes I enjoy writing lots of '+' in my code ..
but sometimes I prefer some thing like ++++[->++++<] to shorten it.
But With This New Judge, the first way is shorter.
This New BF_OPERTIONS_COUNTER counts how many BFoperations your implemintaion do ..

example..


code1  :  +++++++++++++++.
code2  :  +++[->+++++<]>.


as you see LengthOfcode2< LengthOfcode1
But .. the judge look at code2 like this:
+++[->+++++<]->+++++<]->+++++<]>.
and It will count these operators : '+','-','<','>' only


so : code1 will have score of 15
and code2 will have score of 28

Score is "how many '+','-','>','<' your code does at the run time"

BUT: since there is many test files ... and your code may expand or shorten as the judge see it ..
So the final Score will be your scores average ...

Thanks for Tjandra Satria Gunawan for his suggestion for the new judge .

 

note: you can see how the judge read your code at your submission info (only the first test file).

LAST UPDATE NOTE 15/1/2012:

I've complete improving test files ... there is now 59 test files ,also now you can write  100,000 byte code

after solving the problem,maybe you can see that MCLT: MORE CODE --> LESS TIME Wink

Enjoy :)


hide comments
Mostafa 36a2: 2013-01-15 15:47:34

@Mitch Schwartz and @Tjandra Satria Gunawan : The Best Code Is The General Code which solve any case .. cause i will add another 7 inputs files ..
it still not cover all the cases but if i make several test cases in one file the expanded code will be HUGE ..
for example any code run in 0.01 on pyramid will be nearly 10^5 byte(expanded)
so i will add more and more files to cover all the cases as possible .
so try make tour code GENERAL .
NOTE: the Judge is open source for who want .. just send me a PM to send you the judge ..(if you want)
happy to have your appreciation .
thanks

Aditya Pande: 2013-01-15 15:47:34

maybe i should start optimizing...
my "clean" code is about to get less clean...

Mitch Schwartz: 2013-01-15 15:47:34

How about having multiple test cases per input file? (With or without "T" number of test cases on first line.) Of course it would invalidate current entries, but modifying code to handle multiple cases is not a big deal I think, and all entries so far have gotten 0.00s, so this could be the best solution. And, data should not just be random but also have some special qualities to prevent specific exploits.

Last edit: 2013-01-10 08:17:29
(Tjandra Satria Gunawan)(曾毅昆): 2013-01-15 15:47:34

@Mostafa 36a2: I agree with Mitch Schwartz, this problem must have many cases to get the general score (good scoring for general case), my last submission is faster (less commands) only for large A, but seems that it slower (more commands), so I think to get the good scoring, you should increase number of random test data..

Last edit: 2013-01-10 07:51:04
Mitch Schwartz: 2013-01-15 15:47:34

@Mostafa: After more thought, exploiting weak input data is pretty embedded into this problem, hundreds of test cases are required to make the test data really strong. I don't know what to recommend. If you need an explanation, let me know.

Last edit: 2013-01-10 07:29:55
Mitch Schwartz: 2013-01-15 15:47:34

My code is also not fully optimised, I avoided certain ideas for now to keep the code relatively "clean", a term I use very loosely... Anyway, I prefer this not to be a "guess the input weakness" game; please make the test data stronger. A lower bound for this is 17 input sets, probably more but I haven't thought about it that deeply.

By the way, thanks Mostafa for all the interesting BF problems lately - also to Aditya, for ADITYA13 - and I also enjoyed the scoring for this problem.

And "BF" isn't clickable for us solvers; I haven't investigated much, but for example SELF gives users additional info through the "error" page, arrived at by clicking on the score. I believe it was accomplished by making the problem interactive: http://www.spoj.com/tutorials/PSINT/ .

Last edit: 2013-01-10 04:45:40
(Tjandra Satria Gunawan)(曾毅昆): 2013-01-15 15:47:34

Finally only ~500 commands :-)
This is not my best, I can simplify the code more, but need extra work, so maybe another time ;-)
Nice problem, thanks... I like this judge :-D
EDIT: now ~400 commands and still not my best, there are so many ways for optimization... :-X ups..
EDIT2: seems that my ~400 commands is wrong code, it give wrong ans for case like this: "015 6", but it got AC, now I've replaced it with more strong code: ~350 commands... btw seems that you upload only 7 test cases..
EDIT3: again, ~350 commands code is wrong and getting TLE fore some input and it got AC, now I've replaced it with more strong code ~300 commands...

Last edit: 2013-01-10 07:12:06
Mitch Schwartz: 2013-01-15 15:47:34

Thanks for the info! And please make sure every possible value of b appears in the input data, I think otherwise it would be too weak.

Edit: There are other potential weaknesses I can think of, maybe I can PM you about them at some point (if you want), for now I'll work on a solution that works for any input.

--Edit:any PM is welcomed to improve the test cases Thank you very much

Last edit: 2013-01-10 11:40:01
Mostafa 36a2: 2013-01-15 15:47:34

@ Aditya Pande : you should press the word BF at right of your submission
It should worked cause i used the handle:
spoj_p_info; which gave additional info - psetter and solution's owner
any way i gonna send you the expanded code to your email ..
Sorry for this ..

Mostafa 36a2: 2013-01-15 15:47:34

@Mitch Schwartz : my compiler do the same as the BF compiler in spoj do..
the array is : int array[32768]={0};
you can travel left and right as you want
the command "," is equal to getchar() in C .
i think it doesn't important to consider cause it is the same as bff 1.0.3.1
have fun:)


Added by:Mostafa 36a2
Date:2013-01-07
Time limit:1s
Source limit:100000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:BF
Resource:FizzBuzz Happy 2013