A Step Chart for a Price That Changes Suddenly
A wholesaler's price for one line holds steady for weeks at a time, then jumps. Charting the price history with sloping lines between the entries would suggest it drifted from one level to the next, which it never did, so the history is drawn as flat runs with vertical jumps between them. The note under the chart says how many times the price actually moved: every entry that differs from the entry immediately before it counts as one move, whether it went up or down, and an entry equal to the one before it is not a move at all.
Task: Print how many times the price moved.
Input
The first line holds an integer n, the number of price entries. Each of the next n lines holds one price, in date order.
Output
One line holding the count of moves, as a plain integer.
Example:
Input:
4
10
10
15
15
Output:
1
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in