赞 | 15 |
VIP | 0 |
好人卡 | 0 |
积分 | 19 |
经验 | 16801 |
最后登录 | 2024-7-10 |
在线时间 | 403 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1939
- 在线时间
- 403 小时
- 注册时间
- 2015-8-30
- 帖子
- 395
|
本帖最后由 有丘直方 于 2016-7-21 17:11 编辑
- =begin
- <<=============================================>>
- << [随意闲聊] 大家来亮出自己的脑洞做一个长数组 >>
- <<=============================================>>
- 就是用某种方法让ruby输出一个[1,2,3,...,100]的数组。
- 注意请不要用诸如
- ary = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
- p(ary)
- 的非常没用的方法。
- =end
- #------------------------------------------------
- # 有丘直方
- #------------------------------------------------
- str = "def a; " * 100
- for i in 1...100
- str += "#{101 - i}; end; "
- end
- str += "#{1} ;end"
- eval(str)
- ary = eval("[" + "a, " * 99 + "a]")
- p(ary)
- #------------------------------------------------
- # 英顺的马甲
- #------------------------------------------------
- print "[%s]" % 100.times.to_a.map{|i|i+1}.join(", ")
- #~ print("[%s]" % 100.times.to_a.map { |i| i+1 }.join(", ") + "/n")
- #------------------------------------------------
- # 英顺的马甲
- #------------------------------------------------
- a=0;p Array.new(100).map{a+=1}
- #~ a = 0
- #~ p(Array.new(100).map { a += 1 })
- #------------------------------------------------
- # 英顺的马甲
- #------------------------------------------------
- p "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]" # 没说不让这样啊
- #~ print("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]") # 太耍赖。
- #------------------------------------------------
- # 英顺的马甲
- #------------------------------------------------
- p [a=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1, a+=1]
- #~ # 太耍赖。
- #------------------------------------------------
- # 英顺的马甲
- #------------------------------------------------
- $a[$i||=0] = $i+=1 while ($a||=[]).size < 100; p $a
- #~ $a[$i || = 0] = $i += 1 while ($a || = []).size < 100
- #~ p($a)
- #------------------------------------------------
- # 英顺的马甲
- #------------------------------------------------
- i=0;print "[";print "%d, " % i+=1 while i < 100;print "%d]" % i
- #~ i = 0
- #~ print("[")
- #~ print("%d, " % i += 1) while i < 100
- #~ print("%d]" % i)
- #------------------------------------------------
- # 喵呜喵5
- #------------------------------------------------
- p (1..100).to_a
- #------------------------------------------------
- # 喵呜喵5
- #------------------------------------------------
- p Array.new(100){|i| i+1}
- #~ p(Array.new(100) { |i| i + 1 })
- #------------------------------------------------
- # 喵呜喵5
- #------------------------------------------------
- p [].tap{|a| a << a.size+1 until a.size == 100}
- #~ p([].tap { |a| a << a.size + 1 until a.size == 100 })
- #------------------------------------------------
- # 余烬之中
- #------------------------------------------------
- def func(n, a = [])
- n.zero? ? a : func(n-1,a.push(n))
- end
- func(100).reverse
- #~ def func(n, a = [])
- #~ n.zero? ? a : func(n - 1, a.push(n))
- #~ end
- #~ p(func(100).reverse)
- #------------------------------------------------
- # 余烬之中
- #------------------------------------------------
- func = ->(n = 0) { -> { n += 1 } }.call
- 100.times.collect { func.call }
- # 或者 Array.new(100) { func.call }
- #~ func = -> (n = 0) { -> { n += 1 } }.call
- #~ p(100.times.collect { func.call })
- #~ p(Array.new(100) { func.call })
- #------------------------------------------------
- # iisnow
- #------------------------------------------------
- ary = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1].reverse
- #~ p([100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1].reverse) # 太耍赖。
- #------------------------------------------------
- # taroxd
- #------------------------------------------------
- [*1..100]
- [*1.upto(100)]
- #~ p([*1..100])
- #~ p([*1.upto(100)])
- #------------------------------------------------
- # taroxd
- #------------------------------------------------
- p << .chomp.split(' ').map(&:length)
-
-
- #~ # 各位要获取这条代码的,注意把空格复制全啊。
- #~ "p << .chomp.split(' ').map(&:length)\n" + (1..100).map{|i| ' ' * i}.join(?\s) + "\n \n" # 寒冷魔王
- #------------------------------------------------
- # 英顺的马甲
- #------------------------------------------------
- p "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/QEFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaW1xdXl9gYWJjZA==".unpack('m0').first.unpack('C*')
- #~ # 这……算耍赖吗?
- #------------------------------------------------
- # 有丘直方
- #------------------------------------------------
- str = "["
- for i in 1...100
- str += "#{i}, "
- end
- ary = eval(str + "#{100}]")
- p(ary)
- #------------------------------------------------
- # 有丘直方
- #------------------------------------------------
- p(eval("[a = 1, " + "a += 1, " * 98 + "a += 1]"))
复制代码 |
|