Skip to content

Instantly share code, notes, and snippets.

@johnislarry
johnislarry / gist:7510944
Created November 17, 2013 08:45
wtf is hashcode
// hashCode() generation :
//
// Possibilities:
// * MD5Digest of {obj,stwRandom}
// * CRC32 of {obj,stwRandom} or any linear-feedback shift register function.
// * A DES- or AES-style SBox[] mechanism
// * One of the Phi-based schemes, such as:
// 2654435761 = 2^32 * Phi (golden ratio)
// HashCodeValue = ((uintptr_t(obj) >> 3) * 2654435761) ^ GVars.stwRandom ;
// * A variation of Marsaglia's shift-xor RNG scheme.
'use strict';
function swiftney_impl(nums, expr, goal) {
if (goal === eval(expr) && nums.length === 0) {
console.log(`${expr} = ${goal}`);
}
if (nums.length > 0) {
const num = nums[0];
['+', '-', '*', '/'].forEach(op => swiftney_impl(nums.slice(1), `(${expr}${op}${num})`, goal));
}
<!DOCTYPE html>
<html class="client-nojs" lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<title>Commands/weather – Minecraft Wiki</title>
<script>document.documentElement.className="client-js";RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"a6e000fee3d9f9493f71f0a7fa507d46","wgCSPNonce":false,"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Commands/weather","wgTitle":"Commands/weather","wgCurRevisionId":2302442,"wgRevisionId":2302442,"wgArticleId":90444,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Commands"],"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Commands/weather","wgRelevantArticleId":90444,"wgIsProbablyEditable":false,"wgRel