# Here your code ! n,k = gets.chomp.split.map &:to_i if(n == k+2) (k-1).times do print ("#{1} ") end puts 1 end lis = [1,3,2,4,1,3,2,4] (k).times do print("1 ") end b = 0 (n-1-k).times do |i| print "#{lis[i%4]} " b = i end puts lis[(b+1)%4]