summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'ruby')
-rw-r--r--ruby/conversioneBinariaDec.ru32
-rw-r--r--ruby/lswf.rb44
2 files changed, 0 insertions, 76 deletions
diff --git a/ruby/conversioneBinariaDec.ru b/ruby/conversioneBinariaDec.ru
deleted file mode 100644
index c506372..0000000
--- a/ruby/conversioneBinariaDec.ru
+++ /dev/null
@@ -1,32 +0,0 @@
-b = 32
-v = Array.new(b, 0)
-
-stringa = gets.to_s
-
-unless stringa.size > b then
- valVuoto = stringa.size
-end
-
-i = b - valVuoto
-j = 0
-
-loop do
- v[i] = stringa[j].to_i
-
- i += 1
- j += 1
-
- break unless i < b
-end
-
-i = b - 1
-j = 0
-num = 0
-
-while i > -1 do
- num += v[i] * (2 ** j)
- i -= 1
- j += 1
-end
-
-puts num/2
diff --git a/ruby/lswf.rb b/ruby/lswf.rb
deleted file mode 100644
index 236847e..0000000
--- a/ruby/lswf.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-fib = []
-fib.push 1
-fib.push 1
-
-def fibonacci(n, fib)
- for i in 2...n do
- fib.push fib[i-1] + fib[i-2]
-
- break if fib[i] > n
- end
-
- return i
-end
-
-File.open('input.txt', 'r') do |fin|
- N = fin.gets.to_i
-end
-
-fibonacci(N, fib)
-
-fib = fib.reverse
-
-somma = 0
-seq = []
-
-for i in 0...fib.length-1 do
- potSomma = somma + fib[i]
-
- if potSomma < N
- somma = potSomma
- seq << 1
- else
- seq << 0
- end
-end
-
-seq << 1
-seq = seq.reverse
-
-seq.pop if N == 1 || N > 4
-
-File.open('output.txt', 'w') do |fout|
- seq.each {|c| fout.print c}
-end