You want to write your English essay. However, all characters on your keyboard broke other than the arrow keys and the enter key. You want to find out how to place the characters so you can write your essay with the least movement.
Formally, you have to assign to each character of !"$%&'()+,-./0123456789:;<=?[]`abcdefghijklmnopqrstuvwxyz⇦⇧
a unique 2D integer coordinate, and minimize \$ d = \sum_{c_1 , c_2} {\text{freq}(c_1, c_2) \text{dist}(c_1, c_2)} \$, with \$\text{dist}\$ being the Manhattan destince between the position of the characters, and \$\text{freq}\$ being the frequency of the character pair, which is described here, with the frequency of each pair not detailed assumed \$0\$. Note that some pairs appear in both permutations - you have to take into account both of them.
Scoring
The winner is the code which would produce the best result in a minute on my computer (Intel Core i7-9700 with 8 threads, 32GB RAM), with the tie breaker being the time until that result is found.
Rules
- Your language must have a freely available interpreter/compiler capable of running on Linux
- Standard loopholes are disallowed, except optimizing for the given test cases - you are allowed (and even expected) to fine-tune your solution to produce the best solution on this given test case.
- You can't hardcode calculations - the solution should be found by the code during its execution, not beforehand.
- You can use any reasonable output format (i.e. output your solution and when did you find it when your program terminates, output your solution whenever the program improves it, etc.).
- You will receive the frequency JSON in stdin.
- Your solution must be deterministic. You can use PRNGs, you just have to hardcode their seed.