Good day. Help please build an algorithm. There is an array of flights, below one of the flights.
2017/2018 = год 1..52 = номера недель 1..7 номера дней that is, the record 2017=> { 8=>[2, 5, 7] } means that the flight makes a flight in 2017 on the 8th week, on Tuesday, Friday and Sunday
hash = { :airline=>'U6', :flight_number=>'873', :origin=>'PEK', :destination=>'BKK', :dates=>[ { 2017=> { 8=>[2, 5, 7], 9=>[2, 5, 7], 10=>[2, 5, 7], 11=>[2, 5, 7], 12=>[1, 2, 5, 7], 13=>[2, 5, 7], 14=>[2, 5, 7], 15=>[2, 5], 27=>[2, 5, 7], 28=>[2, 5, 7], 29=>[2, 5, 7], 30=>[2, 5, 7], 31=>[2, 5, 7], 32=>[2, 5, 7], 33=>[2, 5, 7], 34=>[2, 5, 7], 35=>[2], 49=>[5, 7], 50=>[2, 5, 7], 51=>[2, 5, 7], 52=>[2, 5, 7] } }, { 2018=>{ 1=>[2, 5, 7], 2=>[2, 5, 7], 3=>[2, 5, 7], 4=>[2, 5, 7], 5=>[2, 5, 7], 6=>[2, 5, 7], 7=>[2, 5, 7], 8=>[2, 5, 7], 9=>[2, 5, 7], 10=>[2, 5, 7], 11=>[2, 5, 7], 12=>[2, 5] } } ] } I can not think of an algorithm, how to decompose the hash into four periods
U6 873 PEK BKK -2--5-7 2017/02/21 - 2017/04/14 (- 8..15 недели) U6 873 PEK BKK 1------ 2017/03/20 - 2017/03/20 (- 12 неделя) U6 873 PEK BKK -2--5-7 2017/07/04 - 2017/08/29 (- 27..35 недели) U6 873 PEK BKK -2--5-7 2017/12/08 - 2018/03/23 (- 49..52..1..12 недели)