Skip to content

Crypto Square #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rabestro opened this issue May 5, 2025 · 1 comment · Fixed by #302
Closed

Crypto Square #301

rabestro opened this issue May 5, 2025 · 1 comment · Fixed by #302
Assignees
Labels
x:action/create Work on something from scratch x:module/practice-exercise Work on Practice Exercises x:status/claimed Someone is working on this issue x:type/content Work on content (e.g. exercises, concepts)

Comments

@rabestro
Copy link
Member

rabestro commented May 5, 2025

Implement for AWK track

@rabestro rabestro added x:type/content Work on content (e.g. exercises, concepts) x:module/practice-exercise Work on Practice Exercises x:action/create Work on something from scratch x:status/claimed Someone is working on this issue labels May 5, 2025
@rabestro rabestro self-assigned this May 5, 2025
@rabestro
Copy link
Member Author

rabestro commented May 5, 2025

Proposed solution:

BEGIN {
    OFS = " "
}
{
    plainText = tolower(gensub(/[^[:alnum:]]/, "", "g"))

    len = length(plainText)
    side = int(sqrt(len))
    cols = side * side < len ? side + 1 : side
    rows = side * cols < len ? side + 1 : side

    NF=0
    for (i = 0; i < rows * cols; ++i) {
        symbol = i >= len ? " " : substr(plainText, i + 1, 1)
        chunk = 1 + i % cols
        $chunk = $chunk symbol
    }
    print
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/create Work on something from scratch x:module/practice-exercise Work on Practice Exercises x:status/claimed Someone is working on this issue x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant