takeda64
BAN USERI computed myself and it came to 20 (value in parenthesis is what the if statement be like for the specific process, if not provided the fork is after the if statement):
- First part: parent(FF), child(TF), child(TT), child (this effectively multiplies next part by 4)
- Second part: parent(FF), child(TF), child, child(FT), child -> 5 processes
4*5 = 20
After seeing your solution and that it had 3 votes I started doubting myself but I then just compiled the code and run and it showed the message 20 times as well.
I wonder if this would be acceptable:
import re
def is_a_word(word):
return bool(re.match(r'^(h+i+r+e+)*$', word))
This question is practically begging to use already highly optimized automata that is available pretty much in any modern language. The way the language is expressed is similar how it was done in automata theory class. It feels as interviewer wanted to hint toward this direction.
- takeda64 October 30, 2013
- First part: parent(FF), child(TF), child(TT), child (this effectively multiplies next part by 4)
- takeda64 October 30, 2013- Second part: parent(FF), child(TF), child, child(FT), child -> 5 processes
4*5 = 20