This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(problem_2). | |
-export([s/0]). | |
-define(L, 4000000). | |
s() -> s(1, 2, 0). | |
s(P, N, S) when P >= ?L; N >= ?L -> S; | |
s(P, N, S) -> S1 = case N rem 2 of 0 -> N + S; _ -> S end, s(N, P + N, S1). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(l ,ss = 4000000, proc {|p, n, s| p >= l || n >= l ? s : n.even?? ss[n, n + p, s + n] : ss[n, n + p, s] })[1][1, 2, 0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(f=->*a{a[2]+=a[1]%2==0?a[1]:0;a[0],a[1]=a[1],a[1]+a[0];a[0]>=a[3]||a[1]>=a[-1]?a[2]: f[*a]})[1,2,0,4000000] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(problem_4). | |
-export([solve/0]). | |
solve() -> | |
List = lists:seq(100, 999), | |
[H | L] = [X * Y || X <- List, | |
Y <- List, | |
integer_to_list(X * Y) =:= lists:reverse(integer_to_list(X * Y))], | |
solve(L, H). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(100..999).to_a.repeated_permutation(2).collect{|x| x[0] * x[1] if "#{x[0] * x[1]}" == "#{x[0] * x[1]}".reverse }.compact.max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* taking out the big guns, yes... size matters *) | |
open Num | |
open Printf | |
(* a throw away helper function just like pred but works with Nums, ought to give it a better name *) | |
let pred' n = Int (pred (int_of_num n)) | |
(* field test *) | |
let rec fact x = if x =/ Int 0 then Int 1 else x */ fact (pred' x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' # needed for creating tcp servers | |
require 'base64' # we'll use base64 for encoding images and embedding them in the response | |
require 'cgi' # has a lovely helper method for generating rfc1123 compliant dates for http headers | |
refresh_rate = 1 # in seconds, interval between each screen capture | |
server = TCPServer.open 3005 # start our server at port 3005 | |
# the html page template we'll be sending over to the browser | |
page_tmpl = %Q[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[email protected] | Stefanie | House | |
---|---|---|---|
[email protected] | Dinah | Erickson | |
[email protected] | Melisa | Reynolds | |
[email protected] | Lily | Carson | |
[email protected] | Millard | Rubio | |
[email protected] | Octavia | Santana | |
[email protected] | Royal | Bender | |
[email protected] | Laverne | Hutchins | |
[email protected] | Sherman | Wilder | |
[email protected] | Thelma | Burris |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
date_of_birth = Time.new(1988, 8, 31) | |
# Credit: http://stackoverflow.com/a/4136485 | |
def humanize seconds | |
[[60, :seconds], | |
[60, :minutes], | |
[24, :hours], | |
[365, :days], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fun exercise with Elixir. | |
# The joke's on arabic tech news and yes it's that bad I had to write this. | |
# That's an elixir script hence .exs so run it with | |
# > elixir kill_braincells.exs | |
defmodule Content do | |
@moduledoc """ | |
Content is responsible for consuming different types of content | |
""" |