/*
tape_measure.cpp
changelog:
2000-06-29:DAV: David Cary <d.cary at ieee.org> started.

*/

#include <iostream.h>
#include <iomanip.h>
#include <string.h>


// assume that there is currently a 1:1 correspondence
// between bits and sensors.
// move sensors to right until there is again a 1:1 correspondence.
// The bits on the tape measure are assumed to be just
// slightly wider than the separation between the sensors,
// such that when moving the sensors to the right,
// the first thing that happens is that the leftmost
// sensor begins seeing the left edge of the next-to-leftmost sensor.
// Assume that the bits are narrow enough that over the
// entire sensor head, at most 1 of the tape bits
// is seen by 2 sensors.
// Then the next-to-leftmost sensor jumps to seeing the next bit to right ...
// ... until the rightmost sensor jumps to seeing a
// never-seen-before bit of the single-track tape measure.
// Then there is again a 1:1 correspondence
// between bits and sensors, and this routine exits.
void
go_to_next_bit( int n, char * bitstring ){

	char sensed_bits[n];
	//    ( dest, source, size );
	strncpy( sensed_bits, bitstring, n );

	for(int i=0; i<n; i++){
		cout << i;
		cout << sensed_bits << "\n";
		sensed_bits[i] = bitstring[i+1];
	};

}


void
print_tape_measure_sequence( int n, char * bitstring ){

	cout << " using bitstring: [" << bitstring << "]\n";
	cout << " using " << n << "sensors\n";

	go_to_next_bit( n, bitstring );

};

int
main(void){

	print_tape_measure_sequence( 4, "1001");


}





