Skip to content

Instantly share code, notes, and snippets.

# This class knows about supported JRubyArt operating systems
class HostOS
def self.os
detect_os = RbConfig::CONFIG['host_os']
case detect_os
when /mac|darwin/ then :mac
when /gnueabihf/ then :arm
when /linux/ then :linux
when /solaris|bsd/ then :unix
else
@ShadowfeindX
ShadowfeindX / hangman.md
Created May 31, 2017 03:38
Hang Yourself

A player wins a game of hangman if they can correctly guess all the letters in a word, or the word itself, before exceeding their allotted number of incorrect guesses. Generally this number is 7 (Head, neck, body, 2 arms, and 2 legs). If the player guesses the entire word they automatically receive the maximum possible score. If they guess the word incorrectly they immediately fail.

When playing multiple games or playing competitively, the games are scored. If the player guesses the same letter more than once, they lose points but they do not suffer an incorrect guess penalty. If the player gives up before guessing the word they also fail. The maximum score is 100, the minimum score is 0, and if the player fails to correctly guess the word, or all the letters, there score would be -10.

Given the word to be guessed as a string, the number of unique characters in the word and the players guesses in order as an array of strings, determine the players score and the total amount of incorrect characters they gues

@ShadowfeindX
ShadowfeindX / math.exs
Last active May 31, 2017 03:13
Integer Pow function and Benchmark
# Following Zen
defmodule Math do
def pow(0,_), do: 0
def pow(_,0), do: 1
def pow(lhs,rhs) when rhs < 0, do: 1 / pow(lhs,-rhs)
def pow(lhs,rhs), do: 1..rh |> Enum.reduce(1, &(elem({&1, &2*lhs},1)))
end
defmodule Benchmark do
#include "canvas.hxx"
//#define SPEED
Canvas * canvas = nullptr;
Painter * scene = new Painter;
double dA = 1.0, dB = 0.5,
f = 0.055, k = 0.062;
int cols;
Starting C:\Source\GitHub\build-server-test-Desktop_Qt_5_8_0_MSVC2015_64bit-Release\release\server-test.exe...
"Serving HTTP at 127.0.0.1 on port 8000..."
"Socket has connected to the server from address 127.0.0.1 on port 63484"
"GET / HTTP/1.1\r\nHost: localhost:8000\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nDNT: 1\r\nAccept-Encoding: gzip, deflate, sdch, br\r\nAccept-Language: en-US,en;q=0.8\r\n\r\n"
"Socket %1 has been disconnected from the server"
"Socket has connected to the server from address 127.0.0.1 on port 63485"
""
"Socket %1 has been disconnected from the server"
"Socket has connected to the server from address 127.0.0.1 on port 63486"
""
const static std::vector<int> primes {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1