An algorithm, implemented in C, that puts words from a unique sorted
list into a new order that maximizes the sum of the absolute shifts from
the original positions of the words.
Am 31.03.2026 um 23:33 schrieb DFS:
An algorithm, implemented in C, that puts words from a unique sorted
list into a new order that maximizes the sum of the absolute shifts
from the original positions of the words.
Just rotate the sorted list bei 50% ?
I haven't written any code yet, so it might be too easy or too hard or
too nonsense or too time-consuming (it took me a couple hours just
writing this up).
Let me know what you think.
-----------------------
Objective
-----------------------
An algorithm, implemented in C, that puts words from a unique sorted
list into a new order that maximizes the sum of the absolute shifts from
the original positions of the words.
---------------It looks like maybe that should be in the output, but maybe it's just
Example N = 10
------------------------------------------------------------------------- Initial Rand Abs Reverse Abs Rotate by 1...
Words Address Algo Shift Sort Shift Pos Shift
------------------------------------------------------------------------- aaaaa 0 4 4 9 9 9 9
bbbbb 1 9 8 8 7 0 1
-----------------------
Challenge requirements
-----------------------
1) 0-based positioning
2) N = count of unique words
If you read this far, can you think of any real-world usage for it?
On 31/03/2026 22:33, DFS wrote:
I haven't written any code yet, so it might be too easy or too hard orI think it's pretty hard, solutions could be slow like a bubble-sort for
too nonsense or too time-consuming (it took me a couple hours just
writing this up).
Let me know what you think.
an (relatively) easy solution or fast (if possible) for a difficult one.
-----------------------I think this should have "subject to additional constraints as described
Objective
-----------------------
An algorithm, implemented in C, that puts words from a unique sorted
list into a new order that maximizes the sum of the absolute shifts from
the original positions of the words.
in the requirements list below" to set an excited mind steady enough to
take it all in before finding strategies.
---------------It looks like maybe that should be in the output, but maybe it's just
Example N = 10
the title of the example output.
-------------------------------------------------------------------------...
Initial Rand Abs Reverse Abs Rotate by 1
Words Address Algo Shift Sort Shift Pos Shift
-------------------------------------------------------------------------
aaaaa 0 4 4 9 9 9 9
bbbbb 1 9 8 8 7 0 1
-----------------------If that's/not/ in the output then it's confusing to be in a
Challenge requirements
-----------------------
1) 0-based positioning
2) N = count of unique words
requirements section:
- perhaps I have to define a nonconforming variable called 'N' instead
of 'n'! Not what I want to do if I know C, and
- perhaps, also, it has to have external linkage, otherwise it's not
really there at all; something doesn't add up.
If you read this far, can you think of any real-world usage for it?Perhaps storage planning for fissile materials?
- to prevent problems in that area when working on the Manhatten
Project, nuclear physicist Richard Feynmann insisted the factory
designers be told what they were working so they would get it right. I
think that factory is where nuclear secrets leaked to the USSR so they
got the bomb. Mr. Feynmann talks about both events gleefully in his
hilarious "Los Alamos From Below" recording but doesn't seem to note the coincidence. Perhaps if he'd had an enthusiastic coder working with a language just difficult enough to seem like an end in itself that could
have been prevented.
use it to promote my greatness and general superiority > my opinionof my greatness and general superiority
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,113 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 492402:20:21 |
| Calls: | 14,249 |
| Files: | 186,315 |
| D/L today: |
84 files (21,992K bytes) |
| Messages: | 2,515,139 |