-
Notifications
You must be signed in to change notification settings - Fork 3
/
challenge_slides.html
184 lines (182 loc) · 130 KB
/
challenge_slides.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
<link href="data:text/css;charset=utf-8,%0Abody%0A%7B%0Amargin%3A%200%200%200%200%3B%0Apadding%3A%200%200%200%200%3B%0Awidth%3A%20100%25%3B%0Aheight%3A%20100%25%3B%0Acolor%3A%20black%3B%0Abackground%2Dcolor%3A%20white%3B%0Afont%2Dfamily%3A%20%22Gill%20Sans%20MT%22%2C%20%22Gill%20Sans%22%2C%20GillSans%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014pt%3B%0A%7D%0Adiv%2Etoolbar%20%7B%0Aposition%3A%20fixed%3B%20z%2Dindex%3A%20200%3B%0Atop%3A%20auto%3B%20bottom%3A%200%3B%20left%3A%200%3B%20right%3A%200%3B%0Aheight%3A%201%2E2em%3B%20text%2Dalign%3A%20right%3B%0Apadding%2Dleft%3A%201em%3B%0Apadding%2Dright%3A%201em%3B%20font%2Dsize%3A%2060%25%3B%0Acolor%3A%20DimGray%3B%0Abackground%2Dcolor%3A%20rgb%28240%2C240%2C240%29%3B%0Aborder%2Dtop%3A%20solid%201px%20rgb%28180%2C180%2C180%29%3B%0A%7D%0Adiv%2Etoolbar%20span%2Ecopyright%20%7B%0Acolor%3A%20DimGray%3B%0Amargin%2Dleft%3A%200%2E5em%3B%0A%7D%0Adiv%2Einitial%5Fprompt%20%7B%0Aposition%3A%20absolute%3B%0Az%2Dindex%3A%201000%3B%0Abottom%3A%201%2E2em%3B%0Awidth%3A%20100%25%3B%0Abackground%2Dcolor%3A%20rgb%28200%2C200%2C200%29%3B%0Aopacity%3A%200%2E35%3B%0Abackground%2Dcolor%3A%20rgb%28200%2C200%2C200%2C%200%2E35%29%3B%0Acursor%3A%20pointer%3B%0A%7D%0Adiv%2Einitial%5Fprompt%20p%2Ehelp%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Adiv%2Einitial%5Fprompt%20p%2Eclose%20%7B%0Atext%2Dalign%3A%20right%3B%0Afont%2Dstyle%3A%20italic%3B%0A%7D%0Adiv%2Eslidy%5Ftoc%20%7B%0Aposition%3A%20absolute%3B%0Az%2Dindex%3A%20300%3B%0Awidth%3A%2060%25%3B%0Amax%2Dwidth%3A%2030em%3B%0Aheight%3A%2030em%3B%0Aoverflow%3A%20auto%3B%0Atop%3A%20auto%3B%0Aright%3A%20auto%3B%0Aleft%3A%204em%3B%0Abottom%3A%204em%3B%0Apadding%3A%201em%3B%0Abackground%3A%20rgb%28240%2C240%2C240%29%3B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%2Dwidth%3A%202px%3B%0Afont%2Dsize%3A%2060%25%3B%0A%7D%0Adiv%2Eslidy%5Ftoc%20%2Etoc%5Fheading%20%7B%0Atext%2Dalign%3A%20center%3B%0Awidth%3A%20100%25%3B%0Amargin%3A%200%3B%0Amargin%2Dbottom%3A%201em%3B%0Aborder%2Dbottom%2Dstyle%3A%20solid%3B%0Aborder%2Dbottom%2Dcolor%3A%20rgb%28180%2C180%2C180%29%3B%0Aborder%2Dbottom%2Dwidth%3A%201px%3B%0A%7D%0Adiv%2Eslide%20%7B%0Az%2Dindex%3A%2020%3B%0Amargin%3A%200%200%200%200%3B%0Apadding%2Dtop%3A%200%3B%0Apadding%2Dbottom%3A%200%3B%0Apadding%2Dleft%3A%2020px%3B%0Apadding%2Dright%3A%2020px%3B%0Aborder%2Dwidth%3A%200%3B%0Aclear%3A%20both%3B%0Atop%3A%200%3B%0Abottom%3A%200%3B%0Aleft%3A%200%3B%0Aright%3A%200%3B%0Aline%2Dheight%3A%20120%25%3B%0Abackground%2Dcolor%3A%20transparent%3B%0A%7D%0Adiv%2Ebackground%20%7B%0Adisplay%3A%20none%3B%0A%7D%0Adiv%2Ehandout%20%7B%0Amargin%2Dleft%3A%2020px%3B%0Amargin%2Dright%3A%2020px%3B%0A%7D%0Adiv%2Eslide%2Etitlepage%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Adiv%2Eslide%2Etitlepage%20h1%20%7B%0Apadding%2Dtop%3A%2010%25%3B%0Amargin%2Dright%3A%200%3B%0A%7D%0Adiv%2Eslide%20h1%20%7B%0Apadding%2Dleft%3A%200%3B%0Apadding%2Dright%3A%2020pt%3B%0Apadding%2Dtop%3A%204pt%3B%0Apadding%2Dbottom%3A%204pt%3B%0Amargin%2Dtop%3A%200%3B%0Amargin%2Dleft%3A%200%3B%0Amargin%2Dright%3A%2060pt%3B%0Amargin%2Dbottom%3A%200%2E5em%3B%0Adisplay%3A%20block%3B%20font%2Dsize%3A%20160%25%3B%0Aline%2Dheight%3A%201%2E2em%3B%0Abackground%3A%20transparent%3B%0A%7D%0A%40media%20screen%20and%20%28max%2Ddevice%2Dwidth%3A%201024px%29%0A%7B%0Adiv%2Eslide%20%7B%20font%2Dsize%3A%20100%25%3B%20%7D%0A%7D%0A%40media%20screen%20and%20%28max%2Ddevice%2Dwidth%3A%20800px%29%0A%7B%0Adiv%2Eslide%20%7B%20font%2Dsize%3A%20200%25%3B%20%7D%0Adiv%2Eslidy%5Ftoc%20%7B%0Atop%3A%201em%3B%0Aleft%3A%201em%3B%0Aright%3A%20auto%3B%0Awidth%3A%2080%25%3B%0Afont%2Dsize%3A%20180%25%3B%0A%7D%0A%7D%0Adiv%2Etoc%2Dheading%20%7B%0Awidth%3A%20100%25%3B%0Aborder%2Dbottom%3A%20solid%201px%20rgb%28180%2C180%2C180%29%3B%0Amargin%2Dbottom%3A%201em%3B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0Aimage%2Drendering%3A%20optimize%2Dquality%3B%0A%7D%0Apre%20%7B%0Afont%2Dsize%3A%2080%25%3B%0Afont%2Dweight%3A%20bold%3B%0Aline%2Dheight%3A%20120%25%3B%0Apadding%2Dtop%3A%200%2E2em%3B%0Apadding%2Dbottom%3A%200%2E2em%3B%0Apadding%2Dleft%3A%201em%3B%0Apadding%2Dright%3A%201em%3B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%2Dleft%2Dwidth%3A%201em%3B%0Aborder%2Dtop%2Dwidth%3A%20thin%3B%0Aborder%2Dright%2Dwidth%3A%20thin%3B%0Aborder%2Dbottom%2Dwidth%3A%20thin%3B%0Aborder%2Dcolor%3A%20%2395ABD0%3B%0Acolor%3A%20%2300428C%3B%0Abackground%2Dcolor%3A%20%23E4E5E7%3B%0A%7D%0Ali%20pre%20%7B%20margin%2Dleft%3A%200%3B%20%7D%0Ablockquote%20%7B%20font%2Dstyle%3A%20italic%20%7D%0Aimg%20%7B%20background%2Dcolor%3A%20transparent%20%7D%0Ap%2Ecopyright%20%7B%20font%2Dsize%3A%20smaller%20%7D%0A%2Ecenter%20%7B%20text%2Dalign%3A%20center%20%7D%0A%2Efootnote%20%7B%20font%2Dsize%3A%20smaller%3B%20margin%2Dleft%3A%202em%3B%20%7D%0Aa%20img%20%7B%20border%2Dwidth%3A%200%3B%20border%2Dstyle%3A%20none%20%7D%0Aa%3Avisited%20%7B%20color%3A%20navy%20%7D%0Aa%3Alink%20%7B%20color%3A%20navy%20%7D%0Aa%3Ahover%20%7B%20color%3A%20red%3B%20text%2Ddecoration%3A%20underline%20%7D%0Aa%3Aactive%20%7B%20color%3A%20red%3B%20text%2Ddecoration%3A%20underline%20%7D%0Aa%20%7Btext%2Ddecoration%3A%20none%7D%0A%2Etoolbar%20a%3Alink%20%7Bcolor%3A%20blue%7D%0A%2Etoolbar%20a%3Avisited%20%7Bcolor%3A%20blue%7D%0A%2Etoolbar%20a%3Aactive%20%7Bcolor%3A%20red%7D%0A%2Etoolbar%20a%3Ahover%20%7Bcolor%3A%20red%7D%0Aul%20%7B%20list%2Dstyle%2Dtype%3A%20square%3B%20%7D%0Aul%20ul%20%7B%20list%2Dstyle%2Dtype%3A%20disc%3B%20%7D%0Aul%20ul%20ul%20%7B%20list%2Dstyle%2Dtype%3A%20circle%3B%20%7D%0Aul%20ul%20ul%20ul%20%7B%20list%2Dstyle%2Dtype%3A%20disc%3B%20%7D%0Ali%20%7B%20margin%2Dleft%3A%200%2E5em%3B%20margin%2Dtop%3A%200%2E5em%3B%20%7D%0Ali%20li%20%7B%20font%2Dsize%3A%2085%25%3B%20font%2Dstyle%3A%20italic%20%7D%0Ali%20li%20li%20%7B%20font%2Dsize%3A%2085%25%3B%20font%2Dstyle%3A%20normal%20%7D%0Adiv%20dt%0A%7B%0Amargin%2Dleft%3A%200%3B%0Amargin%2Dtop%3A%201em%3B%0Amargin%2Dbottom%3A%200%2E5em%3B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Adiv%20dd%0A%7B%0Amargin%2Dleft%3A%202em%3B%0Amargin%2Dbottom%3A%200%2E5em%3B%0A%7D%0Ap%2Cpre%2Cul%2Col%2Cblockquote%2Ch2%2Ch3%2Ch4%2Ch5%2Ch6%2Cdl%2Ctable%20%7B%0Amargin%2Dleft%3A%201em%3B%0Amargin%2Dright%3A%201em%3B%0A%7D%0Ap%2Esubhead%20%7B%20font%2Dweight%3A%20bold%3B%20margin%2Dtop%3A%202em%3B%20%7D%0A%2Esmaller%20%7B%20font%2Dsize%3A%20smaller%20%7D%0A%2Ebigger%20%7B%20font%2Dsize%3A%20130%25%20%7D%0Atd%2Cth%20%7B%20padding%3A%200%2E2em%20%7D%0Aul%20%7B%0Amargin%3A%200%2E5em%201%2E5em%200%2E5em%201%2E5em%3B%0Apadding%3A%200%3B%0A%7D%0Aol%20%7B%0Amargin%3A%200%2E5em%201%2E5em%200%2E5em%201%2E5em%3B%0Apadding%3A%200%3B%0A%7D%0Aul%20%7B%20list%2Dstyle%2Dtype%3A%20square%3B%20%7D%0Aul%20ul%20%7B%20list%2Dstyle%2Dtype%3A%20disc%3B%20%7D%0Aul%20ul%20ul%20%7B%20list%2Dstyle%2Dtype%3A%20circle%3B%20%7D%0Aul%20ul%20ul%20ul%20%7B%20list%2Dstyle%2Dtype%3A%20disc%3B%20%7D%0Aul%20li%20%7B%20list%2Dstyle%3A%20square%3B%0Amargin%3A%200%2E1em%200em%200%2E6em%200%3B%0Apadding%3A%200%200%200%200%3B%0Aline%2Dheight%3A%20140%25%3B%0A%7D%0Aol%20li%20%7B%20margin%3A%200%2E1em%200em%200%2E6em%201%2E5em%3B%0Apadding%3A%200%200%200%200px%3B%0Aline%2Dheight%3A%20140%25%3B%0Alist%2Dstyle%2Dtype%3A%20decimal%3B%0A%7D%0Ali%20ul%20li%20%7B%20font%2Dsize%3A%2085%25%3B%20font%2Dstyle%3A%20italic%3B%0Alist%2Dstyle%2Dtype%3A%20disc%3B%0Abackground%3A%20transparent%3B%0Apadding%3A%200%200%200%200%3B%0A%7D%0Ali%20li%20ul%20li%20%7B%20font%2Dsize%3A%2085%25%3B%20font%2Dstyle%3A%20normal%3B%0Alist%2Dstyle%2Dtype%3A%20circle%3B%0Abackground%3A%20transparent%3B%0Apadding%3A%200%200%200%200%3B%0A%7D%0Ali%20li%20li%20ul%20li%20%7B%0Alist%2Dstyle%2Dtype%3A%20disc%3B%0Abackground%3A%20transparent%3B%0Apadding%3A%200%200%200%200%3B%0A%7D%0Ali%20ol%20li%20%7B%0Alist%2Dstyle%2Dtype%3A%20decimal%3B%0A%7D%0Ali%20li%20ol%20li%20%7B%0Alist%2Dstyle%2Dtype%3A%20decimal%3B%0A%7D%0A%0Aol%2Eoutline%20li%3Ahover%20%7B%20cursor%3A%20pointer%20%7D%0Aol%2Eoutline%20li%2Enofold%3Ahover%20%7B%20cursor%3A%20default%20%7D%0Aul%2Eoutline%20li%3Ahover%20%7B%20cursor%3A%20pointer%20%7D%0Aul%2Eoutline%20li%2Enofold%3Ahover%20%7B%20cursor%3A%20default%20%7D%0Aol%2Eoutline%20%7B%20list%2Dstyle%3Adecimal%3B%20%7D%0Aol%2Eoutline%20ol%20%7B%20list%2Dstyle%2Dtype%3Alower%2Dalpha%20%7D%0Aol%2Eoutline%20li%2Enofold%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAIACAMzMzOvr%2FywAAAAACQAJAAACD4SPoRvG614Dctb4MEMcFAA7%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aol%2Eoutline%20li%2Eunfolded%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAMPD%2F8zMzOvr%2F%2F%2F%2F%2FywAAAAACQAJAAACEYyPoivG614LAlg7ZZbxoR8UADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aol%2Eoutline%20li%2Efolded%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAMPD%2F8zMzOvr%2F%2F%2F%2F%2FywAAAAACQAJAAACFIyPoiu2sJyCyoF7W3hxz850CFIAADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aol%2Eoutline%20li%2Eunfolded%3Ahover%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAAAAAAAA%2F8PD%2F%2F%2F%2F%2FywAAAAACQAJAAACEYSPoivG614DIlg7ZZbxoQ8UADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aol%2Eoutline%20li%2Efolded%3Ahover%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAAAAAAAA%2F8PD%2F%2F%2F%2F%2FywAAAAACQAJAAACFISPoiu2sZyCyoV7G3hxz850CFIAADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aul%2Eoutline%20li%2Enofold%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAIACAMzMzOvr%2FywAAAAACQAJAAACD4SPoRvG614Dctb4MEMcFAA7%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aul%2Eoutline%20li%2Eunfolded%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAMPD%2F8zMzOvr%2F%2F%2F%2F%2FywAAAAACQAJAAACEYyPoivG614LAlg7ZZbxoR8UADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aul%2Eoutline%20li%2Efolded%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAMPD%2F8zMzOvr%2F%2F%2F%2F%2FywAAAAACQAJAAACFIyPoiu2sJyCyoF7W3hxz850CFIAADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aul%2Eoutline%20li%2Eunfolded%3Ahover%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAAAAAAAA%2F8PD%2F%2F%2F%2F%2FywAAAAACQAJAAACEYSPoivG614DIlg7ZZbxoQ8UADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0Aul%2Eoutline%20li%2Efolded%3Ahover%20%7B%0Apadding%3A%200%200%200%2020px%3B%0Abackground%3A%20transparent%20url%28data%3Aimage%2Fgif%3Bbase64%2CR0lGODdhCQAJAKEDAAAAAAAA%2F8PD%2F%2F%2F%2F%2FywAAAAACQAJAAACFISPoiu2sZyCyoV7G3hxz850CFIAADs%3D%29%20no%2Drepeat%200px%200%2E5em%3B%0A%7D%0A%0Aa%2Etitleslide%20%7B%20font%2Dweight%3A%20bold%3B%20font%2Dstyle%3A%20italic%20%7D%0A%0Aimg%2Ehidden%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%20%7D%0Adiv%2Einitial%5Fprompt%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%20%7D%0Adiv%2Eslide%20%7B%0Avisibility%3A%20visible%3B%0Aposition%3A%20inherit%3B%0A%7D%0Adiv%2Ehandout%20%7B%0Aborder%2Dtop%2Dstyle%3A%20solid%3B%0Aborder%2Dtop%2Dwidth%3A%20thin%3B%0Aborder%2Dtop%2Dcolor%3A%20black%3B%0A%7D%0A%40media%20screen%20%7B%0A%2Ehidden%20%7B%20display%3A%20none%3B%20visibility%3A%20visible%20%7D%0Adiv%2Eslide%2Ehidden%20%7B%20display%3A%20block%3B%20visibility%3A%20visible%20%7D%0Adiv%2Ehandout%2Ehidden%20%7B%20display%3A%20block%3B%20visibility%3A%20visible%20%7D%0Adiv%2Ebackground%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%20%7D%0Abody%2Esingle%5Fslide%20div%2Einitial%5Fprompt%20%7B%20display%3A%20block%3B%20visibility%3A%20visible%20%7D%0Abody%2Esingle%5Fslide%20div%2Ebackground%20%7B%20display%3A%20block%3B%20visibility%3A%20visible%20%7D%0Abody%2Esingle%5Fslide%20div%2Ebackground%2Ehidden%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%20%7D%0Abody%2Esingle%5Fslide%20%2Einvisible%20%7B%20visibility%3A%20hidden%20%7D%0Abody%2Esingle%5Fslide%20%2Ehidden%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%20%7D%0Abody%2Esingle%5Fslide%20div%2Eslide%20%7B%20position%3A%20absolute%20%7D%0Abody%2Esingle%5Fslide%20div%2Ehandout%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%20%7D%0A%7D%0A%40media%20print%20%7B%0A%2Ehidden%20%7B%20display%3A%20block%3B%20visibility%3A%20visible%20%7D%0Adiv%2Eslide%20pre%20%7B%20font%2Dsize%3A%2060%25%3B%20padding%2Dleft%3A%200%2E5em%3B%20%7D%0Adiv%2Etoolbar%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%3B%20%7D%0Adiv%2Eslidy%5Ftoc%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%3B%20%7D%0Adiv%2Ebackground%20%7B%20display%3A%20none%3B%20visibility%3A%20hidden%3B%20%7D%0Adiv%2Eslide%20%7B%20page%2Dbreak%2Dbefore%3A%20always%20%7D%0A%0Adiv%2Eslide%2Efirst%2Dslide%20%7B%20page%2Dbreak%2Dbefore%3A%20avoid%20%7D%0A%7D%0A%0A%0A%2Ejslider%20table%20%7B%0Amargin%2Dleft%3A%200em%3B%0Amargin%2Dright%3A%200em%3B%0A%7D%0A%0Atable%2EdataTable%2C%20%2Eshiny%2Ddatatable%2Doutput%20div%20%7B%0Afont%2Dsize%3A%2014pt%3B%0A%7D%0A%0A%2EdataTables%5Finfo%2C%20%2EdataTables%5Fpaginate%20%7B%0Afont%2Dsize%3A%2019px%3B%0A%7D%0A%0Apre%2EsourceCode%2C%20code%2EsourceCode%20%7B%0Afont%2Dsize%3A%2080%25%3B%0A%7D%0A%0Alabel%2C%20button%2C%20input%2C%20select%2C%20textarea%20%7B%0Afont%2Dsize%3A%2014pt%3B%0A%7D%0A%0Aul%2Enav%2C%20ul%2Enav%20li%20%7B%0Alist%2Dstyle%2Dtype%3A%20none%3B%0A%7D%0A" rel="stylesheet" />
<script src="data:application/x-javascript;base64,Lyogc2xpZHkuanMKCiAgIENvcHlyaWdodCAoYykgMjAwNS0yMDEzIFczQyAoTUlULCBFUkNJTSwgS2VpbyksIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgIFczQyBsaWFiaWxpdHksIHRyYWRlbWFyaywgZG9jdW1lbnQgdXNlIGFuZCBzb2Z0d2FyZSBsaWNlbnNpbmcKICAgcnVsZXMgYXBwbHksIHNlZToKCiAgIGh0dHA6Ly93d3cudzMub3JnL0NvbnNvcnRpdW0vTGVnYWwvY29weXJpZ2h0LWRvY3VtZW50cwogICBodHRwOi8vd3d3LnczLm9yZy9Db25zb3J0aXVtL0xlZ2FsL2NvcHlyaWdodC1zb2Z0d2FyZQoKICAgRGVmaW5lcyBzaW5nbGUgbmFtZSAidzNjX3NsaWR5IiBpbiBnbG9iYWwgbmFtZXNwYWNlCiAgIEFkZHMgZXZlbnQgaGFuZGxlcnMgd2l0aG91dCB0cmFtcGxpbmcgb24gYW55IG90aGVycwoqLwoKLy8gdGhlIHNsaWR5IG9iamVjdCBpbXBsZW1lbnRhdGlvbgp2YXIgdzNjX3NsaWR5ID0gewogIC8vIGNsYXNzaWZ5IHdoaWNoIGtpbmQgb2YgYnJvd3NlciB3ZSdyZSBydW5uaW5nIHVuZGVyCiAgbnNfcG9zOiAodHlwZW9mIHdpbmRvdy5wYWdlWU9mZnNldCE9J3VuZGVmaW5lZCcpLAogIGtodG1sOiAoKG5hdmlnYXRvci51c2VyQWdlbnQpLmluZGV4T2YoIktIVE1MIikgPj0gMCA/IHRydWUgOiBmYWxzZSksCiAgb3BlcmE6ICgobmF2aWdhdG9yLnVzZXJBZ2VudCkuaW5kZXhPZigiT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lc1t3M2Nfc2xpZHkuc2xpZGVfbnVtYmVyXTsKICAgICAgICB3M2Nfc2xpZHkuaGlkZV9zbGlkZShzbGlkZSk7CiAgICAgICAgdzNjX3NsaWR5LnNsaWRlX251bWJlciA9IHczY19zbGlkeS5maW5kX3NsaWRlX251bWJlcih1cmkpOwogICAgICAgIHNsaWRlID0gdzNjX3NsaWR5LnNsaWRlc1t3M2Nfc2xpZHkuc2xpZGVfbnVtYmVyXTsKICAgICAgICB3M2Nfc2xpZHkubGFzdF9zaG93biA9IG51bGw7CiAgICAgICAgdzNjX3NsaWR5LnNldF9sb2NhdGlvbigpOwogICAgICAgIHczY19zbGlkeS5zZXRfdmlzaWJpbGl0eV9hbGxfaW5jcmVtZW50YWwoImhpZGRlbiIpOwogICAgICAgIHczY19zbGlkeS5zZXRfZW9zX3N0YXR1cyghdzNjX3NsaWR5Lm5leHRfaW5jcmVtZW50YWxfaXRlbSh3M2Nfc2xpZHkubGFzdF9zaG93bikpOwogICAgICAgIHczY19zbGlkeS5zaG93X3NsaWRlKHNsaWRlKTsKICAgICAgICAvL3RhcmdldC5mb2N1cygpOwoKICAgICAgICB0cnkKICAgICAgICB7CiAgICAgICAgICBpZiAoIXczY19zbGlkeS5vcGVyYSkKICAgICAgICAgICAgdzNjX3NsaWR5LnNldF9mb2N1cygpOwogICAgICAgIH0KICAgICAgICBjYXRjaCAoZSkKICAgICAgICB7CiAgICAgICAgfQogICAgICB9CgogICAgICB3M2Nfc2xpZHkuaGlkZV90YWJsZV9vZl9jb250ZW50cyh0cnVlKTsKCiAgICAgIGlmIChzZWxmLmllNykKICAgICAgIHczY19zbGlkeS5pZV9oYWNrKCk7CgogICAgICByZXR1cm4gdzNjX3NsaWR5LmNhbmNlbChldmVudCk7CiAgICB9CgogICAgaWYgKGtleSA9PSA0MCAmJiB0aGlzLm5leHQpCiAgICB7CiAgICAgIHRoaXMubmV4dC5mb2N1cygpOwogICAgICByZXR1cm4gdzNjX3NsaWR5LmNhbmNlbChldm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AuNWVtIjsKICAgICAgICAgdGhpcy50b29sYmFyLmFwcGVuZENoaWxkKHNwYW4pOwogICAgICAgfQoKICAgICAgIGNvdW50ZXIgPSB0aGlzLmNyZWF0ZV9lbGVtZW50KCJkaXYiKQogICAgICAgY291bnRlci5zdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICAgICBjb3VudGVyLnN0eWxlLndpZHRoID0gImF1dG8iOyAvLyIyMCUiOwogICAgICAgY291bnRlci5zdHlsZS5oZWlnaHQgPSAiMS4yZW0iOwogICAgICAgY291bnRlci5zdHlsZS50b3AgPSAiYXV0byI7CiAgICAgICBjb3VudGVyLnN0eWxlLmJvdHRvbSA9IDA7CiAgICAgICBjb3VudGVyLnN0eWxlLnJpZ2h0ID0gIjAiOwogICAgICAgY291bnRlci5zdHlsZS50ZXh0QWxpZ24gPSAicmlnaHQiOwogICAgICAgY291bnRlci5zdHlsZS5jb2xvciA9ICJyZWQiOwogICAgICAgY291bnRlci5zdHlsZS5iYWNrZ3JvdW5kID0gInJnYigyNDAsMjQwLDI0MCkiOwoKICAgICAgIGNvdW50ZXIuaW5uZXJIVE1MID0gdGhpcy5sb2NhbGl6ZSgic2xpZGUiKSArICIgbi9tIjsKICAgICAgIHRoaXMudG9vbGJhci5hcHBlbmRDaGlsZChjb3VudGVyKTsKICAgICB9CgogICAgIC8vIGVuc3VyZSB0aGF0IGNsaWNrIGlzbid0IHBhc3NlZCB0aHJvdWdoIHRvIHRoZSBwYWdlCiAgICAgdGhpcy50b29sYmFyLm9uY2xpY2sgPQogICAgICAgICBmdW5jdGlvbiAoZSkgewogICAgICAgICAgIGlmICghZSkKICAgICAgICAgICAgIGUgPSB3aW5kb3cuZXZlbnQ7CgogICAgICAgICAgIHZhciB0YXJnZXQgPSBlLnRhcmdldDsKCiAgICAgICAgICAgaWYgKCF0YXJnZXQgJiYgZS5zcmNFbGVtZW50KQogICAgICAgICAgICAgdGFyZ2V0ID0gZS5zcmNFbGVtZW50OwoKIC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lYWRpbmdzKQogICAgICByZXR1cm47CgogICAgZm9yIChpID0gMDsgaSA8IGhlYWRpbmdzLmxlbmd0aDsgKytpKQogICAgewogICAgICBoZWFkaW5nID0gaGVhZGluZ3NbaV07CgogICAgICBpZiAoaGVhZGluZy5wYXJlbnROb2RlICE9IGRvY3VtZW50LmJvZHkpCiAgICAgICAgY29udGludWU7CgogICAgICBub2RlID0gaGVhZGluZy5uZXh0U2libGluZzsKCiAgICAgIGRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICB0aGlzLmFkZF9jbGFzcyhkaXYsICJzbGlkZSIpOwogICAgICBkb2N1bWVudC5ib2R5LnJlcGxhY2VDaGlsZChkaXYsIGhlYWRpbmcpOwogICAgICBkaXYuYXBwZW5kQ2hpbGQoaGVhZGluZyk7CgogICAgICB3aGlsZSAobm9kZSkKICAgICAgewogICAgICAgIGlmIChub2RlLm5vZGVUeXBlID09IDEpIC8vIGFuIGVsZW1lbnQKICAgICAgICB7CiAgICAgICAgICAgaWYgKG5vZGUubm9kZU5hbWUgPT0gIkgxIiB8fCBub2RlLm5vZGVOYW1lID09ICJoMSIpCiAgICAgICAgICAgICBicmVhazsKCiAgICAgICAgICAgaWYgKG5vZGUubm9kZU5hbWUgPT0gIkRJViIgfHwgbm9kZS5ub2RlTmFtZSA9PSAiZGl2IikKICAgICAgICAgICB7CiAgICAgICAgICAgICBpZiAodGhpcy5oYXNfY2xhc3Mobm9kZSwgInNsaWRlIikpCiAgICAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICAgICAgIGlmICh0aGlzLmhhc19jbGFzcyhub2RlLCAiaGFuZG91dCIpKQogICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBuZXh0ID0gbm9kZS5uZXh0U2libGluZzsKICAgICAgICBub2RlID0gZG9jdW1lbnQuYm9keS5yZW1vdmVDaGlsZChub2RlKTsKICAgICAgICBkaXYuYXBwZW5kQ2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1cmkuc3Vic3RyKGkrMSkpOwoKICAgIC8vIG5vdyB1c2UgYW5jaG9yIGFzIFhNTCBJRCB0byBmaW5kIHRhcmdldAogICAgdmFyIHRhcmdldCA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKGFuY2hvcik7CgogICAgaWYgKCF0YXJnZXQpCiAgICB7CiAgICAgIC8vIGRvZXMgYW5jaG9yIGxvb2sgbGlrZSAiKDIpIiBmb3Igc2xpZGUgMiA/PwogICAgICAvLyB3aGVyZSBmaXJzdCBzbGlkZSBpcyAoMSkKICAgICAgdmFyIHJlID0gL1woKFxkKStcKS87CgogICAgICBpZiAoYW5jaG9yLm1hdGNoKHJlKSkKICAgICAgewogICAgICAgIHZhciBudW0gPSBwYXJzZUludChhbmNob3Iuc3Vic3RyaW5nKDEsIGFuY2hvci5sZW5ndGgtMSkpOwoKICAgICAgICBpZiAobnVtID4gdGhpcy5zbGlkZXMubGVuZ3RoKQogICAgICAgICAgbnVtID0gMTsKCiAgICAgICAgaWYgKC0tbnVtIDwgMCkKICAgICAgICAgIG51bSA9IDA7CgogICAgICAgIHJldHVybiBudW07CiAgICAgIH0KCiAgICAgIC8vIGFjY2VwdCBbMl0gZm9yIGJhY2t3YXJkcyBjb21wYXRpYmlsaXR5CiAgICAgIHJlID0gL1xbKFxkKStcXS87CgogICAgICBpZiAoYW5jaG9yLm1hdGNoKHJlKSkKICAgICAgewogICAgICAgICB2YXIgbnVtID0gcGFyc2VJbnQoYW5jaG9yLnN1YnN0cmluZygxLCBhbmNob3IubGVuZ3RoLTEpKTsKCiAgICAgICAgIGlmIChudW0gPiB0aGlzLnNsaWRlcy5sZW5ndGgpCiAgICAgICAgICAgIG51bSA9IDE7CgogICAgICAgICBpZiAoLS1udW0gPCAwKQogICAgICAgICAgICBudW0gPSAwOwoKICAgICAgICAgcmV0dXJuIG51bTsKICAgICAgfQoKICAgICAgLy8gb2ggZGVhciB1bmtub3duIGFuY2hvcgogICAgICByZXR1cm4gMDsKICAgIH0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AgICAgIHczY19zbGlkeS5mb2xkKHczY19zbGlkeS5vdXRsaW5lKTsKICAgICAgICBlbHNlCiAgICAgICAgICB3M2Nfc2xpZHkudW5mb2xkKHczY19zbGlkeS5vdXRsaW5lKTsKICAgICAgICAgIAogICAgICAgcmV0dXJuIHczY19zbGlkeS5jYW5jZWwoZXZlbnQpOwogICAgICB9CiAgICB9CiAgICBlbHNlIGlmIChrZXkgPT0gMTg4KSAgLy8gPCBmb3Igc21hbGxlciBmb250cwogICAgewogICAgICB3M2Nfc2xpZHkuc21hbGxlcigpOwogICAgICByZXR1cm4gdzNjX3NsaWR5LmNhbmNlbChldmVudCk7CiAgICB9CiAgICBlbHNlIGlmIChrZXkgPT0gMTkwKSAgLy8gPiBmb3IgbGFyZ2VyIGZvbnRzCiAgICB7CiAgICAgIHczY19zbGlkeS5iaWdnZXIoKTsKICAgICAgcmV0dXJuIHczY19zbGlkeS5jYW5jZWwoZXZlbnQpOwogICAgfQogICAgZWxzZSBpZiAoa2V5ID09IDE4OSB8fCBrZXkgPT0gMTA5KSAgLy8gLSBmb3Igc21hbGxlciBmb250cwogICAgewogICAgICB3M2Nfc2xpZHkuc21hbGxlcigpOwogICAgICByZXR1cm4gdzNjX3NsaWR5LmNhbmNlbChldmVudCk7CiAgICB9CiAgICBlbHNlIGlmIChrZXkgPT0gMTg3IHx8IGtleSA9PSAxOTEgfHwga2V5ID09IDEwNykgIC8vID0gKyAgZm9yIGxhcmdlciBmb250cwogICAgewogICAgICB3M2Nfc2xpZHkuYmlnZ2VyKCk7CiAgICAgIHJldHVybiB3M2Nfc2xpZHkuY2FuY2VsKGV2ZW50KTsKICAgIH0KICAgIGVsc2UgaWYgKGtleSA9PSA4MykgIC8vIFMgZm9yIHNtYWxsZXIgZm9udHMKICAgIHsKICAgICAgdzNjX3NsaWR5LnNtYWxsZXIoKTsKICAgICAgcmV0dXJuIHczY19zbGlkeS5jYW5jZWwoZXZlbnQpOwogICAgfQogICAgZWxzZSBpZiAoa2V5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UiI7CiAgICB2YXIgc2xpZGUgPSB3M2Nfc2xpZHkuc2xpZGVzW3czY19zbGlkeS5zbGlkZV9udW1iZXJdOwoKICAgIGZvciAoOzspCiAgICB7CiAgICAgIG5vZGUgPSB3M2Nfc2xpZHkubmV4dF9ub2RlKHNsaWRlLCBub2RlKTsKCiAgICAgIGlmIChub2RlID09IG51bGwgfHwgbm9kZS5wYXJlbnROb2RlID09IG51bGwpCiAgICAgICAgYnJlYWs7CgogICAgICBpZiAobm9kZS5ub2RlVHlwZSA9PSAxKSAgLy8gRUxFTUVOVAogICAgICB7CiAgICAgICAgaWYgKG5vZGUubm9kZU5hbWUgPT0gYnIpCiAgICAgICAgICBjb250aW51ZTsKCiAgICAgICAgaWYgKHczY19zbGlkeS5oYXNfY2xhc3Mobm9kZSwgImluY3JlbWVudGFsIikKICAgICAgICAgICAgICYmIHczY19zbGlkeS5va2F5X2Zvcl9pbmNyZW1lbnRhbChub2RlLm5vZGVOYW1lKSkKICAgICAgICAgIHJldHVybiBub2RlOwoKICAgICAgICBpZiAodzNjX3NsaWR5Lmhhc19jbGFzcyhub2RlLnBhcmVudE5vZGUsICJpbmNyZW1lbnRhbCIpCiAgICAgICAgICAgICAmJiAhdzNjX3NsaWR5Lmhhc19jbGFzcyhub2RlLCAibm9uLWluY3JlbWVudGFsIikpCiAgICAgICAgICByZXR1cm4gbm9kZTsKICAgICAgfQogICAgfQoKICAgIHJldHVybiBub2RlOwogIH0sCgogIHByZXZpb3VzX2luY3JlbWVudGFsX2l0ZW06IGZ1bmN0aW9uIChub2RlKSB7CiAgICB2YXIgYnIgPSB0aGlzLmlzX3hodG1sID8gImJyIiA6ICJCUiI7CiAgICB2YXIgc2xpZGUgPSB3M2Nfc2xpZHkuc2xpZGVzW3czY19zbGlkeS5zbGlkZV9udW1iZXJdOwoKICAgIGZvciAoOzspCiAgICB7CiAgICAgIG5vZGUgPSB3M2Nfc2xpZHkucHJldmlvdXNfbm9kZShzbGlkZSwgbm9kZSk7Cgog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ZGU6IGZ1bmN0aW9uIChyb290LCBub2RlKSB7CiAgICBpZiAobm9kZSA9PSBudWxsKQogICAgICByZXR1cm4gcm9vdC5maXJzdENoaWxkOwoKICAgIGlmIChub2RlLmZpcnN0Q2hpbGQpCiAgICAgIHJldHVybiBub2RlLmZpcnN0Q2hpbGQ7CgogICAgaWYgKG5vZGUubmV4dFNpYmxpbmcpCiAgICAgIHJldHVybiBub2RlLm5leHRTaWJsaW5nOwoKICAgIGZvciAoOzspCiAgICB7CiAgICAgIG5vZGUgPSBub2RlLnBhcmVudE5vZGU7CgogICAgICBpZiAoIW5vZGUgfHwgbm9kZSA9PSByb290KQogICAgICAgIGJyZWFrOwoKICAgICAgaWYgKG5vZGUgJiYgbm9kZS5uZXh0U2libGluZykKICAgICAgICByZXR1cm4gbm9kZS5uZXh0U2libGluZzsKICAgIH0KCiAgICByZXR1cm4gbnVsbDsKICB9LAoKICAvLyByaWdodCB0byBsZWZ0IHRyYXZlcnNhbCBvZiByb290J3MgY29udGVudAogIHByZXZpb3VzX25vZGU6IGZ1bmN0aW9uIChyb290LCBub2RlKSB7CiAgICBpZiAobm9kZSA9PSBudWxsKQogICAgewogICAgICBub2RlID0gcm9vdC5sYXN0Q2hpbGQ7CgogICAgICBpZiAobm9kZSkKICAgICAgewogICAgICAgIHdoaWxlIChub2RlLmxhc3RDaGlsZCkKICAgICAgICAgIG5vZGUgPSBub2RlLmxhc3RDaGlsZDsKICAgICAgfQoKICAgICAgcmV0dXJuIG5vZGU7CiAgICB9CgogICAgaWYgKG5vZGUucHJldmlvdXNTaWJsaW5nKQogICAgewogICAgICBub2RlID0gbm9kZS5wcmV2aW91c1NpYmxpbmc7CgogICAgICB3aGlsZSAobm9kZS5sYXN0Q2hpbGQpCiAgICAgICAgbm9kZSA9IG5vZGUubGFzdENoaWxkOwoKICAgICAgcmV0dXJuIG5vZGU7CiAgICB9CgogICAgaWYgKG5vZGUucGFyZW50Tm9kZSAhPSByb290KQogICAgICByZXR1cm4gbm9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+FIM+Azr/Ovc+EzrnOus65zr/PjSwgz4TOvyBzcGFjZSwgz4TOsSDOss6tzrvOtyDOsc+BzrnPg8+EzrXPgc6sL860zrXOvs65zqwsICIgKwogICAgIs6uIFBhZ2UgVXAgzrrOsc65IFBhZ2UgRG93bi4gzqfPgc63z4POuc68zr/PgM6/zrnOrs+Dz4TOtSDPhM6xIM+AzrvOrs66z4TPgc6xIFMgzrrOsc65IEIgzrPOuc6xIM69zrEgzrHOu867zqzOvs61z4TOtSAiICsKICAgICLPhM6/IM68zq3Os861zrjOv8+CIM+EzrfPgiDOs8+BzrHOvM68zrHPhM6/z4POtc65z4HOrM+CLiIsCgogIHN0cmluZ3NfamE6IHsKICAgICJzbGlkZSI6IuOCueODqeOCpOODiSIsCiAgICAiaGVscD8iOiLjg5jjg6vjg5ciLAogICAgImNvbnRlbnRzPyI6IuebruasoSIsCiAgICAidGFibGUgb2YgY29udGVudHMiOiLnm67mrKHjgpLooajnpLoiLAogICAgIlRhYmxlIG9mIENvbnRlbnRzIjoi55uu5qyhIiwKICAgICJyZXN0YXJ0IHByZXNlbnRhdGlvbiI6IuacgOWIneOBi+OCieWGjeeUnyIsCiAgICAicmVzdGFydD8iOiLmnIDliJ3jgYvjgokiCiAgfSwKICBoZWxwX2phOgogICAgICLjg57jgqbjgrnlt6bjgq/jg6rjg4Pjgq8g44O7IOOCueODmuODvOOCuSDjg7sg5bem5Y+z44Kt44O8ICIgKwogICAgICLjgb7jgZ/jga8gUGFnZSBVcCDjg7sgUGFnZSBEb3du44Gn5pON5L2c77yMIFMg44O7IELjgafjg5Xjgqnjg7Pjg4jjgrXjgqTjgrrlpInmm7QiLAoKICBzdHJpbmdzX3poOiB7CiAgICAic2xpZGUiOiLlubvnga/niYciLAogICAgImhlbHA/Ijoi5biu5YqpPyIsCiAgICAiY29udGVudHM/Ijoi5YaF5a65PyIsCiAgICAidGFibGUgb2YgY29udGVudHMiOiLnm67lvZUiLAogICAgIlRhYmxlIG9mIENvbnRlbnRzIjoi55uu5b2VIiwKICAgICJyZXN0YXJ0IHByZXNlbnRhdGlvbiI6IumHjeaWsOWQr+WKqOWxleekuiIsCiAgICAicmVzdGFydD8iOiLph43mlrDlkK/liqg/IgogIH0sCiAgaGVscF96aDoKICAgICLnlKjpvKDmoIfngrnlh7ssIOepuuagvOadoSwg5bem5Y+z566t5aS0LCBQZyBVcCDlkowgUGcgRG4g5a+86IiqLiAiICsKICAgICLnlKggUywgQiDmlLnlj5jlrZfkvZPlpKflsI8uIiwKCiAgc3RyaW5nc19ydTogewogICAgInNsaWRlIjoi0YHQu9Cw0LnQtCIsCiAgICAiaGVscD8iOiLQv9C+0LzQvtGJ0Yw/IiwKICAgICJjb250ZW50cz8iOiLRgdC+0LTQtdGA0LbQsNC90LjQtT8iLAogICAgInRhYmxlIG9mIGNvbnRlbnRzIjoi0L7Qs9C70LDQstC70LXQvdC40LUiLAogICAgIlRhYmxlIG9mIENvbnRlbnRzIjoi0J7Qs9C70LDQstC70LXQvdC40LUiLAogICAgInJlc3RhcnQgcHJlc2VudGF0aW9uIjoi0L/QtdGA0LXQt9Cw0L/Rg9GB0YLQuNGC0Ywg0L/RgNC10LfQtdC90YLQsNGG0LjRjiIsCiAgICAicmVzdGFydD8iOiLQv9C10YDQtdC30LDQv9GD0YHQuj8iCiAgfSwKICBoZWxwX3J1OgogICAgItCf0LXRgNC10LzQtdGJ0LDQudGC0LXRgdGMINC60LvQuNC60LDRjyDQvNGL0YjQutC+0LksINC40YHQv9C+0LvRjNC30YPRjyDQutC70LDQstC40YjRgyDQv9GA0L7QsdC10LssINGB0YLRgNC10LvQutC4IiArCiAgICAi0LLQu9C10LLQvi/QstC/0YDQsNCy0L4g0LjQu9C4IFBnIFVwINC4IFBnIERuLiDQmtC70LDQstC40YjQuCBTINC4IEIg0LzQtdC90Y/RjtGCINGA0LDQt9C80LXRgCDRiNGA0LjRhNGC0LAuIiwKCiAgc3RyaW5nc19zdjogewogICAgInNsaWRlIjoic2lkYSIsCiAgIC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2Nfc2xpZHkubGFuZykKICAgICAgdzNjX3NsaWR5LmxhbmcgPSBkb2N1bWVudC5ib2R5LnBhcmVudE5vZGUuZ2V0QXR0cmlidXRlKCJ4bWw6bGFuZyIpOwoKICAgIGlmICghdzNjX3NsaWR5LmxhbmcpCiAgICAgIHczY19zbGlkeS5sYW5nID0gImVuIjsKICB9Cn07CgovLyBoYWNrIGZvciBiYWNrIGJ1dHRvbiBiZWhhdmlvcgppZiAodzNjX3NsaWR5LmllNiB8fCB3M2Nfc2xpZHkuaWU3KQp7CiAgZG9jdW1lbnQud3JpdGUoIjxpZnJhbWUgaWQ9J2hpc3RvcnlGcmFtZScgIiArCiAgInNyYz0namF2YXNjcmlwdDpcIjxodG1sIisiPjwvIisiaHRtbD5cIicgIiArCiAgImhlaWdodD0nMScgd2lkdGg9JzEnICIgKwogICJzdHlsZT0ncG9zaXRpb246YWJzb2x1dGU7bGVmdDotODAwcHgnPjwvaWZyYW1lPiIpOwp9CgovLyBhdHRhY2ggZXZlbnQgbGlzdGVuZXJzIGZvciBpbml0aWFsaXphdGlvbgp3M2Nfc2xpZHkuc2V0X3VwKCk7CgovLyBoaWRlIHRoZSBzbGlkZXMgYXMgc29vbiBhcyBib2R5IGVsZW1lbnQgaXMgYXZhaWxhYmxlCi8vIHRvIHJlZHVjZSBhbm5veWluZyBzY3JlZW4gbWVzcyBiZWZvcmUgdGhlIG9ubG9hZCBldmVudApzZXRUaW1lb3V0KHczY19zbGlkeS5oaWRlX3NsaWRlcywgNTApOwoK"></script>
</head>
<body>
<div id="challenge-1" class="slide section level1">
<h1>Challenge 1</h1>
<p>What is the value of <code>y</code> after doing the following?</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">x <-<span class="st"> </span><span class="dv">50</span>
y <-<span class="st"> </span>x *<span class="st"> </span><span class="dv">2</span>
x <-<span class="st"> </span><span class="dv">80</span></code></pre></div>
</div>
<div id="challenge-2" class="slide section level1">
<h1>Challenge 2</h1>
<p>Study the output of <code>str(surveys)</code>. How are the missing values being treated?</p>
</div>
<div id="challenge-3" class="slide section level1">
<h1>Challenge 3</h1>
<p>The function <code>nrow()</code> on a <code>data.frame</code> returns the number of rows.</p>
<p>Use <code>nrow()</code>, in conjuction with <code>seq()</code> to create a new <code>data.frame</code> called <code>surveys_by_10</code> that includes every 10th row of the survey data frame starting at row 10 (10, 20, 30, …)</p>
</div>
<div id="challenge-4" class="slide section level1">
<h1>Challenge 4</h1>
<p>The function <code>table()</code> tabulates observations.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">expt <-<span class="st"> </span><span class="kw">c</span>(<span class="st">"treat1"</span>, <span class="st">"treat2"</span>, <span class="st">"treat1"</span>, <span class="st">"treat3"</span>, <span class="st">"treat1"</span>,
<span class="st">"control"</span>, <span class="st">"treat1"</span>, <span class="st">"treat2"</span>, <span class="st">"treat3"</span>)
expt <-<span class="st"> </span><span class="kw">factor</span>(expt)
<span class="kw">table</span>(expt)</code></pre></div>
<ul>
<li>In which order are the treatments listed?</li>
<li>How can you recreate this table with “<code>control</code>” listed last instead of first?</li>
</ul>
</div>
<div id="challenge-5" class="slide section level1">
<h1>Challenge 5</h1>
<p>Using pipes, subset the data to include individuals collected before 1995, and retain the columns <code>year</code>, <code>sex</code>, and <code>weight.</code></p>
</div>
<div id="challenge-6" class="slide section level1">
<h1>Challenge 6</h1>
<p>Create a new dataframe from the survey data that meets the following criteria:</p>
<ul>
<li>contains only the <code>species_id</code> column and a column that contains values that are the square-root of <code>hindfoot_length</code> values (e.g. a new column <code>hindfoot_sqrt</code>).</li>
<li>In this <code>hindfoot_sqrt</code> column, there are no NA values and all values are < 3.</li>
</ul>
<p>Hint: think about how the commands should be ordered</p>
</div>
<div id="challenge-7" class="slide section level1">
<h1>Challenge 7</h1>
<p>How many times was each <code>plot_type</code> surveyed?</p>
</div>
<div id="challenge-8" class="slide section level1">
<h1>Challenge 8</h1>
<p>Use <code>group_by()</code> and <code>summarize()</code> to find the mean, min, and max hindfoot length for each species.</p>
</div>
<div id="challenge-9" class="slide section level1">
<h1>Challenge 9</h1>
<p>What was the heaviest animal measured in each year? Return the columns <code>year</code>, <code>genus</code>, <code>species</code>, and <code>weight</code>.</p>
<p>Hint: Use <code>filter()</code> rather than <code>summarize()</code>.</p>
</div>
<div id="challenge-10" class="slide section level1">
<h1>Challenge 10</h1>
<p>Make a scatterplot of <code>hindfoot_length</code> vs <code>weight</code>, but only for the <code>species_id</code>, <code>"DM"</code>.</p>
</div>
<div id="challenge-11" class="slide section level1">
<h1>Challenge 11</h1>
<p>Use dplyr to calculate the mean <code>weight</code> and <code>hindfoot_length</code> as well as the sample size for each species.</p>
<p>Make a scatterplot of mean <code>hindfoot_length</code> vs mean <code>weight</code>, with the sizes of the points corresponding to the sample size.</p>
</div>
<div id="challenge-12" class="slide section level1">
<h1>Challenge 12</h1>
<p>Make a plot of counts of <code>species_id</code> <code>"DM"</code> and <code>"DS"</code> by year.</p>
</div>
<div id="challenge-13" class="slide section level1">
<h1>Challenge 13</h1>
<p>Try using <code>geom_histogram()</code> to make a histogram visualization of the distribution of <code>weight</code>.</p>
<p>Hint: You want <code>weight</code> as the x-axis aesthetic. Try specifying <code>bins</code> in <code>geom_histogram()</code>.</p>
</div>
<div id="challenge-14" class="slide section level1">
<h1>Challenge 14</h1>
<p>A variant on the box plot is the violin plot. Use <code>geom_violin()</code> to make violin plots of <code>hindfoot_length</code> by <code>species_id</code>.</p>
</div>
<div id="challenge-15" class="slide section level1">
<h1>Challenge 15</h1>
<ul>
<li><p>Calculate counts grouped by year, species_id, and sex</p></li>
<li><p>make the faceted plot splitting further by sex (within each panel)</p></li>
<li><p>color by sex rather than species</p></li>
</ul>
</div>
<div id="challenge-16" class="slide section level1">
<h1>Challenge 16</h1>
<ul>
<li>Create a new R Markdown document.</li>
<li>Delete all of the R code chunks and write a bit of Markdown (some sections, some italicized text, and an itemized list).</li>
<li>Convert the document to a webpage.</li>
</ul>
</div>
<div id="challenge-17" class="slide section level1">
<h1>Challenge 17</h1>
<p>Add code chunks to</p>
<ul>
<li>Load the ggplot2 package</li>
<li>Read the portal data</li>
<li>Create a plot</li>
</ul>
</div>
<div id="challenge-18" class="slide section level1">
<h1>Challenge 18</h1>
<p>Use chunk options to control the size of a figure and to hide the code.</p>
</div>
<div id="challenge-19" class="slide section level1">
<h1>Challenge 19</h1>
<p>Try out a bit of in-line R code.</p>
</div>
<div id="capstone-project" class="slide section level1">
<h1>Capstone project</h1>
<p>Create and compile an R Markdown report:</p>
<ol style="list-style-type: decimal">
<li><p>Load the <code>portal_data_joined.csv</code> data.</p></li>
<li><p>Create boxplots of weight by sex, <em>omitting individuals with missing sex</em>.</p></li>
<li><p>Create a histogram of hindfoot lengths.</p></li>
<li><p>Create a scatterplot of hindfoot length vs weight for the species <code>"DM"</code>, <code>"DO"</code>, and <code>"DS"</code>. <em>Use different colors for the three species, and put the three species in different panels.</em></p></li>
<li><p>Create a table of counts of <code>"DM"</code> by plot type for the year 1977.</p></li>
<li><p>Create a line plot of the counts of <code>"DM"</code> in <code>"Rodent Exclosure"</code> plots over time.</p></li>
</ol>
</div>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>