Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a program to solve the Tower of Hanoi problem for a hardcoded number of disks.

Hard

Problem Statement

Create a program to solve the Tower of Hanoi problem for a hardcoded number of disks.

Sample Input

Number of Disks: 3

Sample Output

Move disk 1 from A to C
Move disk 2 from A to B
Move disk 1 from C to B
Move disk 3 from A to C
Move disk 1 from B to A
Move disk 2 from B to C
Move disk 1 from A to C

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
using System; class TowerOfHanoi { static void Main() { // Solve the Tower of Hanoi problem } }
Log in or sign up to run or submit your code.Log inSign up
Input
Number of Disks: 3
Expected Output
Move disk 1 from A to C
Move disk 2 from A to B
Move disk 1 from C to B
Move disk 3 from A to C
Move disk 1 from B to A
Move disk 2 from B to C
Move disk 1 from A to C