Various code is available online for finding magic hexagons:

File Type Notes
magic_hexagon.mod AMPL
magic_hexagon2.mod AMPL
magic_hexagon_bp.pl B-Prolog
magic_hexagon.ecl ECLiPSe CLP
magic_hexagon.cpp Gecode
magic_hexagon.mzn MiniZinc
MagicHexagon.py Numberjack
magic_hexagon.py Numberjack Numberjack
magic_hexagon.pi Picat
magic_hexagon_sicstus.pl SICStus Prolog