untitled

Pasted Sep 15, 2026, 4:12 AM1 file73 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/zzgtjkzk80c76ee4
untitled
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class Solution {

    public static void printGridFromUrl(String url) throws IOException {
        // Fetch and parse the HTML document
        Document doc = Jsoup.connect(url).get();

        Element table = doc.selectFirst("table");
        if (table == null) {
            System.err.println("No table found in the provided URL.");
            return;
        }

        Elements rows = table.select("tr");

        // Map key format: "x,y" -> Character string
        Map<String, String> grid = new HashMap<>();
        int maxX = 0;
        int maxY = 0;

        // Skip the header row (index 0)
        for (int i = 1; i < rows.size(); i++) {
            Elements cells = rows.get(i).select("td, th");
            if (cells.size() < 3) {
                continue;
            }

            // Col 0: x-coordinate, Col 1: Character, Col 2: y-coordinate
            String xStr = cells.get(0).text().trim();
            String character = cells.get(1).text();
            String yStr = cells.get(2).text().trim();

            try {
                int x = Integer.parseInt(xStr);
                int y = Integer.parseInt(yStr);

                grid.put(x + "," + y, character);

                if (x > maxX) maxX = x;
                if (y > maxY) maxY = y;
            } catch (NumberFormatException e) {
                // Ignore rows with non-numeric coordinates
            }
        }

        // Print row by row: top-down (maxY to 0), left-to-right (0 to maxX)
        for (int y = maxY; y >= 0; y--) {
            StringBuilder line = new StringBuilder();
            for (int x = 0; x <= maxX; x++) {
                line.append(grid.getOrDefault(x + "," + y, " "));
            }
            System.out.println(line.toString());
        }
    }

    public static void main(String[] args) {
        String docUrl = "YOUR_PUBLISHED_DOC_URL_HERE";
        try {
            printGridFromUrl(docUrl);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

2,211 chars · codepastes.com