Skip to content

Instantly share code, notes, and snippets.

@ConorOBrien-Foxx
Last active May 2, 2022 02:13
Show Gist options
  • Save ConorOBrien-Foxx/29b06e6b0a047fbc46ce521b158870b9 to your computer and use it in GitHub Desktop.
Save ConorOBrien-Foxx/29b06e6b0a047fbc46ce521b158870b9 to your computer and use it in GitHub Desktop.
C++ just lets you do this
#include <iostream>
#include <vector>
class ElectronBurner {
public:
std::vector<int> stack { 0 };
size_t size() { return stack.size(); }
ElectronBurner& operator++() {
if(size() < 1) return *this;
++stack.back();
return *this;
}
ElectronBurner& operator--() {
if(size() < 1) return *this;
--stack.back();
return *this;
}
ElectronBurner& operator-() {
stack.push_back(0);
return *this;
}
ElectronBurner& operator+() {
if(size() < 2) return *this;
int b = stack.back();
stack.pop_back();
int a = stack.back();
stack.pop_back();
stack.push_back(a + b);
return *this;
}
ElectronBurner& operator!() {
if(size() < 1) return *this;
std::cout << (char) stack.back();
return *this;
}
ElectronBurner& operator*() {
if(size() < 2) return *this;
int b = stack.back();
stack.pop_back();
int a = stack.back();
stack.pop_back();
stack.push_back(a * b);
return *this;
}
ElectronBurner& operator&() {
if(size() < 1) return *this;
stack.push_back(stack.back());
return *this;
}
ElectronBurner& operator~() {
if(size() < 2) return *this;
std::swap(stack[size() - 1], stack[size() - 2]);
return *this;
}
};
int main() {
!+*-+!*++++++-++~!*& & &*++++++&++++-!+**--&--&-- -!++++++!~!+ ++*++++++&++++-+!~!+**++& &++++-&**&*& &++++-!+!!+!+--*++&++++++++++-!*++&++&++++++++&++++++ElectronBurner();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment