
Gyro Zeppeli is a Jojo character who utilizes "Golden ratio" to fight enemies. "Golden ratio" is the ratio you get when you divide a number in a Fibonacci sequence, Fn+1/Fn for n = infinity. The ratio is 1.618.
Given N commands and K length, you are asked to implement a list of numbers and generators that get manipulated by N commands and output the first K numbers.
The list's element is either:
Given this code:
Implement:
limited Fibonacci sequence generator to the list at the given index.value to the list at the given index.index.comparison and the value given.
For example, in sample input two:
10 10, means we are given 10 commands, and 10 numbers to output
fib 0 100, means push the first 100 Fibonacci generator to index 0. Your list now should look like this: [fib(0 to 100)]
push 1 10, means push the integer 10 to index 1. Your list now should look like this: [fib(0 to 100), 10]
push 0 15, means push the integer 15 to index 0. Your list now should look like this: [15, fib(0 to 100), 10]
push 0 150, means push the integer 150 to index 0. Your list now should look like this: [150, 15, fib(0 to 100), 10]
pop 1, means remove the index 1. Your list now should look like this: [150, fib(0 to 100), 10]
filter higher 20, means filter everything in your list only to remain every number that is higher than 20. Your list now should look like this: [150, filter(fib_gen(0 to 100, higher than 20))]
fib 0 15, means push the first 15 Fibonacci generator to index 0. Your list now should look like this: [fib(0 to 15), 150, filter(fib(0 to 100, higher than 20))]
filter lower 100, means filter everything in your list only to remain every number that is lower than 100. Your list now should look like this: [filter(fib(0 to 15), lower than 100), filter(filter(fib(0 to 100, higher than 20)), lower than 100)]
pop 0, means remove the index 0. Your list now should look like this: [filter(filter(fib(0 to 100, higher than 20)), lower than 100)]
push 0 100, means push the integer 100 to index 0. Your list now should look like this: [100, filter(filter(fib(0 to 100, higher than 20)), lower than 100)]
Therefore, your first 10 numbers should be 100, 34, 55, 89
The first line is 2 integers, N and K, where:
N = the number of commandsK = the number of numbers you have to output. (generator is not a number)The next N line will be either of these commands, in this format:
fib index limitpush index valuepop indexfilter comparison valuecomparison is either lower | higherindex is never out of bounds.limit <= 5000value is an integer>Note: lower is < and higher is > (not equal to)
Output K number from the list starting from the front.
If K > len(list), output len(list) numbers.