Skip to content

Instantly share code, notes, and snippets.

View Acesmndr's full-sized avatar
🃏
Let's put a smile on that face!

Aashish Manandhar Acesmndr

🃏
Let's put a smile on that face!
View GitHub Profile
def wins_rock_scissors_paper(player: str, opponent: str) -> bool:
# Normalize the casing of the input strings
player = player.lower()
opponent = opponent.lower()
# Define the winning conditions
winning_conditions = {
"rock": "scissors",
"paper": "rock",
"scissors": "paper"
@Acesmndr
Acesmndr / PythagorianTriplet.js
Created September 19, 2018 11:10
WCC W05::C01 Pythagorean triplet
for(let c = 500; c > 0; c--) {
let b = c - 1;
for(; b > 0; b--) {
let a = b - 1;
for(; a > 0; a--) {
if (((a**2 + b**2) === c**2) && (a + b + c === 1000)){
console.log(`The Pythagorian Triplets are ${a}, ${b} and ${c}.`);
break;
}
}
@Acesmndr
Acesmndr / PythagorianTriplet.js
Created September 19, 2018 11:10
WCC W05::C01 Pythagorean triplet
for(let c = 500; c > 0; c--) {
let b = c - 1;
for(; b > 0; b--) {
let a = b - 1;
for(; a > 0; a--) {
if (((a**2 + b**2) === c**2) && (a + b + c === 1000)){
console.log(`The Pythagorian Triplets are ${a}, ${b} and ${c}.`);
break;
}
}
@Acesmndr
Acesmndr / async.js
Created January 6, 2018 08:39
AJAX with callbacks and promises
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; // importing xmlhttprequest package because node doesn't support it out of the box
const superHeroes = ['Batman', 'Superman', 'WonderWoman', 'Flash', 'Cyborg', 'Aquaman', 'Green Lantern', 'Martian Manhunter']; // an array of request params
const completedFetchingData = () => { // function to be called when all ajax requests complete.
console.log('Just completed fetching the data');
}
const failedFetchingData = () => { // function to be called when data fetching fails
console.log('Failed to fetch the data');
}
const ajaxRequestWithPromise = (param) => {
@Acesmndr
Acesmndr / instagramunfollowers.js
Last active October 19, 2024 10:34
Get Instagram Unfollowers: Get a list of people whom you follow but who do not follow you back on Instagram as well as the list of people who follow you but whom you don't follow back!
// Gist by [email protected] Rev 2.1.2 May 15, 2019
// go to your insta profile page (not the home page). It looks something like this: https://instagram.com/YOUR_PROFILE
// Open javascript console "Ctrl + Shift + i" in Windows/Linux and "Cmd + option + i" in Mac.
// Paste the entire code below to the console and hit enter
// You will get the list of people whom you follow but who don't follow you back and viceversa as well as the entire list of followers and following
var following = [],
followers = [],
followersCount = 0,
followingCount = 0,