Skip to content

Instantly share code, notes, and snippets.

View victoraldecoa's full-sized avatar

Victor Maia Aldecoa victoraldecoa

View GitHub Profile
@victoraldecoa
victoraldecoa / PriorityQueue.cs
Created September 11, 2021 13:33
C# PriorityQueue that allows repeated values implemented using SortedDictionary.
public class PriorityQueue<T>
{
readonly SortedDictionary<T, int> dict;
public PriorityQueue()
{
dict = new SortedDictionary<T, int>();
}
public PriorityQueue(IComparer<T> comparer)
@victoraldecoa
victoraldecoa / core.clj
Last active January 12, 2021 17:18
Walk Tutorial
(ns walk-tutorial.core
(:require [clojure.pprint :as p]
[clojure.walk :as w]))
; estamos recebendo como input um mapa com strings ao invés de symbols
; como chaves
(def tree-map {"a" {"b" {"d" 4
"e" 5}
"c" 3}
"f" 6})
@victoraldecoa
victoraldecoa / DailyMission.cs
Created December 13, 2016 00:47
Daily Weapon algorithm
_currentDailyWeapon = _possibleWeapons[0];
foreach( var weapon in _possibleWeapons)
{
if(weapon.HardCurrencyCost.HasValue && _currentDailyWeapon.HardCurrencyCost.HasValue)
{
if( weapon.HardCurrencyCost.Value < _currentDailyWeapon.HardCurrencyCost.Value)
_currentDailyWeapon = weapon;
}
else if(weapon.SoftCurrencyCost.HasValue && _currentDailyWeapon.SoftCurrencyCost.HasValue)
{
#pragma mark - wtf apple section
// instead of relying on SKPaymentTransactionState, use isTransactionRestore and isTransactionPurchase
- (BOOL)isTransactionRestore:(SKPaymentTransaction *)transaction {
BOOL purchasedButStillRestore = [self isPurchaseButStillRestoreTransaction:transaction];
return (transaction.transactionState == SKPaymentTransactionStateRestored) || purchasedButStillRestore;
}
- (BOOL)isTransactionPurchase:(SKPaymentTransaction *)transaction {