Mastering Numpad Inputs: A Statistical Programming Challenge
This document presents a programming challenge revolving around the analysis of numpad input statistics. With a maximum value of 15 and a mean of 49.7 for attempted inputs, the task is to calculate how long it took users to complete the input process. By utilizing suitable data types such as char, int, and arrays, participants are encouraged to simulate input handling, focusing on efficient decision-making and the accuracy of calculations. The challenge aims to sharpen programming skills while testing the understanding of basic computational formulas and data management.
Mastering Numpad Inputs: A Statistical Programming Challenge
E N D
Presentation Transcript
Numpad 30th January, 2010
Statistics • #Max = 15 • Mean (attempted) = 49.7
How long did you take? • >1hr? • 45 min? • 30 min? • 20 min? • 15 min? • 10 min? • 5 min? • 1 min?
Aim • Test your programming skills • if • for • Use of suitable data types • char • int • array • Carefulness • hardcode
Observation • Decision does not depend on future presses • ‘Causal’ • Analyzing the sequence would not help • So we can just simulate!
Skills • Reading the number • The question says ‘a positive integer N, which is less than 1030.’ • How do I know how large is the number? (When to stop input?) • while scanf()... • while cin >> • while not eoln do
Use of data types • Array • What size? • How to access an array? • What index to use? • Char • How to convert to integer? • Integer
Carefulness • If conditions • When to use the left zero / right zero? • How to determine the distance? • Formula? • Hardcode?
Formula • Steps = Steps in horizontal direction (dx) + Steps in vertical direction (dy) • dx = abs(prev % 3 – cur % 3) • dy = abs((prev-1) \ 3 – (cur-1) \ 3) • Zero is left for you to think