Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Counter Conundrum Hammy Reasoner is building a digital counter for counting spectators entering a stadium. The counter is made up of k small LED displays,
Counter Conundrum Hammy Reasoner is building a digital counter for counting spectators entering a stadium. The counter is made up of k small LED displays, each of which shows a single digit from 0 to 9 , and has logic to increment it by 1 . ( k is a fixed, given number) Each display has two connector ports: an input and an output. The input on each display is supposed to be connected to the output of the display to its right. A pulse on an input causes the display to increment its value. If a display is currently showing 9 and receives a pulse on its input, it rolls around to 0 and then emits a pulse on its output port. The display for the (intended) units position is connected to a clicker that generates a pulse every time a spectator goes through the entrance. Unfortunately Hammy was very preoccupied and had a hard time focusing on the job, and consequently ended up connecting the displays in a haphazard way. Write a program that, given the sequence in which the displays are connected and n spectator counts: s1sn, determines for each si, the value the counter will show for the si th spectator who triggers the counter. Input Format Line 1: kn:2 space separated integers Line 2: d_1 d_2 ... d_k: k space separated integers indicating the order in which the displays are connected (for each i:1dik ). (The spectator trigger pulse is connected to the first display in the list) Line 3: s_1 s_2 ... s_n: n space separated integers indicating the spectator counts at which we must report the number showing on the counter. 2k81dik3n1071si0>2). Recall that display 0 is the rightmost display and display 2 is the leftmost one (See figure below). We are asked to determine what number would be reading on the displays after the 7 th and 12 th spectators have entered. The table below indicates the digits that would show on the displays (arranged in the order that they would be read) after several increments, including for the two specific ones in which we are interested
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started