So for the last couple of months I've been busy making a simple (and unfortunately slow) interpreted programming language called Cotton. Today, I was able to compress its entire source code into a single file and solve an atcoder problem using a small program in Cotton written in a huge interpreter in C++.
Why you need this information? You don't. I just wanted to share my excitement with someone.
The program in Cotton:
arr = make(Array)
.resize(read(Integer))
.apply(function(x){x=read(Integer);});
target = arr.copy().sort(function(a,b){a>b;})[1];
// don't have a function that would return element's position yet
for i = 0; i < arr.size(); i++; {
if arr[i] == target; {
println(i + 1);
return;
}
}
If you want to look at the beautiful obfuscated code of the interpreter, it's available here
That is pretty cool. It kind of looks like Rust with all those methods.
btw, is it faster or slower than Python?