Right Linear Grammar - ∞ points
S->ε
S->1A
S->0S
S->9I
S->3C
S->5E
S->4D
S->2B
S->7G
S->6F
S->8H
F->3K
K->0F
A->2L
K->1G
A->5B
A->0J
B->7A
J->5A
G->6K
G->8S
H->9K
F->5S
K->2H
I->6E
I->5D
J->4S
D->8I
B->6S
K->9B
F->6A
G->9A
K->6L
K->4J
C->1E
L->8K
E->5C
B->4K
C->0D
J->2K
D->2C
A->9F
J->7C
C->6J
C->8L
E->0K
L->0C
B->9C
E->2S
L->6I
I->0L
J->0I
B->2I
I->3B
H->1C
I->7F
C->4H
F->1I
G->4I
I->0G
C->3G
F->8C
D->0A
E->3A
I->9H
A->7D
C->2F
H->7I
A->8E
F->9D
E->8F
A->6C
D->6G
G->0E
D->5F
E->9G
H->2D
D->7H
H->3E
I->2A
K->3I
C->9S
C->7K
E->4B
D->1B
L->1D
J->9E
I->1S
E->1L
J->8D
D->9J
L->2E
J->3L
B->5L
B->8B
L->7J
L->9L
G->1F
A->4A
K->5K
B->3J
H->6H
E->7E
J->1J
D->4E
G->2G
J->6B
D->3D
E->6D
H->4F
I->4C
C->5I
F->0H
H->5G
K->7S
G->3H
L->5H
H->8J
A->3S
H->0B
B->1H
G->7L
K->8A
F->2J
F->7B
L->4G
F->4L
A->1K
B->0G
G->5J
L->3F
Then depending on how you choose to 'run' it, it will output 'yes' or 'no'.
Not a serious entry, just some fun ;)
EDIT:
Perhaps I should explain a bit.
A grammar is a set of rules (productions) which define a language. A language can be thought of as all of the possible strings formed by an alphabet, that conform to the rules of it's grammar.
Here the alphabet is the set of all decimal digits. The grammar's rules are that all strings must form decimal integers that are divisible by 13.
We can use the grammar above to test whether a string belongs to our language.
The rules of the grammar contain terminal symbols (which are elements in the language) as well as non-terminal symbols which are replaced recursively.
It's easier to explain what's going on with an example:
Lets say for example that the string we are testing is 71955.
There is always a start symbol (which is non-terminal), in the case of the grammar above this is 'S'. At this point we have not read any characters from our string:
current pattern symbol read
S ε
Now, we read the first symbol in our string which is '7', then we look for a rule in the grammar which has any of the non-terminals in our current pattern in the left hand side of the '->' and that has our symbol in the right hand side of the '->'.
Luckily there is one (S->7G), so we replace the non-terminal symbols in our current pattern with the right hand side of the new rule:
current pattern symbol read
7G 7
Now we have the non-terminal 'G' in our pattern, and the next symbol to be read is '1', So we look for a rule in our grammar that begins with 'G->1". We find there is one (G->1F), so we replace the non terminal with the RHS of our new rule:
current pattern symbol read
71F 1
Keep repeating this process:
Next rule: F->9D
current pattern symbol read
719D 9
Next rule: D->5F
current pattern symbol read
7195F 5
Next rule: F->5S
current pattern symbol read
71955S 5
At this point we have no more symbols in our string, but we have another non-terminal symbol in there. We see from the first rule in the grammar that we can replace 'S' with the empty string (ε): S->ε
Doing so gives us the current patter: 71955ε which is the equivalent to 71955.
We have read all of the symbols in our string, and the pattern contains no non-terminal symbols. Which means that the string belongs to the language and therefore 71955 is in fact divisible by 13.
I.e. the goal is to have pattern = string.
If you are left with any non-terminal symbols, after reading all of the symbols in your string, the string doesnt belong to the language. Likewise, if you still have more symbols in your string to read, but there are no rules in the grammar allowing you to go forward, then the string does not belong to the language.
is 'true' or 'false' a valid output? – Blazer – 2012-02-23T19:09:21.800
8JavaScript (27 chars)
function f(n){return "yes"}
. This will return 'yes' for all the numbers that can be divided by 13 – ajax333221 – 2012-02-23T21:59:36.6875
"(whitespace not included)" always have been resulted in one of these two situation : a program encodes its content in whitespace, or a program written in Whitespace (programming language).
– JiminP – 2012-02-23T22:29:48.617@JiminP, there's already a challenge for that. Exploit "free whitespace"
– boothby – 2012-02-24T05:58:00.347How does the bonus work if you have no mod, no div? then just 0.8? – Teun Pronk – 2014-04-15T13:00:31.817
Do "the 6th Fibonacci number", or "the 6th prime number" count as cop-outs here? – Tal – 2014-04-16T07:32:36.120
4
Using some roundabout method of generating the number 13 for use is acceptable.
How do you determine what is "roundabout enough"? – Cruncher – 2014-04-17T15:57:52.373@Cruncher This post is two years old. Rather than ask a ghost for clarification, why don't you just submit an edit to make it clearer? – Rainbolt – 2014-04-17T18:57:16.480
3@Rusher To be honest, I didn't notice that it was 2 years old, it just recently became active. As for your suggestion, I'd rather not ninja-change as non-OP a question with 2 pages of answers.. – Cruncher – 2014-04-17T18:59:30.167
@Cruncher - I'd totally forgotten about it too but I kept getting notifications about it. I had no idea it would suddenly become popular again. – Mr. Llama – 2014-04-17T20:51:03.600
@ajax333221 and JavaScript (26 chars)
function f(n){return "no"}
. This will return 'no' for all the numbers that can't be divided by 13 – user3459110 – 2014-04-18T09:54:27.460var o=" "; if((input%(o.length))==0){return "yes"} else {return "no"}
– user3459110 – 2014-04-18T09:57:36.577