The reason the circuit from wikipedia isn't working is because the provided phase gates are turning clockwise instead of counter-clockwise (e.g. -45 degrees instead of +45 degrees). The circuit on Wikipedia (and probably the text book too) is using an R_(pi/2) gate, but you have an R_(-pi/2) gate.
There are several ways to deal with the issue:
- Simulate the +45 degree gate using a Z (-180), -90, and -45. Similar idea for the +90.
- Turn the circuit upside down, so the gates on wire 1 now are on wire 3 after, and vice versa.
- Move the swapping part (the last three X gates) from the end to the start
- Reverse the order of all the gates except for the three Xs at the end.
- (I think) Apply exactly three of the above.
- Probably a bunch more ways. Figuring out why each one works is interesting.
Sorry the backwards phases were confusing. (It's actually my circuit simulator, which I wrote for a blog post that includes a solution.)