Alloy Interview Question

One medium difficulty HackerRank question