Skip to content

Instantly share code, notes, and snippets.

View taptapdan's full-sized avatar

Daniel Fiore taptapdan

View GitHub Profile
@taptapdan
taptapdan / coco.boulder.woods.js
Created December 26, 2015 19:32
CodeCombat: Boulder Woods Solution
// Use isPathClear to move around the randomly positioned boulders.
// Automatic pathfinding doesn't work in Boulder Woods.
loop {
var angle = Math.PI / 2 - Math.PI / 16;
while (angle >= -Math.PI / 2) {
var targetX = this.pos.x + 5 * Math.cos(angle);
var targetY = this.pos.y + 5 * Math.sin(angle);
// Use isPathClear between your current pos and the target.
targetPos = { x: targetX, y: targetY };
@taptapdan
taptapdan / coco.backwoods.treasure.js
Created January 1, 2016 18:40
CodeCombat: Backwoods Treasure Solution
// Returns Best Coin to Move Toward
this.bestCoin = function() {
var bestCoin = null;
var coinRank = 0;
var coins = this.findItems();
for (var i=0; i < coins.length; i++) {
if ( coins[i].value / this.distanceTo(coins[i]) > coinRank ) {
coinRank = coins[i].value / this.distanceTo(coins[i]);
bestCoin = coins[i];
@taptapdan
taptapdan / coco.black.diamond.js
Created January 1, 2016 19:11
CodeCombat: Black Diamond Solution
// track positions for safe route back to center
var positionStack = [];
// track last target, to determine changes
var lastTarget = { x: 40, y: 34 };
loop {
var gem = this.findNearest(this.findItems());
if (gem) {
@taptapdan
taptapdan / coco.binary.search.js
Last active January 1, 2016 23:41
CodeCombat: Binary Search Solution
// http://codecombat.com/play/level/binary-search
// Guess the number that the paladin is thinking of each round.
// She will indicate whether the answer is a higher or lower number after each guess.
// She moves to x<39.5 if lower and x>40.5 if higher
// and x==40 if correct.
// The paladin's maxNum property is the upper bound of the number.
var paladin = this.findNearest(this.findFriends());
@taptapdan
taptapdan / wordpress.hide.profile.photo.js
Created January 4, 2016 18:33
Wordpress: jQuery to Hide Google Profile Avatars Ad Link on Profile Page
$("table.form-table td:contains('Google Profile Avatars')").hide();
@taptapdan
taptapdan / coco.hunting.party.js
Created January 17, 2016 19:27
CodeCombat: Hunting Party Solution
// http://codecombat.com/play/level/hunting-party
// Strategy: move all troops continuously to the right,
// making sure to keep the archers behind the frontline
// so that the soldiers take the enemy attacks. Player
// character follows along the front line and heals
// any soldier/archer that is below max health.
var front = [ 30, 30, 30 ]; // Frontline for Groups
@taptapdan
taptapdan / coco.the.bane.of.soldiers.js
Created January 17, 2016 21:07
CodeCombat: The Bane of Soldiers Solution
// http://codecombat.com/play/level/the-bane-of-soldiers
// Robobombs explode when they die or touch an enemy.
// Split up your soldiers so that they don't all get exploded together.
while (true) {
var friends = this.findFriends();
var enemies = this.findEnemies();
var targets = [];
@taptapdan
taptapdan / coco.ring.bearer.js
Created January 18, 2016 17:15
CodeCombat: Ring Bearer Solution
// http://codecombat.com/play/level/ring-bearer
// You must escort a powerful magical ring back to town to be studied.
// The goal is to escape, not fight. More ogres lurk in the surrounding mountains!
// Make a circle of soldiers around the peasant!
// We give you two functions to help with this:
// findSoldierOffset figures out the position a soldier should stand at in relation to the peasant.
// The first argument 'soldiers' should be an array of your soldiers.
// The second argument 'i' is the index of the soldier (in soldiers) you want to find the position for.
@taptapdan
taptapdan / JavaScript.babel-node.sublime-build
Last active July 30, 2016 17:27
Sublime Text 3: JavaScript Builds
// Babel ES6
// ~/Library/Application Support/Sublime Text 3/Packages/User/JavaScript.sublime-build
{
"cmd": ["/Users/fiore/.nvm/versions/node/v6.2.1/bin/babel-node", "$file"],
"selector": "source.js"
}
@taptapdan
taptapdan / safe-words.results.txt
Last active March 29, 2017 21:15
Safe Word Combination Results
Checking for bad word combinations...
There are 14 words in fruits.
There are 39 words in animals.
There are 19 words in colors.
There are 72 total words in the pool.
There are 5112 unique word combinations.
####
apple mango: apple mango soda; someone with the initials A.M. with the "soda" added on to camoflauge the true meaning.
variation: hawaiian apple mango.