-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethodLockdown.rb
More file actions
44 lines (32 loc) · 789 Bytes
/
methodLockdown.rb
File metadata and controls
44 lines (32 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
=begin
Source: Codewars
Difficulty: 4 kyu
Title: Method Lockdown
Description
You're a kata author trying to prevent code warriors from using Ruby's
built in random number generators because you want them to implement their own.
Prevent the usage of random number generators by preventing calls to rand and
srand in both the Kernel module and the Random class. Also prevent sneaky types
from using sample and shuffle on arrays to get random numbers.
The test will require calls to these methods to throw an error.
=end
class << Kernel
undef rand
undef srand
end
module Kernel
undef rand
undef srand
end
class Random
undef rand
undef srand rescue nil
end
class << Random
undef rand
undef srand
end
class Array
undef sample
undef shuffle
end