import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static List<String> solve(int protonsStart, int neutronsStart, int protonsTarget, int neutronsTarget){
        System.err.println("Start : " + protonsStart + " " + neutronsStart);
        System.err.println("Target : " + protonsTarget + " " + neutronsTarget);
        
        ArrayList<String> list = new ArrayList<>();
        while (protonsStart!=protonsTarget || neutronsStart!=neutronsTarget){
                if(protonsTarget>protonsStart){
                    list.add("PROTON");
                    protonsStart+=1;
                    System.err.println("Current : " + protonsStart + " " + neutronsStart);
                }
                if(neutronsTarget>neutronsStart){
                    list.add("NEUTRON");
                    neutronsStart+=1;
                    System.err.println("Current : " + protonsStart + " " + neutronsStart);
                }
                if(protonsStart>protonsTarget || neutronsStart>neutronsTarget){
                    list.add("ALPHA");
                    protonsStart-=2;
                    neutronsStart-=2;
                    System.err.println("Current : " + protonsStart + " " + neutronsStart);
                }
        }
        return list;
    }
    
    public static void main(String[] args) {
        //System.out.println(solve(9,7,2,8));
        System.out.println(solve(9,7, 14,12));
        
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: