• Nov 19, 2022 •CodeCatch
0 likes • 1 view
// There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9. // You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where: // The first character of the ith pair denotes the ith ring's color ('R', 'G', 'B'). // The second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9'). // For example, "R3G2B1" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1. // Return the number of rods that have all three colors of rings on them. let rings = "B0B6G0R6R0R6G9"; var countPoints = function(rings) { let sum = 0; // Always 10 Rods for (let i = 0; i < 10; i++) { if (rings.includes(`B${i}`) && rings.includes(`G${i}`) && rings.includes(`R${i}`)) { sum+=1; } } return sum; }; console.log(countPoints(rings));
• Sep 13, 2023 •C S
0 likes • 11 views
/** * @param {number[]} nums * @return {number[]} */ var productExceptSelf = function(nums) { var output = []; var leftMult = 1; var rightMult = 1; for (var i=nums.length - 1; i >= 0; i--) { output[i] = rightMult; rightMult *= nums[i]; console.log({output: JSON.stringify(output), i}) } for (var j=0; j < nums.length; j++) { output[j] *= leftMult; leftMult *= nums[j]; console.log({output: JSON.stringify(output), j}) } return output; }; console.log(productExceptSelf([1, 2, 3, 4]))
• Jan 26, 2023 •AustinLeath
0 likes • 5 views
function printHeap(heap, index, level) { if (index >= heap.length) { return; } console.log(" ".repeat(level) + heap[index]); printHeap(heap, 2 * index + 1, level + 1); printHeap(heap, 2 * index + 2, level + 1); } //You can call this function by passing in the heap array and the index of the root node, which is typically 0, and level = 0. let heap = [3, 8, 7, 15, 17, 30, 35, 2, 4, 5, 9]; printHeap(heap,0,0)
• Jan 25, 2023 •C S
0 likes • 21 views
const ResponsiveCardImg = styled(Card.Img)` // For screens wider than 768px @media(min-width: 768px) { // Your responsive styles here. } // For screens smaller than 768px @media(max-width: 768px) { // Your responsive styles here. } ` export default function App() { return ( <MainContainer> <Container> <Card text='white' bg='dark' style={styles.mainCard}> <ResponsiveCardImg style={styles.cardImage} onClick={handleClick} src={apeImage} alt='Degenerate Ape Academy' /> <Card.Body> <Card.Title className='text-center' as='h2'> {apeId} </Card.Title> </Card.Body> </Card> </Container> </MainContainer> ); }
• Oct 29, 2020 •LeifMessinger
0 likes • 2 views
questions = Array.from(document.querySelectorAll(".multiple-choice-question")); async function hackRadio(question){ if(question.querySelector(".question-chevron").getAttribute("aria-label") == "Question completed") return; let answerChoices = question.querySelectorAll(".zb-radio-button"); async function guess(answerChoice){ answerChoice.querySelector("label").click(); } let pause = 0; for(let answerChoice of answerChoices){ setTimeout(()=>{guess(answerChoice)},pause); //No need to check given that it will record the correct answer anyways. pause += 1000; } } for(let question of questions){ hackRadio(question); } questions = Array.from(document.querySelectorAll(".short-answer-question")); async function hackShortAnswer(question){ if(question.querySelector(".question-chevron").getAttribute("aria-label") == "Question completed") return; question.querySelector("textarea").value = question.querySelector(".forfeit-answer").textContent; //question.querySelector(".check-button").click(); They are smart bastards } for(let question of questions){ const showAnswerButton = question.querySelector(".show-answer-button"); showAnswerButton.click(); showAnswerButton.click(); hackShortAnswer(question); }
• Apr 26, 2025 •hasnaoui1
console.log("xa")