Skip to content

Instantly share code, notes, and snippets.

@jadon1979
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save jadon1979/b47feeebc5c31048d6d1 to your computer and use it in GitHub Desktop.

Select an option

Save jadon1979/b47feeebc5c31048d6d1 to your computer and use it in GitHub Desktop.
Simple number generator for kid's math worksheets
def get_problems(total, max)
1.upto(total).map { |i| num_swap(rand(1..max), rand(1..max)) }
end
def num_swap(a, b)
return [a, b] if a > b
a = a+b
b = a-b
a = a-b
[a, b]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment