From b9735ca52e80421603522f4b109e1f0745e62932 Mon Sep 17 00:00:00 2001 From: Sahil Shingate <118622202+sahilshingate01@users.noreply.github.com> Date: Thu, 2 Oct 2025 23:09:37 +0530 Subject: [PATCH 1/2] Create addBinary.py --- addBinary.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 addBinary.py diff --git a/addBinary.py b/addBinary.py new file mode 100644 index 0000000..6acc842 --- /dev/null +++ b/addBinary.py @@ -0,0 +1,10 @@ +class Solution: + def addBinary(self, a: str, b: str) -> str: + # Convert binary strings to integers, sum them, then convert back to binary + sum_decimal = int(a, 2) + int(b, 2) + return bin(sum_decimal)[2:] # bin() returns a string like '0b101', so we skip '0b' + +# Example Usage: +sol = Solution() +print(sol.addBinary("11", "1")) # Output: "100" +print(sol.addBinary("1010", "1011")) # Output: "10101" From 06cb9254e73022662ad324cff8139b0dc1450247 Mon Sep 17 00:00:00 2001 From: Sahil Shingate Date: Tue, 14 Oct 2025 20:08:46 +0530 Subject: [PATCH 2/2] random meme generator --- Javascript/SimpleMemeGenerator.js | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Javascript/SimpleMemeGenerator.js diff --git a/Javascript/SimpleMemeGenerator.js b/Javascript/SimpleMemeGenerator.js new file mode 100644 index 0000000..7c7e4cf --- /dev/null +++ b/Javascript/SimpleMemeGenerator.js @@ -0,0 +1,61 @@ +/** + * SimpleMemeGenerator: Generates a random meme caption by combining predefined top and bottom texts. + * + * This function simulates a "meme" by outputting text in a classic meme format. + */ +function generateRandomMemeCaption() { + // --- Data: Lists of common meme text components --- + const TOP_TEXTS = [ + "One does not simply", + "Brace yourselves,", + "You had one job.", + "They asked me what I do.", + "Wait, that's illegal.", + "A challenger appears." + ]; + + const BOTTOM_TEXTS = [ + "understand this code.", + "the JavaScript is coming.", + "and you failed it.", + "I said I write code.", + "I will ignore that.", + "The bug won't fix itself." + ]; + + // --- Random Selection Logic --- + + /** + * Helper function to get a random item from an array. + */ + function getRandomItem(arr) { + // Math.random() returns a float between 0 (inclusive) and 1 (exclusive). + // Multiplying by arr.length gives a number between 0 and arr.length. + // Math.floor() converts it to a solid integer index. + const randomIndex = Math.floor(Math.random() * arr.length); + return arr[randomIndex]; + } + + // 1. Get a random top text + const topText = getRandomItem(TOP_TEXTS); + + // 2. Get a random bottom text + const bottomText = getRandomItem(BOTTOM_TEXTS); + + // 3. Combine them into a classic meme format + return ` +🔥 RANDOM MEME CAPTION 🔥 + +--- TOP TEXT --- +${topText.toUpperCase()} + +--- BOTTOM TEXT --- +${bottomText.toUpperCase()} + `; +} + +// --- Example Usage --- + +console.log(generateRandomMemeCaption()); +console.log("\n" + "=".repeat(40) + "\n"); +console.log(generateRandomMemeCaption()); \ No newline at end of file