The 3x3 Hexa Prime Square Puzzle The 3x3 Hexa Prime Square Puzzle

Introduction

We consider 3x3 squares of hexadecimal digits (from 0 to F) such as:

2 E 3    1 F 3
8 1 5    7 2 7
D D 5    B B 9


We define a 3x3 Hexa Prime Square (HPS3) as such a square for which all hexadecimal numbers read from left to right and from top to bottom are odd primes (i.e. primes greater than 2).

This is true for the left square and false for the right square:

2 E 3 --&gt; 0x2E3 = 739       1 F 3 --&gt; 0x1F3 = 499
8 1 5 --&gt; 0x815 = 2069      7 2 7 --&gt; 0x727 = 1831
D D 5 --&gt; 0xDD5 = 3541      B B 9 --&gt; 0xBB9 = 3001
| | |                       | | |
| | +---&gt; 0x355 = 853       | | +---&gt; 0x379 = 889 = 7 x 127
| +-----&gt; 0xE1D = 3613      | +-----&gt; 0xF2B = 3883 = 11 x 353
+-------&gt; 0x28D = 653       +-------&gt; 0x17B = 379


Goal

Given a list of 9 hexadecimal digits, your goal is to find an arrangement that forms a HPS3.

Example:

Input: 123558DDE
Possible output: 2E3815DD5 (a flattened representation of the above left example)


Input / Output

Input and output formats are flexible. The only requirement is that output digits are ordered from left to right and from top to bottom. Below are some possible options:

"2E3815DD5"
[ 0x2, 0xE, 0x3, 0x8, 0x1, 0x5, 0xD, 0xD, 0x5 ]
[ "2", "E", "3", "8", "1", "5", "D", "D", "5" ]
[
  [ 0x2, 0xE, 0x3 ],
  [ 0x8, 0x1, 0x5 ],
  [ 0xD, 0xD, 0x5 ]
]
[ "2E3", "815", "DD5" ]
etc.


Using the same format for both input and output is not required.

Rules


This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.
Your algorithm must be deterministic
You can't just bogosort the array until it's valid, even in a deterministic way (by using a constant random seed).
You may list all possible solutions for a given input, but this is neither required nor subject to a bonus.
You're not required to support inputs that do not admit any solution. (It's perfectly fine if your code is looping forever or crashing in that case.)


Test cases

Input       Possible output
---------------------------
123558dde   2e3815dd5
1155578ab   a7b851551
03bddffff   ffd0dfb3f
35899beff   8f99e3bf5
15899bbdf   581bb9fd9
14667799f   6f1469779
13378bcdd   78d1cd33b
24577bbdd   7274bd5db
1118bbddd   11b18dbdd
223556cdd   623c25dd5
12557899a   8a5295971
113579bbd   5b3db7191
05AB1E, 23 21 bytes

Uses CP-1252 encoding.

œJvy3ôD€SøJìHDps2›*P—


Too slow for TIO.

Explanation

œJ                     # all permutations of input as strings
  v                    # for each permutation
                       # EXAMPLE: 2E3815DD5
   y3ô                 # split in pieces of 3
                       # EXAMPLE: ['2E3','815','DD5']
      D                # duplicate
                       # EXAMPLE: ['2E3','815','DD5'], ['2E3','815','DD5']
       €SøJ            # zip the copy to swap rows and columns 
                       # EXAMPLE: ['2E3','815','DD5'], ['28D','E1D','355']
           ì           # attach them to the same list
                       # EXAMPLE: ['2E3','815','DD5','28D','E1D','355']
            H          # convert from base 16 to base 10
                       # EXAMPLE: [739, 2069, 3541, 653, 3613, 853]
             D         # duplicate
                       # EXAMPLE: [739, 2069, 3541, 653, 3613, 853],[739, 2069, 3541, 653, 3613, 853]
              p        # check first copy for primality
                       # EXAMPLE: [739, 2069, 3541, 653, 3613, 853],[1,1,1,1,1,1]
               s2›     # check that each in second copy is larger than 2
                       # EXAMPLE: [1,1,1,1,1,1],[1,1,1,1,1,1]
                  *    # pairwise multiplication
                       # EXAMPLE: [1,1,1,1,1,1]
                   P   # product (1 if all were primes larger than 2, else 0)
                       # EXAMPLE: 1
                    —  # if 1, print y
                       # EXAMPLE: 2E3815DD5