From a0fefa018c61806becd81ed791fb09da28115752 Mon Sep 17 00:00:00 2001 From: Noura Algohary Date: Fri, 28 Apr 2023 01:01:30 +0300 Subject: [PATCH 1/2] add day 27 challenge --- .../27- Bulb Switcher (Noura Algohary).cpp | 12 ++++++++++++ .../27- Bulb Switcher (Noura Algohary).py | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).cpp create mode 100644 04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).py diff --git a/04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).cpp b/04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).cpp new file mode 100644 index 000000000..961cb34c3 --- /dev/null +++ b/04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).cpp @@ -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); + } +}; \ No newline at end of file diff --git a/04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).py b/04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).py new file mode 100644 index 000000000..effb9854e --- /dev/null +++ b/04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).py @@ -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) + \ No newline at end of file From 03f1976041788310ddb1e87b6f2a3c549c1d1d7a Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Fri, 28 Apr 2023 01:11:02 +0000 Subject: [PATCH 2/2] Add new daily problem --- .github/data/problems.json | 4 ++++ 04- April/28- Similar String Groups/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/28- Similar String Groups/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index a867e1ce9..ada23e045 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -473,6 +473,10 @@ { "day": "27", "title": "Bulb Switcher" + }, + { + "day": "28", + "title": "Similar String Groups" } ] } \ No newline at end of file diff --git a/04- April/28- Similar String Groups/.gitkeep b/04- April/28- Similar String Groups/.gitkeep new file mode 100644 index 000000000..e69de29bb