Skip to content

Instantly share code, notes, and snippets.

View ahangarha's full-sized avatar
🎯

Mostafa Ahangarha ahangarha

🎯
View GitHub Profile
@ahangarha
ahangarha / comsSame.rb
Created May 24, 2022 07:58
DSA - Are they the "same"?
def comp(array1, array2)
return false if array1.nil? || array2.nil?
hash1 = {}
hash2 = {}
array1.each do |a|
hash1[a] = hash1[a].nil? ? 1 : hash1[a] + 1
end
array2.each do |a|
/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var twoSum = function(nums, target) {
for (let i = 0; i < nums.length; i++) {
const firstNumber = nums[i];
const secondNumberIndex = nums.slice(i+1).indexOf(target - firstNumber) + i + 1;
@ahangarha
ahangarha / rowSumOddNumbers.js
Created May 19, 2022 07:30
rowSumOddNumbers
// https://www.codewars.com/kata/55fd2d567d94ac3bc9000064/solutions/javascript
function rowSumOddNumbers(n) {
return n ** 3;
}
@ahangarha
ahangarha / minimum_distances.rb
Created May 10, 2022 07:34
Minimum Distances - Ruby - HackerRank
#!/bin/ruby
require 'json'
require 'stringio'
#
# Complete the 'minimumDistances' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER_ARRAY a as parameter.
// == EXAMPLE 1 ====================================
const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse', 'Lion', 'Dragon'];
// Print all pets
console.log(pets[0]);
console.log(pets[1]);
console.log(pets[2]);
console.log(pets[3]);
//...
// == EXAMPLE 2 ====================================
@ahangarha
ahangarha / afghanistan-rough.geojson
Created April 16, 2021 09:17
A Rough Boundry for Afghanistan
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahangarha
ahangarha / yoast-seo-sitemap.php
Created January 31, 2019 19:57 — forked from mohandere/yoast-seo-sitemap.php
Wordpress yoast seo plugin, generate custom sitemap for custom URLS
<?php
/**
* Create a new custom yoast seo sitemap
*/
add_filter( 'wpseo_sitemap_index', 'ex_add_sitemap_custom_items' );
add_action( 'init', 'init_wpseo_do_sitemap_actions' );
// Add custom index
@ahangarha
ahangarha / designer.html
Last active August 29, 2015 14:16
designer
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../topeka-elements/category-icons.html">
<polymer-element name="my-element">
<template>