GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesRobot Q-Learner

Gamified challenge · Reinforcement learning

Robot Q-Learner

A robot has nStates rooms and nActions moves. experiences[k] = [s, a, r, next] says that in room s move a earned reward r (an integer) and led to room next, or ended the episode if next = -1. Start with every Q[s][a] = 0 and replay the experiences once, in order. Q values are kept in hundredths of a point, as integers:

best = 0 if next == -1 else max(Q[next]), target = 100·r + ⌊gammaPct · best / 100⌋, then Q[s][a] += ⌊alphaPct · (target − Q[s][a]) / 100⌋, where ⌊ ⌋ rounds down (toward −∞: // in Python, Math.floorDiv in Java).

Write greedyPolicy(nStates, nActions, experiences, alphaPct, gammaPct) returning, for every room, the move with the largest Q (ties go to the lowest action, so an untouched room answers 0). Example: [[0,1,0,1],[1,1,10,-1],[0,1,0,1]] with 2 rooms, 2 moves, α = 50, γ = 90 gives Q(1,1) = 500 then Q(0,1) = 225, so the answer is [1, 1].

Sign in to play Robot Q-Learner

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account