##The Programmer's Tales: Prologue ###The Knight
Thomas Shields
There was a geek, a most distinguished man
Who from the day on which he first began
to code JS had done so elegantly -
/* | |
Copyright (c) 2011 Ivo Wetzel. | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
// solve(num) with isPrime(num) | |
// approx. time to solve for 600 trillion: several hours | |
function solve(num) { | |
var i = num - 1, result = num; | |
for(;i>1;i--) | |
{ | |
if(num%i === 0) { | |
if(isPrime(i)) | |
{ | |
result = i; |
function factor(num, index) { | |
if(!index) index = 2; | |
var lim = Math.ceil(num/2)+1, result=num; | |
if(index < lim) { | |
if(num%index === 0) { | |
return factor2(num/index); | |
} | |
result = factor(num, ++index; | |
} | |
return result; |
for(;i<nums.length;i++) { | |
var northeast = nums[i]*nums[i-(n-1)]*nums[i-2*(n-1)]*nums[i-3*(n-1)], | |
if(northeast > p) p = northeast; | |
} | |
for(;i<nums.length;i++) { | |
var north = nums[i]*nums[i-n]*nums[i-2*n]*nums[i-3*n]; | |
if(north > p) p = north; | |
} | |
for(;i<nums.length;i++) { | |
var east = nums[i]*nums[i+1]*nums[i+2]*nums[i+3]; |
var nums = [], lengths = []; | |
function findNumLength(n) { | |
//preliminary check to see if | |
//we've done this number before | |
var indexOf = nums.indexOf(n); | |
if(indexOf !== -1) { | |
return lengths[indexOf]; | |
} | |
function even (n2) { return n2%2===0; } | |
if(n===1) { |
var DATE_PRETTIFIER = { | |
date: null, | |
parse: function(input) { | |
if(input.length >= 8) { | |
var day, month, year; | |
day = parseInt(input.substring(6,8), 10); | |
month = parseInt(input.substring(4,6), 10); | |
year = parseInt(input.substring(0,4), 10); | |
this.date = new Date(year, month, day); | |
} |
var Mail = Mail || {}; | |
Mail.Message = Mail.Message || { | |
from: "", //Contact | |
subject: "", | |
date: "", | |
body: "" | |
}; | |
Mail.Contact = Mail.Contact || { | |
name: "", | |
email: "" |
var messages = document.getElementById("messages"), | |
i=0; | |
for(;i<Mail.messages.length;i++) { | |
function addSender(m, row) { | |
var cell = row.insertCell(-1); | |
Utils.traversal.setText(m.from.name, cell); | |
} | |
function addSubject(m, row) { | |
var cell = row.insertCell(-1); | |
Utils.traversal.setText(m.subject, cell); |
##The Programmer's Tales: Prologue ###The Knight
Thomas Shields
There was a geek, a most distinguished man
Who from the day on which he first began
to code JS had done so elegantly -
(function () { | |
"use strict"; | |
WinJS.Binding.optimizeBindingReferences = true; | |
var app = WinJS.Application; | |
var activation = Windows.ApplicationModel.Activation; | |
WinJS.strictProcessing(); | |
app.onactivated = function (args) { |