Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix solution for problem 2

  • Loading branch information...
commit 05b912241088ddd85122cb4c624c0935b554fb28 1 parent a46f7e0
Eugene Pirogov authored

Showing 1 changed file with 7 additions and 12 deletions. Show diff stats Hide diff stats

  1. +7 12 problem_2.rb
19 problem_2.rb
... ... @@ -1,17 +1,12 @@
1   -a = [1, 2]
2   -s = a[-1] + a[-2]
3   -flag = 0
4   -totag = 0
  1 +a = [1, 2]
  2 +new_value = 3
  3 +total = 2
5 4
6   -while s < 4_000_000
7   - a << s = a[-1] + a[-2]
  5 +while new_value <= 4_000_000
  6 + new_value = a.first + a.last
  7 + a = [a.last, new_value]
8 8
9   - if flag.zero?
10   - flag = 1
11   - else
12   - total += s
13   - flag = 0
14   - end
  9 + total += new_value if new_value.even?
15 10 end
16 11
17 12 puts total

0 comments on commit 05b9122

Please sign in to comment.
Something went wrong with that request. Please try again.