Skip to content

Commit

Permalink
Merge pull request 7oSkaaa#1008 from NouraAlgohary/main
Browse files Browse the repository at this point in the history
add day 27 challenge
  • Loading branch information
aboelsooud committed Apr 28, 2023
2 parents 4fa3539 + 03f1976 commit 2be1c02
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 2be1c02

Please sign in to comment.