An algorithm to dynamically cut rods into various sizes and implemented using two different algorithms