programming
Programming shape-warrior-t 4 months ago 100%
[Personal project] AlgeZip: navigate and manipulate boolean expressions github.com

For some time now, I've been thinking about the concept of interactively manipulating mathematical expressions and equations via software. Like doing some quick algebra in Notepad or similar, except there's no potential for arithmetic/algebra errors, typos, etc. ruining any results. At the same time, I also wanted to experiment a bit with [zippers](https://en.wikipedia.org/wiki/Zipper_(data_structure)) from functional programming. You need some way of specifying what (sub)expression to perform operations on, and it seemed like this kind of data structure could help with that. And so, I made AlgeZip, a small proof-of-concept of the whole general idea. Although this polished Python version was completed only a few days ago, there were various other versions before this one in different languages and with worse-quality code. Instructions for things are on GitHub; requires Python 3.12 to run. For simplicity, I decided to use boolean expressions instead of generic numeric algebraic expressions/equations, and only decided to include the minimum in terms of commands and functionality. From my understanding, it should be possible to transform any boolean expression into any other boolean expression in AlgeZip (without using the `r!` command except to set things up), though I could be wrong. Thoughts, comments, and criticism on the idea as a whole, the program, or the source code are welcome, though I'm not sure if I'll be making any changes at this time.

12
0
challenges Programming Challenges [Easy] Bracket Simplification
Jump
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearSH
    shape-warrior-t
    1 year ago 100%

    Here's an O(n) solution using a stack instead of repeated search & replace:

    closing_to_opening = {')': '(', ']': '[', '}': '{'}
    brackets = input()
    acc = []
    for bracket in brackets:
        if bracket in closing_to_opening:
            if acc and acc[-1] == closing_to_opening[bracket]:
                acc.pop()
            else:
                acc.append(bracket)
        else:
            acc.append(bracket)
    print(''.join(acc))
    
    

    Haven't thoroughly thought the problem through (so I'm not 100% confident in the correctness of the solution), but the general intuition here is that pairs of brackets can only match up if they only have other matching pairs of brackets between them. You can deal with matching pairs of brackets on the fly simply by removing them, so there's actually no need for backtracking.

    Golfed, just for fun:

    a=[]
    [a.pop()if a and a[-1]==dict(zip(')]}','([{')).get(b)else a.append(b)for b in input()]
    print(''.join(a))
    
    
    2
  • kirby
    Kirby shape-warrior-t 1 year ago 100%
    Japanese guidebook Elfilin lore

    [This is a rewritten version of a post I made on r/Kirby 8 months ago.] One day, I came across the following passages in [Elfilin's character entry on TV Tropes (final entry under "Other Heroes")](https://tvtropes.org/pmwiki/pmwiki.php/Characters/KirbyHeroesAndSupportingCharacters): > > > Cosmic Motifs: According to the official guidebook, Elfilin's ears were designed to resemble the waxing and waning of the moon. This was meant to represent "having lost the quality of a single existence", that is, having separated from Fecto Forgo. > > > > > The Fog of Ages: According to the official guidebook, he barely has any memory of his time as a test subject in Lab Discovera anymore. > > At the time, I wasn't able to find anything else that talked about this information. At some point, I checked out this [official(? It's official enough for WiKirby.) guidebook](https://www.amazon.co.jp/dp/4047336181?tag=kadoofce-22) myself. [This is the relevant page](https://m.media-amazon.com/images/I/81y73+Wi28L.jpg) (it's also the final page in the preview). My attempt at a transcription of the relevant passages (I can't read Japanese): > > > ともに旅をしながらアドバイスをくれるカービイのパートナー。本人の記憶にはほとんど残っていないが、ID-F86の中に残されていた小さな博愛の心が分離して生まれた存在で、かつて研究者たちには"ID-F87"と呼ばれていた。再び融合することを目論むID-F86によって、とらわれの身となってしまう。 > > > > > 月の満ち欠けをイメージしてデザインされたという耳。1つの存在だったものが欠けたことが表現されている。 > > Based on machine translations, the TV Tropes descriptions seem pretty accurate. And according to a commenter on the original Reddit post, in the Kirby light novels (separate continuity from the games, so take the implications with respect to game canon with a grain of salt), Elfilin also doesn't remember Lab Discovera. So that's some not-so-new-at-this-point-but-still-not-widely-talked-about Elfilin lore for you.

    1
    0
    deltarune Deltarune The summer newsletter is out!
    Jump
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearSH
    shape-warrior-t
    1 year ago 100%

    (Attempt 2 at posting something like this, kbin was being weird last time)

    Link to a YouTube video going through the main part of the newsletter, with links to other stuff in the description: https://youtu.be/wadIR3wjDfQ

    Out-of-context picture

    4
  • deltarune Deltarune What do you think about Kris?
    Jump
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearSH
    shape-warrior-t
    1 year ago 100%

    M O S S

    They're certainly a rather interesting character. Both for the audience and, in a different way, presumably for the people in their life (Noelle and Toriel in particular).

    3
  • deltarune
    Deltarune shape-warrior-t 1 year ago 100%
    Reversing the controls for the teacup ride

    I haven't actually played Deltarune in quite a long time, but this community needs some more posts, and I'd like to do my part for that. For Deltarune's teacup rides, the left key makes you go clockwise and the right key makes you go counterclockwise. This way, when you press left/right from the starting position (bottom), you go in that direction. But I was more used to pressing left to go counterclockwise and pressing right to go clockwise, the same as the controls for Super Hexagon (and its predecessor Hexagon, which is how I got used to those controls). This way, you go left/right when you press left/right from the *top* instead of the bottom. So in my latest playthrough, I swapped the left and right controls in the settings whenever there was a teacup section. Actually made those sections quite a bit easier for me.

    10
    1