These are chat archives for camperbot/bonfire-no-repeats-please

23rd
Sep 2015
Rob
@BobsHub
Sep 23 2015 00:25
greetings folks
I'm trying to go through this paper in inclusion-exclusion http://www.trentu.ca/academic/math/bz/460-pie.pdf

`
permAlone('abracadabra') -> 1480320
[aaaaa][bb][rr][c][d]

a1 -> property where all a's are together
a2 -> property where all b's are together
a3 -> property where all r's are together

N(a1'a2'a3') = N - [ N(a1) + N(a2) + N(a3) ] + [ N(a1a2) + N(a1a3) + N(a2a3) ] + [ (-1)^3 * N(a1a2a3) ]

= 11!/(5!2!2!) - 7!5!/(2!2!) - 210!2!/5!2! + 26!5!2!/(5!2!) + 9!2!2!/5! - 5!5!2!2!

= 83160 - 151200 - 60480 + 172800 + 12096 - 57600
= -1224 distinct words
-1224 5!2!*2! = -587520 ???

I'm screwing up badly somewhere.
`

Chad Schmidt
@TheHexorcist
Sep 23 2015 01:17
@BobsHub i used brute force on this one. Is there an equation that works for this?
Rob
@BobsHub
Sep 23 2015 01:18
Hi Hex. I can do it for simpler strings like aa... and aabb... there is an equation for

This is the only requirement for the bonfire tests:
any string length with only 1 group of 2 characters
aa...
len! - 2 * (len-1)!

any string length with only 2 groups of 2 characters each
aabb...
len! - 4 (len-2)! (len-2)

Chad Schmidt
@TheHexorcist
Sep 23 2015 01:21
@BobsHub it doesnt work for the longer strings?
Rob
@BobsHub
Sep 23 2015 01:22
yes longer strings, but groups of 2 letters each
I learned to do simple ones like this
``````for groups of only 2:
wwxxyyzz
4P0 * 8! / 2^4
- 4P1 * 7! / 2^3
+ 4P2 * 6! / 2^2
- 4P3 * 5! / 2^1
+ 4P4 * 5! / 2^0
= 864 distinct words
864 * 2^4 = 13824 permutations``````
Chad Schmidt
@TheHexorcist
Sep 23 2015 01:24
I generated all the permutation then subtracted out the ones with repeates
Brute force
Rob
@BobsHub
Sep 23 2015 01:25
Ya, for now that's the only way I can do it too
permAlone("abracadabra") crashes my browers hehe
Chad Schmidt
@TheHexorcist
Sep 23 2015 01:26
ouch
Well good luck im gonna stick with brute force for now
Rob
@BobsHub
Sep 23 2015 01:29
lol thx, I dont think I have the head for that advanced math, I'm trying
CamperBot
@camperbot
Sep 23 2015 01:29
if you want to thank someone, put an @ before their name!