iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 6
0
影片教學

懶人寫寫 BOT系列 第 6

Day 6

  • 分享至 

  • twitterImage
  •  

嗨,我是 Fly,用 Ruby 寫 Chatbot 並挑戰30天分享心得
為確保不會沒靈感
每日含 Ruby 解題增加內容
https://www.hackerrank.com/domains/tutorials/30-days-of-code

Day 6: Let's Review

  • gets after chomp incase \n will leave in string
  • All variable should declare first!
  • String.split('') to Array with each letter
ns = gets.to_i
ns.times do |n|
    odd = []
    even = []
    xs = gets.to_s.chomp
    xs.split('').each_with_index do |x, index|
      odd << x if index.odd?
      even << x if index.even?
    end
    print "#{even.join} #{odd.join}\n"
end

上一篇
Day 5
下一篇
Day 7
系列文
懶人寫寫 BOT30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言