Skip to content
View jrg94's full-sized avatar
🏒
Watching hockey
🏒
Watching hockey

Organizations

@TheRenegadeCoder

Block or report jrg94

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Maximum 250 characters. Please don't include any personal information such as legal names or email addresses. Markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
jrg94/README.md

Welcome to My Profile!

This week's code snippet, Longest Word in Brainfuck, is brought to you by Subete and the Sample Programs repo.

[
    Source for comparing two numbers:
    https://stackoverflow.com/questions/6168584/brainfuck-compare-2-numbers-as-greater-than-or-less-than

    Source for printing memory value as number:
    https://esolangs.org/wiki/Brainfuck_algorithms#Print_value_of_cell_x_as_number_.288-bit.29

    Source for error message
    https://copy.sh/brainfuck/text.html
]
; Mem 0 = 1 (indicate no input)
+
; Mem 1 = 0 (word length)
>
; Mem 2 = 0 (max word length)
>
; Mem 3 = input; Loop while input not null
>,[
    ; Mem 5 = 1 (assume whitespace)
    >>+
    ; Mem 0 = 0 (indicate input)
    <<<<<[-]
    ; Sub 9 from Mem 3; If not zero (not tab)
    >>>---------[
        ; Dec Mem 3; If not zero (not newline)
        -[
            ; Sub 3 from Mem 3; If not zero (not carriage return)
            ---[
                ; Sub 19 from Mem 3; If not zero (not space)
                >[-]+++[            ; Mem 4 = 3
                    <------         ; Sub 6 from Mem 3
                    >-              ; Dec Mem 4
                ]
                <-                  ; Dec Mem 3
                [
                    ; Inc Mem 1 (word length)
                    <<+
                    ; Copy Mem 1 (word length) to Mem 7 and Mem 9; Mem 1 = 0
                    [
                        >>>>>>+     ; Inc Mem 7
                        >>+         ; Inc Mem 9
                        <<<<<<<<-   ; Dec Mem 1
                    ]
                    ; Copy Mem 2 (max word length) to Mem 6 and 10; Mem 2 = 0
                    >[
                        >>>>+       ; Inc Mem 6
                        >>>>+       ; Inc Mem 10
                        <<<<<<<<-   ; Dec Mem 2
                    ]
                    ; Mem 3 = 0
                    >[-]
                    ; Mem 4 = 1
                    >+
                    ; Mem 5 = 0
                    >-
                    ; Mem 8 = 0
                    >>>[-]
                    ; If Mem 6 (max word length) less than Mem 7 (word length);
                    ; pointer is 6; Mem 6 is 0; Mem 7 is word length minus max word length;
                    ; else pointer is 5; Mem 5 is 0; Mem 6 is max word length minus word length
                    <+<+[->-[>]<<]
                    ; If less than
                    <<[
                        ; Increment Mem 10 (max word length)
                        >>>>>>+
                        ; Move pointer to Mem 3
                        <<<<<<<
                    ]
                    ; Mem 6 = 0
                    >>>[-]
                    ; Mem 7 = 0
                    >[-]
                    ; Copy Mem 9 (word length) back to Mem 1; Mem 9 = 0
                    >>[
                        <<<<<<<<+   ; Inc Mem 1
                        >>>>>>>>-   ; Dec Mem 9
                    ]
                    ; Copy Mem 10 (max word length) back to Mem 2; Mem 10 = 0
                    >[
                        <<<<<<<<+   ; Inc Mem 2
                        >>>>>>>>-   ; Dec Mem 10
                    ]
                    ; Set pointer to Mem 3
                    <<<<<<<
                ]
            ]
        ]
    ]

    ; If Mem 5 not zero (whitespace)
    >>[
        ; Mem 1 = 0 (word length)
        <<<<[-]

        ; Mem 5 = 0
        >>>>[-]
    ]
    ; Mem 4 = 0
    <[-]
    ; Mem 3 = input
    <,
]
; If Mem 2 (max word length) not zero
<[
    ; Display it as a number
    >>++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-
    <+>]>+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++
    <]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]<
    ; Clear it
    [-]
]
; If no input; display error message
<<[
    [-]
    -[--->+<]>.
    +[--->+<]>+.
    ++[->+++<]>++.
    ++++++.
    --.
    +++[->+++<]>++.
    [-->+<]>+++.
    [-->+++++++<]>.
    ----.
    -------.
    ----.
    --[--->+<]>--.
    ++++[->+++<]>.
    --[--->+<]>-.
    [-->+++++++<]>.
    ++.
    ---.
    +++++++.
    [------>+<]>.
    -----.
    +.
    --[--->+<]>-.
    [->+++<]>+.
    -[->+++<]>.
    ---[->++++<]>-.
    +.
    --.
    ---------.
    +++++.
    -------.
    [-]
]

Below you'll find an up-to-date list of articles by me on The Renegade Coder. For ease of browsing, emojis let you know the article category (i.e., blog: ✒️, code: 💻, meta: 💭, teach: 🍎)

Also, here are some fun links you can use to support my work.

An image of @jrg94's Holopin badges, which is a link to view their full Holopin profile


This document was automatically rendered on 2025-12-05 using SnakeMD.

Pinned Loading

  1. TheRenegadeCoder/sample-programs TheRenegadeCoder/sample-programs Public

    Sample Programs in Every Programming Language

    BASIC 621 631

  2. TheRenegadeCoder/how-to-python-code TheRenegadeCoder/how-to-python-code Public

    A collection of Jupyter Notebooks from the How to Python series

    Jupyter Notebook 87 30

  3. TheRenegadeCoder/SnakeMD TheRenegadeCoder/SnakeMD Public

    A markdown generation library for Python.

    Python 47 11

  4. TheRenegadeCoder/image-titler TheRenegadeCoder/image-titler Public

    An image title generator using The Renegade Coder style

    Python 17 6

  5. JuxtaMIDI JuxtaMIDI Public

    Pinpointing Mistakes in MIDI Practice Recordings

    JavaScript 16 2

  6. Orpheus Orpheus Public archive

    An adventure game with a focus on 3D audio

    Python 4