{"id":3658,"date":"2025-07-28T17:50:28","date_gmt":"2025-07-28T17:50:28","guid":{"rendered":"https:\/\/ma8.company\/?p=3658"},"modified":"2025-07-28T18:19:52","modified_gmt":"2025-07-28T18:19:52","slug":"87","status":"publish","type":"post","link":"https:\/\/ma8.company\/zh\/2025\/07\/28\/87\/","title":{"rendered":"Draft"},"content":{"rendered":"<pre class=\"wp-block-code\"><code>import os\n\ndef encode_message_to_coords(message: str) -&gt; list&#91;tuple&#91;int, int, str]]:\n    \"\"\"\n    Encodes a string message into a list of (x, y, character) coordinates.\n    The message is encoded sequentially, filling a conceptual grid row by row.\n    \"\"\"\n    coordinates = &#91;]\n    x, y = 0, 0\n    max_x_per_row = 50 # Arbitrary max width for visual clarity in a text file\n\n    for char in message:\n        coordinates.append((x, y, char))\n        x += 1\n        if x &gt;= max_x_per_row:\n            x = 0\n            y += 1\n    return coordinates\n\ndef save_coords_to_file(coordinates: list&#91;tuple&#91;int, int, str]], filename: str):\n    \"\"\"\n    Saves the list of coordinates to a text file, one coordinate per line.\n    \"\"\"\n    try:\n        with open(filename, 'w') as f:\n            for x, y, char in coordinates:\n                f.write(f\"{x} {y} {char}\\n\")\n        print(f\"Coordinates saved to {filename}\")\n    except IOError as e:\n        print(f\"Error saving coordinates to file: {e}\")\n        raise\n\ndef load_coords_from_file(filename: str) -&gt; list&#91;tuple&#91;int, int, str]]:\n    \"\"\"\n    Loads coordinates from a text file. Each line should be in the format 'x y char'.\n    \"\"\"\n    coordinates = &#91;]\n    try:\n        with open(filename, 'r') as f:\n            for line in f:\n                parts = line.strip().split(maxsplit=2) # maxsplit=2 to handle multi-word chars if needed, though here it's single char\n                if len(parts) == 3:\n                    try:\n                        x = int(parts&#91;0])\n                        y = int(parts&#91;1])\n                        char = parts&#91;2]\n                        coordinates.append((x, y, char))\n                    except ValueError:\n                        print(f\"Skipping malformed line (non-integer coordinates): {line.strip()}\")\n                else:\n                    print(f\"Skipping malformed line (incorrect parts count): {line.strip()}\")\n    except FileNotFoundError:\n        print(f\"Error: File '{filename}' not found.\")\n        raise\n    except IOError as e:\n        print(f\"Error reading file '{filename}': {e}\")\n        raise\n    return coordinates\n\ndef build_grid(coordinates: list&#91;tuple&#91;int, int, str]]) -&gt; list&#91;list&#91;str]]:\n    \"\"\"\n    Reconstructs a 2D grid from a list of (x, y, character) coordinates.\n    The grid will be sized to fit all characters.\n    \"\"\"\n    if not coordinates:\n        return &#91;]\n\n    max_x = 0\n    max_y = 0\n    for x, y, _ in coordinates:\n        if x &gt; max_x:\n            max_x = x\n        if y &gt; max_y:\n            max_y = y\n\n    # Initialize grid with spaces\n    grid = &#91;&#91;' ' for _ in range(max_x + 1)] for _ in range(max_y + 1)]\n\n    # Place characters on the grid\n    for x, y, char in coordinates:\n        if 0 &lt;= y &lt;= max_y and 0 &lt;= x &lt;= max_x: # Ensure coordinates are within bounds\n            grid&#91;y]&#91;x] = char\n        else:\n            print(f\"Warning: Coordinate ({x},{y}) out of calculated grid bounds. Skipping character '{char}'.\")\n    return grid\n\ndef decode_grid_to_message(grid: list&#91;list&#91;str]]) -&gt; str:\n    \"\"\"\n    Decodes the characters from the grid back into a sequential message.\n    It reads row by row, then column by column, collecting non-space characters.\n    \"\"\"\n    if not grid:\n        return \"\"\n\n    message_chars = &#91;]\n    # Assuming the message was encoded sequentially, reading row by row, column by column\n    # will reconstruct it in order.\n    for row in grid:\n        for char in row:\n            if char != ' ': # Only collect actual characters, ignore padding spaces\n                message_chars.append(char)\n    return \"\".join(message_chars)\n\ndef print_grid_to_console(grid: list&#91;list&#91;str]]):\n    \"\"\"\n    Prints the grid to the console.\n    \"\"\"\n    if not grid:\n        print(\"Empty grid.\")\n        return\n    for row in grid:\n        print(''.join(row))\n\n# Example Usage (for testing the script directly)\nif __name__ == \"__main__\":\n    # --- Encoding Example ---\n    secret_policy_message = \"This is a highly confidential corporate policy directive. Unauthorized disclosure is strictly prohibited. All personnel must adhere to these guidelines by 2025-08-01.\"\n    print(\"--- Encoding Message ---\")\n    print(f\"Original Message:\\n{secret_policy_message}\\n\")\n    encoded_coords = encode_message_to_coords(secret_policy_message)\n    print(f\"Encoded Coordinates (first 5):\\n{encoded_coords&#91;:5]}...\\n\")\n\n    # Save to a temporary file\n    temp_encoded_filename = \"encoded_policy_document.txt\"\n    try:\n        save_coords_to_file(encoded_coords, temp_encoded_filename)\n    except Exception as e:\n        print(f\"Failed to save encoded file: {e}\")\n        exit()\n\n    # --- Decoding Example ---\n    print(\"\\n--- Decoding Message from File ---\")\n    try:\n        loaded_coords = load_coords_from_file(temp_encoded_filename)\n        reconstructed_grid = build_grid(loaded_coords)\n        print(\"\\nReconstructed Grid (visual):\")\n        print_grid_to_console(reconstructed_grid)\n\n        decoded_message = decode_grid_to_message(reconstructed_grid)\n        print(f\"\\nDecoded Message:\\n{decoded_message}\")\n\n        # Verification\n        if decoded_message == secret_policy_message:\n            print(\"\\nDecoding successful: Original message matches decoded message!\")\n        else:\n            print(\"\\nDecoding failed: Messages do NOT match.\")\n\n    except Exception as e:\n        print(f\"Failed to decode file: {e}\")\n\n    finally:\n        # Clean up temporary file\n        if os.path.exists(temp_encoded_filename):\n            os.remove(temp_encoded_filename)\n            print(f\"\\nCleaned up temporary file: {temp_encoded_filename}\")\n\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"724\" height=\"1024\" src=\"https:\/\/i0.wp.com\/ma8.company\/wp-content\/uploads\/2025\/07\/draft.87-1-pdf.jpg?resize=724%2C1024&#038;ssl=1\" alt=\"\" class=\"wp-image-3661\"\/><\/figure>","protected":false},"excerpt":{"rendered":"","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[155],"tags":[],"class_list":["post-3658","post","type-post","status-publish","format-standard","hentry","category-peer-review"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Draft - MA8<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Draft - MA8\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ma8.company\/zh\/2025\/07\/28\/87\/\" \/>\n<meta property=\"og:site_name\" content=\"MA8\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-28T17:50:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-28T18:19:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ma8.company\/wp-content\/uploads\/2025\/07\/draft.87-1-pdf-724x1024.jpg\" \/>\n<meta name=\"author\" content=\"Michael A\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael A\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/\"},\"author\":{\"name\":\"Michael A\",\"@id\":\"https:\\\/\\\/ma8.company\\\/#\\\/schema\\\/person\\\/25da7298f1b7d13962c39b33f3ff9c4b\"},\"headline\":\"Draft\",\"datePublished\":\"2025-07-28T17:50:28+00:00\",\"dateModified\":\"2025-07-28T18:19:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/\"},\"wordCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ma8.company\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/draft.87-1-pdf-724x1024.jpg\",\"articleSection\":[\"Peer Review\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/\",\"url\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/\",\"name\":\"Draft - MA8\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ma8.company\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/draft.87-1-pdf-724x1024.jpg\",\"datePublished\":\"2025-07-28T17:50:28+00:00\",\"dateModified\":\"2025-07-28T18:19:52+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/#\\\/schema\\\/person\\\/25da7298f1b7d13962c39b33f3ff9c4b\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/#primaryimage\",\"url\":\"https:\\\/\\\/ma8.company\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/draft.87-1-pdf-724x1024.jpg\",\"contentUrl\":\"https:\\\/\\\/ma8.company\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/draft.87-1-pdf-724x1024.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ma8.company\\\/2025\\\/07\\\/28\\\/87\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ma8.company\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Draft\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ma8.company\\\/#website\",\"url\":\"https:\\\/\\\/ma8.company\\\/\",\"name\":\"MA8\",\"description\":\"The Software and Architecture division of M\u00c6c.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ma8.company\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ma8.company\\\/#\\\/schema\\\/person\\\/25da7298f1b7d13962c39b33f3ff9c4b\",\"name\":\"Michael A\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7cb1a0a50eaf429de1d63245436c06f33f9a6770060682aa45b254d27b0b9602?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7cb1a0a50eaf429de1d63245436c06f33f9a6770060682aa45b254d27b0b9602?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7cb1a0a50eaf429de1d63245436c06f33f9a6770060682aa45b254d27b0b9602?s=96&d=mm&r=g\",\"caption\":\"Michael A\"},\"description\":\"Head of Software and Architecture\",\"sameAs\":[\"https:\\\/\\\/ma8.company\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/michael-a-88tvu088\\\/\"],\"url\":\"https:\\\/\\\/ma8.company\\\/zh\\\/author\\\/admin-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Draft - MA8","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"zh_CN","og_type":"article","og_title":"Draft - MA8","og_url":"https:\/\/ma8.company\/zh\/2025\/07\/28\/87\/","og_site_name":"MA8","article_published_time":"2025-07-28T17:50:28+00:00","article_modified_time":"2025-07-28T18:19:52+00:00","og_image":[{"url":"https:\/\/ma8.company\/wp-content\/uploads\/2025\/07\/draft.87-1-pdf-724x1024.jpg","type":"","width":"","height":""}],"author":"Michael A","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"Michael A","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/#article","isPartOf":{"@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/"},"author":{"name":"Michael A","@id":"https:\/\/ma8.company\/#\/schema\/person\/25da7298f1b7d13962c39b33f3ff9c4b"},"headline":"Draft","datePublished":"2025-07-28T17:50:28+00:00","dateModified":"2025-07-28T18:19:52+00:00","mainEntityOfPage":{"@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/"},"wordCount":1,"image":{"@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/#primaryimage"},"thumbnailUrl":"https:\/\/ma8.company\/wp-content\/uploads\/2025\/07\/draft.87-1-pdf-724x1024.jpg","articleSection":["Peer Review"],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/","url":"https:\/\/ma8.company\/2025\/07\/28\/87\/","name":"Draft - MA8","isPartOf":{"@id":"https:\/\/ma8.company\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/#primaryimage"},"image":{"@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/#primaryimage"},"thumbnailUrl":"https:\/\/ma8.company\/wp-content\/uploads\/2025\/07\/draft.87-1-pdf-724x1024.jpg","datePublished":"2025-07-28T17:50:28+00:00","dateModified":"2025-07-28T18:19:52+00:00","author":{"@id":"https:\/\/ma8.company\/#\/schema\/person\/25da7298f1b7d13962c39b33f3ff9c4b"},"breadcrumb":{"@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ma8.company\/2025\/07\/28\/87\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/#primaryimage","url":"https:\/\/ma8.company\/wp-content\/uploads\/2025\/07\/draft.87-1-pdf-724x1024.jpg","contentUrl":"https:\/\/ma8.company\/wp-content\/uploads\/2025\/07\/draft.87-1-pdf-724x1024.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/ma8.company\/2025\/07\/28\/87\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ma8.company\/"},{"@type":"ListItem","position":2,"name":"Draft"}]},{"@type":"WebSite","@id":"https:\/\/ma8.company\/#website","url":"https:\/\/ma8.company\/","name":"MA8","description":"The Software and Architecture division of M\u00c6c.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ma8.company\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/ma8.company\/#\/schema\/person\/25da7298f1b7d13962c39b33f3ff9c4b","name":"Michael A","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/secure.gravatar.com\/avatar\/7cb1a0a50eaf429de1d63245436c06f33f9a6770060682aa45b254d27b0b9602?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7cb1a0a50eaf429de1d63245436c06f33f9a6770060682aa45b254d27b0b9602?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7cb1a0a50eaf429de1d63245436c06f33f9a6770060682aa45b254d27b0b9602?s=96&d=mm&r=g","caption":"Michael A"},"description":"Head of Software and Architecture","sameAs":["https:\/\/ma8.company","https:\/\/www.linkedin.com\/in\/michael-a-88tvu088\/"],"url":"https:\/\/ma8.company\/zh\/author\/admin-2\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/posts\/3658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/comments?post=3658"}],"version-history":[{"count":2,"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/posts\/3658\/revisions"}],"predecessor-version":[{"id":3663,"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/posts\/3658\/revisions\/3663"}],"wp:attachment":[{"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/media?parent=3658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/categories?post=3658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ma8.company\/zh\/wp-json\/wp\/v2\/tags?post=3658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}