Let $\Sigma$ be 0,1,2. I am interested in the language of all strings $w$ such that the sum of $w$ characters (where the char 0 is treated as the number 0, the char 1 as the number 1 etc) is divideable by 5. Obviously this is a regular language, and I can also find a simple linear grammer.
My idea for a regular expression was to check all the combinations where I can receive sum zero (in modulo 5) with the digits 1 and 2 and put 0* in between. But is there no better way? Something more elegant?
Edit: My expression is $0^* 1 0^* 1 0^* 1 0^* 1 0^* 1 0^* \cup 0^* 1 0^* 1 0^* 1 0^* 2 0^* \cup 0^* 1 0^* 1 0^* 2 0^* 1 0^* \cup 0^* 1 0^* 2 0^* 1 0^* 1 0^* \cup \ldots $ and so it goes on for all the possible combination. My question is if there is a way to simplify this - Or maybe a different approach?