This paper presents a framework for automatically discovering new algorithms by representing algorithms as sequences of operation tokens and using ensemble Monte Carlo tree search (MCTS) guided by reinforcement learning. The framework uses a grammar to link tokens to form increasingly sophisticated procedures and generate new tokens. As a result, we rediscover, improve, and generate novel algorithms that outperform existing methods on strongly NP-hard combinatorial optimization problems and fundamental quantum computing approaches such as Grover's algorithm and quantum approximate optimization algorithms. We operate at the computational level rather than the code generation level, generating algorithms that are specifically tailored to problem instances.