DEV Community

Cover image for Programmatically output lyrics on a tee-shirt
Corentin Girard
Corentin Girard

Posted on β€’ Edited on

3 3

Programmatically output lyrics on a tee-shirt

Some years ago I re-wrote the lyrics of a song as a JS script. I ordered a tee-shirt with this "art" of mine (I actually find it quite beautiful πŸ˜…).

But everytime someone looked at my tee-shirt, they would ask me if it really means or does something. I would answer "no, it doesn't work, it's just a representation".

My tee-shirt with source code art

But now, I've implemented it!

I chose C++ to be able to overload operators exactly as I wanted... My goal was to not change anything about this source code, which I designed without knowing I would implement it.

So in the main.cpp file, all I have is the following:

#include "logic.cpp"

int main()
{
    /**
     * Guess the song... 😌 😎
     */

    imagine(!heaven) == "easy";
    us.below = !hell;
    us.above = sky;
    imagineAll("living for today");

    imagine(!countries) != "hard";
    (kill || die).reasons.length == 0;
    religion = undefined;
    imagineAll("living life in peace");

    chorus(); //🎡🎢

    imagine(!possessions) ? "πŸ˜€" : "πŸ˜₯";
    need(greed || hunger) == false;
    men.reduce([]() { return "brothers"; });
    imagineAll("sharing all the world");

    chorus(); //🎡🎢
}
Enter fullscreen mode Exit fullscreen mode

All the logic is included in another file.

As you can see, the only differences are the double quotes for the string literals and the syntax of the lambda expression. Apart from that, it's the exact same thing as my tee-shirt.

Here's the output of the program, without any hardcoding:

image

Here's the repo: https://github.com/Drarig29/tee-shirt-song

So, did you guess the song?

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free β†’