Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippon-extreme-startup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
François SARRADIN
ippon-extreme-startup
Commits
7aa7d1dd
Commit
7aa7d1dd
authored
7 years ago
by
François Sarradin
Committed by
François Sarradin
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add geometry questions + regex correction + review point distribution
parent
28f15d77
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/extreme_startup/question_factory.rb
+103
-9
103 additions, 9 deletions
lib/extreme_startup/question_factory.rb
with
103 additions
and
9 deletions
lib/extreme_startup/question_factory.rb
+
103
−
9
View file @
7aa7d1dd
# encoding: utf-8
require
'set'
require
'prime'
...
...
@@ -154,6 +156,90 @@ module ExtremeStartup
end
end
class
RectangleIntersectionQuestion
<
GetQuestion
def
initialize
(
player
,
*
numbers
)
if
numbers
.
any?
@x1
,
@y1
,
@w1
,
@h1
,
@x2
,
@y2
,
@w2
,
@h2
=
*
numbers
else
@x1
,
@y1
,
@w1
,
@h1
=
rand
(
100
),
rand
(
100
),
rand
(
100
),
rand
(
100
)
@x2
,
@y2
,
@w2
,
@h2
=
rand
(
100
),
rand
(
100
),
rand
(
100
),
rand
(
100
)
end
end
def
as_text
"give the intersection of those rectangles (x0,y0,width,height): (
#{
@x1
}
,
#{
@y1
}
,
#{
@w1
}
,
#{
@h1
}
) x (
#{
@x2
}
,
#{
@y2
}
,
#{
@w2
}
,
#{
@h2
}
)"
end
def
answered_correctly?
(
answer
)
correct_answer
.
to_s
.
downcase
.
gsub
(
/[ \\t\\r\\n]+/
,
''
)
==
answer
.
gsub
(
/[ \\t\\r\\n]+/
,
''
)
end
def
points
50
end
private
def
correct_answer
_x1
=
@x1
+
@w1
_y1
=
@y1
+
@h1
_x2
=
@x2
+
@w2
_y2
=
@y2
+
@w2
x
=
[
@x1
,
@x2
].
max
y
=
[
@y1
,
@y2
].
max
_x
=
[
_x1
,
_x2
].
min
_y
=
[
_y1
,
_y2
].
min
w
=
_x
-
x
h
=
_y
-
y
if
(
w
>=
0
)
and
(
h
>=
0
)
"(
#{
x
}
,
#{
y
}
,
#{
w
}
,
#{
h
}
)"
else
""
end
end
end
class
RectangleUnionQuestion
<
GetQuestion
def
initialize
(
player
,
*
numbers
)
if
numbers
.
any?
@x1
,
@y1
,
@w1
,
@h1
,
@x2
,
@y2
,
@w2
,
@h2
=
*
numbers
else
@x1
,
@y1
,
@w1
,
@h1
=
rand
(
100
),
rand
(
100
),
rand
(
100
),
rand
(
100
)
@x2
,
@y2
,
@w2
,
@h2
=
rand
(
100
),
rand
(
100
),
rand
(
100
),
rand
(
100
)
end
end
def
as_text
"give the union of those rectangles (x0,y0,width,height): (
#{
@x1
}
,
#{
@y1
}
,
#{
@w1
}
,
#{
@h1
}
) + (
#{
@x2
}
,
#{
@y2
}
,
#{
@w2
}
,
#{
@h2
}
)"
end
def
answered_correctly?
(
answer
)
correct_answer
.
to_s
.
downcase
.
gsub
(
/[ \\t\\r\\n]+/
,
''
)
==
answer
.
gsub
(
/[ \\t\\r\\n]+/
,
''
)
end
def
points
50
end
private
def
correct_answer
_x1
=
@x1
+
@w1
_y1
=
@y1
+
@h1
_x2
=
@x2
+
@w2
_y2
=
@y2
+
@w2
x
=
[
@x1
,
@x2
].
min
y
=
[
@y1
,
@y2
].
min
_x
=
[
_x1
,
_x2
].
max
_y
=
[
_y1
,
_y2
].
max
w
=
_x
-
x
h
=
_y
-
y
"(
#{
x
}
,
#{
y
}
,
#{
w
}
,
#{
h
}
)"
end
end
class
ListQuestion
<
GetQuestion
def
random_numbers
randoms
=
Set
.
new
...
...
@@ -171,12 +257,8 @@ module ExtremeStartup
random_numbers
[
0
..
size
].
concat
(
candidate_numbers
.
shuffle
[
0
..
size
]).
shuffle
end
def
answer
@answer
&&
@answer
.
downcase
.
strip
.
gsub
(
/[ \\t\\r\\n]*,[ \\t\\r\\n]*/
,
','
)
end
def
answered_correctly?
(
answer
)
correct_answer
.
to_s
.
downcase
.
gsub
(
/[ \\t\\r\\n]
*,
[ \\t\\r\\n]
*
/
,
'
,
'
)
==
answer
correct_answer
.
to_s
.
downcase
.
gsub
(
/[ \\t\\r\\n]
+/
,
''
)
==
answer
.
gsub
(
/
[ \\t\\r\\n]
+
/
,
''
)
end
end
...
...
@@ -212,6 +294,10 @@ module ExtremeStartup
def
as_text
"give the sum of elements in: "
+
@numbers
.
join
(
', '
)
end
def
points
20
end
private
def
correct_answer
@numbers
.
reduce
(:
+
)
...
...
@@ -226,13 +312,17 @@ module ExtremeStartup
else
@n
=
rand
(
1000
)
size
=
rand
(
5
)
@numbers
=
generate_numbers
[
0
..
size
]
.
concat
(
candidate_numbers
.
shuffle
[
0
..
size
]).
shuffle
@numbers
=
generate_numbers
(
size
)
.
concat
(
candidate_numbers
.
shuffle
[
0
..
size
]).
shuffle
end
end
def
as_text
"multiply by
#{
@n
}
those elements: "
+
@numbers
.
join
(
', '
)
end
def
points
20
end
private
def
correct_answer
@numbers
.
map
{
|
e
|
e
*
@n
}.
join
(
','
)
...
...
@@ -255,6 +345,10 @@ module ExtremeStartup
end
"what
#{
count
}
of the Fibonacci sequence"
end
def
points
60
end
private
def
fibonacci
(
n
)
a
,
b
=
0
,
1
...
...
@@ -453,11 +547,11 @@ module ExtremeStartup
class
<<
self
def
question_bank
[
[
"who is the
Prime Minister of Great Britain"
,
"Theresa May
"
],
[
"which city is the
Eiffel t
ower in"
,
"
Paris
"
],
[
"who is the
president of France"
,
"François Hollande
"
],
[
"which city is the
Oriental Pearl T
ower in"
,
"
Shanghai
"
],
[
"what currency did Spain use before the Euro"
,
"peseta"
],
[
"what colour is a banana"
,
"yellow"
],
[
"wh
o played James Bond in
the
f
il
m Dr No"
,
"Sean Connery
"
]
[
"wh
ere does
the
k
il
ler rabbit comes from"
,
"Caerbannog
"
]
]
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment