The code below (source) DOES work and it outputs the lyrics (as shown in the gif below).
Nothing is hardcoded.
#include "logic.hpp"
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(); //🎵🎶
}
To run the program without compiling it, run the following:
bash <(curl -s https://drarig29.github.io/tee-shirt-song/run.sh)
If VLC is installed on your computer, the MIDI file embedded in the code will be played.
Note: On Linux, VLC requires the vlc-plugin-fluidsynth
plugin to play MIDI files (more info).
I made this translation from a song's lyrics into source code with JavaScript in mind. But to actually implement it, I had to use a lower level language to overload operators, so I chose C++.
Because I used C++, the only difference you'll see between the original source code and the C++ implementation will be the strings (with the use double quotes instead of single quotes) and the lambda function syntax.
You can make your own tee-shirt with this "art", I own one personally. If you need the SVG file, just ask me.