Is it possible to make an electromagnet with two like ends?

Is it possible to create an electromagnet with one continuous wire with 2 like poles (i.e. both ends either north or south)?.

Visualising it with the right hand screw rule for current carrying coils, it will be like the picture below, but one end of the coil will be as shown, while the other end of the electromagnet will be coiled in the other direction as dictated by the right hand screw rule pointing to the right, to give both extreme ends North, with 2 South pole ends in the middle.

Right now in my head it seems possible to create this kind of electromagnet, given that i can find a way to keep the coils from messing up when a current passes through it.

Is this actually possible? What are some complications that you may foresee or ways to make it work if it can't?

• If you want, you can take two bar magnets and push their south poles very hard towards each other. Assuming that you're strong enough to overcome the magnetic repulsion between them, you then end up with an object that has one north pole at each end, but a double south pole on the middle. (It might help trying to draw the field lines of this configuration). The case with electromagnets should behave the same as two bar magnets pushed together like this; they repel each other violently, but yes, they do have one north pole sticking out at each end, and a double south pole at the interface. – jabirali Mar 4 '15 at 2:39