Skip to content

The solutions #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 205 additions & 0 deletions last2_solutions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
6.
def overlap(rectangle_1, rectangle_2)
if (rectangle_2 [1][1] < rectangle_1 [0][0]) ||
(rectangle_1 [1][0] < rectangle_2 [0][1])
false
else
true
end
end

overlap()



7.# table for the game, it was an awry paste from the text edit. I keyed in the players again on the right.the table depicts player 10 saying '100'. see the code below.


players
10
9
8
1
2
3
4
5
6
7
count players



'1' 1
'2' 2
'3' 3
'4' 4
'5' 5
'6' 6
'7' 7


'14' 9
'13' 8
'12' 1
- 2
'11' 3
'10' 4
'9' 5
'8' 6




'15' 8
'16' 1
'17' 2
'18' 3
'19' 4
'20' 5
'21' 6


'28' 10
'27' 9
'26' 8
'25' 1
'24' 2
'23' 3
- 4
'22' 5




'29' 9
'30' 8
'31' 1
'32' 2
'33' 3
- 4
'34' 5
'35' 6



'42' 9
'41' 8
'40' 1
'39' 2
'38' 3
'37' 4
'36' 5





'43' 8
'44' 1
- 2
'45' 3
'46' 4
'47' 5
'48' 6
'49' 7


'56' 9
- 8
'55' 1
'54' 2
'53' 3
'52' 4
'51' 5
'50' 6




'57' 8
'58' 1
'59' 2
'60' 3
'61' 4
'62' 5
'63' 6


'70' 10
'69' 9
'68' 8
'67' 1
- 2
66' 3
'65' 4
'64'




'71' 9
'72' 8
'73' 1
'74' 2
'75' 3
'76' 4
'77' 5



'83' '84' 10
'82' 9
'81' 8
'80' 1
'79' 2
'78' 3
- 4





'85' 9
'86' 8
'87' 1
'88' 2
- 3
'89' 4
'90' 5
'91' 6



'98' 9
'97' 8
'96' 1
'95' 2
'94' 3
'93' 4
'92' 5





'99' 8
"100" 1




def counting_game(players, counting)
while players <= 10 && counting <= 100 do
players += 1
counting += 1
if counting % 7 == 0
player -= 1
elsif counting % 11 == 0
next
end
end
end



43 changes: 43 additions & 0 deletions ruby_solutions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
1.
def power(base, exponent)
result = 1
exponent.times do result *= base
end
result
end


2.
def factorial(number)
if number == 0
else
number * factorial(number - 1)
end
end

3.
def unique(array)
response = Array.new
array.each do |element|
response << element unless response.include?(element)
end
response
end



4.
def combinations(array_a, array_b)
a.product(b).map do |a| a[0] + a[1]
end
end



5.
require 'prime'

def prime?(number)
number.prime?
end