--- /dev/null
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "class Integer\n",
+ " def factorial\n",
+ " (1..self).inject(:*) || 1\n",
+ " end\n",
+ " alias :! :factorial\n",
+ "end"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "(1..100).each do |n|\n",
+ " (1..n).each do |r|\n",
+ " end\n",
+ "end"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "7"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "(1..10).to_a.product((1..10).to_a).select {|n, r| n >= r}.map {|n, r| n.! / (r.! * (n - r).!)}.select {|c| c> 100}.length"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "4075"
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "(1..100).to_a.product((1..100).to_a).select {|n, r| \n",
+ " n >= r}.map {|n, r| \n",
+ " n.! / (r.! * (n - r).!)}.select {|c| \n",
+ " c > 10 ** 6}.length"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Ruby 2.4.0",
+ "language": "ruby",
+ "name": "ruby"
+ },
+ "language_info": {
+ "file_extension": ".rb",
+ "mimetype": "application/x-ruby",
+ "name": "ruby",
+ "version": "2.4.0"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}