Instructions
Barry is a not so good backend developer in charge of a small API that should give you information about purchases made in a client's shop. However, he hasn't done a great job and your boss tells you to fix it client-side instead. Ideally you should receive comma-separated values such as 927,2,45,90
which correspond to something like item_id
,item_amount
,unit_price
,total
In this first puzzle we only care about item_id
and item_amount
but we need the other fields in place to present the problem. Barry sometimes gets things mixed up and returns noise as part of the output, he also gets the order wrong, returning noise
, noise
, unit_price
, total
, item_id
, item_amount
.
Your Task
You need to store in a map (or similar structure) the pairs of item_id
and item_amount
regardless of whether Barry returns them correctly or not and print each element in a new line in the least number of characters possible. (Storing is not mandatory, we just care about the output)
Sample input (mixed correct and messy formats)
103,2,50,100
106,1,900,900
459,40,150,300,67,2
4,20,30,6000
In other words input will be either a,b,x,x
or x,x,x,x,a,b
where what we care about is a
& b
. You need to provide code assuming we have a variable called G
(or any other name) with all the lines of csv.
Sample output
103,2
106,1
67,2 //This one was messy
4,20
Tolerance
There is a certain margin for tolerance when it comes to the answer. Answers in similar formats but adhering to the correct values, will also be accepted. Formats like [a,b]
,(a,b)
or {a,b}
are valid, but a,b
is preferred.
Although the first puzzle had mixed acceptance due to the fact that it was easy and fast to solve, I also felt that some people liked that too. So I'm going to continue making quickgolfs for now
x,x,x,x
andx,x,x,x,x,x
wherex
denotes a number? \$\endgroup\$