Skip to content

Commit

Permalink
add day 27 challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
NouraAlgohary committed Apr 27, 2023
1 parent 8b713a2 commit a0fefa0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Author: Noura Algohary

class Solution {
public:
int bulbSwitch(int n) {
// bulbs are counted (turned on) when it have odd number of divisors
// only numbers with perfect square roots have odd divisors
// to count the number of perfect square roots in n,
// it must be equal to sqrt(n)
return sqrt(n);
}
};
11 changes: 11 additions & 0 deletions 04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Author: Noura Algohary

class Solution:
def bulbSwitch(self, n: int) -> int:
# bulbs are counted (turned on) when it have odd number of divisors
# only numbers with perfect square roots have odd divisors
# to count the number of perfect square roots in n,
# it must be equal to sqrt(n)

return int(n ** 0.5)

0 comments on commit a0fefa0

Please sign in to comment.