Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Javascript/SimpleMemeGenerator.js
Original file line number Diff line number Diff line change
@@ -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());
10 changes: 10 additions & 0 deletions addBinary.py
Original file line number Diff line number Diff line change
@@ -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"