Done puzzle 43
[project-euler.git] / euler29.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "metadata": {
7 "collapsed": false
8 },
9 "outputs": [
10 {
11 "data": {
12 "text/plain": [
13 "false"
14 ]
15 },
16 "execution_count": 1,
17 "metadata": {},
18 "output_type": "execute_result"
19 }
20 ],
21 "source": [
22 "require 'set'"
23 ]
24 },
25 {
26 "cell_type": "code",
27 "execution_count": 2,
28 "metadata": {
29 "collapsed": false
30 },
31 "outputs": [
32 {
33 "data": {
34 "text/plain": [
35 "#<Set: {1, 2}>"
36 ]
37 },
38 "execution_count": 2,
39 "metadata": {},
40 "output_type": "execute_result"
41 }
42 ],
43 "source": [
44 "Set.new([1,2])"
45 ]
46 },
47 {
48 "cell_type": "code",
49 "execution_count": 4,
50 "metadata": {
51 "collapsed": false
52 },
53 "outputs": [
54 {
55 "data": {
56 "text/plain": [
57 "[[2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5]]"
58 ]
59 },
60 "execution_count": 4,
61 "metadata": {},
62 "output_type": "execute_result"
63 }
64 ],
65 "source": [
66 "(2..5).to_a.product((2..5).to_a)"
67 ]
68 },
69 {
70 "cell_type": "code",
71 "execution_count": 5,
72 "metadata": {
73 "collapsed": false
74 },
75 "outputs": [
76 {
77 "data": {
78 "text/plain": [
79 "[4, 8, 16, 32, 9, 27, 81, 243, 16, 64, 256, 1024, 25, 125, 625, 3125]"
80 ]
81 },
82 "execution_count": 5,
83 "metadata": {},
84 "output_type": "execute_result"
85 }
86 ],
87 "source": [
88 "(2..5).to_a.product((2..5).to_a).map {|a, b| a ** b}"
89 ]
90 },
91 {
92 "cell_type": "code",
93 "execution_count": 6,
94 "metadata": {
95 "collapsed": false
96 },
97 "outputs": [
98 {
99 "data": {
100 "text/plain": [
101 "#<Set: {4, 8, 16, 32, 9, 27, 81, 243, 64, 256, 1024, 25, 125, 625, 3125}>"
102 ]
103 },
104 "execution_count": 6,
105 "metadata": {},
106 "output_type": "execute_result"
107 }
108 ],
109 "source": [
110 "Set.new((2..5).to_a.product((2..5).to_a).map {|a, b| a ** b})"
111 ]
112 },
113 {
114 "cell_type": "code",
115 "execution_count": 7,
116 "metadata": {
117 "collapsed": false
118 },
119 "outputs": [
120 {
121 "data": {
122 "text/plain": [
123 "15"
124 ]
125 },
126 "execution_count": 7,
127 "metadata": {},
128 "output_type": "execute_result"
129 }
130 ],
131 "source": [
132 "Set.new((2..5).to_a.product((2..5).to_a).map {|a, b| a ** b}).length"
133 ]
134 },
135 {
136 "cell_type": "code",
137 "execution_count": 8,
138 "metadata": {
139 "collapsed": false
140 },
141 "outputs": [
142 {
143 "data": {
144 "text/plain": [
145 "9183"
146 ]
147 },
148 "execution_count": 8,
149 "metadata": {},
150 "output_type": "execute_result"
151 }
152 ],
153 "source": [
154 "Set.new((2..100).to_a.product((2..100).to_a).map {|a, b| a ** b}).length"
155 ]
156 },
157 {
158 "cell_type": "code",
159 "execution_count": null,
160 "metadata": {
161 "collapsed": true
162 },
163 "outputs": [],
164 "source": []
165 }
166 ],
167 "metadata": {
168 "kernelspec": {
169 "display_name": "Ruby 2.4.0",
170 "language": "ruby",
171 "name": "ruby"
172 },
173 "language_info": {
174 "file_extension": ".rb",
175 "mimetype": "application/x-ruby",
176 "name": "ruby",
177 "version": "2.4.0"
178 }
179 },
180 "nbformat": 4,
181 "nbformat_minor": 0
182 }