@anonymous/

PrimeSomeBlock

Ruby

No description

fork
loading
Files
  • main.rb
  • linked_list.rb
  • node.rb

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.13645501334469823","path":"main.rb","file":{"path":"main.rb","content":{"asEncoding":{"base64":"cmVxdWlyZV9yZWxhdGl2ZSAiLi9ub2RlIgpyZXF1aXJlX3JlbGF0aXZlICIuL2xpbmtlZF9saXN0IgoKbjQgPSBOb2RlLm5ldyh2YWx1ZTogNSkKbjMgPSBOb2RlLm5ldyh2YWx1ZTogMywgbmV4dF9ub2RlOiBuNCkKbjIgPSBOb2RlLm5ldyh2YWx1ZTogNywgbmV4dF9ub2RlOiBuMykKbjEgPSBOb2RlLm5ldyh2YWx1ZTogNywgbmV4dF9ub2RlOiBuMikKCmxpbmtlZF9saXN0MSA9IExpbmtlZExpc3QubmV3KAogIG5vZGVzOiBbbjEsIG4yLCBuMywgbjRdCikKCnB1dHMgPDx+SEVSRURPQwogIFJvdGF0aW5nICN7bGlua2VkX2xpc3QxLnRvX3N9IGJ5IDIgcGxhY2VzLgogICAgOjogI3tsaW5rZWRfbGlzdDEucm90YXRlKDIpLnRvX3N9CiAgICAKSEVSRURPQwoKbjkgPSBOb2RlLm5ldyh2YWx1ZTogNSkKbjggPSBOb2RlLm5ldyh2YWx1ZTogNCwgbmV4dF9ub2RlOiBuOSkKbjcgPSBOb2RlLm5ldyh2YWx1ZTogMywgbmV4dF9ub2RlOiBuOCkKbjYgPSBOb2RlLm5ldyh2YWx1ZTogMiwgbmV4dF9ub2RlOiBuNykKbjUgPSBOb2RlLm5ldyh2YWx1ZTogMSwgbmV4dF9ub2RlOiBuNikKCmxpbmtlZF9saXN0MiA9IExpbmtlZExpc3QubmV3KAogIG5vZGVzOiBbbjUsIG42LCBuNywgbjgsIG45XQopCgpwdXRzIDw8fkhFUkVET0MKICBSb3RhdGluZyAje2xpbmtlZF9saXN0Mi50b19zfSBieSAzIHBsYWNlcy4KICAgIDo6ICN7bGlua2VkX2xpc3QyLnJvdGF0ZSgzKS50b19zfQpIRVJFRE9D"},"asBuffer":null},"loaded":true}}
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
require_relative "./node"
require_relative "./linked_list"

n4 = Node.new(value: 5)
n3 = Node.new(value: 3, next_node: n4)
n2 = Node.new(value: 7, next_node: n3)
n1 = Node.new(value: 7, next_node: n2)

linked_list1 = LinkedList.new(
  nodes: [n1, n2, n3, n4]
)

puts <<~HEREDOC
  Rotating #{linked_list1.to_s} by 2 places.
    :: #{linked_list1.rotate(2).to_s}
    
HEREDOC

n9 = Node.new(value: 5)
n8 = Node.new(value: 4, next_node: n9)
n7 = Node.new(value: 3, next_node: n8)
n6 = Node.new(value: 2, next_node: n7)
n5 = Node.new(value: 1, next_node: n6)

linked_list2 = LinkedList.new(
  nodes: [n5, n6, n7, n8, n9]
)

puts <<~HEREDOC
  Rotating #{linked_list2.to_s} by 3 places.
    :: #{linked_list2.rotate(3).to_s}
HEREDOC
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]