Skip to content

Instantly share code, notes, and snippets.

Ali Ghanavatian thg303

Block or report user

Report or block thg303

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thg303
thg303 / gist:ea5ff438ead0bbf0a87dfe7ebb8896b0
Last active Nov 4, 2019 — forked from ebraminio/gist:5292017
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go
View gist:ea5ff438ead0bbf0a87dfe7ebb8896b0
// Check Iranian National Code Validity - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، روبی، جاوااسکریپت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست http://www.fardanews.com/fa/news/127747
/**
* @author Ebrahim Byagowi (2013-)
* @lincense: Public Domain
*/
View stack example - bracket match
let input = '[{}]'
let input2 = '[[{}]()]'
let input3 = '[{})[]'
function isOk (inputString) {
let arr = inputString.split('');
let stack = []
for (let i = 0; i < arr.length; i++) {
View Queue example - traverse graph
// graph image https://imagebin.ca/v/4fEWnt6XNraD
// 11. Breadth first search and queue [udemy easy to advanced data structure]
class Node {
constructor (value = null) {
this.value = value;
this.neighbours = []
}
setNeighbours (neighbours) {
View implement MinHeap - priority list
class MinHeap {
constructor() {
this.data = [];
}
add (item) {
let newData = [...this.data, item];
// it's the first item in the heap
if (this.data.length === 0) {
return this.data = newData;
You can’t perform that action at this time.