Created
May 19, 2015 08:26
-
-
Save caryamiel/2d348802f09394918d8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| num = 0 | |
| while num < 1000 | |
| puts num +=2 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| puts "get num players" | |
| numPlayers = gets.to_i | |
| puts "get rythim number" | |
| rythimNum = gets.to_i | |
| puts "get starting point" | |
| start = gets.to_i | |
| if start == 0 | |
| repeat | |
| end | |
| array1 = (start..numPlayers).to_a | |
| until array1.length !=1 | |
| if array1.length>rythimNum | |
| a = array1.take(rythimNum-1) | |
| v = array1-[a.last] | |
| puts v | |
| else a = array1.take(rythimNum) | |
| v = array1-[a.last] | |
| numPlayers -1 | |
| puts v | |
| end | |
| until array1.length !=1 | |
| if array1.length>rythimNum | |
| b = array1.take (rythimNum-1) | |
| v = array1-[b.first] | |
| puts v | |
| else b = array1.take(rythimNum) | |
| v = array1-[b.first] | |
| puts v | |
| end | |
| end | |
| end | |
| puts v | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Pokemon | |
| def initialize(name,owner,type,level) | |
| @name = name | |
| @owner = owner | |
| @type = type | |
| @level = level | |
| puts "a pokemn is born" | |
| end | |
| def property | |
| puts @name | |
| puts @owner | |
| puts @type | |
| puts @level | |
| end | |
| end | |
| edsil= Pokemon.new("edsilosaur","raven","programmer",1000) | |
| puts edsil.property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'prime' | |
| while true do | |
| print "Enter a number: " | |
| number = gets.chomp | |
| if number == "EXIT" | |
| break | |
| elsif Prime.prime?(number.to_i) | |
| puts "#{number} is prime!" | |
| else | |
| puts "#{number} is not prime." | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| puts "input positive integer please:" | |
| number = gets.to_i | |
| if num % 1 == 0 && num % num == 0 | |
| print "prime" | |
| elseif (num % 1 == 0 ) && (num % num == 0 ) && ((num % 2 == 0) || ((num % 3 == 0 )) ) | |
| print "composite" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment