Codebase list plm / 7fe99d1
New upstream version 2.9.2 Martin Quinson 3 years ago
267 changed file(s) with 40449 addition(s) and 863 deletion(s). Raw diff Collapse all Expand all
0 20201011: 2.9.2
1
2 The Portuguese release: we now have complete translation of the PLM.
3
4 * Core:
5 - Introduce a new Portuguese translation, thanks ssantos.
6 - Introduce a new Swedish translation, thanks Kristoffer Grundström.
7 * Pedagogical content:
8 - recursion/lego/spiral:
9 - clarify in text how the learner's code is called automatically
10
011 20200920: 2.9
112
213 The Saved Session Release:
0 Manifest-Version: 1.0
1 Built-By: M. Quinson, G. Oster and others
2
img/big_buggle.png less more
Binary diff not shown
img/logoBW.png less more
Binary diff not shown
img/logoCircle.png less more
Binary diff not shown
+0
-741
img/logoCircle.svg less more
0 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1 <!-- Created with Inkscape (http://www.inkscape.org/) -->
2
3 <svg
4 xmlns:dc="http://purl.org/dc/elements/1.1/"
5 xmlns:cc="http://creativecommons.org/ns#"
6 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7 xmlns:svg="http://www.w3.org/2000/svg"
8 xmlns="http://www.w3.org/2000/svg"
9 xmlns:xlink="http://www.w3.org/1999/xlink"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 version="1.1"
13 id="svg2"
14 width="555.67169"
15 height="555.67169"
16 viewBox="0 0 555.6717 555.6717"
17 sodipodi:docname="logoCircle.svg"
18 inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
19 inkscape:export-filename="/home/mquinson/Code/javaPLM/img/logoCircle.png"
20 inkscape:export-xdpi="67"
21 inkscape:export-ydpi="67">
22 <metadata
23 id="metadata8">
24 <rdf:RDF>
25 <cc:Work
26 rdf:about="">
27 <dc:format>image/svg+xml</dc:format>
28 <dc:type
29 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
30 <dc:title></dc:title>
31 </cc:Work>
32 </rdf:RDF>
33 </metadata>
34 <defs
35 id="defs6" />
36 <sodipodi:namedview
37 pagecolor="#ffffff"
38 bordercolor="#666666"
39 borderopacity="1"
40 objecttolerance="10"
41 gridtolerance="10"
42 guidetolerance="10"
43 inkscape:pageopacity="0"
44 inkscape:pageshadow="2"
45 inkscape:window-width="1920"
46 inkscape:window-height="1024"
47 id="namedview4"
48 showgrid="false"
49 inkscape:zoom="1.0276349"
50 inkscape:cx="227.6703"
51 inkscape:cy="176.09812"
52 inkscape:window-x="0"
53 inkscape:window-y="32"
54 inkscape:window-maximized="1"
55 inkscape:current-layer="svg2"
56 fit-margin-top="0"
57 fit-margin-left="0"
58 fit-margin-right="0"
59 fit-margin-bottom="0" />
60 <circle
61 style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:#270000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
62 id="path4650"
63 cx="277.83585"
64 cy="277.83585"
65 r="277.33585" />
66 <image
67 width="518.66669"
68 height="518.66669"
69 preserveAspectRatio="none"
70 style="image-rendering:optimizeQuality"
71 xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAwoAAAMKCAYAAAAlOLMhAAAABGdBTUEAALGPC/xhBQAAAAZiS0dE
72 AP8A/wD/oL2nkwAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAAd0SU1FB94LARAGFQwtYZYAAAAZdEVY
73 dENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAgAElEQVR42uzdWZMcx3Ww4VNL77PvAKoB
74 kCBAUKQka3GIIzmsG0f4D9gX/o3flcP2hSMohyXTAuUgKdKmREokJYLTJAEIO2brru27ELKUnZPV
75 XT0Lpqv6fSImCMwMyamczJN5cisRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
76 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
77 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
78 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
79 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
80 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
81 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
82 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
83 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYIY4FAEmFYbhdhzHbx4eHm7X
84 6/Veo9HYSdO053neTJZHHMfZn9M07fm+vxNFUTeO4zdFRJIkeafdbt+i5gDA6UvTNIiiqOs4ThBF
85 UZAkiTQaDXFdt6fis+qf9HitK1P/FcexmM+l//yDwWDo+13X7fm+v+M4To/agkn5FAEmDchJkrz5
86 1Vdf/eOXX3657Xlez/O8HRHpJUly5Ptd161cGajnVM8Wx7G0221ZWVmRhYWF3vz8/C1bWQAATl8U
87 Rd39/f03nz59un3//v3g8ePHUqvVxHXdXl5/lBejy9BnxXF8pB9yHEfSNM2+7nme+L4va2trcuHC
88 BTVRRaIAEgWcfUAOw7D7ySefBG+99ZYcHh4Gh4eHQRRFuTM1iuM4oxKQUpfLpUuX5Pvf/768+uqr
89 vZdeekkajcYtz/PeERFpNBo71BwAOBuO4wR3797d/vjjj//x//7v/+R3v/td1qfo/3RdNxtYj+tz
90 pq2/StNUHMcR13WHfrY0TcXsf13XlWazKUtLS/LDH/5Q/v7v/17q9TpJAkgUcPaSJAnSNA3u3r3b
91 /fDDD+Xp06eyu7s7NMMxg52U3LhxQy5evCiXLl0KRCQQEanVamw3AoAXYG9vT+7evSu///3v5d13
92 35UkSYb6JDW4L/Mqt0oQHMfJVhDSND3yrK7rSrvdltXVVdnY2JAoiqggIFHAi+G6bs9xnN6zZ892
93 vvjii+6jR4/k6dOnR2Y4bH+uWnKgfywuLsr+/r4kSSKzelYDAM6D53kSx7Hs7u7KvXv35Msvv8wG
94 z6pvSpKktP2RvhJiW7lX/ZDe77bbbdnb25P79++PXe0HSBRwehXG93dc11VnErpxHGezFWYQrmqS
95 oAKz/ucwDCWO42x5mGQBAF4cNbMehqEcHh5ms+0qVtv+Xqb+xnXd7BnNfkhPFNRzDQYDGQwGM73a
96 DxIFnE/A6qVp2qvVaj3f98XzPHFd90ggmoUkQd/7qs9Wua5LogAA5yBJkiMz6Gqbjr5lp2xJkO2Z
97 zC1Iep9U5T4YJAqYcvrMuTlILpoklHFWJ+8Z1GyPecgMAPDiqEkaz/OG+iXzn2VnrpLYvq7KQt+2
98 BByrXVEEOGmwsh0YK/LvmX8ue5JAogAA5xuX9QGybTBdldl2M1lQz6SvNJAk4DSwooATMQNukWXd
99 sgdps9NRh+ZY6gWA8x046/G4jNuMJkkQzD6XPggkCpjqJGGSZKFqz27O6gAAzscsTNzoiYL5ef3c
100 AnBSrEkBAAAAIFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAABIFAAAAACQKAAAAAEgUAAAAAJAoAAAA
101 ACBRAAAAAECiAAAAAIBEAQAAAACJAgAAAAASBQAAAAAkCgAAAABIFAAAAACARAEAAAAAiQIAAAAA
102 EgUAAAAAJAoAAAAASBQAAAAAkCgAAAAAIFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAABIFAAAAACQK
103 AAAAAEgUAAAAAJAoAAAAACBRAAAAAAASBQAAAAAkCgAAAABIFAAAAACQKAAAAAAgUQAAAABAogAA
104 AACARAEAAAAAiQIAAAAAEgUAAAAAJAoAAAAASBQAAAAAkCgAVmmaUggAAJwhx3FGfm3U1wESBZAk
105 vMBgTUAGAExDkqD3S/RPIFFAqYIXAAA4njRNs48i3weQKGDqkoS8ZIGZDQAATi9pOGlCAZAoYKqS
106 CBIGAMCL7HMAkCgA54YZGwAgSTiv5yQpwlnyKQKcVrAatwxKsgAAeBHxuKoxedTW3llMlnD2WFHA
107 iQIWwYhkAQCIw+VJKoBJsKIAgvQxAzAdEgBMb99TpRhtDvpHPRsJAk4TKwrACQO2GbyTJKGQAGBK
108 4vIsJEXm17nxCKeFFQWcODgzuw4AwPklB6OSBfpnnAQrCjjV4MWSJwDgPMzqubm8NzCTIOA0sKKA
109 EycJaZoO3XxkW2GwBW+CGADgNLiuO7K/qUr/Y94yqF+RqvfFRW4jBEgU8MKSBT2ImclC0evcyl4O
110 BGQAmI6BdJHvO07MnpZ+S19BMJOFKvaxIFFAeQbEQZIkQZqmgbmiYCYJ5tuY85KMsgUzEgIAmC76
111 JRJFVxSO2/ecR59l6y/NLUe2/pdkASQKeKGiKOoeHBx04zgO9ACkD571BEIFqiq+jE09l7rpKAxD
112 iaJoaAkcAPBC+iZ59uyZDAYDa/+i4vJJD/hOy+Ud6hkcxxHXdYf6I/NnjeM4m+BzHKdHbQGJAs5M
113 GIYSx7F4nicLCwvS7/dzrwOdhTdjqmecm5uTer0unudxPepfyibQyozOCaB9nXlsbjabsrCwMDSY
114 Ps1E4byfz3XdI9dwe54nrutKHMeSJIm4riudTkfm5+el0WhIkiT0SyBRwIvRarV2fN/feeWVV3o/
115 /elPu8+ePZO9vb3cxKCKyYKtk7l69ap897vflQsXLoiIBGEYbkdRNPQ9nudJHMcj/9ue5031s4/7
116 +fXn7Pf7gYhIrVaTMAzf8X1/hwENcPIEIYqibhiGb0ZRJI1GQ6Io6pU5rkwSb/RnUV+Pomh7Y2Mj
117 +OEPfyiu68ra2lqWGMRxLGmaiud51ln3skiSRBzHEc/zjjyDerYoirLvazabsri4KK+//rp0Oh2p
118 1Wo0HpAo4IXMaPTSNO1duXKlt729LYPBQMIwrGxSkJckmFut1tfX5dVXX5VWqyX37t3rPv+eQHVW
119 SZIU2hM7zduWbDNS5r5Z/XkHg0Hguq4sLCxIu93uttvtW2ma3iJZAI6fJAwGg+3Dw8PtR48evXlw
120 cCC1Wk183++Z7bQKWyBtMUd/LvV1x3ECx3GCV199VXzfl83NTfF9X1zXlSiKhhKFk/ZV53U+QT2r
121 7/tH+iC19SiOY4njWBzHkVqtJq1WSy5fvrzTbDbfSZLkHc/ziL0gUcAL0dvc3LxVr9ezGR21JDpr
122 kiSROI6l3qzL0sJSsLOzE3zwwQfdR48eBfv7+9n3qZketURc4kTxSJJgfl79OUkSmZubk6tXr8qV
123 K1e6L730knQ6nZ6I0FkBx9N98ODB9tdff/0Pn3zySferr77KHfyWbeKmyBXa+gFdFXt935dmsynf
124 /va3d37wgx/s+L4vFy9elHq93vN9v5fXR6kB9aTOI36riSaR4RUVPSnUziNk249835d2u91rNpu3
125 PM/bofmARAEvyk673ZZms5kN+PTgVdZl7uNQMzjPO6Ltx48fv/n+++93v/rqK3n48GHW2anlb9d1
126 S59Q2ZIFs8NVf19dXZW9vT1pNBpBEASBiAQ0H+DYgidPngR//OMfu++99558/PHHQ4PIsiYJecmC
127 7Tn0xCiOY6nX69LpdGRhYUH+5m/+pler1XrLy8u9Vqu147puT8Vo1S+pfxbZRpnnRfdx+s9q23pl
128 +5x65jRNe57nse0TJAp4ocGcWWGLfr8vDx48CD755BP5wx/+IHfv3s2dga9aopD39c3NTZmfn5du
129 t3vkNhIAkw8Ynzx5Ir1eTz766CN57733KhdfJo0/jUZD2u22fO9733OiJOr5vn/LcZx3XNdlcAyQ
130 KADTQx3i3dvbk2fPnsnTp0+P3O09rjOf1s7etmJguxLX/J5msyl7e3skCcApJgv9fl+ePXsmjx49
131 KjQLX9R5xp/j7v1vNBoyGAzk4OAgSOM0EFeEixMAEgVgKhMFz/PE9/3sz6pjL/Lym5O8AOhFd+Tm
132 rJ7t51YvAlL7ZwGcToyp1WrZeSfzhVu2AX+RBOC8488k/2/zBWMK14ACJArAVFNnEGyD47z9/GXZ
133 MmB7gV4VX6QHTDMz+bZd91nGq6rz4uO42OK6rrr5acfzvB4rCQCJAjCV1G0TqrOzzfTlbT8qy6C6
134 yJYjHbN7wNlMRuhJQt4NZFVP2lXSVK/XpVar9Xzfv1Wr1biCGSBRAKaT6pCTJBl6+U2RDm+an0f/
135 Gc1lf9v36InRrF6dC5zFZIT60BMEc1LiuInBi45Do64/LZLg6IkS246AM5qcoAiA06Xu+FYv+jE7
136 8rI+kzmQGHXuQv9cFa6EBaaJGhSr+JK33bEscWVcPBmXKDwvi26SJN0oirrUEOD0sKIAnCJ12FAf
137 GE+6XWca2VYPijwPh5mB02cmBkUOIheZpT/P2JQXY/J+JsdxsrctP08WgjRNgyRJeFcLcJrxhiIA
138 Tlfe6sFJtgRMS7Jw0oHFSV5yBGA4+Ta3GxWJMdOctE8aT8wyYOsRcPpYUQBOiX4dqt5hjTvIXPZk
139 YdTXtW0BQ2UE4GTtUP8o8ztaiiQDtmfQ33ivkie2OAKnj1YFnFEnDsoDOIvJiKolAyeNLWxtBEgU
140 AAAAAJAoAAAAACBRAAAAAECiAAAAAIBEAQAAAACJAgAAAAASBQAAAAAkCgAAAABIFAAAAACQKAAA
141 AAAAiQIAAAAAEgUAAAAAJAoAAAAASBQAAAAAnA6fIgCAM+EYf08pEgAAiQIAkCA4OV8nYQAAkCgA
142 wIwmCI7YVxRSEgYAAIkCAMxWkpD3oScJqZEwkCwAAEgUAGBGkgVX+9AThUT7IEkAAJAoAMCMJAgq
143 SfCef9gShfj53xPjawAAkCgAQIWTBT1R8IxkINb+nD7/GkkCAIBEAQAqnCCY24487c8iw9uNXPnL
144 igKrCgAAEgUAmNGkQbRkIO9GJAAApg5vZgYAAABwBCsKAHA6zOtPE+1ridivRwUAgEQBACqaHIiR
145 HOi3G+lfj7WvkzQAAEgUAGBGEobUkiTYrkdNSBAAACQKADAbSYKeDKg/j3rhGqsJAAASBQCYsYQh
146 0RIDPVFguxEAgEQBAGY0SRh1BaqZJJAsAABIFABghpIFPWHISyYAACBRAIAZThiKfB4AABIFACBh
147 AACgHHgzMwAAAAASBQAAAAAkCgAAAABIFAAAAACQKAAAAAAgUQAAAABAogAAAACARAEAAAAAiQIA
148 AACAqcWbmYFTEsexiIg4jpN9Lk3Tob9Xgfk8aZpO9P0ATiZN0+zDbGvj2mMZnm1SSZKI4zg7juP0
149 XNftUUOA08OKAnDGg+myd9zjBv1FEgGSBQBnEY/0hMl1GdIAp40VBeCU6Z2W4zjiOI4kSSJJklTm
150 2Yp24ipBqFKyBJyXOI6ztuQ4TiUHxrZJhbz4oVZsXdeVNE2dKIrE8zwqCnCKSL+BU2J2UKoDY5YL
151 wGklCrZkXE/Kq2jcsz3/epAkSZAkSUBNAU4PKwrAKVNL4UmSDJ1RKOv+4SLbqEZ15PrWAHOgA6A4
152 z/OGVhLUKmUVEwXbWS/bmQzzewCQKACl6ODUAFlPFEYNtqucNLH1CDidREFtaTRjiUoeqnCg+Tjx
153 1nVdDjMDJArA9NM7crMTL2MHXuRnHvU9+tfYPwycXZuswox63urBuGTBdV3xfYY0AIkCMMXMPcP6
154 jHoVOvFJDhrqKylsCQBOLo7jbEuj2cZmYRUh7zmfx1hHRII0Td8Mw1B8399xHIfVBYBEAZjehEHr
155 xI507lVKFmwJg36YmwPdwOkkCurmI8dxxPO8oTNR49roNMo7d5A3KWGeS1AfcRwHYRgGjuN0Xdd9
156 h9UFgEQBmMpOT12FalzdV5kZv6LPoT8zZxSAk7OdUahq2yryXMah7h3P83qu6+5U4SpqgEQBqKgo
157 irJZP9/3xfM8CcNQZq3zMm9/AnDyREF9iAy/Dd58+VjVJyLUJIx6bs/zxPf9nuM47zSbzVvUFoBE
158 AZimzi0Iw1AtfefO+M3KXn1VBvqMn9o2AeB41BkFM/muYowZd65Lf5FlkiTS7/edMAwD3/eDNE0D
159 zicAJArAVBkMBhLHcTbjp28R0Ge/qnIziW1Qov/d8zyp1WrZjB/bAYCTJwoqWRAR69mfKpwHGpX4
160 6JMwekxJkiTY39/f7nQ66uu3SBYAEgWcXyAPoijq+r4/k2/BVAmB/vd6vd7d3NyUb3/727KwsCCX
161 L1/OEoayMu9rt20LMG830jv25eVluXnzpmxtbUmz2QySJNnu9/vW7RO6ql+jGkVRT7+VZdbbU175
162 PP/zTJeL3j6SJNleXFwMLl26JN/5znfE932p1+viOI4MBoPKJwp6rFGrlM1mU+bm5uTGjRs7nbmO
163 SCpBv9//R9d1gyiKeqr8zJhStRiTt1qbpmmPG6BAooAXniTEcbwdhuF2GIbBqD2lVdxqo2ay9G01
164 juP0Go1GsLa2Jq+99pqsrKzIw4cPsxt/VMJQZL/+tJWZufc575YSc8UkjmOZm5uTV155RTY2NsT3
165 /W4URdLv94Pn+4lHJh5lHdgU/P5eHMc7/X6/9/wMSzAYDLqDwSCoevsZV2bPn7mXpumOiIheLrOw
166 dc8cJD+/0Ue9lTlot9vBpUuX5PXXX5f5+Xlpt9viuq4cHBxImqbW97gUKftpKNsifYn6Z5IkEkWR
167 NJtNWVhYkGvXrkmj3pDd3d1gf3+/2263A9/3e/oAWt8OWfa4M6qs9BUnx3F6juPcYoUFJAp4kbr3
168 7t3bvnPnzj/0+/3uYDCwBtmqdurmtpsoimRubq4XBEHquq5cvHhRms2mLC0tZYmC7/vium7hQ83T
169 VHbj3p1gDmz0rUadTke2trak0+nI/v5+cPfu3eDOnTuSpqnUarWhPca2ZOM4g/LzKjs9odITQlUH
170 1Axomqbi+V5vY31jZ2lpqVev1+XZs2dBr9cLwjDs1uv17HvVv2vWubJetasnkaps9C0kjuPI3Nyc
171 dDqdXqfT2RERuXPnTrC3t9e1DYDLlnSfZGJiYWFBlpeXxXVd2drakm63K47jSLPZFNd1JYoi6/Wh
172 xxmMT3OiYJZLu92WpaUl6XQ6zuPHj9Ovvv5K7t65G3ieF5htJ+/q1WmvJ2a5mNdtm+/uiaJIXNeV
173 ZrMpq6urvYsXL0qtVuuJCIkCSBRw5gErSJLkzW+++ebNd999t/vs2TPZ398/8eCujIMdfbZva2sr
174 iKJIkiSRg4MDOTw8lMPDw6xcVKIwGAwm3qtvDg7PK0kwD2nrHZbt4KGa3QzDUPb392Vvb096vZ78
175 9re/lTAMszvg9WTh+azpkf/3NNcfsz7YEgXP8ySOY4miSEREms1mcP369eDSpUvS6XTk/v378v77
176 78vu7q40Go3se9UWLfXfU4Nl/frdMrUbvc2ISFYH4jjO3guwsbEha2trwerqapAkiXzyySdy//79
177 UtWJs0jMgyCQl156SVZWVqTZbMpgMJCDgwMJw3BkMm8bZFZpwkatTO7u7gY7Ozvy8ccfy6effjp2
178 +1KZJ6jMSzL0M3FpmspgMBDf92VhYUFee+21YGNjI6jX62xrBIkCzt7BwUE3DMPuxx9/HPzrv/6r
179 PHr0SJ4+fTqz11+qTueVV16RMAzl4OBAPvnkE/nmm2/k3r17R2Z+y7b1aNxtKuPOLGxsbMj29rYE
180 QSCO48jHH38sb7/9tuzt7WXbt8w3WE/yM01r+ZkJlVpRSJJE6vW6LCwsyJ07d+T69euyvLwsX3/9
181 tbz11lty9+7drJ6oxEnfsqYG22U/GK6Xi0qsfN8X3/flypUr0u125cKFC5KmqfzP//yPfPnll6IS
182 8UnqQxVWFNSq0htvvCE/+MEPZHV1VWq1mvzsZz+TDz/8cOgFbKNWXKY9RudtaRwXk9bX1+Xy5csS
183 BIFcvHhRfvWrX8kHH3yQXVNtSxLKeI2s7Xes9y96LE2SRBqNhiwvL8vh4aG88cYb0mg0GMCARAEv
184 zp/+9Cf5+OOP5cGDB/LkyZOxQbeKKwr6C9Vc15Xvfve7sru7K3/4wx/kiy++kJ2dnYkGwEUGOudR
185 jvrM9aifx7acHwSBXL58WZrNpnieJ1999ZV8/PHH8vTp06GtNXrnPel2iWmsH/oz6c+QpmnWgS8v
186 L8vCwoI4jiP379+Xzz//XG7fvp0N/NQgUV9BMP+7ZW1XtsGOuiUrDMPs2eM4lk8//VQ+/fTTI4nC
187 rExOqBWpTqcjly9fzt4Z8Nlnn8mHH34oYRhmn7OVyyTlVLYyVVs9VZ1pNBpy+/btbNVSf8+EOSNf
188 xmQ7Lxm0xedWqyVra2vyxhtvZCuZAIkCzlyr1dppNBo7nuf1BoNBt2iw1QP1uMFwGQc6tVpNlpeX
189 xfM8aTQa2SDnpJ2w3glMYyee97vTf9/qVhLP86Rerw910uafJ/3/2Mr3POvTqO0BShzH2XaRRqMh
190 CwsLoq50NFecnh+Uzz5ntreyzpjb3lauDqeKiNRqNel0OlnSpAbD45KNspdLXp2KoiirL61WK0sK
191 bOVy3AFw2ZIElUA7jpPVl5WVlSzZ1FdabJcxlPHwsrnNU38mWx+rJmJm5f09IFHAdATnXpqmPc/z
192 emrf/UkHsmXba20+q3mwTO2zL7IdoGwdeNHflW2QrO/fV+Wkd362GfOylNG437F+qFIdVFafN7dD
193 5P23RiXbZU6y9b/rW6xUfNETphmLtdb4oh9wNw+05g0Yy3DGZ5Jkz3xudWGEem+LShJsh7vLWo+K
194 vMQzr19Sq1IAiQJeCHVVX7PZlFqtZr32s8yD4eMMCqMokv39fVE3QJkvWssbPJcpIZr0d6XfwNHv
195 98VxnKFtEvV6XcIwzGaRzTc5F/3/TMOgKG9wr5IffS+++c8wDLOX9ZnJg3k2ocztZtSgUB/4monU
196 WdXjMtBjh1pxUWdX9DIdd+lA0fI4j0H0qFVJWzzR/66/p0afcMhbVdHLpkxbj/J+p0XPpejvrQFI
197 FPDCEgU1e3PSJKFsbHtC1fYItUXAfHvoNG8fmvSZJ+nc9Jl08+pTczVBnxEt2wCwyBkdcxZUvUvC
198 7PRth7vNswplr0t5z2yrH2Y9mrS+ljke5V0WoJeZkreFb9pXF8YlM3kz6ebtYvrfbWWkf75qfZTt
199 kgMzKcp7IRtAooCzqzzPBzmzGIDMFxupmXPz5T76lpoqJAuTdlx6cqDPaumdunnVahkGN0UGv+rP
200 5uBF31pTq9WyrWrm4EZ/t4D+LoYqDXzNmXDzZic9UZh0QqLsg0FbWekvcBy3Ze045TBtZWYO6s2f
201 L47joW1G+vtYVOyJ47gSt4TlJTh6nLUl2FVoCyBRQAklSTK0XcLs9GclWVCdku/72f33+gBP/75x
202 h+imNZiP+r2O20esd9zmXd/6LTb6FhNzP3qZ3xeQ97vV3x9hJhe2AXFVDjHbykk9s5lgqvcrmOVU
203 xjpxWgNmNTDWD+qadWLSLY7TPIFhe0ZbAmW2nXGTDmU/F5cXZ23nF1TSzYoCSBTwwqiXR+kvD5u1
204 TtvscHzfl3q9LoPB4MhWmjIPbEbtHy6yb97stGxbaMwOzUyoyrQSY87u5XXs+qAvb8uN+e/kfW9Z
205 65O5eqInCfqZDtugeFZijF4uep3Jaz/HTRLyBuHTGHPzbvdR5WVLFsy2V8Y+a1SikDcZNe5FqACJ
206 As6Mufe8jAd1TyNwq8Gted2n/rm8QF+G8spb6h41K2e7r1wN+IpsARg1CJ7221v0twybgzizAzfr
207 irkVyzaAK5JUlLEd2cpSvZE6b/tEld/MPGqLib6d77gXAJgxrKyD5FFnDsYlUmVOsouWEbcegUQB
208 50LfZ17Vw2GTBG7bLJbt4N24QXAZB3a26wdt36vvIS6SAJSxfGzlYnsRUl5ypepR3naSqiTX48rN
209 TBaqVgYnGRSbFwKcNFHQ62qZ3tNifs089G+7PnRUnCprwlA06WFVASQKeKHUXkeVMORtP6pyx27b
210 g66/LEo/oKoPlMvcKRUpD3P2W3XeZnnYBitlvs1n3GDWdhuJfjDVdth9VHJx0jd+T9uAWH8+fUvW
211 qDZX5dhiO6+iXwdqiyu2enPcK4bPO57mDfBtkxP6/nt1Xbftv1v2bXujkmzbVbKqbMp+AQJIFFDi
212 RGHcFpSqd+xmJ6QPjGfpbZjjZv3MG5CmcaBy1h38uNtKJq0rZb/FJa8tFbkHfxYHPXl1qApbz45z
213 7bIt7prnpmwXIlThrMskqwckCCBRwLkostdxFt6lYBsQq0TKNotTxkFOkZ933Mub8rZk6eUxaja9
214 rGc5bCskZpnknUuoahsqMptrJk6zdv5p1Lkg/aawvKSxKjHGNri3tSl9/71ePuOuWi7rgNq2tSov
215 frDlCKfBpQhwloPIqj//qEHgLA5y8gaGRQdDeStTtBHqzSzHFvW5vMSyqnGm6DOZb2eetGyr1D5G
216 vasEIFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAABIFAAAAACQKAAAAAEgUAAAAAJAoAAAAACBRAAAA
217 AECiAAAAAIBEAQAAAACJAgAAAAASBWmSow8AACAASURBVAAAAAAgUQAAAABAogAAAACARAEAAAAA
218 iQIAAAAAEgUAAAAAJAoAAAAASBQAAAAAkCgAAAAAIFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAABIF
219 AAAAACQKAAAAAEgUgJNK09T656o+q+0ZHcfJ/qn+PO7fmZV6Memzz1p9Aoow48qs1J9ZjZ/HqRej
220 +iHgOHyKAKc1wCGQC4HZ0rmfRrIwS/Vn1HOr+kVbm614kqbp0MBP/f5VfaE+FCu/Kk9A2JIF4DSw
221 ogAGxTiz+qEPbqgvAM5C3qD/JBMVAEgUALygZJIkAQAAEgUwKASsSQJ7ZgHQXwEkCiDoAtZkYZJ/
222 jzoF4Cz7H2IMQKIAnItRtyIBAKY7iQBAogCcSYJAksDtPADOPyEgSQBIFDCFwXoWgvOs3md+nN+/
223 fk3qpGVER49Ziy04nuPGX+oUQKIAnHmSADmzl8xR3gCKJAm2d/vM0ssbgbPAC9dw4kEcAzmMqgO8
224 EApnVdeoVyhaF6grAIkCgClMEookmCSbOG7dYwAIYghwdth6BOCFJQn625pZjQIDRJxmHTDrgvlm
225 eOoKMDlWFHBmgZuZPuR15uojTdOhDnzUCgT1CYAtNoz6KJJQEl8AEgWQLLzwATHGl80s1RHbYW+M
226 TihBXSiSJIxKGIq2vzLGItoISBQwleI4HgrMruvO9M0S6nld1xXXda1L3PoMet4NHdPaaZ30radJ
227 kkiSJEeuSVXPp5dLkbKZ5g5bfybz0K1ZB5IkkSiKjvw7+veY/92iKzBlajv6ypLruuJ5nvi+nzvI
228 m6XE0oytqqziOM7alOu6WTs7TtlMQ106zpvb1c+s2lLeNcx5Nx+VtR7p8SKvr2ASAqeJMwo4liRJ
229 cvd/zurLxfTOPS9RKFJO01R+p/Gz5HXcozrzstYD2yym/vvW60bRl/PZ6kxV9lvnJVj652dx1nTU
230 7LgaGOt1yhZzjhO7yhhjbBMQejIw6u9V6HNGxVrOZeA0sKKA42WYz2f+9KTBnM0oGozLGsjUz606
231 6SiKJEkS8X3/yEygWUbnNWg/Tid80p/XNkueN0Nc9EV2o7YRnFd9ss3u6gNg1WZUGfi+L/V6Pasv
232 eUmVPmDW21zZB9HqefQZ4SRJJI7jrC3ZEoq81bZprBMnia/q96w/j1rNdV1XfN8Xz/OOJA36vzNp
233 +y5TjNFXtPX2M6ofGjXAnvb6pMdOvQ3kJQeqX1JxR8UOYOJ4RBHgpAH+JEGz7LMd5uzwqK0nx90a
234 MA3Pd9LBoBrAmJ3dqJWXSX6GaatHtpn/vMQhb5Uhb5a4KjOE5oBGDYz1rWqjyrXqscUWb/WEUZWb
235 ucJw0q2CZa1LeTG2CvEk72crsjqivq6STGBSrChgYmoWK4qi7O95MxtFk40yDqDz9pOHYShJkmTl
236 NMkM3zS+W+C4P4e531yfKVaz73qCpZepWoHJqxej6st51CVzlk+f6VSz5Pq+cv2f5sBY/bu+7x/5
237 ehzHR8qpLG1HTwriOD6SFOmJpL5iWfR3Om114iSSJBlagVK/d9WefN8fWmFQ/04ZB/0n/VlV+1L/
238 1OuQrY2YZ6OOU1/OK8aYv2fb+RU9MYiiSKIoyuIPQKKAF0oFZz1JmIVDzaNmiVUgtwXwsidHx2UO
239 /myHcdXWAf37R20zmdbBTl6irP/O9UGwPhusEotRWwqKDHLKNDi0Hcy0HfzHcOwx28usMldwVXwp
240 Eo/y2ui0J1N5ZxD0pMjsjyeZrAJIFHCq9JWF4wbcsh24MmeqzOdVnbg++2sb+I3q+KaxgzpOJx7H
241 sYRhKGmaSrPZlGazKbVaLZtVVv8Pc6bZtu2mLHvO8w5Wqp+7VqtJvV4/MtuptpOoBNzWuZtbTaa9
242 LGzxwpYo6smS+rqaEVWfNxNsM3GqEj2G2LYz2var2841lCGROI3tja7rSr1el2azKb7vW9uh7d/J
243 uy1oGutT3mSESo70tqRvUVNxhTMKIFHAuQQuc8uF2YGfZocwTQNB/Z/6IDcMQxkMBtm1l/oBwzLO
244 /J3kwKzqoKMokjAMpV6vD5WDbfBn1pOylJk5mLMlj3pHrj7UYFjflqQnSiopMGdAyzpANmfC9Tai
245 f10voyKD3qrdjqTXFb1OqRhjm4gYF3+rFmP0MgrDMPswk+hxVwvbEolprU+23+uoa6W58QgkCjgX
246 +s0barai6HYa2yxx2QbQ+s+r9pKrW48Gg4EcHh5mM6HHeenPJJ3EeXVORQeFaZpKGIbS7/fF930Z
247 DAbZCoN+hsM8jGnWpzLcE26eHTB//+o5oyiSfr+fJQj6IMe81UY/06FvOzH3+JdlYkHNfuoDOnNL
248 mvmegFEzw9NeJ06rzak6FYZhFl/0yYi8ZLvogPe8y+4k//84juXw8FD29/dlf38/S6T0ZNu2Xads
249 MSavr8hb2bb1PwCJAk4rIAVaoOnZvqfT6cj6+nq2laLI4L9qM376bOjq6qosLy9LrVaTtbU12d3d
250 lcPDwyPbRIoMpqoyCHIcR1ZWVmR5eVmWl5el3W7L0tKSrKysSKvVylYY9LMu+tWyozryaatL5myl
251 nijYfva5uTlZXV2VpaWlrEy2traGDsJ7npcdQjRX707jlpvzqhMiMnQRgr6VL0mSrL6srq5KkiSy
252 uroq6+vrY/flV+l6VNuK0dramiwvL8vi4qK4ritzc3MyPz+fe4PYixikn3cZJUkiKysrsr6+nrWn
253 tbU12dzczJJP2/Yt26pCXrlP4+RUXl+rP1er1ZLFxUVptVqqLALVt+f16wCJwjEGzFEUdR3HCVSn
254 NulMR5mo5wvDMIiiSBqNhqRp2tOfJU3Tnuu6wdzcnGxtbYnv+9JqtY5c8ThJR13GWQ/zKr6NjQ1Z
255 X1+XdrstFy5ckMFgIHEcS7/flzAMh+7KH9U5Vy2ZWltbk/X1dVlbW5NWqyXr6+uysbEh/X5fms3m
256 0BacNE2l0WhkN72UJVGwzUTqdUPfTqQGL/Pz87KxsSGrq6uyuroqBwcHEgRBNog2t6yZs6NqS0qR
257 w5vTVE76Connedl5lTRNsy17qs5sbGxImqaytbUlz549y773OIlCmdpW3vaSra0tWV9fl5WVFRER
258 WVpaksXFxex9CidNGMpGrc5tbGzIxYsXZXNzU9bW1mRra0uCIBi5ulfkvT/TFmPMd6not6aZh9yj
259 KJJ6vS4LCwvS6XTE87wgSZJttbKr+vUqj2PGiaKo5/v+DkkTicKJkoTBYLD96NGj7b29vWCWnt11
260 3UAFmzRNe6rhxXEsc3NzvfX19eDy5cvBT3/6U3n27JkcHBxYb2yZ5hmakzDfkBpFkVy8eFFefvll
261 cV135/Lly72nT5/2nj17duTFWHqyMAva7bZcvXo1mJ+fD+I47qotNmrGS22/Mcv2OEnnee4r1ge/
262 5uF1tSqgDjGrxPH69evS7XZlcXFR6vW6/PjHP5YnT55IrVYbGgSo/67+Mq28sxBlGNzp7cB8KWEc
263 x7KxsSGbm5ty5coVcV1Xnj59Kq+88orU6/VC51qqkmSbW7E2NzdleXlZLl26tLO0tNT7p3/6p97f
264 /u3fWq+TnRVxHMvi4qKsrq4GnU4naDQa3e9973vSarWyVUu1pS/v/SST9FXnGWNsq5a265hVQl6r
265 1WRxcVG+9a1vSbPZ7D558iT45ptvgkajIb7v9/RnNq8mrkoiqY1pjny90Wj01tfXb6VpeotkgUTh
266 2EnCwcHBP3711Vdv7uzsdE86qCxTw2o2m+J5nuzv70sURUP34AdB0FtaWkqXl5flxo0b0u/3ZTAY
267 jL3acdIZtGlPFNTvVe0xV1slVlZXpNPu9FzXvaWSLLWFZJLZjorZ3t/ff/PBgwfdCxcuSBRF4rqu
268 tFotCcNQoijKykXfd23rzIuc4TiPNqcGImp2V7UFlUiGYSiNRkOazaYcHBxImqZy4cIFWV1dlVar
269 JWmayrVr12QwGEi73c72o6sOXK1I6SsJ+v+3bG1HvSNiMBgM3dgjItJqtWRubk7W19ezhGptbe1I
270 olDxPmhoVUm1Edd1ZWlpSV566SW5cuVKz/O8HTU7POO32mw/ffr0zQcPHnS73a64risLCwvSbDaz
271 VV3VdmyDxqKxYxomvvK2H5qJQr1el6WlJdnc3BQRCe7cuSMfffRRt1arZZMR5oftZZhlGsPoq7nm
272 BJ35PGtra71OpxM8X8EmWSBRmEwURd3Hjx9vP378+M233nqr+4tf/GLkzQJVY9vbqbYJ/OhHPwqa
273 zaZ89NFH8vbbb8uDBw/kyZMn1rvPq1xO+j3/ruvKSy+9JD/5yU/k9ddfd65du9ZrNBrv1Ov1W7Sm
274 P9eDR08eBR988IG8//778v7778tgMBg6zDzqvRRFVxPOK0E39w+b/281U66SRjUY/s53viPXrl2T
275 xcVFuXv3rrz99tvypz/96ciWAn0wMOrsQ1kTbX1Lhe/7cvHiRbl06ZJ0u11JkkR++ctfypdffjlz
276 q3HmoFDtv0+SxFlZWZFOp7PjOM47tVpt5uNMFEXy9ddfBx988IG899578pvf/GboilnVh9ne3lw0
277 dkzTCpa5kmB7BrU9+PXXX5e//uu/lnfffVf+7d/+Ldv+l5f8VGUXgO051CRFu92W119/Peh0Otsv
278 vfRSr91u90SERIFEobgkSYIwDINHjx51//d//1f+/d///citG1UcBNveLqv+7vu+NJtNabfb8uMf
279 /1g+//xzuXXrlnzzzTfypz/96UjjrPLLkvSA6rquNBoNuX//vmxubsrW1lbwyiuvBOpcC/5sf3df
280 bt++LR988IH853/+p+zu7lrrSZEB8Li96OdZJ2wvkjMPtNdqNVlaWsq+f319XW7fvi3vvPOOfPHF
281 F9Lv963bJIrc/FPGNqR34L7vy82bN+XGjRuyt7cnYRjKL3/5S/nd735X6FaaMidQ4+r41taWdLtd
282 eeONN4LBYJA2Go1uo9F4h+jyZw8fPpTPP/9cfv3rX8utW7eyMy/6RJc6C3Oc2/mmrc2o51KrTvok
283 guu6sry8LJcvXxbHceTKlSvy+9//Xn7xi1/IwcGB9Pv9I/9d/RKJsrYf21XBZpmplZYoiuQnP/lJ
284 EAQB/TWJwuRUUNGXuke9uKWK1/LZ9tWHYSi1Wk3W19el1WplB3bz9m1O4+zvaQcj1fGEYVip/Z1n
285 0abUy9bGzWSNqxO2t/lOW/vRJh2s8SJJkqHku9FoZCsP5n+vSnej22Kl2l+vrtJVKym1Wm3oEPe4
286 dliVMtLjr97/qGtA6/X6zuLiolqx3CG6/Dm+1Ov17GINdQ5Kjy1qW2PRfmra6lPeeyD0n03tBtBX
287 JJvNZnbrnHlmLu/tzWV8l01emeRdUZ2maTbOw2iManKCjuM51oOJVWZ7aZq5RKs6cPNtkLOwbziv
288 zNT1ntxZPbqj1bfe2LYYTdopT2Ody7uxxkwe9EO96vyBOvRsdm7mJEUV6tmojtx8q+wsxhfb71cN
289 cFzX7TUajVue57Gv2ui31USEedBXRIbezVHmhHLUu4jMLcCqHdXr9Wyr56iXFlalnY17Dv2SCN5Y
290 TaJwLHEciyRy5CVHtqBStQ7MNmuhVg1UoHn27JnEcTx0leWsD4Ixvl6Z+4NP4zrHaat7+iqHihl5
291 Hbt+Naz5gjGzfMwZvqqtYtomJY7TtqpUNiNWZHtpmvZIEvIHgEVW4qoQt23txvy7fqHCqDhja49l
292 bkujtn/Sd5MonGnnPysVy/ZeBJUU9Pv9bOvErNxCMm4wMot15LTKLe+GozLHi3H1QU8S9LdTF91i
293 U5VOPC8xqPLVp5P0ObOwkn0WScKouFP2GD1pfdBXvUetKFSlnZmrlXo5mL97+utiOKNQoEFOemd5
294 2Q/UmW+BVZ/TX+aivwSqaBlWtX4wOzFZojCqXYyrL9PepvI6KVtMsK2ynMVAYdpjq/n3SZOEKg+k
295 zWczb/KBZOWRF1tOcq7wuGcazjq25CVCtq3AtmtQ88YrZT9zqU/Q2FZM9HHMeb4To2xYUTiHhj3t
296 CYLeiPSzCGrpTr0hVQVn8+VJs3RuYdbehnpabcKcGT9JXZnWelbk2fT7zyfdAlCF/dXjEofj/u7L
297 Hntss+Cqjszqy9VGsZ1lGXVzURUT0FErKeYW6lHPX/b+LC+GVukZXzRWFE6pw6vKcp66MUFdVyjy
298 lyXdOI7FcRxpNBriOM7QysK462OrlL2P+l0TfCZrM6dVXuddv/IGuHlvfdUTTHWgTr8xq8rbA/R3
299 kIxLDE56fqWs5WXbKqNP3KBYHSsykCxrkjDJrYIqxugv8dMH0nkroVXvr0GicKozO0XuXbZdLVr2
300 TNy2x0+9qTnvurlJGyx7cGerAz/utZbj6sl51SPboGSSbYrmx3H2IFexI5/2/zZmd0wwbXG0yLak
301 Uc8w6gV0Zf9d6e+XMN9AjWLYemRhLuuO299XlduQxgUUczvSpHurZ6ZRsTVgbOeWF6TL2J5G3TpS
302 NAmatOOqyovFTvL7JfZg0gF1lepP0WQh77lt2z+r9FJHMx7bEgUuCyiGFYURKdRJ34hatgpoNhy1
303 1Uh9TQ1+1UE69Xd9GRM4rY6vjC/6GZcY6G1MvyLVdiPJqLKo0oHmUYnPrMaUvCt11bkwFEug87b8
304 FblQoUztaNyKQpFb1arQ9sxDzLbyof0cazgMe8G4pX7x00mzb/V3/QVI6iCU+pzaU83KAiYdHI47
305 4Fu1gUve+xTGXY1atK1WIeaMegnfrCcLeiy23QeP8cl1kVnksrSpUZMqeYeabQfkqxZzGYecDVYU
306 CjZG20xFVd9MPG6fuP5W2Vl4CR1Od1A4S/Vj1OH+vCsMZ6EjzLu+kBWF/HISEZKECZOEvNnkKryH
307 RP8wxyJ5V7ub14dWca++7SKAUdutQKJwJsFar5Blv3e4aEeeF6BmvWOfpatgTzOAjwvkVX1e2yQE
308 cfXotkdWFMR69TQmTxZsf6/qLoAi5VLVyYdxcca2WwIkCqdWyUbta6zSFgrbDKc+oFH7Y1VZqFuP
309 ZvXNqXTepzt4LnNHnrc3elQ8MO81L3LlctFrmcueNNjKatbaSd4ZFy5LsMu7Xvg028h5xv1RMabI
310 pETeyspJkoxp72Ns74YyDzWjQNuiCM5nUFSmnzvvYBgDZZy0PeRtwaniYDjvbvxJOqsqzIrakoBZ
311 uxJ2kuckzp68js1CPM1LLGe5jzG3oDF2OR5WFHIkkowcwORVOLPTK3OyYN76pJ9JyHsV+qw0RALN
312 2Qf3WagPx7mSsMx1z4wPo/YPm+Uzi+1CH+CojyRJspvnoPXZ2laSs7rlZlrqYV6SkPcyQ9v4JW/i
313 r8jqaJnaEFuMTo4VhQKBmlkMgMQL1IlpKQcShfyymtV+eJbPIZwkjjBuI1EAAAAAQKIAAAAAgEQB
314 AAAAAIkCAAAAABIFAAAAACQKAAAAAEgUAAAAAJAoAAAAACBRAAAAAECiAAAAAIBEAQAAAACJAgAA
315 AAASBQAAAAAkCgAAAABAogAAAACARAEAAAAAiQIAAAAAEgUAAAAAJAoAAAAASBQAAAAAkCgAAAAA
316 IFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAABIFAAAAACQKAIrZSZKkJyI9igIAAJSZTxEU4ziOOI4j
317 aZqKiGT/1KnP6d9Xxuc8zs9e1uc9DfqzO47Tc113R0R2aDWj69ksS9N0ZCyZhbai/l7meHle5eZ5
318 HoUyIq7obcuMNWWta+N+7lFjElv5mPHHLLuyt0v99z4qzhB7xmNF4RjJwqwNhCZ5buqI01MflIa9
319 HpEkpHRSBTtqygeFBzOuW2iQPKttyRw4E2dAonDKGeksD2L02QeMrhtpmgbqg1I6WrfMD8x2HJp0
320 8mVWE00mak5eZlWLN6dRJ0b9N8peXnn9jFpdYOKKROEUCoaiIQsvFlz1vydJ0k2SpCsiXUoKDBAp
321 l9N6Vn1QE8cxlYD6caLnJLaARAFnHojMrJzAI+I4TuC6biAirCgUTLDMujOLg0BQPuOSBMAWL/M+
322 b/49b9Jv1ndOgEQBdNIEH+ocz0xbqxQOM+O028usxSH66+K49QhHgkXRBqTvAWSwg0kDs34TxSze
323 AHScjtu8maSsz3SSn3/WbokyY7J5aBen05+VrU7k9cdF+usi7amsZZdXNjg+Ik6ORBIGdsdoXLN+
324 swQoS9oI9eUsnpm4Qzs7SZ0wtwizygASBTqlU3lm200148qFZAGU5XDnXLSNzGrHXOS5eVcLRkmS
325 hD7I0nePKo8q1itu1SNRwDkNdGyHljnEPNuDu7McSM9avaEdgYSB8jmrGFOkr67iy8hGbasi3hbH
326 GQVMFGRGJQ6zHKgJPJMnnWY90/fe0uEDdvrMOYr1YXo8mZUYY/bfrutO1E9VpXxGvXhPlQtIFE7c
327 0Gb5edkiQR15kQkWiQJoY6OfP01T3qNQ4YHtaSUHlM/4OJKmKYl3AaRSuQXjznxjyrvnnqAz0k6S
328 JD0R6VEUxZKEvG1tZU548GLqStXLPCcG8/b3YyYLVagz41Zmze/Ry0U/szAr7WdUv8JZhmJYUaDz
329 zw20enBJkuTIRxzHkiQJ16MadYalzKP0emN2WlUN1mfZJqp47WORmDtqK8lxB49lGeRoz9MVke3B
330 YNBL0/SW4zhMSkz4+y771Z/mds28gbD+fSr22q40z2t3Zb+GedQhbvWhxjLIx4hmVOE8H/DZBs9V
331 D7TmM4+7/WiWs3K9Q0/T1EmSRKIoogE9F8fxkZkss15VrQ4VTRKKTkZMsi2wam3qpM9b5nLKWeFN
332 GdwcjTHjBolln0U3n+s47cPst4sm5mUtJ/1sxrgJB+RjRcFiMBhIIkk266D2sI2qVFU50GsO4sxD
333 UK7riu/74nmeuK4rnueJ7/tDg8EqlceocsoZ/AZxHAf1ep1tAUZ5+b4vtVpN6vW6eJ4nURRlZZck
334 f25v6o2zesc/rt1NY/0at8qmty31YVsWV5/XY1CZB77mdY22352qB77vZ/WiijeyTDpxo9WZnu/7
335 PVYSjtL7KrM/0if+8urdJHX4POuDihlqlVYfHJuTeaqfNstE/dksl6rEGPVsqq/RP1+r1aRWq2XP
336 yZvOSRRONLjJy9hHLX1XYVuAbSBszgCbeyX1gDWrVPkw22evU3mD4rx2Z3sz7aQd+7TFE7Mj1rfv
337 qc4/76YOve1VaaCcl0DoWytm/b022sCuV6vVbjmOc4uoYo+/45LRqjxjXhy0vT8hb3ZdfU1NRlRl
338 km/ceySel8dOmqa9NE1JukkUJuN5nniOZz00ZNtXbZsJLGPHZiYA5m0AagA8GAyyDF0tgZuDn1H3
339 F0/bDM1xy0o9SxzHWRnoKy6QodmawWAgg8FgaPXJHAhNkmBNY70x270+W2cmCkmSyGAwkH6/L2EY
340 DnXmtv3EVTkzlXelspr9S9NUBoOB7O/vZ1/zPO/IquUsJQnq7+bMKGSofvT7fYmiSJIkySYl9L3o
341 oyYYylSueqy0nVdQcUTF3n6/L2maSqPRyPor9e/oq5V6G6zCZFeSJBKGYdYvq3OVg8FAfb5Xr9d3
342 fN/foRWRKEwcdNI0lTAMCzWWKh3mzXsWFUz05ME8nFpkgFDVDl2dS1AdFP5CDfD0Q/G2emabbS/7
343 YFhPHPSOfNSd5nlJt23CoszlM26Qph+An1XmYVUzBsNep2wrcCou6wlD2WfMVRzJS4T07Ue27Vhm
344 27MdjC5TGdkmIdROB33SJooiieNYHMfpqQ9aEInCxMIwlP39fQnD8EgDHHX4cpLbOKYx8OjBRf1d
345 Pb8a8NXr9SOznifZHlDWcjI7bzVLgaOJQpIk2bkWffUlbytbkcFQXkd2XvXJNqOn7yNWZaHKoV6v
346 S7PZlEajIb7vD23vU/9+3na/Mt82Zh42VLOX6jk9z5N6vS6+72fJtzl7Oq5tViXG6D+/vm2ErY1H
347 eZ4njUYjqzv6zLn6mlqtyosvRa5XnZZ+R48xzwe9Q/FD9UkiIu12WzzPy3YD2BIKM56q+FOmxFQ/
348 56b6ZVUHzEnO5/1S4DhOkKZpQLJAojDxwMaredLpdOTixYty48aNY2fYZczG9WCjByfP8+TSpUtS
349 r9dleXlZrl69KnNzc7K6upp7jqHo4K6Mgxw96Fy9elXW19el0+kw42ehOrR6vS5zc3NDdUXN+OSt
350 KExal86jM7cdxtY7XPMGNXWgWz237/vSbrdlbm4uO+Tted7Qip0+W1b2OqZ+z2r1Vv97u93OEijP
351 82Rubk7m5+cLPXNVEgXb4LDT6cjCwoL4vh9EUcTg5i9lFIRhGDiOE7RaLVEfaoJCJQq1Wm0ovhzn
352 VsPznITQY6mKm2rSQc2Qe56Xfa7T6Uiz2czamOd5Q383L0rIa5tljDV6f6L3L6ouNJtNabfbkqZp
353 NwzDbdd1Z/6q4TRNgyiKuiIivu/v6GXhh2G47ThOoGfetv3VVZjB0Dtx/Xn0Z47jWKIo2m7Wm8H6
354 +rrcvHlT7t+/bw0Sow5YjhswT/NgzrxJQZ/lu3HjhtTrddnc3JTvfve78vjxY3n27NnQrQq2m6LM
355 WxlsXytTPdKDUJqmcvnyZXn55ZdleXlZ0jQNkiTZNq9IVftoy9hmisQB2/fGcSyu6267rhu4riut
356 VkvW1tak0Whkq3XmeQ8RGbqRosjhvfOm2kuz2ZQ0TWVvb0/CMJQ0TbNOSX3fYDCQZrM51NZ835fF
357 xUVZXl6WwWAwtFfYXLGzvYeibINfVV6+72cDNvXMCwsL0mq1pNlsSpIksry8LGtra0Oru5MkC2U8
358 9K7KRH9XzeLioqyurkq9Xu/GcbwdhqFEUdQbdx6qqqsP6rmTJAn6YX/bcZyg3W5Lp9ORTqdzpC6o
359 9qPqXK1Ws7ajaU029TMEURQNxQm1StJqtaTRaIjrulmCXa/XJQzDrG2p+qAnCuqZ1RlE3/ezFZgy
360 JQpqpUDFFlvyU6/Xpd1uy+LioqRpGvT7/e3nfXoQRdFMJgrP21IQhmE3iiJpt9u39MTJ7/f7bz5+
361 /Hj74cOHsr+/b+3wq/BSLX1/0+oDSAAAIABJREFUoqr86nNawFHZerC2thasrKzI2tqadLvdwjNk
362 Zb4xQJ+tNGccVGDd2NjYWVhYkOXlZdnc3Oy22205ODjIgq9evrbBXRUSBbNtJEkiW1tbsry8LGEY
363 yh//+MduGIYyGAwCNbOskovjzH6eZ9szz1uM6jT071VnNur1uqyurgappMHNmzfF8zxZWVmROI6z
364 jlqvc6oT07fi2Dr8aZ35VbFEJQnmFaiu68rh4aG4riuvvfaaXL58eWdhYUE2NzfFcZzu48ePhxII
365 84pifdtWGfdYq3iiD1bU4X/1+eXlZVldXZUgCMT3fanX63L37t2ZOsSrz3rHcSxhGMry8rKsr6/L
366 tWvXgsP+4fYXX3wRPHz4sKdff2k7H5V3vXdVzow5jhN4nhekaSrf+ta3dvb392VlZaXbarWkXq8P
367 JVuqXanrd8uWKJg/TxRFEkWR1Gq1rA2pQXKz2ZSFhQV5+eWXd9TE3j/8wz90zZU8c4LT3NNf1kkI
368 24qR+r37vi9Xr17d2djYkP39ffnss8+2n29DmplEQR9XqETp8PAw8Gu+89LVl4KVlRURkf8nIuI/
369 evToH3u93vZnn30m9+7dy7IxvZD1xmXOapUl6JozwPpgRB/wqY7pe9/7nmxubsrS0pJcuHBh5PPm
370 DYjLdkuJeTjZvHvZcRxZXl6W+fl5WVpakpWVFWk2mzIYDLJAZR5YLZoolKmc9CVtNbhdWVmRubk5
371 2d/fl16vFzx8+DB49OiRdUl43KrTNJWF3lnYbmGx/bzqd9zv96XT6cjNmzfl5Zdflr/6q7+Sa9eu
372 yWuvvSatVktWVlay8lAXB6hyNQfC0/4mXn2vvYot6mMwGMjBwUF2d/fBwYHEcSyrq6syPz+ffe76
373 9esi8uf9xOrf0QfTruvKYDCQNE2lVqtlWxDKFofVTSSqo1Lv1uj3+3JwcJCd87l48aK02225ceOG
374 HB4eZs9cZIA9DXXipLFYbZeJokgODw+l1Wpl2/YODg6Cjz76KPjtb3879D4b2za3spZB0cFOs9mU
375 +fl5eeONN3Z+8IMfyPr6unz/+9+X9fV1mZ+fz/blq/Muqm9TSf1xEoXzijHPdzxIrVaTdrste3t7
376 sru7K8vLy9LpdOTx48dycHAg9Xo965M7cx1ZWlxSSYPU6/VslUH1TeZNSZOcC5rGGGPrX/WvxXEs
377 zWZTVldX5Q9/+IO89957we7ubjBJvavKhIRKLB3HkcFgIIuLizLXmduem5vrZYnCgwcPgs8++0xu
378 3boln376aXb92riT82XroMxAoM/S6QmE2ibgOI6srq7KO++8Iz//+c/HBhPbK9HLHHzNBEt5/Pix
379 c+XKlfQ3v/mNvPXWW/L06VPZ39/PPaMwatWgrCsK+qFLNfC5evWqxHEsBwcH8vvf/16++uqrbBbU
380 dr1lWbaN2OrAuMRGD8YrKyvS7/dlf39f7t69K3fu3JGPPvpI+v2+NbDntdmibfs8y1Q/Y6F/qG0C
381 6oVz6kKAV199VYIgcBYXF9N79+7Ju+++K48fPx6KSebAT21nq9fr2YCyjJ2W2Y/oKy/Ly8uysrIi
382 33zzjbiuKx999JHcvXt3bJwY94K7ss2KqgRRJaBXr16VGzduiOd5sr+/L2+//bZ88MEHRw4621aa
383 qroa4ziOtFotmZ+fl6dPnzrNVjP94NcfyG9/+9tsxUBtyzHLyEyopvnsoX65QRRF2YBeJQ7NZlNq
384 tVp2Paw667O0tCQvv/yy8+1vfzv95JNP5Je//KU837KW/XfNl1zqOyzKVnds73bSV8HVxMTCwoJc
385 vHjRuXnzZvrpp5/Kz3/+c3nw4IGY24WrnCCYE4Kqfl26dEkuXboUrK2tZYmT/+jRI7l9+7a8//77
386 8utf/3rkPtBRLwQqYxZlbrURkezA2KVLl+TmzZvywQcfyH/8x3/k7r23VaCyHtjVg5H+8+u3rywu
387 LgZ/93d/J59++qn893//tzx69EiePHkydAPSLDD3V9+7d0/W19dlb29PPvzwQ/njH/8ot2/fPnKX
388 t55olCVRKBIobUmy4zhy8eJFtRdU7ty5I59//rncunVL7t27J0+ePBmaxTJni4uUzTQlXvqATW8P
389 anZOzRCr8wjb29vyxhtvBGtra3L79m35l3/5F7l9+3Z277eaEVTbT9SH6uxEpHT36uurCGpwolbd
390 Wq2WdDoduX79urz88sty//59CcNQfvazn8lnn3029j0KVVlN0PsZ9ft3XVd++MMfyuHhodTrdTk8
391 PJT3339f3nnnnZErlFWOx6q9tdttmZ+fl2azGVy+fFneeecd+a//+i/Z29uTg4OD7OYf/QIBs3ym
392 /YISfUCvBr9xHGerlrZZ84WFBQmCQH70ox8Fq6ur8uGHH8o///M/Z5N7asuf2gmg3rVgvt26bIeZ
393 bTfO6b+zdrst3W5X3njjjcDzPPnkk0/kV7/6ldy5c0cODw8r327MCUB9csv3fbl+/bpsb2/LzZs3
394 s+/3a7Vaz/f9rtpTnLfXXr8qs8w31tieS39m/Wo+NRC0HSIctW+8zHvvbUFBzZ6rslHL3I1G48hh
395 qFl4M7P+9mW9vNRB1mazObStTV+xqsJKU9HBoJpBV4Nj13Vlf39fvvnmG3n48GF2GM/2zoFx/99p
396 nD3Oe/unbeY8DEPZ29vLrtQ9ODiQx48fy5MnT7LOWp/xtLWvMl6YoM9g6f1JmqZyeHgou7u7os6G
397 ra6uShzH8vTpU3n48OGxkoQyDphtq2yO48je3p5EUZQd9LZtnSnrjXPHjYtqpUCdR/A8T549eyZf
398 f/31ke2M6mxQ3iUJZxELz6pO6Kvavu8PHeLVy2ZpaUkGg4E4jpPF3n6/P3TA3bxIwvb+lzKP9czf
399 cxiGsrCwkJ2tNK/StcXZWRjTqIknNamlHwb3fd/vqU+Ye9LKtk1ikoCUt39NP+yi7ym3VboqvWht
400 3IBMDfxUmahyUonCpOVQ5mtSbS+4cRwnOzinysm2YlXG2c2TvB9Dn0UX+fMbQh8+fChPnz4dGjCO
401 KptJE4VpaUP69gbbMrjaj6+2Ju3t7cne3t7QYEa/gSzv+tUqxBr996lmPNWe8v39fdnd3T31QeY0
402 xxf1e9ZXjFR9USsyaqWyyLXUtvhV9iRB1SN17bIqk/39fXnw4MGRpFQ/e1fGmXLb70z1w9oLxLLv
403 VWef1Jmffr8vjx49yuKJSqKqNuGZ93PrffDu7q70+33riv8s048Z6Jca+WaBmgPivIOKZUwOVMdr
404 DoLMu8ltN4oU2StdpX2h5iyvflBz1DaRoltVylxO5p3/5lkX87Cz7WU203pg7ri/H9u5JjUIVisL
405 Zj0ZF0uO+7VpGvSYL2vUt/bpicOopX697piTOWXq4PJuhbPNYOo3l4y74amKHbz6PevPpq/6m7fW
406 nFY7ntb4Mq4+2d43krc6aSvbMrUds06oRMCcYNAvFtG3sqk+Sr8yVL9RrQqTeXoSab4rQp3z0M9q
407 6GOaWVpBsL3rx5Y4+XkFU6ZZvNMMSratV1XukI5TbkXrQRkHescdEOatVNkS7qrWI/M59dnwvLcw
408 522rmYV2M2pLUV7iWOa6VGS7JvKTP/MmmlnY5jlJeU2yNbLssdUWE0Z93Ywz5gSG+rP5vVW9KSuv
409 Lc1SHLI9q54w6MmVbx72MCtdFSpNXtKTF1xsN9XkBaOqbT+ylZk5c247p3KclYSqdOa2mWGzoRXd
410 elT2crMNctX+T/Pcxrjks4zB+7iz3kX/vSp2aKOuUS77xRmnPTGhzwDOWsydpJ/J2w1Q1cGvnkzq
411 z6pfe2oeXrVd0FK1g/C2+KmXyagxzawl23o9MN+j4Va1gkwabMatoIyasahyeVVpKXKaBo6zVgZ5
412 2/KK1K+qJOLms550b3ZZZ0bH/exl3FY17YnoLCVT1JF05DjmOG2y7H1P3rPZLoygj7aUE80KAAAA
413 AIkCAAAAABIFAAAAACQKAAAAAEgUAAAAAJAoAAAqJ++9JCLcSAIAJAoAAJIFAACJAgAAAAASBQAA
414 JsaWIwA4Xz5FAABg4A8AMLGiAAAAAIBEAQAAAACJAgBMvaI3/lTxqtBRz85NSMDJ5MUL2hZIFAAA
415 U5cU6AMU9WcGLcDZJgt6wjAuOac9gkQBAKZo8AwAAIkCAAAAABIFAAAAACQKAAAAAEgUAAAAAJAo
416 AAAAACBRAAAAAECiAAAAAAAkCgAAAABIFAAAAACQKAAAAAAgUQAAAABAogAAAACARAEAAAAAiQIA
417 AAAAEgUAAAAAJAoAAAAASBQAAAAAkCgAAAAAIFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAAJAoAAAA
418 ACBRAAAAAECiAAAAAIBEAQAAAACJwgvnOA6FAODUYkiapkP/BDEXx0c7wqQxhDpTjK8KM68TM79e
419 1YJVz6eXg3pW/Wt5z1+lclG/b/OZzM/b6s2sdlC237/tc7b6VfWysdURM6aYg+Yyls2o+JD3PbPW
420 UZkx1awfZj9DfGGAPOpZbfXD/J6qlM+458jrhyYdSOttrwplZ/Yz+geK1SF3kuyr6lnnqOc3v1bl
421 QbItMcz7HB3z8b9nlsqvyLOWOXAzoKUMSRIoj2kfAJ5GIjHL5VH12FsoUah6QeQN7vVZzLyZYSoU
422 8jokW70yP0cdGt/pMFCcvYELCQRwdon1uNV/xjUogjMKOQ2myIpBlRvZqGej42ZgQ5mdLBbQQdOW
423 gBeZLIDYctzy8SmO41WkvMZXhT3oefvKCUDj60uRbWwo3ubKVMdOa0sagNOLJ7PS5sytwbZVO/ql
424 4XKgPOzjFxMrCqfYgKpU6WwHwjhgCJy8TZEsnG7yBVS9Pz5O+ziN569y+2McU9zMrCiwleb0BzYk
425 DpKbTDGTc7xOhzoFs66QLDDYwfHiqX42c9Izc7NyWxTGm/kVhbxAe5zDp1WrkHllM+6EPAGcMpm0
426 Lc1qmTHQo06AtkN7Odsyybt8xHYJCY6a6TMKtv3QebPC5vWgee+VqGKyMAvvjjhOvSEwj25TkyaS
427 o947wexWdWMuTjdGVzk+nWQgV/ZyKdJ2ipydJP4QlyflznoFyas0s7yfuMgVsTQsTNrGqDOnP/ip
428 cplw4JB6dRrPY267qXJ9oq0UL6NxOyYwY4nCqHcoTJo42AJPlZOFcTc/MfjDaQTXqrWpvL3BmKz+
429 UHZCuzqDSYgq1ivek3B6v39i93DdYUUh53td1xXXdYcKzJYwVLmc2MdXPEHSA4vrukcCzSzeHjFu
430 Js/271U9OM/6TPm4dmBLsGa9w571G/lIFof7nVH9T9GkmwSC+jfJ9f9cjzqio1IDvlmZOZ+0QRBs
431 jiZURd4APmt1ZlSZzMqWgFF1hmQhP5FkZu/0EmgG3LNVR/SkgiThZO1pFpMFEgVLgzETBM/zxPO8
432 sTf8jOrcGMgQfCgTZ2RSZftzVQI19WF07M2Lp3n1gbIERifStmQBOCk3TdNg1mcdzE4pTVNJkkSS
433 JJmpffjjziWoconjWJIkofUYdSaO4+xDzeJUdbBY5LnM9pR3IN4cDJY9WbA9j1qdzGtTtq0E5r9T
434 xTMcZl1wXTdrS3oMxl/KTdWZIvVrlpNP29bHKm4FnWSb6yTPXdX6lKapRFEkURQRW0bEZX2M59sS
435 BcdxjgwE9U69jIVr+5nN4Ko6pjAMpd/vy/7+voRhOFQu427/KXvFS9N0aMuVPsBTZXNwcJCVi14n
436 ZqnRmUE0SRI5PDyU/f39rN7odcYc8KjPj2tP09bexm2r0uOE+r7BYCCDwUA8z8vqlyozVddU+eS1
437 M1u5T1t9y9tapVYm4ziWKIqOlFcYhll9cV03KxfP87LEUy+nsscZ9ZyqDuhJgnrmw8NDOTw8FBHJ
438 Em868D9/RFGUlZvv+1lypcfkKk5g2dqY3jfpH3q7U21O1bk4jgu332mLvebYY9z2PD2RHDUpYRvn
439 lTGpGtd/qJhzcHAgBwcHhSY8i5yrKlt80svJnKhR/bT+TH6tVpN2uy0rKyuysbExdsBX9juI8wKN
440 +vPi4qKsrq5Kq9WSJEmk1WrJ8vJyFoDMxlSVBMFWTvr+Rs/zpFarydzcnNRqNVlfX5dXX31VVldX
441 5dGjRzO9zSJNU7l+/bpcuHBBdnd35cqVK1Kv12VlZeVI/bIF4jIGY/2fee8dcV1XNjY2JAgCWVpa
442 kjRNZW5uTjY2NqTZbFqD9LhricuSKNhm+fTf/9zcnMzNzUmr1ZL5+XnZ2tqSmzdvZuWkT9iYyVWZ
443 315tlok+M+55nvi+LxcvXpRLly7J1taWOI4j169fzwbERQaPVYkp5naSV155Rba2tqTVaslgMJCF
444 hQVZW1vL6pW+klm1/ntUotDpdGRhYUFarZbU6/WsXMzEwPf9oQnBMiYKeTFStQ+9DiwuLsry8rK0
445 220REWk2m7K6uiphGA7FI5VQFbkWvSyTEHrCaM6S12o1WVpakvn5eanVatJsNmVlZSVbZZikDpR5
446 hcoc47muK41GQ9bW1qTRaAx9r99qtXorKyvda9euSRiGMhgMhjomPWiZWyrKFHTV7Ivv+1kBDQYD
447 iaJI4jjOOqrl5WXZ3NyUCxcuSL1el/X1dXnppZdyZ4WrlijogxF9SVuVXRAEsrq6Kt/5znekXq/L
448 48ePZXd3V3zfF8/zZi5BUB30xYsX5fvf/74cHBzI1taWPH78WJ49ezY082fObukzq0UGyWXouM3B
449 zfz8vFy7dk1835e7d+/K5uamvP7667K7u5vNpMdxLLVaTRzHkX6/L0mSZOVVJNGfxo5KH6SouFqr
450 1aRWq4mISLvdls3NTVlZWZFutysXL16UVqslz549G1p9UP8t9dwqBpdxq4mKsfo2PRVn1CBODXBW
451 Vlbk0qVL4rqudDoduXfv3lDstg2mbfWh7FtN/n97d9Ycx3UefPzpZbpnw2AAEiQI9FCkSFkUJcVO
452 HJfEqtdvpVLlVCpXuXh9k8+WTxDfJ64sF/ZFSKmUVGy5KqpQkULPxLak4iZimaWX90I4zTMHp2cG
453 C4npnv+vCiUJACn0wVme52ytZoKzLJPd3V25ceOGDIdDefr0qURRJE+ePMkDP72unKZuXGQZzZt0
454 KOpz0jSVMAzzCYhOpyNRFMnbb78t4/E4X41TE12zZtYXTTovqpxsWzlVO1J9i76CoMpETVh1u125
455 c+eOjEajPChO01Q8z8vLSO9nyri9WD276ndd182TKMdx8n54Z2dHbt++LWtra9LtduXmzZvS7XYL
456 68WsVZiy9i9msuj7voRhKL1eTzqdzlQ853c6ncHOzo58//vfl62trbzT0TtlVSHLPmusD65qn5q5
457 17PZbMra2prcvn27v729LR988IFsbGz0zBlBc+ZdryxlLSNz5ts2K/ree+/1u92u7O3vydraWs9x
458 HAnD8NiM3yolCmmayvr6ep6FdzodUeWiElE1SOmDuuqgy5QonOQAapqm0mq1pF6vS7PZlFqtlnfE
459 aquNPtCp8lFbb8y2VKYzCvpee5UQNRqNfDbYcRy5deuWRFEknU5HRqORdLvdqYQyjuM8ATcThTL2
460 xXpirH7Pql/Wl7tbrZaEYSj1el1qtVq+oqsGrqJ+uGhAr8J20CzLpNlsiud5srm5Kevr6/KDH/xA
461 1tbW8mA4CIJ8NrVsAYxtHLUlgubvOo5jCcNQ1tbW5K233pKrV6/KO++8I+Px+Ngsuz5GVWGrrHp+
462 1X+qZFt9LQxDWV9fl5s3b8rGxoa888478ld/9Vd5eaj4R08u9C2OZYz51M+rJlrUf6u+QyUPly5d
463 kiiK8lXLDz74QPb390sf/J+0TzF/91mWycbGhuzs7PSbzeYgTxTW1tfk+vXrsr6+LgcHB3nF0bOw
464 OI5lPB5LGIZSq9Xywb0s1A1GqlHpmbS+yqAaRxzHsru7K1EUDba3twd/9md/9iCVl52vO+OyqFTS
465 mV9fZqmkIqmIuNPPmEoqk9EkOjw8jNrt9mBtbU0m44k8fvy4d3BwIKPR6NxnpssQKOsDVhAE8uTJ
466 ExmPx/L8+XN58eKFqLKZTCb5ID4ejwtncYruyL7oclokgTHfHaGSgWazKa1WS5rNpty6dStfCq/V
467 atLpdI7Nwqs/a9uXvsx1RE+OVCKoz/yppKnZbMqzZ89kOBzK5cuXpd1uy2QykSdPnsiTJ0/k+fPn
468 +d+TJMlU/6Q+r09ulHHGT/1+bZM3WZbJ/v6+DIfDfGvWixcv5NmzZ4UBXpUPXZpbzYIgkLfeekt2
469 dnakXq/LrVu3xPM8CcNQms1mvlJepmTBdqVnUaKg/zNJEhmNRvnW6U6nkyfdly5dkitXrki73ZZv
470 v/02T87LXFdUbKavRqtYTI0nKgFQz1uv1+Xy5cuys7MjV65c6b/33nsD13UHKnBO5bt+JkuyqRsf
471 i2KBspkkE0kmR2e8PEeSSRIdJY1REARSq9V6nU5HWq2WxHF8bFdElZMFFYeoGCRNU9nb2xPP8/JV
472 hTxR+PbZt9GjR4/kN7/5jQwGg2MZpt541WBetMdvWamfWy2n6XsW9UBNbygffvihs729LfV6fdBq
473 tfpZlg30xKOqVKej/l2rVNFwOOwdlWP029/+NvrXf/1X2d/fl8PDwzM1qrJ23npg/MYbb0gYhjIc
474 DuXzzz+Xb775Jt8WoHdA6qYFc4vKIgH5RZbToi/KMoPmzc3NvL84ODiQfr8v//Zv/yZJkkgQBMdm
475 Exc9dLesgY7eL5o/r5r1Ozw8FMdx5M6dOxJFkXieJ48ePZKPP/5Yvv7666mE0Uwmq3ILkH72SS83
476 x3Gk3W7L5cuX861rv/rVr+TLL7/M++9VSRTM3/fW1pZsb2/nW/P+4z/+Qz777LN85lRtazNvc1nm
477 +lK0hWORF4qpsbzVasnGxoa8+eabcvv2bfnkk0/k008/lVarJUEQyHA4PHYpyVn6umUpLz0WMxNu
478 tRe/3W7L3bt3ZX19Xdrt9iAMwwe+79/XYxhz0lcf/8sc66jn0p8jjuPoKEC+F8dxdHh42Pviiy/k
479 l7/8pezt7VViS9FJ+mBza+t4PJaNjQ0Jw9Cp1+svE4Wvv/46+s1vfiN/93d/Jx9//LH17X9qVkvN
480 yJd5YDIHbtWxqlWUdrstnU5HfN+PfvjDH/br9Xq/1Wr9zHGcgaywLMuiWq3Wm0wmHw6Hw+jzzz+P
481 /uVf/iWfOV+lW49UPdIb2bvvviubm5tycHAgv/rVr+TRo0d54q0P9kXnXMp4a8KsDlW1p93dXWk0
482 GjKZTOTRo0fy6aefyj/90z/Js2fPZDwe5392kT2xyxwQzrrFx7bvd319XX7yk5/ID3/4Q7l8+bI8
483 fPhQfvGLX8ijR4+sdWOR2zzKlmCr/cP6NgfXddXSt7Tbbdnc3JSPPvpIfv3rX+d7zlepj9F/15ub
484 m7K1tSXtdlvCMJR//Md/lH/+53+Wvb29/GxPmZ9Vn5Qs+h5zC5Lai9/tduXHP/6x/MVf/IX8wz/8
485 g/z85z/PzyCaZVm0Rda29WlZ+iF94rboFjB9olMlCZubm/KXf/mX8vbbb/eDIHjQbDZ/5vv+/VWO
486 Y1Q/PY7H954/fy6ffPKJ/O3f/q384Q9/qMStcqeJjdWKlFqxvHLlSrS1tZXfiOqrpSq1j1af0VOV
487 TyUI+knyMmdP5p3u6lnVUv9RAtFvNpsDz/NWOkEw9LMsi3zfH4RhKEdLd/mVhqdpXGW+alc/u5Nl
488 mTQajalZDHUxwKwDlvMGxmW8dWPRAVb1I2EYShiGkqapjEajfBVKlZV+TaztTaJlmb3SV4n0LY5m
489 2aVpOtXnmrODttuSzH/XE5Oyth89ida3Vai+RJ1TUG1pla5JLXoZqOM40mg0pNPpSJIksre3J8Ph
490 cGYCVbUb+czPqWev1WrSaDQky7K8f9Fv9VFloScPJ00SLnLCQl9JKbpVTSXdKpZRkzGNRmMQhmHf
491 9/3+KgcwasI3juOB2m4lIlN98aokCno9VpesqKup1TbHPFEQkUGapj3btXv6oTzbtVFlox+as22f
492 0g8eHl0VNUjTdLDqqwnK0RajQRiG/SAIBo1GozcajWQ4HJ56prOMhw3NBFM9R71el/F4nAd9tgFJ
493 325kBoFmYLBs5XOSt3Xr24eCIJAwDPMZvtFolO+hVc+mZjRsgXUZ6oe+lUa/1tRMIMwLIsxB33xD
494 fNE1jkVXhZYpydYnpPQkSk3qqERBb0u29jCrrZT9MLNer9RHo9GQdrstWZblSYIKiG3JY1nLYJFr
495 XvVbW4IgkGazmV+KoPel5pZG/RzRaX8nF5086ufC9IRbPZ+6EMF1XZUoEMvofY2kx8pvGcfdV9W2
496 zMkr/V1ZKlaeShRs91qbwZDneaV/U7FeGGbyoBIFdUWUiDiHh4fH7pNdZY1GQ0SknyRJ5HneQG0b
497 UIfnVultzbb3IOg39pg3Gunfp8/+FSUKy3gDUtGtXrNeOphlmYxGI0mSRBqNhtTr9ZmrJYu+2HBZ
498 gzo1oaJPvOgDuP7SNP2GDj1hsCWiZtmXtS82f7/6eZ18UDra6qralO05bS8AXeRawzIGyfqYpVZc
499 RqNRfi5Bf9HYrGcu27XL897npPez6gCv6mv0+mSWTdE20JOU0+suy6L3PxWtWKuJCX2id1W27S1K
500 HdJW7cg2MVP1MwrHyqTgHLJvduBFg1PRbE7ZOh5bw9JXGdT+vizLojiOo1qtFtGkXi7ZicjUuwBU
501 BrpiZXHs3/Xr5szZY1sHv8iM1bIGgov+TOoZVLnod30vUp5l66jNJLDo92670tN8ydqseqHPgJW9
502 3ZjJg+pX1CSEfvi/KBGtMjNp1PtcdQ5IvYukShM1i77U1DzYbNYXc2KwrHXHtophJtuzXvhYtpsq
503 X3e/ZG5Lr7qiywL05HLqhX76sq6519xcslMdVdlnsczOR3Uu+iydOcuFl/SXSKnA+CxBbVnPvNgG
504 K/1lWKeZGbcF0cvwfo6TJAdmu1Mrdmrrkd4p6zcu2LZMLNrJLWN9KAp69C2QIjL1IraiWeGidyeU
505 re0UrQ6YS/+qLMytaPN/G8PQAAAgAElEQVReklWlG5GKZvzMBMpMtKp0C9S87Ue2q85tWzv1Mlq0
506 n1nm+mCbSDHPzukvNVTb1vCSuhpWrbZUsf0sOl6pMVmvJ1MrCrbGZC1U45BdGTscsyLoe4XNQWtV
507 KsxZKtoqHS5cZBC3bUc67eHcKtxso3dCKsHU25Ztj21Rgl/mwMbW9+h1xVx9WjTxLnsQrJeBPijp
508 W2lWvX+xrbCZh1irUB9OHewd1Rv9vU+z+s+T9CmLTlQsyxhkTkyt0lbg09DfD6GP06tykHlW/THr
509 vq8fItTfxKcfNjvJjQDLSk8G9OBED1zUQUS115ws3E6VyyIvCKtiUGxLCES+mxlWdccMdIoOTRXN
510 Ci1rOdkGz6Kf3zy8aybivu/PXBJfdKBb1vqj/571lVl1LkFfxdVniG3lYm5Lst2KVLZ2ow9O+sCl
511 ViwXTZqWvc2cpbz051d9iu/70mg08hsJza02VQp0FrmiVL+GWG3D0ld2zdsaZ52pKnonyrIHe/pt
512 a+btaEx42mMYx3OmXjhWxfazyFhuxvn6DqOXSZWRUc1rqGW9znLWgTgz0Jl33zKNzKvUgHzWgLlo
513 P20Vy2TRZ5qVRJ7m3EbZy8nWxyz6sqmiv7ts5bboColt+2eZJ6leRfJZdFHCqpbJrHH8JP1M2erZ
514 IrfDkSjYueKu1AvW5tV384KMqQsmzBsBirLoKizJ2A4L6vsW9QPN6vs4AHScKhN9EF+1Bmc7nGpb
515 RTCDuioEPKf52c03QJqdkjngFa3alDlBsF17W7TiNKu+qfKrQlBXdP2r7U28qziI2/bT6+OSrd8t
516 Y7s5TWCsP6O6YMP3/WPvG1g0oC5LmZntQY9pirZX47hU0mO3+1S57SxSz/Xzc3rs69o68FU89T1v
517 kAdeRQC9quVhW3Go+szXojN+qzy4m0kCZtclAkJ7Qr5qffKiq7egfOb1vTbsrQEAAABAogAAAACA
518 RAEAAAAAiQIAAAAAEgUAAAAAJAoAAAAASBQAAAAAkCgAAAAAIFEAAAAAQKIAAAAAgEQBAAAAAIkC
519 AAAAABIFAAAAACQKAAAAAEgUAAAAAJAoAAAAAACJAgAAAAASBQAAAAAkCgAAAABIFAAAAACQKAAA
520 AAAgUQAAAABAogAAAACARAEAAAAAiQIAAAAAEgUAAAAAJAoAAAAASBQAAAAAkCgAAAAAIFEAAAAA
521 QKIAAAAAACQKAAAAAEgUAAAAAJAoAAAAACBRAAAAAECiAAAAAIBEAQAAAACJAgAAAAASBQAAAAAk
522 CgAAAABIFAAAAACUM1HIsuzYJx3HoWSAc0BbelkG88rC1hdhNesUdYG+5LRlo9edqpcZdQKvg29r
523 WOojy7LKddjqedTz0fhOzvO8lR7k9TpkDlBpmkqapsfqmP5nViUQUv2H4zjieZ61vGxtbVbbXPZB
524 2/w9m89iqw9mucz6+9VHmqalLCP1O7e1A9d1xXXdwvJZpeRBLx/HccR13alyUL9/W5lUuZzmjdmq
525 71X1ydZWylyXFpl0Mb+HpLtAOj1GrVofY0uwVVsxxyR/kcGqqhWvKEjByQPmVUkSbPXEbDtmHVrV
526 OjWrXzE/Z6tLZe9LFg1MigI+W7uqQl0qShBR3IaK6ovZ76xiUKgSqaKJHNd1j7WxqiQL5jMsunqL
527 4ombVUwWbMmBzvc8T3zfF8/zxHXdwpmKslc8c4WkKIjRG5qaCcW0JEmODWTzZsyr2nGZM6KqHamZ
528 LLOe6TMYiyZXy5igL/L79DxPPM+TLMskSZK8nqjysQXJVUk+zZ+5qCPWV6FsqxG2761CsGMrD/35
529 bG1m1QIYtcJiW0FQY5Pv+zKZTArbYxnKbZHZ8VkJtp4QmPVGTyL0MixjsrpIO7D1pbDHMHqSoPrg
530 RetE2bfs68+utxPVhsy65s/KrqqcPdn2MeqdCI0Mp+3Ai5LPs9SrMgeEZiBc1C7LvN2xaEuNLWEu
531 GmT0Pz8rWSjaulPmPtlsH/oMMf3K8VUEfYtW2cftWUH7Is9U1PcWTcowtkNvR3qCqU/EVP3ZT7L1
532 3k+SROI4liRJjs1WnSajXfZCsQ1KZmYZx3Fp9wC/DmqVxdyTX8VA9zxme846mC9j2S3yM6VpKkmS
533 5LM3s2aJ1RkG9b1l3xZgllNRIGSuQpmTGeYsT1UGMtuKrp4k6M88b2Crcp9ijslqJcF1XUmSRMbj
534 8czzCmV61rOwrciZ5WeO6WWvT4smWGxDsscwrutKrVbLP/QdNRdRhy86WZjVh/irUJH0IKXocKHe
535 ER8NVH3HcQZZlg1oVosN9qt8EGjWXnw1qJ9l5qzMbXSRelJ06LtsieK8LVO2LUmzkkhb513mIGBW
536 X6zXEZVkVulsxlmCD9WP+L5/7ECz+pr+31VLFGb1m2ZZmN8/a8WhzJMQtq+typbf86ImOvW+ZtVi
537 GHMM0rdM54mCPptlO9RQlcIzB6hZSYLv+/kHijNyve6o8l2lxma7ocUM7tTsqG3Ga5GZoTJ3+kbi
538 fWy7hF5f9P2hi94CtKzJwqx+05ykUPXCtpqr/r4kSaZWHMz+rKxtx9zmaZ5pUR+rGvCYSYI6kyAy
539 vcdarcaVOck+a/9nlpVtLNKTqirsjigql7L3Da8zSYjjWCaTSb6r5iQJWxVvBNXjFH37p58kSVS0
540 bHeSjL+MBWGbYdC2HzlxHEutVqNFTZdhlKZpFMdxVIUl7/OY3TH3Eet1zDxwd5a2VMYZMH0CQt/e
541 aEugytznzLper2hPua0eFR1+n5VklrXtzLoaN03TPDhWg/oq0uuNmvmM41jiOM63IZn9cFX741kH
542 SPVzULaVFf2/yzxm2X7HRdcvcx5jXuOSYxNZq7SN2mwjsxJL3xY8z2qUZb9pwzZIm3sajzrkKI7j
543 yPO8iBY1TWXgi55PqGqSMKuzLjqEuKqdt54o6O9WEJmeHS0KqMuSKNj6TvWseiJp/hlbcKgCIL0u
544 mX1wWbdPLHJlrLnVZhX7GTX7ra+wqNlPx3HE930ZjUYrcRHJvMka86MoXinrmHXSd2aQLCyWiKsJ
545 iVW+xnzeJI5v2y9aNOhVYb+obbtRwYGxvu/7A9d1OaNgaVz6lbrmdXRFZT2rgyvb1WJmsKZ+frNs
546 bANT2ZYuT3tlnJkUmFfHxnG80P77MpSTLTE0kyRbMKeXjb7yYks4Z52vKlv/qz+jbdVJP7S7ysyX
547 N6pV7mazma92m8nnooFkmQMa8/N6n1t0xeN59ieve7yad2PcMvyMZY0Hi9rPSetJ2crbfPfIrPje
548 XZW9bLYrK233uev7QV3XjRzHibIsY1XBUp7mQH6SF40tuuS17B2MuaQtIscCv6IZrKq1u1kDlu2e
549 c9th1bK+w8VcmTW3EKkA2LZ6a+6r1m+KspVNFW64MVcjzTpR9vMq59nHmImC67oShuGxdyxUuazm
550 XQKhn4Eq2up3kregL/Pz265RNr+2ii9BPXkWLpV8Z9ii9cmMgVU7ssUtfpqmkf6HbQcNzVsVynoN
551 lG3FxBysVZIQx7EzHA6jer0eZVnWExFWFkQkjuPecDjsTSaTyNxKMmsGZN4SaVnpL0UaDocyHA6t
552 1+tW6erCRRJA/YVQenCorqQ7amPHDhcWvYCtbP2NOQmhtoro/U8cxzIajWQ0GuUBoOd5U7Pt+t5Z
553 /cB3lQZ/tQqnEiT1jMPhUPb39/N6s0rbHM02piYe0jSV0Wgk+/v7U31N1frVkzyLal/j8VgODg4k
554 TdOp+mRua1TleJb6dFFlW/TSRludKdpWDsnrxmQykTRN80nPVXrXkV7/zYRbnYPKE4VarSaNRkM6
555 nY5sbGxYH9ocrMra8RbNLOhL3a1WS9bW1iQIgihJkyxN057neQ9oWt+ZTCaSZZn4vi+tVkvW19et
556 jWUVOidVh3zfl06nI7VaTZIkkUajkdejWUFAmbbUFCUDswIc3/dVW8pXWcIwlG63m9clvYNepH9Z
557 9tkffauV+Vz6TGer1ZJ6vS6+7+fJU6fTkW63O/UuCVVuKiAs+zkxs6xUXxIEQT44dTodabfbeXDc
558 bDZlfX19JRMF/axGp9ORtbW1vD7UajVpt9tSr9etg37Z2s5pra2tSbPZlCAIxHVdabVacunSpWM3
559 2ZirvIvecrOMkxB6+zFjNZUINRoNWV9fl0ajwTYkW7KQfTcpocYkNWGzChcDzItlfN+fXlFYX18f
560 RFHUu3PnTj4w6ZVQTxT0/aNlLATbL15/sVEQBPm1qFevXu036o0Hnufd932/T7P6TqPR6Pu+39/e
561 3h7cuXOnd3h4mDewon3YVW9cruvKzZs35fr163J4eCjD4VBc15V6vT7VsZvtqozJwqwlb9vnt7a2
562 5NKlS9Jut8V1Xdna2pJbt27J/v6+JEmSB8Lmtpx55bJs98Wr37EaaMxtVlmW5S/2GY/HEoah3Lhx
563 Q7a3t+XSpUsyHo/lrbfekrW1tam7vdXe68lkYr0mtawBsCqTOI7F8zwJgiB/7m63K9vb27K9vS3t
564 dltu376dT+is0sCt9zGe58n6+rpsbm7KlStXpNFoyPXr1+W99947drFEWW9HO+2fVROdvV5Ptre3
565 5datW/LVV1/NXYUo24qCvjXavO3JTBSyLJNGoyEbGxvyxhtvcHujmSQkiXiOJ+12W3Z2duSdd96R
566 7e3tqd9tlQ+DF51LzrJMrl27JpcvX5Z6vf4yUajX64Nutyu9Xk/iOJ66ZcLceqQnCmUarGa9Zdqc
567 1VLLmN1udxCG4X3Xde87jsO2o5dlOciybNDtdge9Xi+/hUMt4a3CQG5b6o2iSLa2tsRxHGm1WhJF
568 kXzzzTdTh+vKGOwsOgtpu0EsyzJpt9ty69Yt2djYyAOeIAjym1r0RKGoYz7p244vOlHQ+0j9Z9QT
569 Bc/z5M0335Td3V1ptVrSaDTk4OBAnj9/PhUAqJWJWX9vWYNgdaBdraio371aqbx165bU63X54IMP
570 5I033li5/cRmsqBWKW/cuCHdblfef/99qdfrx1bjFulflqnczvKzZFkmYRhKo9GQN954Q9rttmxv
571 b8vNmzentoWa/UbZJrT0F2GplRH1JnvbLWqqXLrdrmxtbeUTwMgThYHv+/fb7XZ0+fLlqNfr9brd
572 7tS7s6p+Y5TtrMtkMpFLly5Jt9uVMAxfJgpqkNvY2JDRaHRsJmzezGJZGpntLns9aNOXvw8PD6XZ
573 bK78jRuzNBqNfHnXdnvNIvVj1pmRsgTPqh5tbm5Ku92Wra0tee+99/pxHA/G4/Gg6KVIKzNr43nS
574 aDTED77rgN96+y350z/902MvizJn+crW9hbZTqZPuKiZ0CAIRFyR3rgnt27dylcNTvL3ljUALnom
575 x3HEq31XbzzHk+s3rks8jldxUmaqnFRbabVaEgSB/J//+3/kRz/60cqOQWrV7WjyIRqPx9HBwUGv
576 2WzK1tZWPumpH5DXDz1fVHJzlkRB9Y16X6LKQN8eniRJvp1RbeODTE3aqHbVbrfzwDgMw4Xfcl2F
577 2z/VuTgVI4/HY+l2u9LpdKZXFA4PD+Xx48cyGAzk0aNHhdesVTVRUNTBS/X1J0+e9Eaj0T3f9wdZ
578 lrGq8F2ZRXEc90aj0b2nT59G/X5f9vf35eDg4NgM2LJ3vOeVKCjD4VCuXLkiGxsbsrm5OfB9/4Hj
579 OPf1+rUKSYH+37bP619Tn7f9uVUoM/W8SZKINEW63a61TFYlqSxinoNapfoxq3yazWZhWZhtrMpt
580 x3GcKHOye/1H/eh///d/5X/+53/k4cOHeWKlDmXqk6BnTbwvIlHQgztzRcE8E5UkiYRhKJ1ORzY3
581 N2UymZAdGOI4lvF4LI8fP5Z+vy/Pnz+fmURWNVEwD3FfvXpVnj17JsPh8GWi8Pz5c3n06JF8/PHH
582 8utf/1pGo9HUzRNF/4MynlOYd2e7Ogi1vr4ub7/9drS3txc1m82o0WjQqo5MJpPo8PAw+vLLL6OP
583 PvpIvvrqK3ny5EnpZmjOK1HwPE9qtZq88847+WHUnZ2dQbPZvB+G4c+oMQDwSseke8PDYe+rr76S
584 //zP/5QHDx7IRx99ZA2wT7NNa1nGK9tEnNoVYVspqdfrsrGxIa1WS/78z/+cijJdltF4PL73zTff
585 3Hv48KF89NFH8rvf/W7q5YVVilkWieMdx5F6vS63b9+W9957T27cuPEyUZhMJnJ4eCjPnz+Xx48f
586 59tIzDdolnm/lj6LoK8s6DcEqK+pw3VJkvSDIBh4nsf5BI0KjNM0lRcvXsiLFy/k22+/tXa6sxpS
587 mbdS2G4kefHihYzH46l99wCAV0/tLU+SJI9nzPNgqk9Wny/TYWbbe4dsOzz0G5EajYb4vj81M4xp
588 SZLIwcGBPHnyRJ4+fWrdRl2VuKUoJlbP5TiOBEEgz58/z68uz9uXajCTyUTG43H+l8w6WV/mF2Tp
589 zxcEgTiOk98oor7naH/foNVqcZh5unINsiy77/t+5HlelCRJT3/nxrzrMvXfRdkPY+oJpjpoqpIo
590 dR0oAOCVJwl913X7QRAMwjDs6Xv19X39+tXFZ7lU4qLGL9uOCFvAZ4t3Vulq4UWorVqqbNQ7Sebd
591 kFmVyxPM9xep51N5gLp0RGtjfn7/sLmkZVbQore2laFQbEmDqhh6hVD7+yaTiUwmk6mT3/guWRiN
592 RoM0TQfmW1TNOjFrL2iZV6dsz6FfiXlUFvkbvUk0AeDVjUlxHA/0ftZ21tKMac4yBi3L+GUGtrYb
593 nlBM7Qio1WrHXupo+x1X6VIJM1nWd92YX/N9349sM6C2REB/n0KZmJm3nujYXneukoU4jkkUCuSH
594 MI/qha1OVPGGn1lvodZXGpIkkdFoJJxvAYBXS80Q6wGz7cWqVRyT1PhLcnCy+EWVndoJcLTlvNLx
595 S1GibItp9LLwj2Y+rS9e0AtLzzLKuASjX4+mJwvmXdUquwzCYGrpBdOdsnoxne0qx0UaWhUOAhXM
596 7vRFZOC67oAkAQBeX/CntoHqQbQ5EVj2ANBcqTcDPvW8KgDW3w2Al1JJpyaGbTsiTpIwlD1BUwsB
597 +u2feaJgHlQ2DzGbSUMZG5ntvv6il/eoDNNzvYHrugO2jdgTBfWhEgXbNqOirUdVmPGwvbxHb3BZ
598 llF3AOA198u2WMYcd8oYx8y7idL8XnUe47zeHVHlOmOewz2v301ZEk79MLz+bqM8UXAcZ+A4Ts92
599 9sD2IqwyZ+PmwVvz2fQtR0mSRGqfOQHf8Zmbs7zZ0qycZe20bfcqO47jqIPNAIDX1yf7vn9sG5I+
600 XunfW+YDvrYdH+ZYattrjpfUzgj9TdcniXPLnHjO+tlVm9Hbh390k83cwK8qb5W13d6kr6pobzbs
601 xXHccxynJyIkCkaioN8SVfVXnc9KOi2JQyQikeM4ETUFAF4P/Y3F+sRn0dacsiYHtvjF9t+2gA8v
602 kwRX3MpNhp+2Ps26NUtExNeDvll7+aqwr89sVEVLdkcdTeS6LgHfnKSrKElYpL6UvU6pMy5moskM
603 DgC8/v5Y329uG5uq0Debh7Rtz6df9U6iUFBfJM0nPfU4+LSJW5mTTjPuN+uXa55uLrpKdFblrErh
604 mGVAAyvOxmed9ai6WXctc+MEAFzM+L7oWFSlMcs2qcs4dLKyK3tse9Z4xlYe+rkWXwXE5sHlosCo
605 rA3tpI1Hz8hxPFFQy7vm9puT1Iuyn1Gw/eyu6/aPtvOxXQ0AXmOfvMiEZtmTBNs2EX1lWz2/OsRM
606 0lAgfVl26qzCKk18mof89a33Zr3xTxKwneUAaxkaHs4nWF7Vcj9qaAPXdfu+7/epIQCwPGN6VcYc
607 21bxouckUThZfanKedzTPrutPvn6EkPRH6jaWYV5WSOJw2zmS0lWbalz1lY16g4ALE8AVLU+ed55
608 y6o+97lzp8du86Kbqpefbdu0+WJirajOnqUDENXh9NI07YlIj9IAACxDIAicIacCcF7UbVny3TWp
609 AAAAJAoAAAAASBQAAAAAkCgAAAAAIFEAAAAAQKIAAAAAACQKAAAAAEgUAAAAAJAoAAAAACBRAAAA
610 AECiAAAAAIBEAQAAAACJAgAAAAASBQAAAAAkCgAAAABIFAAAAACQKAAAAAAgUQAAAABAogAAAACA
611 RAEAAAAAiQIAAAAAkCgAAAAAIFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAABIFAAAAAK+ZLyLiOE7+
612 kWWZiEj+z6qp6nNdJMdxKGMAAOP9EozBelwH6ktRndGfN8uywvjfpTLM5nkerYckAQCA0iYOwGnj
613 Y7YeAQAAACucEBQhUQAAAABWnG3LGokCAAAAQIJwDIkCAABAhYNA4LRIFAAAwMoEzQTOwDknCqpR
614 VaVx0UlQtgCA6uHmPeB84zj3tH+QQBaUMfUKAEgSgOpi6xHomEkSAIC+GsDiicIq7uNj7+KrTRaq
615 Ur7UEwAo1zhEnw2cc6IAAAAAYHWTbhIFnBtmbAAAAKqDRAEAAAAAiYKiz37re86zLMs/RESSJKGW
616 LFCGi6jKwWf9OfSrg13XFcdxJE1TKgcAvCZqnNbHcb2Pdt3VCnXU83PZyOKxzCrviDDbjVkevgpu
617 zG/SvznLskoFP6rTUM9kVpA0TQn2TpEkmJ2zrZOqYrLgeZ74vi++74vrupJlGQkmALxmnudNjT2O
618 44jv+3kykaZpqQNCPSbT4zYzsNMnOzF7HNcn+ebFNVWN4cxY33Vd8TzvZcysAmdbQZmVTX29bA2t
619 6Gcu+pzneSs3A3HahIuykrxx6R8AgNcrTVPJskyKJkCrNmusx2e2VQRu6LNLkkSyJCOhmpGI6uXi
620 q9lQz/PE87y8odkKT2Ve6nvKFtSqgE5vPObMt+d5Uq/X81kIFDSyLMtn0mu1msRxvJKz6Gr1YDKZ
621 yHA4lMlkQscDAK+Ril1Go1E+NqkVhCRJ8thFxQFl7KPNxMeWJJixmr7KjekYRtUP9bGqSYN6bsdx
622 pFaried5Mh6PZTgcvkwUzEIytx8VZbBlylKLluvMWQfVqYzHY2aFF6xg+gz6vJWFqjRCc9VNT0Zd
623 1+27rjvIsmxADQGA1xP46WOQuYpQle3U5naRRb8XxxNLx3OmYkBb/VkF5m4itfVIj+d8NSOqPvTG
624 pP5dLzQ1I1/G7SbqufQOQm2fSdNUxuOxTCYTOTg4kMlk0nccZ+C6LgGfpZGpxpQkicRxfKxiVT1R
625 0Jfn1AxWGIYShiGrUQDwmhMF13UlCAJxXffYKoKZPOhBYVnYziLYxiJzQpTVBHsMU/NqUqvV8vHa
626 jGurXG4qUVY7iVQ9UjtDfN+XIAheJgppmkaz9vDZKloZC9B2U41KfPRn1LZiDVzX7fu+36dZFXfO
627 quzKfkjsNPXJHHiOVqOcOI6nDgIBAF5t4KeoLTfm2G5eXlKmOEbfblQ0A25+pGmaB37skDgulfTY
628 2cJVW0lQcYu568Y8a+kXXSOmV7Z5gXcZC0idtdArhzrIHIahBEEgtVqN1lTUyIyyW9WZC72BTSYT
629 SZIkStM0chwnopYAwOtJFDzPy1d3gyDIdwjoMUsVxqhjb83Vzo3qX1Nn5+I45iY+WzkmL3dErFqi
630 oO+k0euFWl1Q5ZInCirosyUGRSsNZWtw5iFs9Zy2JCnLMonjWIbDYW9/f/9eGIaDLMvuO47DFqTv
631 fvfRZDKJHMeJ1I1HpzksVeYGaWbfZb0NDACqQD+cGsexjMfjPAAy4xh9ktDs15d57Cra7WEeblbP
632 qMZn9dysck/XF71cVVmdduWlbPGMShzNGFgl3CovyBOFo334+e01swJtpWyZl549mRVBPYcKeGu1
633 mlp6icbjceT7PjPDmsPDw56I9FzXjdTKSxAEp6oPZU0WVOer1x2111Fl5ACAiwumfd8/tp9f302g
634 z5gu+8tDiyZrbddZqndH1Ot1CcNQarUa173PoHaR1Ov1Y8ll1eMZs30EQSBhGB5LKv0gCKTT6cj1
635 69dlb29vah+fWfmK9vmXoTDMty/rS036yfcgCKTRaMjW1la/2W4OAj9gJWG6UUVJkkTtdru3u7sr
636 QRBIu93Or2Fbtcalfv7d3V3Z2NiQRqMhrutGWZbd0y8K0DP1VRLH8cD3/b5akcuyLIrjuKdWpNTs
637 TpXLpqgOHM3oTJUPjvUPURzHvVWbsFEBi9ku9PaktyXb965SWaVpei8Mw2hzc1N2dnbk5s2b+VWP
638 IpInBuoKSHMrzqLxTNGLRF93sqB+ftuVr2pmuF6vy9rammxubrKaYCtP77u6sL6+LlEUSbPZPHVc
639 UsY4Rl9tUrGw4ziys7Mjm5ub0mq1XiYK7XZbdnZ25P3335f19fWpylY0A29eKVWmzFHdiKD2Zqk9
640 jep5fd+XMAzl+vXrg0bYuC8ibDuarlyDJEkGV65c6b///vu9Z8+eyd7e3lSnvArJgv6zJ0kivV5P
641 oiiSdrst4/G4dzSAReq9CuYbQ0+ShJQlabKVTZZlgyzL+nEcD0RERqNRNBqNeq7rRrb6cpLrl5e9
642 fPRBfTKZfHfTRq1m7gm9f/Sv9DGWBGEymXwYx3FvPB5HpxlzqnTT2lFfMwjD8P5kMhmMx+NoMpnc
643 y7Issr1gbKWCPseJGs1GtLOzI3fv3pUsyyQIgqm3Mo/H4zxRUMnDSRKFi+6b9ZsoVWymkgLbexTU
644 pOcbb7zRD4KAK7un+4WB53iDMAz7165d6/3xH/+x7O3tnenWo7Jtx9ffSK3qU5IkcvXqVbl27Vq/
645 0Wjk9cW/du3a/Xa7LdevX5fDw8OpbUbmQV8zGykL9RzmbN6sjmB3d/e+iDwgSZh2NJt1/91335VL
646 ly5Fara0rFfmnnYGSx+8J5OJtFotuXLlSuQ4TvT48eOeiETqUJAqn5MG2suSCJ3k59aDlfF4LL7v
647 D7a2tvJO58WLF9E333wTOY7TU9evmXeb264BXPZO2HZuS5+tieN46uWEWZbJ2tqatNvtqF6vS5Zl
648 rCpoVJKwt7f302fPnkWj0ahn20JRxaDY3FaiTzBkWTbY2tqK1tbWBt88/ib69tm3HzqO01Pba4vG
649 tipSwU0QBNJqtY2zgvUAABHcSURBVKTdavfv3r17f2dnZ/DjH/84j1PU2GSu0szbj75M45l5pbve
650 T9p+TrWC6fu+bGxsDJrN5n1ucJyOY9I0vb++vi5/9IM/ira3t2UymaxMDFP07qskSSQIAtnd3R2E
651 YXg/H8uyLLsnIpF58tkMisq+dKVvbyjqSNXbHFWHzJaAwoFspZe8zfpzlAhEmZPd6z/qf/jpp5/2
652 Xrx4IaPR6NiqnC2YrHCwJ61WS9566y3Z3NwU13Xl97//vTx8+FD0K2SrmiiobQHqBgk9UfA8T6Io
653 kiiKBru7uz/rdDo/q9Vq9+ld8gsTfvrVV1/9dDAY3Pv888/l6dOn1u2NVZ0914NAVbfUPuq7d+8O
654 oijK/v3f/13++7//u6e+Vw+AV2FVQa3mNhoNWVtbk+9973v333333Qeu6943x/0qjlGztmwacdtA
655 RIhlCuIYzqEerzdm/Os7jsPghBM5qjx0OprJZHJveDjsff755/L3f//38uWXX8of/vCHY4HvSWfo
656 lzmIsT2LvgJZq9Vke3tbPvjgA9nd3RXP8+Thw4fy4MED+fbbb2U8Hh9bsdTPSJ12+9FFlKX5HGqL
657 pu/7+TWF+m0krVZLvv/978uPfvSjqNVqRevr6wxWLxPM3v7+fu/LL7+MPvnkE/nlL38pX3zxxbFb
658 Osrchhat0ypRSNNUrly5IteuXZPhcBiNx2P5+c9/Lr/4xS9kNBpNrVqu2mUKtVpN6vW6/M3f/M3g
659 7t27933f/xmtCMQx54dXyALnxHVdOTg4kH6/Lw8fPpTf/va3U0GMeUFASTrThYJz25+r1Wqyt7cn
660 N27ckGazKb7vy+9//3v5r//6L3n69KmMRqOpxOM8/r/LVE76jLC5YtvpdGRjY0Nu3rwp4/GYxjNd
661 bpGIRHt7e72vv/5avvjiC/nss8+mXvA473dQ9hl121WYz549k8PDQ3n27JlMJhP53e9+J5999pmM
662 x+PCG3yqvLKg+tQwDKXRaMjXX38dZVkWZVkWMXsOkCgAy9WQfL/vum7/6LB3z1xJMK8hM+++XlYn
663 OXxt/vdkMpHJZCK+70uj0ci3jhweHuarCeZKiy1AKkuyYCs7deBQ30KiVhj0GXJuJZGpREpdbam/
664 XdasY+bbavW6Ufb3tOjPod/9PxwO8xUpfd+9+aLUsraZ007QhGEovu/30jTtxXHcE2aKgfNrYxQB
665 cC6D+yDLsoF2DejUQG0O4FXYJjDvZ7e9AMi2qqInUuYVgGULeMxnK5oBX8WbaU4zMultx5YI2BLu
666 spetedWl+Tn9ranzDl9WuZ6Z5eQ4TuS6bqTOzgEgUQBKM5jZBv8yJgtnfQu1bXVFBTuz/u6yBTzm
667 M5rPtqr7yc+rTRUlklUJjPWbj0SmbymJ41iGw6GIyNTKS9WSgkX7mrKszgJlxdYj4Dwzb+06vlkD
668 nJpZ1/+5yGC4rMHwaX5eM3Auerlj0edsP8NFl5OZIMz6nrMmXauqzG3mpM+pH2ZWNxvpz3+WLWvL
669 1nYWaTNFPydJAvAK4xqKADgfahDX33g4L1mYF3AvEpQva5Iwa8vIrMB50f9n0QHiZU4SbEkSFi/f
670 MreZszyz6lf0K2LV9btnDbyXpbxO8nZkAK8PKwrAKxzczZnPs9xIcpHXfi6a2BQ9k540qG0Utn3m
671 Jz08TSCx2u3MVj9tnysrtaVIP/jv+74EQSDqhY6znv+kZVCW8qKNA68PKwrAa0gazEC6rHvuTzNA
672 L3oYtejAdxkDF7ZCnDVCXu0gUj+boL+wUW03qtVqU4kEALwqrCgA50jNmOsDvG3//ayZ96oGP0XP
673 N2tr0rwXuy1LOc0L1myJEE5Xxrb6Mut61DK2naKkWl9BSNN06opd2xXDs/oZZuUBLIIVBeCc6dsF
674 Fr0uc16wWZarQc8jaJ/39yxzOem/X/P3b/vdE6ydXzBdlIyVMTkreg41AVHUr5zkWUlaASyCFQXg
675 nCRJcmz/vfr3ov3DZwmglyEZmPV9tmtBl+lnvMhyI0hbznq7TMx3iqhEIY5jmUwmIiJTFyec5iao
676 ZSqXk/QRRS9oBHD+WFEALnjQq1qgtcjL1Koe5AGvMlnQ3/xOewHwKrGiALympOE8VhXKkiycNak6
677 zfasVSu3KjvNVpoqBs0nvV5ZfzdL2cpg3rkS2hFwMVhRAM6zQRkvWjMHcQa72UFP2c9pnFcQiOLk
678 YdG6UIX6Ynuju+u6+YvW5t16VJVJCfpN4OKwogCck7O+JfU83iHwqgfss/wdJznfULYAvAzvxKhK
679 snCar5W1vPVbjvQkwff9wm1Ip2k/F1k+VVo9BKqIFQWgAkFSGRRtJ5i133oVywnHX1rIatx39BWE
680 s579WYY2c9b/r1kW+jsnAJwPVhSAEiUBVQqW9CDQPLR51heYLXs5EfguniycZ0BZ5uTa9nZzfavj
681 Sd6jsMxldJo3v+vlY67CADgbVhQAAAAAkCgAAAAAIFEAAAAAQKIAAAAAgEQBAAAAAIkCAAAAABIF
682 AAAAACQKAAAAAEgUAAAAAJAoAAAAACBRAAAAAECiAAAAAIBEAQAAAACJAgAAAAASBQAAAAAkCgAA
683 AABAogAAAACARAEAAAAAiQIAAAAAEgUAAAAAJAoAAAAASBQAAAAAkCgAAAAAIFEAAAAAQKIAAAAA
684 gEQBAAAAAIkCAAAAABIFADgtx3Gm/jlLlmUUGLBAe4KI53kUAnCOfIoAwLwgZF6wXvQ96nO2r+l/
685 xgx0qpQcOI5zrHzU51DAnV1+qyLLsmNJdZZlUx/619Xnyv7Mp/0ztCnglXbHAHA8yF30e2zfu6oD
686 N6sg55dgrTozwaR+HS8fygN4dVhRAPBKEgn9a7bv0wd3fWZ0FZIGghtg8b6FtgJcHFYUAFxY8EwA
687 gJMkWAAAEgUAJXVeqwJsO1lxKUVA2wFAogBgqZ3XrK7595zk1iNQ/0i+KQMSI4BEAUDJgjVzr735
688 7/rXi5KFVQ6GCIRBsnD6MqjybWkAiQKASgW8RVegFq0eLDKoVz1AIgA8fd3C6tUtJhcAEgUAKxC0
689 mKsMswJBAgIAen8wq09IkoRCAs4R16MCeCUJgRrQFw30mTkGTt/uqtJ2mBgAlgsrCgBeWZJAWSyG
690 WVB74ojZ9YuDvABeNVYUAJxb8LvKhwuLZnVVMGe+YZcAD6dNDgCARAHAUgcp86481W89mve9ZQ9+
691 OGR5fpIkYTXhnOpZlbYkASBRAFCCJGHeneY6M1kwZ9X1f3ccR9I0LZyVL0PAc9IkgaQCr6NOkiwA
692 IFEALtiq7DOf914FfUWhKNkwv9f8vrIHNurnLyqLqjznq+B5HnfmF9Qps17N+vyqJEFa39J3HGfg
693 uu6AVgSQKABLKU1T2wBW6gDnpD+vGRR7niee54nrujOTiFm3HpWlzIpWTPTPu64rrutO1RfP82g8
694 cwJCVWZ6ea5CsmC+xFCVhapfahVO/++yP++i26qMZx64rtv3fb9PiwFIFIClpAcz5mBWxqDmJDOU
695 8xKiLMumgph55x2Kgu4ylKVtu5YtuDXrC6bPKMz7Pc86QF7m5FzvM8zEUj1LmqaSpqm4rmtdVShz
696 ErVIsqA/79Eq1EB90IoAEgVg6ahZYTVoqyTBHMhfR9B+0cmCHuhlWZZvy9JnP1WQZ9uWMytQWHTG
697 8SKDvFnnL1TCpAJAkoXjiUKSJDNnxvV6Nm+b0rLXl3kJkOM44vu+uK47VYdUOan6E8dx/qxleuZZ
698 q4jznkHVkVqtxqocQKIAlCPIieN4auZPTxzKOMtX9DPbBnEz6FdbJPSgWN+DroIcPWEo44vXigJT
699 23OoREEFw2XfKvIqEm7HO359bJqmC8+WlzE5sLUjfWuNSgxUGantfKoOVXE71rzfo+pTJ5OJJEkS
700 ZVkWZVkWsaoAkCgAS5kkpGmqBq2pLQLncQ3oMgUAiyQ9KkHQgxr1TxXgqO8xA+YyJgq27UVFW6r0
701 GWF9xQUy80zLovXCrJ9l3fanbzlS9UWtMKhVBnNiYlYfs4zlMC/5m/VuErVSNxqNZDKZ0HgAEgVg
702 OWVZFo1Go8j3/ajb7cr6+rrs7+/nQaEazPXgp8yJwqJBTq1WkyRJZDwe59sDWq2WjMdjGY1G+XOp
703 4Mf2crKTlMWybM9Sz6BvoVEJku/70ul0pNVqSRAEXJFqSbjH43EeFDcaDWm1WvnWmmX4fb/uRNx1
704 XWk0GtJutyVNU9nf3xcRkTAM82SzVquV8nxC0VmleWdPVHsKw1DCMJQgCKRWq9GAABIFYDmlaSpB
705 EMj29rYcHBxMBYuj0UjiOM5nAc+QkJQqUbh06ZLU63XxfV9qtZqsra3J1atXJQgCOTw8nNqWpW9P
706 KluioP//9ZnOyWSSz/aqFZV6vS7dblcuX74sa2tr7K22JArJJBHP86TdbsuVK1dkb28vTx7033MV
707 EwU9WVbP67quXL58OW874/FY2u22XL16Vfb29iSOY6nVaud2Hup1P6vepmetHpmJgud5EgSBNBoN
708 WVtbG2RZxmFmgEQBWE5hGMqbb74pP/nJT+T58+dyeHiYz3KpIOcsKwoXERSdJeBI01RarZa8+eab
709 /Y2NjYHv+3L79u3oe9/7Xi+O46mzCuY+67KVkyor2+0zthnTWq0m165dk52dnX632x1kWUZw8zIA
710 HLTb7ft37tyJ1tfXo1u3bvWePn1a+Duedeh9WRLI09Ql81C82m509+7d/u7urvz1X/+1/Mmf/ElP
711 JRTj8VhEjr+HokzPPuucUtE7V2q1moRhKHfu3InSNOWMAnDeCT1FAJyPyWRy7+Dg4KfPnj37f2ma
712 9nzf7zcajUEYhhLHcZSmac9xnL6IDDLn5IGhK6//dpxUTn7Q1smcKJMsSuKk53lev9FqPAhr4X3X
713 dWXvYO/e86fPP/R9X5rN5sDxvhvQkySRNE7VQC+u6w7ElVMN9hdRTsrRDHCktpn5vj9wHCdyXTdK
714 kqSnrTL0gyAY1Gq1B2EY3g+C4D7BTR4sRnEc91zX/XA0GvUODg4+VKtxjuMM1K93kd+zqr8XWSdO
715 2+5ccfWb1KLxeBwNh8Nep9PpN5vNwXA8HCSTRGq1mqRpGu3v70dZlvWCMOg74uR9TFmePZU07zsk
716 k968FQWVTPi+3w+CYOA4zgMRud9oNGhLAIkCsJwBzng8vjcaje45nhM5mTPwfb9/dOCwp2a6XNft
717 V3kgy7IsStO0J65EksrA87z7QRDcFxFR5eP7voRh2I/jeHDsz4lImcsoy7JIC2wGjuNEcRz3RCTS
718 bnEZ+L7fdxznwdE/CWwKEoYkST7Uy3MlB+qjOqTqlt6PeJ4naZpGw+Gw53hO5DleafuYqb5jke9P
719 MnEcZxCGYT/LskGWZQPaE0CiACx7kNgTkSiO44F6S2gcx700TSPXdSs/kKkAz/f9vAzU86qviYiY
720 5TDra2VOFNRzpWkaieS3+gxEhIDmFOW5ykmT7/vRZDKJ4jge1Gq1Qa1Wu69/3XGcqMzBsv4cJ/gz
721 JAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
722 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
723 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
724 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
725 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
726 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
727 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
728 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
729 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB4Rf4/zH7p9WfBxZ8AAAAASUVORK5CYII=
730 "
731 id="image10"
732 x="18.989044"
733 y="-16.042847" />
734 <circle
735 style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
736 id="path4648"
737 cx="-314.78708"
738 cy="-193.14854"
739 r="65.19825" />
740 </svg>
img/menu-locale.png less more
Binary diff not shown
0 # SOME DESCRIPTIVE TITLE.
1 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
2 # This file is distributed under the same license as the PACKAGE package.
3 # ssantos <ssantos@web.de>, 2020.
4 msgid ""
5 msgstr ""
6 "Project-Id-Version: PACKAGE VERSION\n"
7 "Report-Msgid-Bugs-To: \n"
8 "POT-Creation-Date: 2020-09-20 17:03+0200\n"
9 "PO-Revision-Date: 2020-10-11 16:51+0000\n"
10 "Last-Translator: ssantos <ssantos@web.de>\n"
11 "Language-Team: Portuguese <https://hosted.weblate.org/projects/"
12 "programmers-learning-machine/binary/pt/>\n"
13 "Language: pt\n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
17 "Plural-Forms: nplurals=2; plural=n > 1;\n"
18 "X-Generator: Weblate 4.3-dev\n"
19
20 #: src/lessons/lightbot/universe/LightBotExercise.java:56
21 msgid "A light is still off."
22 msgstr "Uma luz ainda está desligada."
23
24 #: src/lessons/lightbot/universe/LightBotExercise.java:58
25 #, java-format
26 msgid "{0} lights (out of {1}) are still off."
27 msgstr "{0} luzes (de {1}) ainda estão desligadas."
28
29 #: src/lessons/maze/island/IslandMazeEntity.java:10
30 #: src/lessons/maze/pledge/PledgeMazeEntity.java:10
31 #: src/lessons/maze/randommouse/RandomMouseMazeEntity.java:9
32 #: src/lessons/maze/shortestpath/ShortestPathMazeEntity.java:14
33 #: src/lessons/maze/wallfindfollow/WallFindFollowMazeEntity.java:12
34 #: src/lessons/maze/wallfollower/WallFollowerMazeEntity.java:12
35 #: src/lessons/recursion/lego/tree/TreeEntity.java:12
36 #: src/lessons/welcome/array/basics/Array1Entity.java:11
37 #: src/lessons/welcome/array/basics/Array2Entity.java:12
38 msgid ""
39 "Sorry Dave, I cannot let you use setX(x) in this exercise. Walk to your goal "
40 "instead."
41 msgstr ""
42 "Desculpe Dave, mas não posso deixá-lo usar setX(x) neste exercício. Em vez "
43 "disto, caminhe para o seu objetivo."
44
45 #: src/lessons/maze/island/IslandMazeEntity.java:15
46 #: src/lessons/maze/pledge/PledgeMazeEntity.java:15
47 #: src/lessons/maze/randommouse/RandomMouseMazeEntity.java:14
48 #: src/lessons/maze/shortestpath/ShortestPathMazeEntity.java:19
49 #: src/lessons/maze/wallfindfollow/WallFindFollowMazeEntity.java:17
50 #: src/lessons/maze/wallfollower/WallFollowerMazeEntity.java:17
51 #: src/lessons/recursion/lego/tree/TreeEntity.java:17
52 #: src/lessons/welcome/array/basics/Array1Entity.java:16
53 #: src/lessons/welcome/array/basics/Array2Entity.java:17
54 msgid ""
55 "Sorry Dave, I cannot let you use setY(y) in this exercise. Walk to your goal "
56 "instead."
57 msgstr ""
58 "Desculpe Dave, mas não posso deixá-lo usar setY(y) neste exercício. Em vez "
59 "disto, caminhe para o seu objetivo."
60
61 #: src/lessons/maze/island/IslandMazeEntity.java:20
62 #: src/lessons/maze/pledge/PledgeMazeEntity.java:20
63 #: src/lessons/maze/randommouse/RandomMouseMazeEntity.java:19
64 #: src/lessons/maze/shortestpath/ShortestPathMazeEntity.java:24
65 #: src/lessons/maze/wallfindfollow/WallFindFollowMazeEntity.java:22
66 #: src/lessons/maze/wallfollower/WallFollowerMazeEntity.java:22
67 #: src/lessons/recursion/lego/tree/TreeEntity.java:22
68 #: src/lessons/welcome/array/basics/Array1Entity.java:21
69 #: src/lessons/welcome/array/basics/Array2Entity.java:22
70 msgid ""
71 "Sorry Dave, I cannot let you use setPos(x,y) in this exercise. Walk to your "
72 "goal instead."
73 msgstr ""
74 "Desculpe Dave, mas não posso deixá-lo usar setPos(x,y) neste exercício. Em "
75 "vez disto, caminhe para o seu objetivo."
76
77 #: src/lessons/recursion/hanoi/LinearHanoiEntity.java:11
78 #: src/lessons/recursion/hanoi/LinearTwinHanoiEntity.java:10
79 msgid ""
80 "Sorry Dave, I cannot let you move disks between slots 0 and 2 directly. Use "
81 "the intermediate slot in all moves."
82 msgstr ""
83 "Desculpe Dave, não posso deixá-lo mover discos entre slots 0 e 2 "
84 "diretamente. Use o slot intermediário em todos os movimentos."
85
86 #: src/lessons/recursion/hanoi/universe/HanoiEntity.java:55
87 #, java-format
88 msgid ""
89 "Sorry Dave, I cannot let you move disks counterclockwise. Move from 0 to 1, "
90 "from 1 to 2 or from 2 to 0 only, not from {0} to {1}."
91 msgstr ""
92 "Desculpe Dave, não posso deixá-lo mover discos no sentido anti-horário. "
93 "Passar de 0 para 1, de 1 para 2 ou apenas de 2 para 0, não de {0} para {1}."
94
95 #: src/lessons/recursion/hanoi/universe/HanoiMovePanel.java:68
96 #: src/lessons/recursion/hanoi/universe/HanoiWorldView.java:172
97 #: src/lessons/sort/baseball/universe/BaseballMovePanel.java:73
98 #, java-format
99 msgid "move({0},{1})"
100 msgstr "move({0},{1})"
101
102 #: src/lessons/recursion/hanoi/universe/HanoiMovePanel.java:71
103 #: src/lessons/recursion/hanoi/universe/HanoiWorldView.java:176
104 #: src/lessons/sort/baseball/universe/BaseballMovePanel.java:77
105 msgid "Invalid move"
106 msgstr "Movimento inválido"
107
108 #: src/lessons/recursion/hanoi/universe/HanoiWorld.java:169
109 #, java-format
110 msgid "The disks were not moved the same amount of time: {0} vs. {1}\n"
111 msgstr "Os discos não foram movidos na mesma quantidade de tempo: {0} vs. {1}\n"
112
113 #: src/lessons/recursion/hanoi/universe/HanoiWorld.java:176
114 #, java-format
115 msgid " Disk #{0} of slot #{1} differs: {2} vs. {3}\n"
116 msgstr " Disco #{0} do espaço #{1} difere: {2} vs. {3}\n"
117
118 #: src/lessons/recursion/hanoi/universe/HanoiWorld.java:181
119 #, java-format
120 msgid " Color of disk #{0} of slot #{1} differs: {2} vs. {3}\n"
121 msgstr " Cor do disco #{0} do espaço #{1} difere: {2} vs. {3}\n"
122
123 #: src/lessons/recursion/hanoi/universe/HanoiWorld.java:202
124 #, java-format
125 msgid ""
126 "Cannot move from slot {0} to {1}: the only existing slots are numbered from "
127 "0 to {2}"
128 msgstr ""
129 "Não me posso mover do espaço {0} para o {1}: os únicos espaços existentes "
130 "são os numerados de 0 a {2}"
131
132 #: src/lessons/recursion/hanoi/universe/HanoiWorld.java:204
133 #, java-format
134 msgid "Cannot move from slot {0} to itself"
135 msgstr "Não me posso mover do slot {0} para ele próprio"
136
137 #: src/lessons/recursion/hanoi/universe/HanoiWorld.java:206
138 #, java-format
139 msgid "No disc to move from slot {0}"
140 msgstr "Não há disco no slot {0} para mover"
141
142 #: src/lessons/recursion/hanoi/universe/HanoiWorld.java:211
143 #, java-format
144 msgid ""
145 "Cannot move disc from slot {0} to {1} small disk must remain over large ones "
146 "but {2} > {3}"
147 msgstr ""
148 "Não posso mover o disco do slot {0} para o {1} disco pequeno deve repousar "
149 "sobre grande, mas {2} > {3}"
150
151 #. Create the button
152 #: src/lessons/sort/baseball/universe/BaseballMovePanel.java:65
153 #: src/plm/core/ui/ChooseLessonDialog.java:192
154 msgid "Go"
155 msgstr "Siga"
156
157 #: src/lessons/sort/baseball/universe/BaseballMovePanel.java:76
158 #, java-format
159 msgid ""
160 "The player {0} of the base {1} cannot reach the hole that is too far from "
161 "its position"
162 msgstr ""
163 "O jogador {0} da base {1} não pode alcançar o buraco que está muito longe de "
164 "sua posição"
165
166 #: src/lessons/sort/baseball/universe/BaseballWorld.java:146
167 msgid "This is not a baseball world :-("
168 msgstr "Este não é um mundo de beisebol :-("
169
170 #: src/lessons/sort/baseball/universe/BaseballWorld.java:150
171 #, java-format
172 msgid "Differing amount of bases: {0} vs {1}"
173 msgstr "Quantidade de bases diferentes: {0} vs {1}"
174
175 #: src/lessons/sort/baseball/universe/BaseballWorld.java:153
176 #, java-format
177 msgid "Differing amount of players: {0} vs {1}"
178 msgstr "Quantidade de jogadores diferentes: {0} vs {1}"
179
180 #: src/lessons/sort/baseball/universe/BaseballWorld.java:159
181 #, java-format
182 msgid "Player at base {0}, pos {1} differs: {2} vs {3}\n"
183 msgstr "Jogador na base {0}, pos {1} difere: {2} vs {3}\n"
184
185 #: src/lessons/sort/baseball/universe/BaseballWorld.java:372
186 #, java-format
187 msgid ""
188 "It''s still not sorted!! PLEASE REPORT THIS BUG, along with the following "
189 "information:\n"
190 "Exercise: {0}; Amount of bases: {1}; Initial situation: {2}"
191 msgstr ""
192 "Ainda não está ordenado!! FAVOR RELATE ESTE ERRO, junto com a seguinte "
193 "informação:\n"
194 "Exercise: {0}; Amount of bases: {1}; Initial situation: {2}"
195
196 #: src/lessons/sort/baseball/universe/BaseballWorld.java:409
197 #, java-format
198 msgid "Cannot move from base {0} since it''s not between 0 and {1}"
199 msgstr "Não pode se mover para da base {0} pois ela não está entre 0 e {1}"
200
201 #: src/lessons/sort/baseball/universe/BaseballWorld.java:412
202 #, java-format
203 msgid "Cannot move from position {0} since it''s not between 0 and {1})"
204 msgstr "Não pode se mover da posição {0} pois não está entre 0 e {1})"
205
206 #: src/lessons/sort/baseball/universe/BaseballWorld.java:421
207 #, java-format
208 msgid ""
209 "The player {0} from base {1} is too far from the hole (at base {2}) to reach "
210 "it in one move"
211 msgstr ""
212 "O jogador {0} da base {1} está muito longe do buraco (na base {2}) para "
213 "alcançá-lo num movimento"
214
215 #: src/lessons/sort/baseball/universe/BaseballWorldView.java:669
216 #: src/plm/universe/sort/SortingWorldView.java:52
217 msgid "Switch to time view"
218 msgstr "Alternar para visão de tempo"
219
220 #: src/lessons/sort/baseball/universe/BaseballWorldView.java:671
221 #: src/plm/universe/sort/SortingWorldView.java:54
222 msgid "Switch to state view"
223 msgstr "Alternar para visão de estado"
224
225 #: src/lessons/sort/dutchflag/universe/DutchFlagEntity.java:28
226 msgid "Flag sorter"
227 msgstr "Ordenador de bandeira"
228
229 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.java:102
230 msgid "This world is not a dutch flag"
231 msgstr "Este mundo não é uma bandeira da holanda"
232
233 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.java:106
234 #: src/lessons/sort/pancake/universe/PancakeWorld.java:120
235 msgid "The two worlds are of differing size"
236 msgstr "Os dois mundos são de tamanhos diferentes"
237
238 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.java:111
239 #, java-format
240 msgid " Ray #{0} differs: color {1} is not color {2}\n"
241 msgstr " Raio #{0} é diferente: cor {1} não é cor {2}\n"
242
243 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.java:177
244 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.java:180
245 #, java-format
246 msgid "Cannot swap {0} and {1} because {2} is not between 0 and {3}"
247 msgstr "Não posso alternar {0} e {1} pois {2} não está entre 0 e {3}"
248
249 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.java:197
250 #, java-format
251 msgid "Cannot get the color of line #{0} because it''s not between 0 and {1}"
252 msgstr "Não posso obter a cor da linha #{0} pois não está entre 0 e {1}"
253
254 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.java:232
255 #, java-format
256 msgid ""
257 "It''s still not sorted!! PLEASE REPORT THIS BUG, along with the following "
258 "information:\n"
259 "Initial situation: {0}"
260 msgstr ""
261 "Ainda não está ordenado!! POR FAVOR REPORTE ESTE ERRO, junto com as "
262 "seguintes informações:\n"
263 "Situação inicial: {0}"
264
265 #: src/lessons/sort/dutchflag/universe/DutchFlagWorldView.java:145
266 #: src/plm/universe/sort/SortingButtonPanel.java:70
267 #, java-format
268 msgid "swap({0},{1})"
269 msgstr "alternar({0},{1})"
270
271 #: src/lessons/sort/pancake/universe/PancakeFlipButtonPanel.java:66
272 #, java-format
273 msgid "flip({0})"
274 msgstr "virar({0})"
275
276 #: src/lessons/sort/pancake/universe/PancakeWorld.java:116
277 msgid "This is not a world of pancakes"
278 msgstr "Este não é um mundo de panquecas"
279
280 #: src/lessons/sort/pancake/universe/PancakeWorld.java:124
281 #, java-format
282 msgid "Stacks were not flipped the same amount of time: {0} vs. {1}\n"
283 msgstr "Pilhas não foram viradas a mesma quantidade de tempo: {0} vs. {1}\n"
284
285 #: src/lessons/sort/pancake/universe/PancakeWorld.java:128
286 #, java-format
287 msgid " Pancake #{0} differs: {1} vs. {2}\n"
288 msgstr " Panqueca #{0} difere: {1} vs. {2}\n"
289
290 #: src/lessons/sort/pancake/universe/PancakeWorld.java:206
291 #, java-format
292 msgid "Asked to flip {0} pancakes, but you must flip at least one"
293 msgstr "Foi pedido para virar {0}, mas deve virar pelo menos uma"
294
295 #: src/lessons/sort/pancake/universe/PancakeWorld.java:208
296 #, java-format
297 msgid ""
298 "Asked to flip {0} pancakes, but there is only {1} pancakes on this stack"
299 msgstr ""
300 "Me foi pedido para virar {0} panquecas, mas existem apenas {1} panquecas "
301 "nesta pilha"
302
303 #: src/lessons/sort/pancake/universe/PancakeWorld.java:242
304 #, java-format
305 msgid ""
306 "Cannot get the radius of pancake #{0} because it''s not between 0 and {1}"
307 msgstr "Não posso obter o raio da panqueca #{0} pois ela não está entre 0 e {1}"
308
309 #: src/lessons/sort/pancake/universe/PancakeWorld.java:261
310 #, java-format
311 msgid ""
312 "Cannot get the orientation of pancake #{0} because it''s not between 0 and "
313 "{1}"
314 msgstr ""
315 "Não consigo pegar a orentação da panqueca #{0} pois ela não está entre 0 e "
316 "{1}"
317
318 #: src/lessons/welcome/loopdowhile/Poucet1Entity.java:10
319 #: src/lessons/welcome/loopdowhile/Poucet2Entity.java:12
320 #: src/lessons/welcome/loopfor/LoopCourseEntity.java:10
321 #: src/lessons/welcome/loopfor/LoopCourseForestEntity.java:10
322 #: src/lessons/welcome/loopfor/LoopForEntity.java:8
323 #: src/lessons/welcome/loopwhile/BaggleSeekerEntity.java:10
324 #: src/lessons/welcome/loopwhile/LoopWhileEntity.java:9
325 #: src/lessons/welcome/summative/MoriaEntity.java:10
326 #: src/lessons/welcome/variables/RunFourEntity.java:8
327 #: src/lessons/welcome/variables/RunHalfEntity.java:10
328 #: src/lessons/welcome/variables/VariablesEntity.java:8
329 msgid ""
330 "Sorry Dave, I cannot let you use forward with an argument in this exercise. "
331 "Use a loop instead."
332 msgstr ""
333 "Desculpe Dave, não posso deixá-lo usar avançar com um argumento neste "
334 "exercício. Use um loop ao invés disto."
335
336 #: src/lessons/welcome/loopdowhile/Poucet1Entity.java:14
337 #: src/lessons/welcome/loopdowhile/Poucet2Entity.java:16
338 #: src/lessons/welcome/loopfor/LoopCourseEntity.java:14
339 #: src/lessons/welcome/loopfor/LoopCourseForestEntity.java:14
340 #: src/lessons/welcome/loopfor/LoopForEntity.java:13
341 #: src/lessons/welcome/loopwhile/BaggleSeekerEntity.java:15
342 #: src/lessons/welcome/loopwhile/LoopWhileEntity.java:14
343 #: src/lessons/welcome/summative/MoriaEntity.java:15
344 #: src/lessons/welcome/variables/RunFourEntity.java:12
345 #: src/lessons/welcome/variables/RunHalfEntity.java:14
346 #: src/lessons/welcome/variables/VariablesEntity.java:13
347 msgid ""
348 "Sorry Dave, I cannot let you use backward with an argument in this exercise. "
349 "Use a loop instead."
350 msgstr ""
351 "Desculpe Dave, não posso deixá-lo usar avançar com um argumento neste "
352 "exercício. Use um loop ao invés disto."
353
354 #: src/lessons/welcome/loopfor/LoopCourseEntity.java:18
355 #: src/lessons/welcome/loopfor/LoopCourseForestEntity.java:18
356 msgid ""
357 "Sorry Dave, you cannot run backward like this. Exercising is hard enough -- "
358 "please don't overplay."
359 msgstr ""
360 "Desculpe Dave, não pode correr para trás desta maneira. Exercitar já é "
361 "difícil -- por favor, não exagere."
362
363 #: src/lessons/welcome/loopfor/LoopCourseForestEntity.java:39
364 msgid "You fall into water."
365 msgstr "Caiu na água."
366
367 #: src/lessons/welcome/loopfor/LoopCourseForestEntity.java:39
368 #: src/plm/universe/bugglequest/SimpleBuggle.java:31
369 #: src/plm/universe/bugglequest/SimpleBuggle.java:36
370 #: src/plm/universe/bugglequest/SimpleBuggle.java:47
371 #: src/plm/universe/bugglequest/SimpleBuggle.java:58
372 #: src/plm/universe/bugglequest/SimpleBuggle.java:69
373 #: src/plm/universe/bugglequest/SimpleBuggle.java:80
374 #: src/plm/universe/bugglequest/SimpleBuggle.java:96
375 #: src/plm/universe/bugglequest/SimpleBuggle.java:100
376 #: src/plm/universe/bugglequest/SimpleBuggle.java:111
377 #: src/plm/universe/bugglequest/SimpleBuggle.java:115
378 #: src/plm/universe/bugglequest/SimpleBuggle.java:125
379 #: src/plm/universe/bugglequest/SimpleBuggle.java:135
380 #: src/plm/universe/bugglequest/SimpleBuggle.java:145
381 msgid "Test failed"
382 msgstr "Teste falhou"
383
384 #: src/lessons/welcome/methods/args/MethodsArgsEntity.java:10
385 msgid ""
386 "I cannot let you use forward with an argument in this exercise. Use a loop "
387 "instead."
388 msgstr ""
389 "Não posso deixá-lo usar avançar com um argumento neste exercício. Use um "
390 "loop ao invés disto."
391
392 #: src/lessons/welcome/methods/args/MethodsArgsEntity.java:14
393 msgid ""
394 "I cannot let you use backward with an argument in this exercise. Use a loop "
395 "instead."
396 msgstr ""
397 "Não posso deixá-lo usar recuar com um argumento neste exercicio. Use um loop "
398 "ao invés disto."
399
400 #: src/lessons/welcome/methods/basics/MethodsDogHouseEntity.java:10
401 msgid ""
402 "Sorry Dave, I cannot let you use right() in this exercise. Use left() "
403 "instead."
404 msgstr ""
405 "Desculpe Dave, não posso deixá-lo usar right() neste exercício. Use left() "
406 "ao invés disto."
407
408 #: src/lessons/welcome/methods/basics/MethodsDogHouseEntity.java:26
409 #, java-format
410 msgid ""
411 "Sorry Dave, I cannot let you use left() both in lines {0} and {1} in this "
412 "exercise. You can write left() only once in this exercise."
413 msgstr ""
414 "Desculpe Dave, não posso deixá-lo usar left() em ambas as linhas {0} e {1} "
415 "neste exercício. Pode escrever left() apenas uma vez neste exercício."
416
417 #: src/lessons/welcome/traversal/column/TraversalByColumnEntity.java:42
418 #: src/lessons/welcome/traversal/column/TraversalByColumnEntity.java:47
419 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonalEntity.java:48
420 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonalEntity.java:53
421 #: src/lessons/welcome/traversal/line/TraversalByLineEntity.java:43
422 #: src/lessons/welcome/traversal/line/TraversalByLineEntity.java:48
423 #: src/lessons/welcome/traversal/zigzag/TraversalZigZagEntity.java:48
424 #: src/lessons/welcome/traversal/zigzag/TraversalZigZagEntity.java:53
425 msgid ""
426 "Sorry Dave, I cannot let you use forward() in this exercise. Use setPos(x,y) "
427 "instead."
428 msgstr ""
429 "Desculpe Dave, não o posso deixar usar forward() neste exercício. Use "
430 "setPos(x,y) ao invés disto."
431
432 #: src/lessons/welcome/traversal/column/TraversalByColumnEntity.java:51
433 #: src/lessons/welcome/traversal/column/TraversalByColumnEntity.java:55
434 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonalEntity.java:57
435 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonalEntity.java:61
436 #: src/lessons/welcome/traversal/line/TraversalByLineEntity.java:52
437 #: src/lessons/welcome/traversal/line/TraversalByLineEntity.java:56
438 #: src/lessons/welcome/traversal/zigzag/TraversalZigZagEntity.java:57
439 #: src/lessons/welcome/traversal/zigzag/TraversalZigZagEntity.java:61
440 msgid ""
441 "Sorry Dave, I cannot let you use backward() in this exercise. Use setPos(x,"
442 "y) instead."
443 msgstr ""
444 "Desculpe Dave, não o posso deixar usar backward() neste exercício. Use "
445 "setPos(x,y) ao invés disto."
446
447 #: src/plm/core/lang/JVMCompiledLang.java:53
448 msgid ""
449 "Your entity failed to start. Did you forgot to put your code within a "
450 "method?\n"
451 "\n"
452 "This problem often arises when the exercise expects you to put all the code "
453 "within a \n"
454 "method e.g. run(), but you put some statements (e.g. forward()) outside of "
455 "any method.\n"
456 "\n"
457 "The easiest solution to sort it out is to copy all your code (Ctrl-A Ctrl-"
458 "C), use the \n"
459 "'Exercise/Revert' menu to reset the template, and paste (Ctrl-V) your code "
460 "within the\n"
461 "provided method."
462 msgstr ""
463 "A sua entidade falhou a iniciar. Será que esqueceu de pôr o seu código "
464 "dentro de um método?\n"
465 "\n"
466 "Este problema normalmente acontece quando o exercício espera que ponha todo "
467 "o código dentro \n"
468 "de um método e.g. executar(), mas põe algumas declarações (p.ex. forward()) "
469 "fora de qualquer método.\n"
470 "\n"
471 "A solução mais fácil para consertar isto é copiar todo o seu código (Ctrl-A "
472 "Ctrl-C), usar \n"
473 "o menu 'Exercício/Reverter' para reconfigurar o modelo e colar (Ctrl-V) o "
474 "seu código \n"
475 "dentro do método fornecido."
476
477 #: src/plm/core/lang/JVMCompiledLang.java:60
478 msgid ""
479 "Your entity failed to start. Your constructor seems to be broken, but I have "
480 "no clue."
481 msgstr ""
482 "Sua entidade falhou para iniciar. O seu construtor parece estar com defeito, "
483 "mas não tenho uma dica para lhe dar."
484
485 #: src/plm/core/lang/JVMCompiledLang.java:83
486 #: src/plm/core/lang/LangLightbot.java:39
487 #, java-format
488 msgid ""
489 "The execution of your program raised a {0} exception: {1}\n"
490 " Please fix your code.\n"
491 msgstr ""
492 "A execução do seu programa levantou uma exceção {0}: {1}\n"
493 " favor consertar o código.\n"
494
495 #: src/plm/core/lang/LangC.java:188 src/plm/core/lang/LangJava.java:82
496 #: src/plm/core/lang/LangScala.java:61
497 msgid "Compilation error:"
498 msgstr "Erro de compilação:"
499
500 #: src/plm/core/lang/LangC.java:260 src/plm/core/lang/LangC.java:267
501 msgid "Error, please recompile the exercise"
502 msgstr "Erro, favor recompile o exercício"
503
504 #.
505 #. * FIXME: provide a way to debug
506 #. * when templates are broken
507 #.
508 #. for (String n:classes.keySet())
509 #. System.out.println("File "+n+":\n"+classes.get(n));
510 #: src/plm/core/lang/LangJava.java:349
511 msgid "Compilation failed."
512 msgstr "Compilação falhou."
513
514 #: src/plm/core/lang/LangPython.java:49
515 #, java-format
516 msgid ""
517 "Syntax error: {0}\n"
518 "Line {1}: {2}\n"
519 "In doubt, check your indentation, and that you don't mix tabs and spaces\n"
520 msgstr ""
521 "Erro de sintaxe: {0}\n"
522 "Linha {1}: {2}\n"
523 "Na dúvida, verifique a sua identação e se não misturou tabs e espaços\n"
524
525 #: src/plm/core/lang/LangPython.java:58
526 #, java-format
527 msgid ""
528 "Indentation error: {0}\n"
529 "line {1}: {2}\n"
530 "Please, check that you did not mix tabs and spaces. Use the TAB and shift-"
531 "TAB keys to clean your indentation.\n"
532 msgstr ""
533 "Erro de indentação: {0}\n"
534 "linha {1}: {2}\n"
535 "Por favor, verifique se não misturou tabs e espaços. Use as teclas TAB e "
536 "shift-TAB para limpar a sua identação.\n"
537
538 #: src/plm/core/lang/LangPython.java:66
539 msgid ""
540 "You interrupted the execution, did you fall into an infinite loop ?\n"
541 "Your program must stop by itself to successfully pass the exercise.\n"
542 msgstr ""
543 "Interrompeu a execução. Entrou num loop infinito?\n"
544 "Seu programa deve parar por si só para realizar o exercício com sucesso.\n"
545
546 #: src/plm/core/lang/LangPython.java:72
547 msgid ""
548 "NameError raised: You seem to use a non-existent identifier; Please check "
549 "for typos\n"
550 msgstr ""
551 "NameError levantado: Parece que está a usar um identificador inexistente; "
552 "favor verificar erros de digitação\n"
553
554 #: src/plm/core/lang/LangPython.java:76
555 msgid "TypeError raised: you are probably misusing a function or something.\n"
556 msgstr ""
557 "TypeError levantado: provavelmente está a mal-utilizar uma função ou outra "
558 "coisa.\n"
559
560 #: src/plm/core/lang/LangPython.java:80
561 msgid ""
562 "UnboundLocalError raised: you are probably using a global variable that is "
563 "not declared as such.\n"
564 msgstr ""
565 "UnboundLocalError levantado: está provavelmente a usar uma variável global "
566 "que não é declarada como tal.\n"
567
568 #: src/plm/core/lang/LangPython.java:87
569 msgid "Error: there is no baggle to pickup under the buggle"
570 msgstr "Erro: não existe bagggle para pegar sob o buggle"
571
572 #: src/plm/core/lang/LangPython.java:89
573 msgid "Error: a buggle cannot carry more than one baggle at the same time"
574 msgstr "Erro: um buggle não pode carregar mais de um baggle ao mesmo tempo"
575
576 #: src/plm/core/lang/LangPython.java:91
577 msgid "Error: your buggle just teleported to the outer space..."
578 msgstr "Erro: o seu buggle foi teletransportado ao espaço sideral..."
579
580 #: src/plm/core/lang/LangPython.java:93
581 msgid "Error: your buggle just hit a wall. That hurts."
582 msgstr "Erro: o seu buggle bateu numa parede. Doi."
583
584 #: src/plm/core/lang/LangPython.java:96
585 #, java-format
586 msgid ""
587 "Unknown error (please report): {0}\n"
588 "Its value is: {1}"
589 msgstr ""
590 "Erro desconhecido (favor relatar): {0}\n"
591 "Seu valor é: {1}"
592
593 #: src/plm/core/lang/ScriptingLanguage.java:86
594 #, java-format
595 msgid ""
596 "No ScriptEngine for {0}. Please check your classpath and similar settings."
597 msgstr ""
598 "Sem ScriptEngine para {0}. Favor verificar o seu classpath e configurações "
599 "similares."
600
601 #: src/plm/core/lang/ScriptingLanguage.java:96
602 #, java-format
603 msgid ""
604 "No {0} script source for entity {1}. Please report that bug against the PLM."
605 msgstr ""
606 "Sem fonte do script {0} para a entidade {1}. Favor relatar este erro ao PLM."
607
608 #: src/plm/core/lang/ScriptingLanguage.java:108
609 #, java-format
610 msgid "Received a ScriptException that does not come from the {0} language.\n"
611 msgstr "Recebeu uma ScriptException que não vem da linguagem {0}.\n"
612
613 #: src/plm/core/lang/ScriptingLanguage.java:113
614 #, java-format
615 msgid ""
616 "Script evaluation raised an exception that is not a ScriptException but a "
617 "{0}.\n"
618 " Please report this as a bug against the PLM, with all details allowing to "
619 "reproduce it.\n"
620 "Exception message: {1}\n"
621 msgstr ""
622 "execução do Script levantou uma exceção que não é uma ScriptException mas "
623 "uma {0}.\n"
624 " Favor relatar isto como um erro (bug) do PLM, com todos os detalhes para "
625 "reproduzir o erro.\n"
626 " Mensagem de exceção: {1}\n"
627
628 #: src/plm/core/model/Game.java:162
629 msgid "Scala is usable on your machine. Congratulations."
630 msgstr "Scala está funcional na sua máquina. Parabéns."
631
632 #: src/plm/core/model/Game.java:164
633 msgid "Please install Scala version 2.11 or higher to use it in the PLM."
634 msgstr "Favor instale Scala versão 2.11 ou superior para usá-la no PLM."
635
636 #: src/plm/core/model/Game.java:166
637 msgid "Jython is usable on your machine. Congratulations."
638 msgstr "Jython está funcional na sua máquina. Parabéns."
639
640 #: src/plm/core/model/Game.java:168
641 msgid ""
642 "Please install jython to use the python programming language in the PLM."
643 msgstr ""
644 "Por favor instale jython para usar a linguagem de programação python no PLM."
645
646 #: src/plm/core/model/Game.java:170
647 msgid "C is usable on your machine. Congratulations."
648 msgstr "C está funcional na sua máquina. Parabéns."
649
650 #: src/plm/core/model/Game.java:172
651 msgid "Please install gcc to use the C programming language in the PLM."
652 msgstr "Por favor instale o gcc para usar a linguagem de programação C no PLM."
653
654 #: src/plm/core/model/Game.java:179
655 #, java-format
656 msgid ""
657 "Warning, the default programming language is neither ''Java'' nor ''python'' "
658 "or ''Scala'' or ''C'' but {0}.\n"
659 " This language will be used to setup the worlds, possibly leading to "
660 "severe issues for the exercises that don''t expect it.\n"
661 " It is safer to change the current language, and restart the PLM before "
662 "proceeding.\n"
663 " Alternatively, the property {1} can be changed in your configuration file "
664 "({2}/plm.properties)"
665 msgstr ""
666 "Cuidado, a linguagem de programação predefinido não é nem ''Java'' nem "
667 "''python'' nem ''Scala'' nem ''C'' mas {0}.\n"
668 " Esta linguagem será usada para configurar mundos, o que provavelmente vai "
669 "gerar problemas severos em exercícios que não esperam tal linguagem.\n"
670 " É seguro trocar a linguagem atual e reiniciar o PLM depois disto.\n"
671 " Alternativamente, a propriedade {1} pode ser mudada no seu ficheiro de "
672 "configuração ({2}/plm.properties)"
673
674 #: src/plm/core/model/Game.java:185
675 msgid ""
676 "The default programming language is Scala, but your scala installation is "
677 "not usable. Switching to Java instead.\n"
678 msgstr ""
679 "A linguagem de programação predefinido é Scala, mas a sua instalação do "
680 "scala não funciona. A trocar para Java.\n"
681
682 #: src/plm/core/model/Game.java:188
683 msgid ""
684 "The default programming language is python, but your python installation is "
685 "not usable. Switching to Java instead.\n"
686 msgstr ""
687 "A linguagem de programação predefinida é python, mas a sua instalação do "
688 "python não funciona. A trocar para Java.\n"
689
690 #: src/plm/core/model/Game.java:191
691 msgid ""
692 "The default programming language is C, but your C installation is not "
693 "usable. Switching to Java instead.\n"
694 msgstr ""
695 "A linguagem de programação predefinida é C, mas a sua instalação do C não "
696 "funciona. A trocar para Java.\n"
697
698 #: src/plm/core/model/Game.java:209 src/plm/core/model/tracking/GitSpy.java:90
699 msgid ""
700 "You found a bug in the PLM. Please report it with all possible details "
701 "(including the stacktrace below)."
702 msgstr ""
703 "Encontrou um bug no PLM. Favor relatar isto com todos os datalhes possíveis ("
704 "incluindo o stacktrace abaixo)."
705
706 #: src/plm/core/model/Game.java:235
707 #, java-format
708 msgid "Error {0} while retrieving the Scala version: {1}"
709 msgstr "Erro {0} enquanto recuperava a versão do Scala: {1}"
710
711 #: src/plm/core/model/Game.java:244
712 #, java-format
713 msgid "Scala is too ancient. Found {0} while I need 2.10 or higher."
714 msgstr "Scala é muito antigo. Encontrei {0} mas preciso do 2.10 ou mais novo."
715
716 #: src/plm/core/model/Game.java:269
717 msgid ""
718 "Cannot retrieve the python ScriptEngine. Are jython.jar and its dependencies "
719 "in the classpath?"
720 msgstr ""
721 "Não consigo recuperar o python ScriptEngine. jython.jar e as dependências "
722 "dele estão na classpath?"
723
724 #: src/plm/core/model/Game.java:308
725 #, java-format
726 msgid ""
727 "Resource {0} not found in the classpath.\n"
728 "Is {1} in your classpath?"
729 msgstr ""
730 "Recurso {0} não encontrado na classpath.\n"
731 "{1} está na classpath?"
732
733 #: src/plm/core/model/Game.java:310
734 #, java-format
735 msgid "{0} received while searching for resource {1}: {2}"
736 msgstr "{0} recebidos enquanto buscava pelo recurso {1}: {2}"
737
738 #: src/plm/core/model/Game.java:345 src/plm/core/model/Game.java:346
739 #, java-format
740 msgid "Cannot switch to lesson {0}: class Main not found."
741 msgstr "Não posso alternar para lição {0}: classe Main não encontrada."
742
743 #: src/plm/core/model/Game.java:347
744 #, java-format
745 msgid "Load lesson {0}"
746 msgstr "Carregar lição {0}"
747
748 #: src/plm/core/model/Game.java:363
749 #, java-format
750 msgid ""
751 "The lesson {0} encountered an issue while loading its exercises, please "
752 "report the issue and choose another lesson."
753 msgstr ""
754 "A lição {0} encontrou um problema enquanto carregava os seus exercícios, "
755 "favor reportar o problema e escolher outra lição."
756
757 #: src/plm/core/model/Game.java:364
758 msgid "Broken lesson"
759 msgstr "Lição com defeito"
760
761 #: src/plm/core/model/Game.java:500
762 #, java-format
763 msgid ""
764 "Exercise {0} does not support language {1}. Fallback to {2} instead. Please "
765 "consider contributing to this project by adapting this exercise to this "
766 "language."
767 msgstr ""
768 "O exercício {0} não suporta a linguagem {1}. A trocar para {2}. Favor "
769 "considere a possibilidade de contribuir para este projeto a adaptar este "
770 "exercício para esta linguagem."
771
772 #: src/plm/core/model/Game.java:508
773 msgid "Operation cancelled by the user"
774 msgstr "Operação cancelada pelo utilizador"
775
776 #: src/plm/core/model/Game.java:580
777 #, java-format
778 msgid "The lecture {0} has no world that I can select"
779 msgstr "A \"lecture\" {0} não tem um mundo que eu possa selecionar"
780
781 #: src/plm/core/model/Game.java:1005
782 msgid ""
783 "Please install Scala version 2.11 or higher to use it in the PLM.\n"
784 "\n"
785 msgstr ""
786 "Por favor, instale a versão do Scala 2.11 ou superior para usá-lo no PLM.\n"
787 "\n"
788
789 #: src/plm/core/model/Game.java:1006
790 msgid "Scala is missing"
791 msgstr "Scala está a faltar"
792
793 #: src/plm/core/model/Game.java:1010
794 msgid ""
795 "Please install jython and its dependencies to use the python programming "
796 "language in the PLM.\n"
797 "\n"
798 msgstr ""
799 "Por favor instale o jython e as dependências dele para usar a linguagem de "
800 "programação pythonno PLM.\n"
801 "\n"
802
803 #: src/plm/core/model/Game.java:1011
804 msgid "Python is missing"
805 msgstr "Python está a faltar"
806
807 #: src/plm/core/model/Game.java:1015
808 msgid ""
809 "Please install C and its dependencies to use the C programming language in "
810 "the PLM.\n"
811 "\n"
812 msgstr ""
813 "Por favor instale o C e as dependências dele para usar a linguagem de "
814 "programação C no PLM.\n"
815 "\n"
816
817 #: src/plm/core/model/Game.java:1016
818 msgid "C is missing"
819 msgstr "C está a faltar"
820
821 #: src/plm/core/model/Game.java:1021
822 msgid ""
823 "The C langage is currently very experimental in the PLM.\n"
824 "If you go for C, you may not be able to complete some exercises that\n"
825 "are still in progress in C, although some other parts are already okay.\n"
826 "\n"
827 "Do you want to proceed anyway?"
828 msgstr ""
829 "A linguagem de programação C é atualmente muito experimental no PLM.\n"
830 "Se for para C, talvez não consiga completar alguns exercícios que ainda "
831 "estão \n"
832 "a ser feitos em C, mas outras partes estão a funcionar.\n"
833 "\n"
834 "Quer continuar mesmo assim?"
835
836 #: src/plm/core/model/Game.java:1025
837 msgid "C is still experimental"
838 msgstr "C ainda é experimental"
839
840 #: src/plm/core/model/HelpServer.java:27 src/plm/core/ui/action/HelpMe.java:130
841 msgid "Asking to the teacher for help"
842 msgstr "A pedir ajuda ao professor"
843
844 #: src/plm/core/model/HelpServer.java:29 src/plm/core/ui/action/HelpMe.java:133
845 #: src/plm/core/ui/action/HelpMe.java:145
846 msgid "Cancel call for help to the teacher"
847 msgstr "Cancelar o pedido de ajuda ao professor"
848
849 #: src/plm/core/model/User.java:36
850 #, java-format
851 msgid "A new PLM user has been created for you: {0}. Save directory: {1}"
852 msgstr "Um novo utilizador plm foi criado para si: {0}. Gravar diretório: {1}"
853
854 #: src/plm/core/model/Users.java:87
855 #, java-format
856 msgid "User {0} exists already; don't add it again."
857 msgstr "Utilizador {0} já existe; não vou adicionar de novo."
858
859 #: src/plm/core/model/Users.java:111
860 #, java-format
861 msgid "Switched to user: {0}"
862 msgstr "A alternar para utilizador: {0}"
863
864 #: src/plm/core/model/lesson/Exercise.java:80
865 #, java-format
866 msgid "The world ''{0}'' differs"
867 msgstr "O mundo ''{0}'' difere"
868
869 #: src/plm/core/model/lesson/ExerciseTemplated.java:47
870 #, java-format
871 msgid "Source file {0}.{1} not found."
872 msgstr "Ficheiro fonte {0}.{1} não encontrado."
873
874 #: src/plm/core/model/lesson/ExerciseTemplated.java:120
875 #, java-format
876 msgid "{0}: BEGIN TEMPLATE within the template. Please fix your entity."
877 msgstr "{0}: BEGIN TEMPLATE dentro do modelo. Favor conserte a sua entidade."
878
879 #: src/plm/core/model/lesson/ExerciseTemplated.java:141
880 #, java-format
881 msgid ""
882 "{0}: BEGIN SOLUTION is closed with END TEMPLATE. Please fix your entity."
883 msgstr ""
884 "{0}: BEGIN SOLUTION termina com END TEMPLATE. Favor conserte a sua entidade."
885
886 #: src/plm/core/model/lesson/ExerciseTemplated.java:159
887 #: src/plm/core/model/lesson/ExerciseTemplated.java:183
888 #, java-format
889 msgid ""
890 "{0}: END TEMPLATE with no matching BEGIN TEMPLATE. Please fix your entity."
891 msgstr ""
892 "{0}: END TEMPLATE sem o respectivo BEGIN TEMPLATE. corrija sua entidade."
893
894 #: src/plm/core/model/lesson/ExerciseTemplated.java:163
895 #, java-format
896 msgid "{0}: Begin solution in template tail. Change it to BEGIN HIDDEN"
897 msgstr "{0}: Começar solução em \"template tail\". Mudar isto para BEGIN HIDDEN"
898
899 #: src/plm/core/model/lesson/ExerciseTemplated.java:203
900 #, java-format
901 msgid ""
902 "Parser error in file {0}. This is a parser bug (state={1}), please report."
903 msgstr ""
904 "Erro de sintaxe no ficheiro {0}. Este é um bug do verificador de sintaxe "
905 "(estado={1}), favor abrir um relatório de erro."
906
907 #: src/plm/core/model/lesson/ExerciseTemplated.java:208
908 #, java-format
909 msgid ""
910 "{0}: End of file unexpected after the solution but within the template. "
911 "Please fix your entity."
912 msgstr ""
913 "{0}: Fim de ficheiro inesperado depois da solução mas dentro do template. "
914 "Favor conserte a sua entidade."
915
916 #: src/plm/core/model/lesson/ExerciseTemplated.java:210
917 #, java-format
918 msgid ""
919 "{0}: End of file unexpected (state: {1}). Did you forget to close your "
920 "template or solution? Please fix your entity."
921 msgstr ""
922 "{0}: Fim de ficheiro inesperado (estado: {1}). Será que esqueceu de fechar o "
923 "seu template ou solução? Favor consertar a sua entidade."
924
925 #: src/plm/core/model/lesson/ExerciseTemplated.java:366
926 #, java-format
927 msgid ""
928 "Exercise {0} is said to be compatible with language {1}, but there is no "
929 "entity for this language: {2}"
930 msgstr ""
931 "exercício {0} é dito ser compatível com a linguagem {1}, mas não existe "
932 "entidade para esta linguagem: {2}"
933
934 #: src/plm/core/model/lesson/ExerciseTemplated.java:375
935 #, java-format
936 msgid "{0}: No entity found. You should fix your paths and such"
937 msgstr "{0}: Nenhuma entidade encontrada. Deve consertar os seus caminhos e tal"
938
939 #: src/plm/core/model/lesson/ExerciseTemplated.java:406
940 #, java-format
941 msgid "World {0} is broken ({1}). Recompute all answer worlds."
942 msgstr "Mundo {0} está quebrado ({1}). Recalcule todos os mundos resposta."
943
944 #: src/plm/core/model/lesson/ExerciseTemplated.java:410
945 #, java-format
946 msgid "Cache file {0} is missing. Recompute all answer worlds."
947 msgstr "Ficheiro de cache {0} a faltar. Recalcular todos os mundos de resposta."
948
949 #: src/plm/core/model/lesson/ExerciseTemplated.java:414
950 #, java-format
951 msgid ""
952 "IO exception while reading world {0} ({1}). Recompute all answer worlds."
953 msgstr ""
954 "Exceção de IO enquanto está a ler o mundo {0} ({1}). Recalcule todos os "
955 "mundos resposta."
956
957 #: src/plm/core/model/lesson/ExerciseTemplated.java:425
958 #, java-format
959 msgid ""
960 "Recompute the answer of {0} despite the cache file, as requested by the "
961 "property {1}"
962 msgstr ""
963 "Recalcular a resposta de {0} a despeito do ficheiro de cache, como pedido "
964 "pela propriedade {1}"
965
966 #: src/plm/core/model/lesson/ExerciseTemplated.java:465
967 #, java-format
968 msgid "Error while writing answer world of {0}:"
969 msgstr "Erro enquanto escrevia o mundo resposta de {0}:"
970
971 #: src/plm/core/model/lesson/ExerciseTemplated.java:469
972 #, java-format
973 msgid "Cannot write answer world of {0}. Please check the permissions."
974 msgstr ""
975 "Não pode escrever o mundo resposta de {0}. Favor verificar as permissões."
976
977 #: src/plm/core/model/lesson/Lecture.java:90
978 #: src/plm/core/model/lesson/Lesson.java:94
979 #, java-format
980 msgid "File {0}.html not found."
981 msgstr "ficheiro {0}.html não encontrado."
982
983 #: src/plm/core/model/lesson/Lecture.java:99
984 #: src/plm/core/model/lesson/Lesson.java:104
985 #, java-format
986 msgid "Cannot find the name of mission in {0}.html"
987 msgstr "Não encontrei o nome da missão em {0}.html"
988
989 #. It should never happen since the session content should be created by the git spy module.
990 #: src/plm/core/model/session/GitSessionKit.java:89
991 msgid ""
992 "Something weird happened. Your session was not created/reloaded properly. "
993 "Please report this issue."
994 msgstr ""
995 "Algo estranho aconteceu. A sua sessão não foi criada/recarregada "
996 "propriamente. Favor relatar esta questão."
997
998 #: src/plm/core/model/session/ZipSessionKit.java:252
999 msgid "Ok, quit and lose my data"
1000 msgstr "tudo bem, saia e perca meus dados"
1001
1002 #: src/plm/core/model/session/ZipSessionKit.java:252
1003 msgid "Please stop! I'll save it myself first"
1004 msgstr "Pare por favor! Mesmo vou gravá-los primeiro"
1005
1006 #: src/plm/core/model/session/ZipSessionKit.java:253
1007 #, java-format
1008 msgid ""
1009 "The PLM were unable to save your session file for lesson {0} ({1}:{2}).\n"
1010 "\n"
1011 " Would you like proceed anyway (and lose any solution typed so far)?"
1012 msgstr ""
1013 "O PLM foi incapaz de gravar o seu ficheiro de sessão para a lição {0} "
1014 "({1}:{2}).\n"
1015 "\n"
1016 " Quer continuar mesmo assim (e perder qualquer solução digitada até agora)?"
1017
1018 #: src/plm/core/model/session/ZipSessionKit.java:256
1019 msgid "Your changes are NOT saved"
1020 msgstr "Suas modificações NÃO FORAM gravadas"
1021
1022 #: src/plm/core/model/session/ZipSessionKit.java:259
1023 msgid "User aborted saving on system error"
1024 msgstr "Utilizador abortou gravação em erro do sistema"
1025
1026 #: src/plm/core/model/session/ZipSessionKit.java:356
1027 msgid "Proceed"
1028 msgstr "Prosseguir"
1029
1030 #: src/plm/core/model/session/ZipSessionKit.java:356
1031 msgid "Abort"
1032 msgstr "Abortar"
1033
1034 #: src/plm/core/model/session/ZipSessionKit.java:357
1035 #, java-format
1036 msgid ""
1037 "The PLM were unable to load your code for lesson {0} ({1}:{2}).\n"
1038 "\n"
1039 " Would you like proceed anyway (and lose any solution typed previously)?"
1040 msgstr ""
1041 "O PLM foi incapaz de carregar o seu código da lição {0} ({1}:{2}).\n"
1042 "\n"
1043 " Quer prosseguir de qualquer forma (e perder qualquer solução digitada "
1044 "anteriormente)?"
1045
1046 #: src/plm/core/model/session/ZipSessionKit.java:360
1047 msgid "Error while loading your session"
1048 msgstr "Erro enquanto carregava sua sessão"
1049
1050 #: src/plm/core/model/session/ZipSessionKit.java:363
1051 msgid "Abording on user request"
1052 msgstr "A abortar a pedido do utilizador"
1053
1054 #. Testing repoDir is not enough because the directory may have been created by another spy but not initialized for git
1055 #: src/plm/core/model/tracking/GitSpy.java:56
1056 #, java-format
1057 msgid "Reusing the disk session located at {0}."
1058 msgstr "A reutilizar a sessão do disco, localizada em {0}."
1059
1060 #: src/plm/core/model/tracking/GitSpy.java:58
1061 #, java-format
1062 msgid "Initialize a new disk session at {0}."
1063 msgstr "Inicializar uma nova sessão de disco em {0}."
1064
1065 #: src/plm/core/model/tracking/GitSpy.java:76
1066 #, java-format
1067 msgid "Your session {0} was automatically retrieved from the servers."
1068 msgstr "Sua sessão {0} foi automaticamente recuperada dos servidores."
1069
1070 #. If no branch can be found remotely, create a new one.
1071 #. System.out.println(Game.i18n.tr("Creating a new session locally, as no corresponding session could be retrieved from the servers.",userBranch));
1072 #: src/plm/core/model/tracking/GitSpy.java:81
1073 msgid "Couldn't retrieve a corresponding session from the servers..."
1074 msgstr "Não consegui recuperar uma sessão correspondente dos servidores..."
1075
1076 #: src/plm/core/model/tracking/GitSpy.java:168
1077 msgid "Pushing to the remote repository before exiting"
1078 msgstr "A empurrar ao repositório remoto antes de sair"
1079
1080 #: src/plm/core/model/tracking/GitUtils.java:76
1081 msgid "An error occurred while configuring the repository..."
1082 msgstr "Um erro ocorreu enquanto configurava o repositório..."
1083
1084 #: src/plm/core/model/tracking/GitUtils.java:85
1085 msgid "Retrieving your session from the servers..."
1086 msgstr "A recuperar a sua sessão dos servidores..."
1087
1088 #: src/plm/core/model/tracking/GitUtils.java:119
1089 msgid "An error occurred while checking out the user's branch: "
1090 msgstr "Um erro ocorreu enquanto verificava o ramo do utilizador: "
1091
1092 #: src/plm/core/model/tracking/GitUtils.java:132
1093 msgid "last session data successfully retrieved"
1094 msgstr "Dados da última sessão recuperados com sucesso"
1095
1096 #: src/plm/core/model/tracking/GitUtils.java:135
1097 msgid "last session data successfully merged"
1098 msgstr "dados da última sessão mesclados com sucesso"
1099
1100 #: src/plm/core/model/tracking/GitUtils.java:138
1101 msgid ""
1102 "Conflicts have been detected while synchronizing with last session data, "
1103 "trying to resolve it..."
1104 msgstr ""
1105 "Conflitos foram detectados enquanto sincronizava com dados da última sessão, "
1106 "a tentar resolver isto..."
1107
1108 #. TODO: handle this case
1109 #: src/plm/core/model/tracking/GitUtils.java:166
1110 msgid "Canceled the merge operation because of the following failures:"
1111 msgstr "Operação de mesclagem cancelada por causa dos seguintes erros:"
1112
1113 #: src/plm/core/model/tracking/GitUtils.java:173
1114 msgid "Can't merge data retrieved from server with local session data."
1115 msgstr "Não posso mesclar dados trazidos do servidor com dados de sessão local."
1116
1117 #: src/plm/core/model/tracking/GitUtils.java:214
1118 msgid "Cannot synchronize your session with the servers (network down)."
1119 msgstr "Não consigo sincronizar a sua sessão com os servidores (nenhuma rede)."
1120
1121 #: src/plm/core/model/tracking/GitUtils.java:241
1122 msgid "Your session has been successfully saved into the clouds."
1123 msgstr "Sua sessão foi gravada na nuvem."
1124
1125 #. An error occurred while pushing
1126 #: src/plm/core/model/tracking/GitUtils.java:245
1127 msgid "Fetching the server's last version..."
1128 msgstr "A recuperar a última versão do servidor..."
1129
1130 #: src/plm/core/model/tracking/GitUtils.java:252
1131 msgid ""
1132 "Fetching the data's last version didn't solve the issue, please report this "
1133 "bug."
1134 msgstr ""
1135 "Recuperar a última versão dos dados não resolveu o problema, por favor, "
1136 "relate este bug."
1137
1138 #: src/plm/core/model/tracking/GitUtils.java:255
1139 msgid ""
1140 "A bug occurred while synchronizing your data with the server, please report "
1141 "the following error:"
1142 msgstr ""
1143 "Um erro ocorreu enquanto sincronizava os seus dados com o servidor, por "
1144 "favor relate o seguinte erro:"
1145
1146 #: src/plm/core/ui/AboutLessonDialog.java:20
1147 msgid "About lesson - "
1148 msgstr "Lição Sobre - "
1149
1150 #: src/plm/core/ui/AboutPLMDialog.java:37 src/plm/core/ui/MainFrame.java:397
1151 #: src/plm/core/ui/MainFrame.java:737
1152 msgid "About the PLM"
1153 msgstr "Sobre o PLM"
1154
1155 #: src/plm/core/ui/AboutPLMDialog.java:60
1156 #, java-format
1157 msgid ""
1158 "<html><h3 style=\"color:#666666;margin:0px;padding:0px;\">version {0}&nbsp;"
1159 "<span style=\"font-size:8px; color:#AAAAAA;margin:0px;padding:0px;\">({1})</"
1160 "span></h3><br/>&copy; 2008-2020 Contributors. All rights reserved.<br/><ul "
1161 "style=\"margin-left:20px;\"><li>Original idea: <i>L. Turbak (Wellesley "
1162 "College)</i></li><li>Design and code: <i>M. Quinson and G. Oster</i></"
1163 "li><li>Tests: <i>Telecom Nancy students (classes from ''11 to ''15)</i></"
1164 "li></ul><br/>Your code is saved to {2}<br/>Your secret session ID is {3}<br/"
1165 "></html>"
1166 msgstr ""
1167 "<html><h3 style=\"color:#666666;margin:0px;padding:0px;\">versão {0}&nbsp;"
1168 "<span style=\"font-size:8px; color:#AAAAAA;margin:0px;padding:0px;\""
1169 ">({1})</span></h3><br/>&copy; 2008-2020 Contribuintes. Todos os direitos "
1170 "reservados.<br/><ul style=\"margin-left:20px;\"><li>Idéia original: <i>L. "
1171 "Turbak (Wellesley College)</i></li><li> Design e código: <i>M. Quinson e G. "
1172 "Oster</i></li><li>Testes: <i>Estudantes da Telecom Nancy (aulas de ''11 a "
1173 "''15)</i></li></ul><br/>O seu código é gravado em {2}<br/>O seu ID de sessão "
1174 "secreta é {3}<br/></html>"
1175
1176 #: src/plm/core/ui/AboutPLMDialog.java:81
1177 msgid "About"
1178 msgstr "Sobre"
1179
1180 #: src/plm/core/ui/AboutPLMDialog.java:118
1181 msgid "Changes"
1182 msgstr "Mudanças"
1183
1184 #: src/plm/core/ui/AboutPLMDialog.java:124
1185 msgid ""
1186 "<h2>The PLM is proudly Free Software</h2><p>Copyright (c) 2008-2020.<br/> "
1187 "The PLM Team: Martin Quinson, Gérald Oster and others.<br/> (see the git "
1188 "logs for the exact authorship of each file).</p> <p>The PLM software was "
1189 "written internally by the team. This software is distributed under the GNU "
1190 "general public license version 3 (GPLv3).</p> <p>The pedagogical material "
1191 "distributed with the PLM is covered both by the GPLv3 license (mainly for "
1192 "the included code) and by the CC-BY-SA license (mainly for the other media "
1193 "files). But the exact boundary here between the source code and the media is "
1194 "left as an exercise to the reader, so this material is distributed under "
1195 "both licenses for sake of simplicity.</p><p>The GPLv3 license can be found "
1196 "in the archive under the name LICENSE-GPL-3. The CC-BY-SA license can be "
1197 "found online: http://creativecommons.org/licenses/by-sa/3.0/</p><p>The whole "
1198 "artwork is free content, licenced under CC-BY-SA, GPL, LGPL and/or CC0-"
1199 "public domain. Some parts were done by us, other parts were borowed from "
1200 "free collections. The specific license and origin of each files is listed in "
1201 "the COPYING file distributed with the archive.</p>"
1202 msgstr ""
1203 "<h2>O PLM é um software orgulhosamente Livre</h2><p>Copyright (c) 2008-2015.<"
1204 "br/> O time PLM: Martin Quinson, Gérald Oster e outros.<br/> (veja os logs "
1205 "do git para a autoria exata de cada ficheiro).</p> <p>O softwtare PLM foi "
1206 "escrito internamente pelo time. Este software é distribuído sob a GNU "
1207 "general public license version 3 (GPLv3).</p> <p>O material pedagógico "
1208 "distribuído com o PLM é coberto tanto pela licença GPLv3 (principalmente o "
1209 "código incluso) e pela licença CC-BY-SA (principalmente os outros ficheiros "
1210 "de mídia). Mas a fronteira exata aqui entre o código-fonte e a mídia é "
1211 "deixada como exercício para o leitor, logo, este material é distribuído sob "
1212 "as duas licenças por questão de simplicidade.</p><p>A licença GPLv3 encontra-"
1213 "se no arquivo sob o nome LICENSE-GPL-3. A licença CC-BY-SA encontra-se "
1214 "online: http://creativecommons.org/licenses/by-sa/3.0/</p><p>Toda a parte "
1215 "artística é conteúdo livre, licenciado sob a CC-BY-SA, GPL, LGPL e/ou CC0-"
1216 "public domain. Algumas partes foram feitas por nós, outras partes foram "
1217 "pegas emprestado de coleções livres. A licença específica e original de cada "
1218 "um dos ficheiros é listada no ficheiro COPYING distribuído no arquivo.</p>"
1219
1220 #: src/plm/core/ui/AboutPLMDialog.java:150
1221 msgid "Copying"
1222 msgstr "Copiar"
1223
1224 #: src/plm/core/ui/AboutPLMDialog.java:156
1225 #: src/plm/core/ui/ExerciseFailedDialog.java:43
1226 #: src/plm/core/ui/ExercisePassedDialog.java:100
1227 msgid "Close"
1228 msgstr "Fechar"
1229
1230 #: src/plm/core/ui/AboutWorldDialog.java:31
1231 #: src/plm/core/ui/AboutWorldDialog.java:50
1232 #, java-format
1233 msgid "About world - {0}"
1234 msgstr "Sobre o mundo - {0}"
1235
1236 #: src/plm/core/ui/ChooseLectureDialog.java:100
1237 msgid "Choose your next exercise"
1238 msgstr "Escolha o seu próximo exercício"
1239
1240 #: src/plm/core/ui/ChooseLessonDialog.java:46
1241 msgid "Choose your lesson"
1242 msgstr "Escolha sua lição"
1243
1244 #: src/plm/core/ui/ChooseLessonDialog.java:66
1245 msgid ""
1246 "<table border=\"0\" align=\"center\"><tr>\n"
1247 "<td valign=\"center\"><img src=\"img/world_buggle.png\" /></td>\n"
1248 "<td valign=\"center\">&nbsp;&nbsp;<font size=\"+2\">Welcome to the "
1249 "Programmer's Learning Machine</font>&nbsp;&nbsp;</td>\n"
1250 "<td valign=\"center\"><img src=\"img/world_buggle.png\" /></td>\n"
1251 "</tr></table>\n"
1252 "\n"
1253 "<p><font size=\"+1\">The PLM is a Learning Management System (LMS) aiming at "
1254 "teaching the art of computer programming through interactive exercises. It "
1255 "offers an extensive set of varied exercises, allowing you to practice at "
1256 "your own pace.</font></p><br/>"
1257 msgstr ""
1258 "<table border=\"0\" align=\"center\"><tr>\n"
1259 "<td valign=\"center\"><img src=\"img/world_buggle.png\" /></td>\n"
1260 "<td valign=\"center\">&nbsp;&nbsp;<font size=\"+2\">Bem-vindo ao "
1261 "Programmer's Learning Machine</font>&nbsp;&nbsp;</td>\n"
1262 "<td valign=\"center\"><img src=\"img/world_buggle.png\" /></td>\n"
1263 "</tr></table>\n"
1264 "\n"
1265 "<p><font size=\"+1\">O PLM é um Sistema de gere de apredizado para ensinar a "
1266 "arte da programação de computadores através de exercícios interativos. Ele "
1267 "oferece um amplo conjunto de exercícios variados, para que possa praticar no "
1268 "seu ritmo.</font></p><br/>"
1269
1270 #: src/plm/core/ui/ChooseLessonDialog.java:144
1271 msgid "PLM lesson files"
1272 msgstr "ficheiros de lição do PLM"
1273
1274 #: src/plm/core/ui/ChooseLessonDialog.java:153
1275 msgid "Error"
1276 msgstr "Erro"
1277
1278 #: src/plm/core/ui/ChooseLessonDialog.java:180
1279 msgid ""
1280 "<h1>Please pick a lesson</h1>\n"
1281 "<p>Please click on an icon on the left to select a lesson.</p>\n"
1282 "<p>Lessons located above are generally simpler than the ones located below.</"
1283 "p>"
1284 msgstr ""
1285 "<h1>Favor escolha uma lição</h1>\n"
1286 "<p>Favor clicar num ícone da esquerda para selecionar uma lição.</p>\n"
1287 "<p>Lições localizadas acima em geral são mais simples que as localizadas "
1288 "abaixo.</p>"
1289
1290 #: src/plm/core/ui/ChooseLessonDialog.java:224
1291 #, java-format
1292 msgid ""
1293 "<p>(unable to display the short description of this lesson: file {0} not "
1294 "found)</p>"
1295 msgstr ""
1296 "<p>(Não posso exibir a descrição curta desta lição: ficheiro {0} não "
1297 "encontrado)</p>"
1298
1299 #: src/plm/core/ui/ChooseLessonDialog.java:227
1300 msgid "<p><b>Your score:</b> "
1301 msgstr "<p><b>Seu placar:</b> "
1302
1303 #: src/plm/core/ui/ChooseLessonDialog.java:235
1304 #, java-format
1305 msgid "{0} out of {1} exercises passed."
1306 msgstr "{0} de {1} exercícios feitos."
1307
1308 #: src/plm/core/ui/ChooseLessonDialog.java:239
1309 #, java-format
1310 msgid "{0} out of {1} exercises passed in {2}."
1311 msgstr "{0} de {1} exercícios feitos em {2}."
1312
1313 #: src/plm/core/ui/ChooseLessonDialog.java:245
1314 msgid "You never attempted this lesson."
1315 msgstr "Nunca tentou esta lição."
1316
1317 #: src/plm/core/ui/ExerciseFailedDialog.java:27
1318 msgid "<i>Practice makes perfect</i>, as they say."
1319 msgstr "<i>A prática produz a perfeição</i>, é o que dizem."
1320
1321 #: src/plm/core/ui/ExerciseFailedDialog.java:28
1322 msgid "<i>To err is human</i>, as they say."
1323 msgstr "<i>Errar é humano</i>, é o que dizem."
1324
1325 #: src/plm/core/ui/ExerciseFailedDialog.java:29
1326 msgid "You should keep trying until you get it right!"
1327 msgstr "Continue a tentar até conseguir fazer direito!"
1328
1329 #: src/plm/core/ui/ExerciseFailedDialog.java:30
1330 msgid "We all learn from our mistakes, so, good job!"
1331 msgstr "Todos aprendemos com nossos erros, então, bom trabalho!"
1332
1333 #: src/plm/core/ui/ExerciseFailedDialog.java:31
1334 msgid "We learn from failure, not from success!"
1335 msgstr "Aprendemos no fracasso, não no sucesso!"
1336
1337 #: src/plm/core/ui/ExerciseFailedDialog.java:32
1338 msgid "Success comes after failure"
1339 msgstr "O sucesso vem depois do fracasso"
1340
1341 #: src/plm/core/ui/ExerciseFailedDialog.java:33
1342 msgid ""
1343 "<i>The master has failed more time than the beginner has even tried</i>,<br> "
1344 "as they say."
1345 msgstr ""
1346 "<i>O mestre falhou mais vezes que o iniciante que nunca tentou</i>,<br> é o "
1347 "que dizem."
1348
1349 #: src/plm/core/ui/ExerciseFailedDialog.java:34
1350 msgid ""
1351 "<i>Anyone who has never made a mistake has never <br>tried anything new.</i> "
1352 "(Einstein)."
1353 msgstr ""
1354 "<i>Qualquer pessoa que nunca cometeu um erro, nunca <br>tentou algo novo.</"
1355 "i> (Einstein)."
1356
1357 #: src/plm/core/ui/ExerciseFailedDialog.java:35
1358 msgid ""
1359 "<i>Success does not consist in never making mistakes,<br> but in never "
1360 "making the same one a second time.</i> (Shaw)"
1361 msgstr ""
1362 "<i>O sucesso não consiste em nunca ter cometido erros,<br> mas em nunca tê-"
1363 "los cometido pela segunda vez.</i> (Shaw)"
1364
1365 #: src/plm/core/ui/ExerciseFailedDialog.java:38
1366 msgid "Mmm, not quite"
1367 msgstr "Mmm, quase"
1368
1369 #: src/plm/core/ui/ExerciseFailedDialog.java:56
1370 #, java-format
1371 msgid ""
1372 "<html>You didn''t manage to reach your objective this time. <br>\n"
1373 "That''s fine. {0}<br>\n"
1374 "<br>\n"
1375 "You should graphically compare the final state of your world <br>\n"
1376 "with the objective to understand the problem. <br>\n"
1377 "<br>\n"
1378 "If you don''t see the error, check the details below for a <br>\n"
1379 "textual description of this difference between both worlds.</html>"
1380 msgstr ""
1381 "<html>Não conseguiu alcançar o objetivo desta vez. <br>\n"
1382 "Mas tudo bem. {0}<br>\n"
1383 "<br>\n"
1384 "Deve comparar graficamente o estado final do seu mundo <br>\n"
1385 "com o objetivo para entender o problema. <br>\n"
1386 "<br>\n"
1387 "Se não ver o erro, verifique os detalhes abaixo para uma <br>\n"
1388 "descrição textual desta diferença entre ambos os mundos.</html>"
1389
1390 #: src/plm/core/ui/ExerciseFailedDialog.java:68
1391 #, java-format
1392 msgid ""
1393 "<html>Compilation error.<br>\n"
1394 "You can find below the detailed error message (as given by {0}).<br>\n"
1395 "Please read it carefully to understand the problem, and fix your code.</html>"
1396 msgstr ""
1397 "<html>Erro de compilação.<br>\n"
1398 "Veja abaixo a mensagem de erro detalhada (como dada por {0}).<br>\n"
1399 "Favor ler cuidadosamente para entender o problema e consertar o seu "
1400 "código.</html>"
1401
1402 #: src/plm/core/ui/ExerciseFailedDialog.java:83
1403 #: src/plm/core/ui/ExerciseFailedDialog.java:90
1404 msgid "Details >>"
1405 msgstr "Detalhes >>"
1406
1407 #: src/plm/core/ui/ExerciseFailedDialog.java:93
1408 msgid "Details <<"
1409 msgstr "Detalhes <<"
1410
1411 #: src/plm/core/ui/ExercisePassedDialog.java:28
1412 msgid "Exercice passed \\o/"
1413 msgstr "Passou no exercício \\o/"
1414
1415 #: src/plm/core/ui/ExercisePassedDialog.java:37
1416 msgid "Congrats"
1417 msgstr "Parabéns"
1418
1419 #: src/plm/core/ui/ExercisePassedDialog.java:46
1420 #, java-format
1421 msgid ""
1422 "<html>Congratulations, you passed this exercise.<br>{0} tests passed.</html>"
1423 msgstr "<html>Parabéns, passou deste exercício.<br>{0} testes feitos.</html>"
1424
1425 #: src/plm/core/ui/ExercisePassedDialog.java:49
1426 msgid "<html>Congratulations, you passed this exercise.</html>"
1427 msgstr "<html>Parabéns, passou deste exercício.</html>"
1428
1429 #: src/plm/core/ui/ExercisePassedDialog.java:59
1430 #, java-format
1431 msgid ""
1432 "<html>Congratulations, you passed this exercise.<br>({0} tests "
1433 "passed)<br><br><br>Select your next exercise:</html>"
1434 msgstr ""
1435 "<html> Parabéns, passou neste exercício.<br>({0} testes passaram)"
1436 "<br><br><br>selecione o seu próximo exercício:</html>"
1437
1438 #: src/plm/core/ui/ExercisePassedDialog.java:62
1439 msgid ""
1440 "<html>Congratulations, you passed this exercise.<br><br><br><br>Select your "
1441 "next exercise:</html>"
1442 msgstr ""
1443 "<html>Parabéns, passou este exercício. <br><br><br><br>Selecione o seu "
1444 "próximo exercício:</html>"
1445
1446 #: src/plm/core/ui/ExercisePassedDialog.java:72
1447 msgid "Give feedback"
1448 msgstr "Diga como foi"
1449
1450 #: src/plm/core/ui/ExercisePassedDialog.java:75
1451 msgid ""
1452 "Please help us to improve this exercise by filling this little evaluation."
1453 msgstr ""
1454 "Por favor nos ajude a melhorar este exercício a preencher esta pequena "
1455 "avaliação."
1456
1457 #: src/plm/core/ui/ExercisePassedDialog.java:77
1458 msgid "Difficulty:"
1459 msgstr "Dificuldade:"
1460
1461 #. Difficulties are the text presented to the user while difficultiesEN are the one that will be added to the report
1462 #: src/plm/core/ui/ExercisePassedDialog.java:80
1463 #: src/plm/core/ui/ExercisePassedDialog.java:87
1464 msgid "(please choose)"
1465 msgstr "(escolha)"
1466
1467 #: src/plm/core/ui/ExercisePassedDialog.java:80
1468 msgid "Too easy"
1469 msgstr "Muito fácil"
1470
1471 #: src/plm/core/ui/ExercisePassedDialog.java:80
1472 msgid "Easy"
1473 msgstr "Fácil"
1474
1475 #: src/plm/core/ui/ExercisePassedDialog.java:80
1476 msgid "Just right"
1477 msgstr "Bom"
1478
1479 #: src/plm/core/ui/ExercisePassedDialog.java:80
1480 msgid "Difficult"
1481 msgstr "Difícil"
1482
1483 #: src/plm/core/ui/ExercisePassedDialog.java:80
1484 msgid "Too difficult"
1485 msgstr "Muito difícil"
1486
1487 #: src/plm/core/ui/ExercisePassedDialog.java:85
1488 msgid "Interest:"
1489 msgstr "Interessante:"
1490
1491 #: src/plm/core/ui/ExercisePassedDialog.java:87
1492 msgid "Really good"
1493 msgstr "Muito bom"
1494
1495 #: src/plm/core/ui/ExercisePassedDialog.java:87
1496 msgid "Amusing"
1497 msgstr "Divertido"
1498
1499 #: src/plm/core/ui/ExercisePassedDialog.java:87
1500 msgid "Just okay"
1501 msgstr "Legal"
1502
1503 #: src/plm/core/ui/ExercisePassedDialog.java:87
1504 msgid "Boring"
1505 msgstr "Chato"
1506
1507 #: src/plm/core/ui/ExercisePassedDialog.java:87
1508 msgid "Really bad"
1509 msgstr "Muito ruim"
1510
1511 #: src/plm/core/ui/ExercisePassedDialog.java:92
1512 msgid "Free comments on that exercise:"
1513 msgstr "Comentários livres sobre este exercício:"
1514
1515 #: src/plm/core/ui/ExerciseView.java:87 src/plm/core/ui/ExerciseView.java:225
1516 msgid "Change the speed of execution"
1517 msgstr "Mudar a velocidade de execução"
1518
1519 #: src/plm/core/ui/ExerciseView.java:94 src/plm/core/ui/ExerciseView.java:168
1520 #: src/plm/core/ui/ExerciseView.java:227
1521 msgid "World"
1522 msgstr "Mundo"
1523
1524 #: src/plm/core/ui/ExerciseView.java:94 src/plm/core/ui/ExerciseView.java:168
1525 #: src/plm/core/ui/ExerciseView.java:228
1526 msgid "The world as it is right now"
1527 msgstr "O mundo como está agora"
1528
1529 #: src/plm/core/ui/ExerciseView.java:98 src/plm/core/ui/ExerciseView.java:170
1530 #: src/plm/core/ui/ExerciseView.java:229
1531 msgid "Objective"
1532 msgstr "Objetivo"
1533
1534 #: src/plm/core/ui/ExerciseView.java:98 src/plm/core/ui/ExerciseView.java:170
1535 #: src/plm/core/ui/ExerciseView.java:230
1536 msgid "The world as it should be"
1537 msgstr "O mundo como deveria ser"
1538
1539 #: src/plm/core/ui/ExerciseView.java:224
1540 msgid "Switch the displayed world"
1541 msgstr "Alternar o mundo mostrado"
1542
1543 #: src/plm/core/ui/ExerciseView.java:226
1544 msgid "Switch the entity"
1545 msgstr "Alternar a entidade"
1546
1547 #: src/plm/core/ui/FeedbackDialog.java:62
1548 msgid "Please describe the problem in a few words"
1549 msgstr "Favor descreva o problema em poucas palavras"
1550
1551 #: src/plm/core/ui/FeedbackDialog.java:64
1552 msgid ""
1553 "Your suggestion comes here, with all necessary details.\n"
1554 "\n"
1555 "\n"
1556 "\n"
1557 "\n"
1558 "\n"
1559 "(The following helps us fixing your problem, please don't erase)\n"
1560 "\n"
1561 "--------------------[ Technical Information ]--------------------\n"
1562 msgstr ""
1563 "A sua sugestão vai aqui, com todos os detalhes necessários.\n"
1564 "\n"
1565 "\n"
1566 "\n"
1567 "\n"
1568 "\n"
1569 "(O seguinte ajuda-nos a resolver o seu problema, por favor não apague)\n"
1570 "\n"
1571 "----------------------------[ Informação Técnica "
1572 "]----------------------------\n"
1573
1574 #: src/plm/core/ui/FeedbackDialog.java:71
1575 msgid "--------------------[ my code for this exercise ]--------------------\n"
1576 msgstr ""
1577 "--------------------[ o meu código para este exercício ]--------------------"
1578 "\n"
1579
1580 #: src/plm/core/ui/FeedbackDialog.java:94
1581 msgid "Report your feedback"
1582 msgstr "Relate o seu feedback"
1583
1584 #: src/plm/core/ui/FeedbackDialog.java:102
1585 msgid "Issue title:"
1586 msgstr "Título do assunto:"
1587
1588 #: src/plm/core/ui/FeedbackDialog.java:109
1589 msgid ""
1590 "<h1>Reporting a bug in PLM</h1><p>If you have your own GitHub account, "
1591 "please head to the <a href='https://github.com/BuggleInc/PLM'>PLM Bug "
1592 "Tracker</a>. If not, you can use this window to report an issue in the PLM "
1593 "(be it in one exercise or in the PLM itself). Please write your report in "
1594 "English or French if possible.</p><p>You should include all relevant "
1595 "information that could help us fixing the issue. Don't remove the technical "
1596 "details unless you are certain that they are not relevant. What you write "
1597 "here will be public: <b>Never disclose passwords or other sensible "
1598 "information on a bug tracker</b></p><p>When you find a typo or a sentence "
1599 "that is hard to understand, it really helps to suggest a new wording.If you "
1600 "encounter a technical bug, please tell us what you did, which outcome you "
1601 "were expecting and what happened instead.</p><br/>"
1602 msgstr ""
1603 "<h1>Reportar um bug em PLM</h1><p>Se tem a sua própria conta do GitHub, por "
1604 "favor vá para o <a href='https://github.com/BuggleInc/PLM'>PLM Bug Tracker</"
1605 "a>. Caso contrário, pode usar esta janela para relatar um problema no PLM ("
1606 "seja em um exercício ou no próprio PLM). Escreva o seu relatório em inglês "
1607 "ou francês, se possível.</p><p> Deve incluir todas as informações relevantes "
1608 "que nos possam ajudar a corrigir o problema. Não remova os detalhes técnicos "
1609 "a menos que tenha a certeza de que não são relevantes. O que escrever aqui "
1610 "será público: <b>Nunca revele palavras-passe ou outras informações sensatas "
1611 "num bug tracker</b></p><p>Quando encontrar um erro de digitação ou uma frase "
1612 "que seja difícil de entender, realmente ajuda sugerir uma nova redação. Se "
1613 "você encontrar um erro técnico, por favor diga-nos o que fez, que resultado "
1614 "estava a esperar e o que aconteceu no seu lugar.</p><br/>"
1615
1616 #: src/plm/core/ui/FeedbackDialog.java:152
1617 #: src/plm/core/ui/action/RevertExercise.java:20
1618 msgid "Cancel"
1619 msgstr "Cancelar"
1620
1621 #: src/plm/core/ui/FeedbackDialog.java:157
1622 msgid "Do you really want to cancel your feedback and lose any edit?"
1623 msgstr "Quer realmente cancelar o seu retorno e perder o que editou?"
1624
1625 #: src/plm/core/ui/FeedbackDialog.java:158
1626 msgid "are you sure?"
1627 msgstr "Tem certeza?"
1628
1629 #: src/plm/core/ui/FeedbackDialog.java:166
1630 msgid "Send feedback"
1631 msgstr "Enviar retorno"
1632
1633 #: src/plm/core/ui/FeedbackDialog.java:193
1634 #, java-format
1635 msgid ""
1636 "Thank you for your remark, we will do our best to integrate it.\n"
1637 "Follow our progress at {0}."
1638 msgstr ""
1639 "Obrigado pela sua opinião, vamos fazer nosso melhor para\n"
1640 "aproveitá-la. Siga nosso progresso em {0}."
1641
1642 #: src/plm/core/ui/FeedbackDialog.java:194
1643 msgid "Thanks for your suggestion"
1644 msgstr "Obrigado pela sua sugestão"
1645
1646 #: src/plm/core/ui/FeedbackDialog.java:203
1647 msgid "Error while uploading your feedback"
1648 msgstr "Erro ao enviar o seu feedback"
1649
1650 #: src/plm/core/ui/FeedbackDialog.java:210
1651 msgid ""
1652 "Your feedback needs some little changes before being send,\n"
1653 "please fix the following issue(s):\n"
1654 "\n"
1655 msgstr ""
1656 "Seu feeedback precisa de algumas mudanças antes de ser enviado. Favor\n"
1657 "consertar o(s) seguinte(s) problema(s):\n"
1658 "\n"
1659
1660 #: src/plm/core/ui/FeedbackDialog.java:211
1661 msgid "Incorrect feedback"
1662 msgstr "Feedback incorreto"
1663
1664 #: src/plm/core/ui/FeedbackDialog.java:236
1665 msgid ""
1666 "The feedback's title is still the default one, please specify a relevant "
1667 "one.\n"
1668 msgstr ""
1669 "O título do feedback ainda é o predefinido, especifique um título relevante."
1670 "\n"
1671
1672 #: src/plm/core/ui/FeedbackDialog.java:240
1673 msgid "The current title is empty, please specify a relevant title.\n"
1674 msgstr "O título atual está vazio. Por favor especifique um título relevante.\n"
1675
1676 #: src/plm/core/ui/FeedbackDialog.java:244
1677 msgid ""
1678 "The feedback still contains the explanatory text (above the line of "
1679 "---------), please remove it.\n"
1680 msgstr ""
1681 "O feedback ainda contém o texto de explicação (sobre a linha de ---------), "
1682 "por favor remova ele.\n"
1683
1684 #: src/plm/core/ui/LoggerPanel.java:30 src/plm/core/ui/LoggerPanel.java:95
1685 msgid "Where error and other messages get written"
1686 msgstr "Onde mensagens de erro e outras são escritas"
1687
1688 #. === FILE menu ===
1689 #. for now: leave the calls to i18n.tr: that way one is sure to get all the localized strings...
1690 #. Menus
1691 #: src/plm/core/ui/MainFrame.java:180 src/plm/core/ui/MainFrame.java:706
1692 msgid "File"
1693 msgstr "ficheiro"
1694
1695 #: src/plm/core/ui/MainFrame.java:182
1696 msgid "File related functions"
1697 msgstr "Funções relativas ao ficheiro"
1698
1699 #: src/plm/core/ui/MainFrame.java:184 src/plm/core/ui/MainFrame.java:707
1700 msgid "Save a picture"
1701 msgstr "Gravar uma figura"
1702
1703 #: src/plm/core/ui/MainFrame.java:190
1704 msgid "PNG Image Files"
1705 msgstr "ficheiros de imagem PNG"
1706
1707 #: src/plm/core/ui/MainFrame.java:198
1708 #, java-format
1709 msgid "Do you want to overwrite {0}?"
1710 msgstr "Quer sobreescrever {0}?"
1711
1712 #: src/plm/core/ui/MainFrame.java:199
1713 #, java-format
1714 msgid "{0} exists"
1715 msgstr "{0} existe"
1716
1717 #: src/plm/core/ui/MainFrame.java:218
1718 #, java-format
1719 msgid "Image saved into {0}."
1720 msgstr "Imagem gravada em {0}."
1721
1722 #: src/plm/core/ui/MainFrame.java:227 src/plm/core/ui/MainFrame.java:708
1723 msgid "Quit"
1724 msgstr "Sair"
1725
1726 #: src/plm/core/ui/MainFrame.java:234 src/plm/core/ui/MainFrame.java:710
1727 msgid "Exercise"
1728 msgstr "Exercício"
1729
1730 #: src/plm/core/ui/MainFrame.java:239 src/plm/core/ui/MainFrame.java:469
1731 #: src/plm/core/ui/MainFrame.java:711
1732 msgid "Switch lesson"
1733 msgstr "Alternar lição"
1734
1735 #: src/plm/core/ui/MainFrame.java:251 src/plm/core/ui/MainFrame.java:472
1736 #: src/plm/core/ui/MainFrame.java:703 src/plm/core/ui/MainFrame.java:712
1737 msgid "Switch exercise"
1738 msgstr "Alternar exercício"
1739
1740 #: src/plm/core/ui/MainFrame.java:262 src/plm/core/ui/MainFrame.java:713
1741 msgid "Revert Exercise"
1742 msgstr "Reverter exercício"
1743
1744 #: src/plm/core/ui/MainFrame.java:266 src/plm/core/ui/MainFrame.java:714
1745 msgid "Debug mode"
1746 msgstr "Modo depuração"
1747
1748 #: src/plm/core/ui/MainFrame.java:278 src/plm/core/ui/MainFrame.java:715
1749 msgid "Creative mode"
1750 msgstr "Modo criativo"
1751
1752 #. === Session menu ===
1753 #: src/plm/core/ui/MainFrame.java:292 src/plm/core/ui/MainFrame.java:717
1754 msgid "Session"
1755 msgstr "Sessão"
1756
1757 #: src/plm/core/ui/MainFrame.java:298
1758 msgid "Write Session to disk"
1759 msgstr "Escrever sessão para o disco"
1760
1761 #: src/plm/core/ui/MainFrame.java:301
1762 msgid "Read Session from disk"
1763 msgstr "Ler sessão do disco"
1764
1765 #: src/plm/core/ui/MainFrame.java:306 src/plm/core/ui/MainFrame.java:723
1766 #: src/plm/core/ui/action/AddUser.java:33
1767 msgid "Add user"
1768 msgstr "Adicionar utilizador"
1769
1770 #: src/plm/core/ui/MainFrame.java:309 src/plm/core/ui/MainFrame.java:724
1771 #: src/plm/core/ui/action/SwitchUser.java:30
1772 msgid "Switch user"
1773 msgstr "Alternar utilizador"
1774
1775 #: src/plm/core/ui/MainFrame.java:312 src/plm/core/ui/MainFrame.java:725
1776 #: src/plm/core/ui/action/RemoveUser.java:27
1777 msgid "Remove user"
1778 msgstr "Remover utilizador"
1779
1780 #. === Language menu ===
1781 #: src/plm/core/ui/MainFrame.java:316 src/plm/core/ui/MainFrame.java:728
1782 msgid "Language"
1783 msgstr "Idioma/linguagem"
1784
1785 #. === Programming language changing ===
1786 #: src/plm/core/ui/MainFrame.java:321 src/plm/core/ui/MainFrame.java:729
1787 msgid "Human"
1788 msgstr "Humano"
1789
1790 #: src/plm/core/ui/MainFrame.java:335 src/plm/core/ui/MainFrame.java:730
1791 msgid "Computer"
1792 msgstr "Computador"
1793
1794 #. === Help menu ===
1795 #: src/plm/core/ui/MainFrame.java:339 src/plm/core/ui/MainFrame.java:732
1796 msgid "Help"
1797 msgstr "Ajuda"
1798
1799 #: src/plm/core/ui/MainFrame.java:343 src/plm/core/ui/MainFrame.java:733
1800 msgid "Provide feedback"
1801 msgstr "Dizer o que achou"
1802
1803 #: src/plm/core/ui/MainFrame.java:353 src/plm/core/ui/MainFrame.java:734
1804 msgid "About this lesson"
1805 msgstr "Sobre esta lição"
1806
1807 #: src/plm/core/ui/MainFrame.java:366 src/plm/core/ui/MainFrame.java:735
1808 msgid "About this world"
1809 msgstr "Sobre este mundo"
1810
1811 #: src/plm/core/ui/MainFrame.java:381
1812 msgid "Show the mission in a window"
1813 msgstr "Mostrar a missão numa janela"
1814
1815 #. Buttons
1816 #: src/plm/core/ui/MainFrame.java:433 src/plm/core/ui/MainFrame.java:698
1817 msgid "Run"
1818 msgstr "Executar"
1819
1820 #: src/plm/core/ui/MainFrame.java:437 src/plm/core/ui/MainFrame.java:535
1821 #: src/plm/core/ui/MainFrame.java:699
1822 msgid "Step"
1823 msgstr "Dar um passo"
1824
1825 #: src/plm/core/ui/MainFrame.java:442 src/plm/core/ui/MainFrame.java:700
1826 msgid "Stop"
1827 msgstr "Parar"
1828
1829 #: src/plm/core/ui/MainFrame.java:448 src/plm/core/ui/MainFrame.java:701
1830 msgid "Reset"
1831 msgstr "Reconfigura"
1832
1833 #: src/plm/core/ui/MainFrame.java:454 src/plm/core/ui/MainFrame.java:702
1834 msgid "Demo"
1835 msgstr "Demonstração"
1836
1837 #: src/plm/core/ui/MainFrame.java:520
1838 msgid "Next"
1839 msgstr "Próximo"
1840
1841 #: src/plm/core/ui/MainFrame.java:587
1842 msgid "Please wait, while the PLM is saving your session data."
1843 msgstr "Favor aguardar enquanto o PLM grava os dados da sua sessão."
1844
1845 #: src/plm/core/ui/MainFrame.java:718
1846 msgid "Lesson related functions"
1847 msgstr "Funções relativas ao exercício"
1848
1849 #: src/plm/core/ui/MainFrame.java:719
1850 msgid "Export Session Cache"
1851 msgstr "Exportar cache de sessão"
1852
1853 #: src/plm/core/ui/MainFrame.java:720
1854 msgid "Import Session Cache"
1855 msgstr "Importar cache de sessão"
1856
1857 #: src/plm/core/ui/MissionEditorTabs.java:72
1858 msgid "Mission"
1859 msgstr "Missão"
1860
1861 #: src/plm/core/ui/MissionEditorTabs.java:73
1862 msgid "Description of the work to do"
1863 msgstr "Descrição do trabalho a fazer"
1864
1865 #. Create the tab with the code editor as content
1866 #: src/plm/core/ui/MissionEditorTabs.java:142
1867 msgid "Type your code here"
1868 msgstr "Digite o seu código aqui"
1869
1870 #: src/plm/core/ui/PlmHtmlEditorKit.java:343
1871 #, java-format
1872 msgid "<img> tag without src attribute at offset {0}."
1873 msgstr "marcação <img> sem atributo src em offset {0}."
1874
1875 #: src/plm/core/ui/PlmHtmlEditorKit.java:345
1876 #, java-format
1877 msgid "<img> tag without src attribute in exercise {0} at offset {1}"
1878 msgstr "etiqueta <img> sem atributo src no exercício {0} em offset {1}"
1879
1880 #: src/plm/core/ui/StatusBar.java:154
1881 msgid "Saving"
1882 msgstr "A gravar"
1883
1884 #: src/plm/core/ui/StatusBar.java:159
1885 msgid "Compiling"
1886 msgstr "A compilar"
1887
1888 #: src/plm/core/ui/StatusBar.java:175
1889 msgid "Running "
1890 msgstr "A executar "
1891
1892 #: src/plm/core/ui/StatusBar.java:180
1893 msgid "Playing demo "
1894 msgstr "A executar a demonstração "
1895
1896 #: src/plm/core/ui/StatusBar.java:185
1897 msgid "Loading "
1898 msgstr "A carregar "
1899
1900 #: src/plm/core/ui/TipsDialog.java:20
1901 msgid "Tips"
1902 msgstr "Dicas"
1903
1904 #: src/plm/core/ui/TipsDialog.java:21
1905 msgid "(no tips to display)"
1906 msgstr "(sem dicas para exibir)"
1907
1908 #: src/plm/core/ui/action/AddUser.java:27
1909 msgid ""
1910 "If you already have a UUID, paste it here. If not, you can use that randomly "
1911 "generated identifier."
1912 msgstr ""
1913 "Se já tem um UUID, cole-o aqui. Se não, pode usar este identificador gerado "
1914 "aleatoriamente."
1915
1916 #: src/plm/core/ui/action/AddUser.java:29
1917 msgid "Username:"
1918 msgstr "Nome de utilizador:"
1919
1920 #: src/plm/core/ui/action/AddUser.java:30
1921 msgid "Secret UUID:"
1922 msgstr "UUID secreto:"
1923
1924 #: src/plm/core/ui/action/AddUser.java:38
1925 msgid ""
1926 "Your new user has been added successfully!\n"
1927 "You were automatically switched to that user."
1928 msgstr ""
1929 "Seu novo utilizador foi adicionado com sucesso!\n"
1930 "Foi alternado automaticamente para este utilizador."
1931
1932 #: src/plm/core/ui/action/AddUser.java:41
1933 msgid ""
1934 "Invalid UUID! Either paste a correct identifier or use the randomly "
1935 "generated one."
1936 msgstr ""
1937 "UUID inválido! Ou cole um identificador correto, ou use o gerado "
1938 "aleatoriamente."
1939
1940 #: src/plm/core/ui/action/HelpMe.java:69
1941 msgid "Please ask here your question for the teacher:"
1942 msgstr "Por favor faça aqui a pergunta para o professor:"
1943
1944 #: src/plm/core/ui/action/HelpMe.java:70
1945 msgid "Call for help"
1946 msgstr "Peça ajuda"
1947
1948 #: src/plm/core/ui/action/HelpMe.java:136
1949 #: src/plm/core/ui/action/HelpMe.java:143
1950 msgid "Cancel call"
1951 msgstr "Cancelar chamado"
1952
1953 #: src/plm/core/ui/action/HelpMe.java:136
1954 #: src/plm/core/ui/action/HelpMe.java:143
1955 msgid "Call for Help"
1956 msgstr "Pedir ajuda"
1957
1958 #: src/plm/core/ui/action/PlayDemo.java:27
1959 msgid "Run the demo of what you should code for this exercise"
1960 msgstr "Execute o demo do que deveria ter codificado para este exercício"
1961
1962 #: src/plm/core/ui/action/PlayDemo.java:28
1963 msgid "Impossible to run the demo right now"
1964 msgstr "Impossível executar o demo agora"
1965
1966 #: src/plm/core/ui/action/QuitGame.java:29
1967 msgid "Quit the application"
1968 msgstr "Sair da aplicação"
1969
1970 #: src/plm/core/ui/action/QuitGame.java:29
1971 msgid "Impossible to quit the application right now"
1972 msgstr "Impossível sair da aplicação agora"
1973
1974 #: src/plm/core/ui/action/RemoveUser.java:27
1975 msgid ""
1976 "<html>Please choose from the drop-down menu the user you want to remove.</"
1977 "html>"
1978 msgstr ""
1979 "<html>Por favor escolha o utilizador que quer remover do menu drop-"
1980 "down.</html>"
1981
1982 #: src/plm/core/ui/action/RemoveUser.java:35
1983 #, java-format
1984 msgid ""
1985 "A deleted user is definitely lost if you don''t know its \n"
1986 "full UUID (something like 110E8400-E29B-11D4-A716-446655440000).\n"
1987 "Are you sure that you want to delete the user {0}?"
1988 msgstr ""
1989 "Um utilizador removido é perdido para sempre se não souber o seu \n"
1990 "UUID completo (algo como 110E8400-E29B-11D4-A716-446655440000).\n"
1991 "Tem certeza que quer apagar o utilizador {0}?"
1992
1993 #: src/plm/core/ui/action/RemoveUser.java:38
1994 msgid "Confirm user deletion"
1995 msgstr "Confirme remoção de utilizador"
1996
1997 #: src/plm/core/ui/action/RemoveUser.java:41
1998 #, java-format
1999 msgid "User {0} successfully deleted"
2000 msgstr "Utilizador {0} removido com sucesso"
2001
2002 #: src/plm/core/ui/action/RemoveUser.java:44
2003 msgid "Sorry, you can't delete the current user."
2004 msgstr "Desculpe, não pode apagar o utilizador atual."
2005
2006 #: src/plm/core/ui/action/RemoveUser.java:44
2007 msgid "Try again"
2008 msgstr "Tente de novo"
2009
2010 #: src/plm/core/ui/action/Reset.java:29
2011 msgid "Reset your world to the initial state"
2012 msgstr "Reconfigura o seu mundo ao estado inicial"
2013
2014 #: src/plm/core/ui/action/Reset.java:29
2015 msgid "World cannot be reset right now"
2016 msgstr "O mundo não pode ser reocnfigurado agora"
2017
2018 #: src/plm/core/ui/action/RevertExercise.java:20
2019 msgid "OK"
2020 msgstr "OK"
2021
2022 #: src/plm/core/ui/action/RevertExercise.java:23
2023 msgid ""
2024 "Reverting this exercise will erase all your work and cannot be undone.\n"
2025 " Are you sure that you want to proceed?"
2026 msgstr ""
2027 "Ao reverter este exercício vai apagar todo o seu trabalho e não\n"
2028 "pode ser defeito. Tem certeza que quer continuar?"
2029
2030 #: src/plm/core/ui/action/RevertExercise.java:24
2031 msgid "Warning"
2032 msgstr "Cuidado"
2033
2034 #: src/plm/core/ui/action/RevertExercise.java:28
2035 msgid "Revert canceled on user request -- your work was preserved."
2036 msgstr ""
2037 "Reversão cancelada a pedido do utilizador -- o seu trabalho foi preservado."
2038
2039 #: src/plm/core/ui/action/RevertExercise.java:39
2040 msgid "Exercise reverted"
2041 msgstr "Exercício revertido"
2042
2043 #: src/plm/core/ui/action/StartExecution.java:32
2044 msgid ""
2045 "The PLM can save your data anonymously on remote servers. That way, you \n"
2046 "can retrieve your session from your anonymous tag from any connected "
2047 "computer.\n"
2048 "This anonymous data also helps scientists understanding how people learn \n"
2049 " programming. No nominative information is stored, only the source code "
2050 "written\n"
2051 "to solve the challenges.\n"
2052 msgstr ""
2053 "O PLM pode gravar os seus dados anonimamente nos servidores remotos. Desta "
2054 "forma, \n"
2055 "pode recuperar a sua sessão com a sua etiqueta anónima em qualquer "
2056 "computador \n"
2057 "conectado. Estes dados anónimos também ajudam os cientistas a entender como "
2058 "as \n"
2059 "pessoas aprendem a programar. Nenhuma informação pessoal é armazenada, "
2060 "apenas \n"
2061 "o código-fonte escrito para resolver os desafios.\n"
2062
2063 #: src/plm/core/ui/action/StartExecution.java:37
2064 msgid "Do you want to store your data online?"
2065 msgstr "Quer guardar os seus dados online?"
2066
2067 #: src/plm/core/ui/action/StartExecution.java:38
2068 msgid "Ok, save my data online"
2069 msgstr "Certo, grave meus dados online"
2070
2071 #: src/plm/core/ui/action/StartExecution.java:38
2072 msgid "No, keep everything local"
2073 msgstr "Não, guarde tudo localmente"
2074
2075 #: src/plm/core/ui/action/StartExecution.java:38
2076 msgid "Let me decide later"
2077 msgstr "Deixe-me decidir mais tarde"
2078
2079 #: src/plm/core/ui/action/StartExecution.java:65
2080 msgid "Launch the execution of your code"
2081 msgstr "Começa a execução do seu código"
2082
2083 #: src/plm/core/ui/action/StartExecution.java:66
2084 msgid ""
2085 "Cannot launch the execution right now. Wait a bit, or interrupt current "
2086 "activity with the stop button"
2087 msgstr ""
2088 "Não posso lançar a execução agora. Espere um pouco, ou interrompa a "
2089 "atividade atual com o botão Parar"
2090
2091 #: src/plm/core/ui/action/StepExecution.java:22
2092 msgid "Execute one step of your code"
2093 msgstr "Executa um passo do seu código"
2094
2095 #: src/plm/core/ui/action/StepExecution.java:23
2096 msgid "Impossible to step your code now. Need to stop the execution first?"
2097 msgstr ""
2098 "Impossível dar um passo no seu código agora. Quer parar a execução primeiro?"
2099
2100 #: src/plm/core/ui/action/StopExecution.java:22
2101 msgid "Stop your code"
2102 msgstr "Pára o seu código"
2103
2104 #: src/plm/core/ui/action/StopExecution.java:23
2105 msgid "No execution to stop right now"
2106 msgstr "Nenhuma execução para parar no momento"
2107
2108 #: src/plm/core/ui/action/SwitchExo.java:29
2109 msgid "Switch to another exercise"
2110 msgstr "Trocar por outro exercício"
2111
2112 #: src/plm/core/ui/action/SwitchUser.java:29
2113 msgid "Please choose the user you want to use"
2114 msgstr "Favor escolher o utilizador que quer usar"
2115
2116 #: src/plm/core/ui/action/SwitchUser.java:37
2117 #, java-format
2118 msgid "User {0} already selected."
2119 msgstr "Utilizador {0} já selecionado."
2120
2121 #: src/plm/core/ui/action/SwitchUser.java:41
2122 #, java-format
2123 msgid "User {0} now selected."
2124 msgstr "Utilizador {0} agora selecionado."
2125
2126 #: src/plm/core/ui/action/SwitchUser.java:43
2127 msgid "Operation canceled by user request"
2128 msgstr "Operação cancelada a pedido do utilizador"
2129
2130 #: src/plm/core/ui/action/SwitchUser.java:44
2131 msgid "Operation canceled as requested by user."
2132 msgstr "Operação cancelada conforme pedido do utilizador."
2133
2134 #: src/plm/core/ui/editor/MissionEditor.java:54
2135 msgid "PLM - Mission Editor (modified)"
2136 msgstr "PLM - Editor de Missão (modificado)"
2137
2138 #: src/plm/core/ui/editor/MissionEditor.java:55
2139 msgid "PLM - Mission Editor"
2140 msgstr "PLM - Editor de Missão"
2141
2142 #: src/plm/core/ui/editor/MissionEditor.java:253
2143 #: src/plm/core/ui/editor/buggleeditor/MainFrame.java:254
2144 #, java-format
2145 msgid "Error while reading {0}"
2146 msgstr "Erro enquanto lia {0}"
2147
2148 #: src/plm/core/ui/editor/MissionEditor.java:260
2149 msgid "You did not save you changes. Do you want to save it before quiting?"
2150 msgstr "Não gravou as suas alterações. Quer gravar antes de sair?"
2151
2152 #: src/plm/core/ui/editor/MissionEditor.java:261
2153 #: src/plm/core/ui/editor/MissionEditor.java:380
2154 msgid "Save or loose your change?"
2155 msgstr "Gravar ou perder a sua mudança?"
2156
2157 #: src/plm/core/ui/editor/MissionEditor.java:372
2158 msgid "Open Mission..."
2159 msgstr "Abrir Missão..."
2160
2161 #: src/plm/core/ui/editor/MissionEditor.java:379
2162 msgid ""
2163 "You did not save you changes. Do you want to save it before opening another "
2164 "file?"
2165 msgstr ""
2166 "Não gravou as suas alterações. Quer gravar-as antes de abrir outro ficheiro?"
2167
2168 #: src/plm/core/ui/editor/MissionEditor.java:397
2169 msgid "HTML files"
2170 msgstr "ficheiros HTML"
2171
2172 #: src/plm/core/ui/editor/MissionEditor.java:405
2173 #, java-format
2174 msgid ""
2175 "You chose a translated mission text for edition ({0}).\n"
2176 "This is wrong. The translations should be handled with po4a in the PLM.\n"
2177 "Please refer to https://github.com/oster/PLM/wiki/Working-with-the-"
2178 "translations for more information.\n"
2179 "\n"
2180 "Proceed anyway?"
2181 msgstr ""
2182 "Escolheu um texto de missão traduzido para edição ({0}).\n"
2183 "Isto está errado. As traduções devem ser manipuladas com o po4a no PLM. \n"
2184 "Leia https://github.com/oster/PLM/wiki/Working-with-the-translations para "
2185 "mais informações.\n"
2186 "\n"
2187 "Continuar mesmo assim?"
2188
2189 #: src/plm/core/ui/editor/MissionEditor.java:409
2190 msgid "This is a translated mission text"
2191 msgstr "Este é um texto de missão traduzido"
2192
2193 #: src/plm/core/ui/editor/MissionEditor.java:426
2194 msgid "Quit Map Editor"
2195 msgstr "Sair do Editor de Mapa"
2196
2197 #: src/plm/core/ui/editor/buggleeditor/MainFrame.java:188
2198 msgid "Create New Map"
2199 msgstr "Criar Novo Mapa"
2200
2201 #: src/plm/core/ui/editor/buggleeditor/MainFrame.java:240
2202 msgid "Open Map..."
2203 msgstr "Abrir Mapa..."
2204
2205 #: src/plm/core/ui/editor/buggleeditor/MainFrame.java:246
2206 msgid "PLM map files"
2207 msgstr "ficheiros de mapa do PLM"
2208
2209 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:57
2210 msgid "Property"
2211 msgstr "Propriedade"
2212
2213 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:57
2214 msgid "Value"
2215 msgstr "Valor"
2216
2217 #. The editor for the name
2218 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:71
2219 msgid "World name"
2220 msgstr "Nome do mundo"
2221
2222 #. ---------- world width ---------------
2223 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:83
2224 msgid "World width"
2225 msgstr "Largura do mundo"
2226
2227 #. ---------- world height ---------------
2228 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:103
2229 msgid "World height"
2230 msgstr "Altura do mundo"
2231
2232 #. ---------- selected cell ---------------
2233 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:123
2234 msgid "Selected cell X"
2235 msgstr "Célula X selecionada"
2236
2237 #. ---------- selected cell ---------------
2238 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:145
2239 msgid "Selected cell Y"
2240 msgstr "Célula Y selecionada"
2241
2242 #. ---------- Ground color ---------------
2243 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:166
2244 msgid "Ground color (name or r/g/b)"
2245 msgstr "Cor do chão (nome ou r/g/b)"
2246
2247 #. ---------- top wall cell ---------------
2248 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:183
2249 msgid "Top wall?"
2250 msgstr "Parede superior?"
2251
2252 #. ---------- left wall cell ---------------
2253 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:205
2254 msgid "Left wall?"
2255 msgstr "Parede da esquerda?"
2256
2257 #. ---------- have baggle ---------------
2258 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:227
2259 msgid "Baggle?"
2260 msgstr "Baggle?"
2261
2262 #. ---------- Buggle name ---------------
2263 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:258
2264 msgid "Buggle name"
2265 msgstr "Nome do buggle"
2266
2267 #. ---------- Buggle direction ---------------
2268 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:269
2269 msgid "Buggle direction (N|S|E|W)"
2270 msgstr "Direção do Buggle (N|S|E|W)"
2271
2272 #. ---------- Buggle color ---------------
2273 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:298
2274 msgid "Buggle color (name or r/g/b)"
2275 msgstr "Cor do Buggle (nome ou r/g/b)"
2276
2277 #. ---------- Buggle color ---------------
2278 #: src/plm/core/ui/editor/buggleeditor/PropertiesEditor.java:314
2279 msgid "Brush color (name or r/g/b)"
2280 msgstr "Cor do pincel (nome ou r/g/b)"
2281
2282 #: src/plm/core/utils/ColorMapper.java:59
2283 msgid "black"
2284 msgstr "preto"
2285
2286 #: src/plm/core/utils/ColorMapper.java:60
2287 msgid "blue"
2288 msgstr "Azul"
2289
2290 #: src/plm/core/utils/ColorMapper.java:61
2291 msgid "cyan"
2292 msgstr "ciano"
2293
2294 #: src/plm/core/utils/ColorMapper.java:62
2295 msgid "dark grey"
2296 msgstr "cinzento escuro"
2297
2298 #: src/plm/core/utils/ColorMapper.java:63
2299 msgid "grey"
2300 msgstr "cinzento"
2301
2302 #: src/plm/core/utils/ColorMapper.java:64
2303 msgid "green"
2304 msgstr "verde"
2305
2306 #: src/plm/core/utils/ColorMapper.java:65
2307 msgid "light grey"
2308 msgstr "verde claro"
2309
2310 #: src/plm/core/utils/ColorMapper.java:66
2311 msgid "magenta"
2312 msgstr "magenta"
2313
2314 #: src/plm/core/utils/ColorMapper.java:67
2315 msgid "orange"
2316 msgstr "laranja"
2317
2318 #: src/plm/core/utils/ColorMapper.java:68
2319 msgid "pink"
2320 msgstr "rosa"
2321
2322 #: src/plm/core/utils/ColorMapper.java:69
2323 msgid "red"
2324 msgstr "vermelho"
2325
2326 #: src/plm/core/utils/ColorMapper.java:70
2327 msgid "white"
2328 msgstr "branco"
2329
2330 #: src/plm/core/utils/ColorMapper.java:71
2331 msgid "yellow"
2332 msgstr "amarelo"
2333
2334 #: src/plm/universe/Direction.java:59
2335 msgid "NORTH"
2336 msgstr "NORTH"
2337
2338 #: src/plm/universe/Direction.java:61
2339 msgid "EAST"
2340 msgstr "EAST"
2341
2342 #: src/plm/universe/Direction.java:63
2343 msgid "SOUTH"
2344 msgstr "SOUTH"
2345
2346 #: src/plm/universe/Direction.java:65
2347 msgid "WEST"
2348 msgstr "WEST"
2349
2350 #: src/plm/universe/bat/BatEntity.java:38
2351 #, java-format
2352 msgid "Exception {0}: {1}"
2353 msgstr "Exceção {0}: {1}"
2354
2355 #: src/plm/universe/bugglequest/AbstractBuggle.java:95
2356 msgid ""
2357 "Sorry Dave, I cannot let you use penDown() here. Buggles have brushes, not "
2358 "pens. Use brushDown() instead."
2359 msgstr ""
2360 "Desculpe Dave, não posso deixá-lo usar penDown() aqui. Os Buggles tem "
2361 "pinceis, não canetas. Tente usar brushDown()."
2362
2363 #: src/plm/universe/bugglequest/AbstractBuggle.java:99
2364 msgid ""
2365 "Sorry Dave, I cannot let you use penUp() here. Buggles have brushes, not "
2366 "pens. Use brushUp() instead."
2367 msgstr ""
2368 "Desculpe Dave, não posso deixá-lo usar penUp() aqui. Os buggles tem pinceis, "
2369 "não canetas. Tente usar brushUp()."
2370
2371 #: src/plm/universe/bugglequest/AbstractBuggle.java:175
2372 #: src/plm/universe/bugglequest/SimpleBuggle.java:31
2373 #: src/plm/universe/turtles/Turtle.java:216
2374 msgid ""
2375 "Sorry Dave, I cannot let you use Left() with an uppercase. Use left() "
2376 "instead."
2377 msgstr ""
2378 "Desculpe Dave, mas não posso deixá-lo usar Left(x) com uma maiúscula. Ao "
2379 "invés disto, use left()."
2380
2381 #: src/plm/universe/bugglequest/AbstractBuggle.java:178
2382 #: src/plm/universe/bugglequest/SimpleBuggle.java:36
2383 #: src/plm/universe/turtles/Turtle.java:219
2384 msgid ""
2385 "Sorry Dave, I cannot let you use Right() with an uppercase. Use right() "
2386 "instead."
2387 msgstr ""
2388 "Desculpe Dave, mas não posso deixá-lo usar Right() com uma maiúscula. Em vez "
2389 "disto, use right()."
2390
2391 #: src/plm/universe/bugglequest/AbstractBuggle.java:198
2392 #, java-format
2393 msgid ""
2394 "You tried to access a cell with Y={0}, but the maximal Y in this world is "
2395 "{1}."
2396 msgstr "Tentou acessar uma célula com Y={0}, mas o Y maximal neste mundo é {1}."
2397
2398 #: src/plm/universe/bugglequest/AbstractBuggle.java:200
2399 #, java-format
2400 msgid ""
2401 "You tried to access a cell with X={0}, but the maximal X in this world is "
2402 "{1}."
2403 msgstr "Tentou acessar uma célula com X={0}, mas o X máximo neste mundo é {1}."
2404
2405 #: src/plm/universe/bugglequest/AbstractBuggle.java:219
2406 #: src/plm/universe/bugglequest/AbstractBuggle.java:255
2407 #, java-format
2408 msgid "You tried to set X to {0}, but the maximal X in this world is {1}."
2409 msgstr "Tentou ajustar X para {0}, mas o X máximo neste mundo é {1}."
2410
2411 #: src/plm/universe/bugglequest/AbstractBuggle.java:238
2412 #: src/plm/universe/bugglequest/AbstractBuggle.java:253
2413 #, java-format
2414 msgid "You tried to set Y to {0}, but the maximal Y in this world is {1}."
2415 msgstr "Tentou configurar Y para {0}, mas o Y máximo neste mundo é {1}."
2416
2417 #: src/plm/universe/bugglequest/AbstractBuggle.java:372
2418 #: src/plm/universe/bugglequest/BuggleWorldCell.java:129
2419 msgid "There is no baggle to pick up here."
2420 msgstr "Não tem baggle para pegar aqui."
2421
2422 #: src/plm/universe/bugglequest/AbstractBuggle.java:374
2423 msgid "You are already carrying a baggle."
2424 msgstr "Já está a carregar um baggle."
2425
2426 #: src/plm/universe/bugglequest/AbstractBuggle.java:465
2427 msgid "Its value is 'null', which is never good."
2428 msgstr "Seu valor é 'null', que nunca é bom."
2429
2430 #: src/plm/universe/bugglequest/AbstractBuggle.java:472
2431 msgid " It should not carry that baggle.\n"
2432 msgstr " Não deveria carregar este baggle.\n"
2433
2434 #: src/plm/universe/bugglequest/AbstractBuggle.java:474
2435 msgid " It is not carrying any baggle.\n"
2436 msgstr " Não está a carregar nenhum baggle.\n"
2437
2438 #: src/plm/universe/bugglequest/AbstractBuggle.java:478
2439 #, java-format
2440 msgid " Unexpected issue: {0}\n"
2441 msgstr " Problema inesperado: {0}\n"
2442
2443 #: src/plm/universe/bugglequest/AbstractBuggle.java:480
2444 msgid " It encountered an unexpected issue (such as bumping into a wall).\n"
2445 msgstr " Encontrou um problema inesperado (tal como esbarrar numa parede).\n"
2446
2447 #: src/plm/universe/bugglequest/AbstractBuggle.java:484
2448 #, java-format
2449 msgid " It did not encounter the expected issue: {0}\n"
2450 msgstr " Não encontrou o problema esperado: {0}\n"
2451
2452 #: src/plm/universe/bugglequest/AbstractBuggle.java:486
2453 msgid ""
2454 " It did not encounter an issue as expected (such as bumping into a "
2455 "wall).\n"
2456 msgstr ""
2457 " Não encontrou um problema como o esperado (como esbarrar numa parede).\n"
2458
2459 #: src/plm/universe/bugglequest/AbstractBuggle.java:491
2460 #, java-format
2461 msgid " Its position is ({0},{1}); expected: ({2},{3}).\n"
2462 msgstr " A posição dele é ({0},{1}); esperado: ({2},{3}).\n"
2463
2464 #: src/plm/universe/bugglequest/AbstractBuggle.java:493
2465 #, java-format
2466 msgid " Its direction is {0}; expected: {1}.\n"
2467 msgstr " A direção dele é {0}; esperada: {1}.\n"
2468
2469 #: src/plm/universe/bugglequest/AbstractBuggle.java:495
2470 #, java-format
2471 msgid " Its color is {0}; expected: {1}.\n"
2472 msgstr " A cor dele é {0}; esperada: {1}.\n"
2473
2474 #: src/plm/universe/bugglequest/AbstractBuggle.java:497
2475 #, java-format
2476 msgid " The color of its brush is {0}; expected: {1}.\n"
2477 msgstr " A cor do seu pincel é {0}; esperada: {1}.\n"
2478
2479 #: src/plm/universe/bugglequest/BuggleWorld.java:122
2480 #, java-format
2481 msgid ""
2482 "{0}: The path to the map on disk should not include the .map extension (or "
2483 "it won''t work in jarfiles). Please fix your exercise."
2484 msgstr ""
2485 "{0}: O caminho ao mapa no disco não deve incluir uma extensão .map (senão "
2486 "falha em ficheiros jar). Favor consertar o seu exercício."
2487
2488 #: src/plm/universe/bugglequest/BuggleWorld.java:130
2489 #, java-format
2490 msgid ""
2491 "{0}.map: this file does not seem to be a serialized BuggleWorld (the file is "
2492 "empty!)"
2493 msgstr ""
2494 "{0}.map: este ficheiro não parece um BuggleWorld serializado (o ficheiro "
2495 "está vazio!)"
2496
2497 #: src/plm/universe/bugglequest/BuggleWorld.java:136
2498 #, java-format
2499 msgid ""
2500 "{0}.map: This file does not seem to be a serialized BuggleWorld (malformated "
2501 "first line: {1})"
2502 msgstr ""
2503 "{0}.map: Este ficheiro não parece ser um BuggleWorld serializado (primeira "
2504 "linha malformada: {1})"
2505
2506 #: src/plm/universe/bugglequest/BuggleWorld.java:142
2507 #, java-format
2508 msgid "{0}.map: End of file reached before world size specification"
2509 msgstr ""
2510 "{0}.map: Fim de ficheiro encontrado antes da especificação de tamanho do "
2511 "mundo"
2512
2513 #: src/plm/universe/bugglequest/BuggleWorld.java:147
2514 #, java-format
2515 msgid "{0}.map:1: Expected ''Size: NNxMM'' but got ''{0}''"
2516 msgstr "{0}.map:1: Esperava ''Size: NNxMM'' mas encontrei ''{0}''"
2517
2518 #: src/plm/universe/bugglequest/BuggleWorld.java:173
2519 #, java-format
2520 msgid "Cannot put a buggle on coordinate {0},{1}: that''s out of the world"
2521 msgstr "Não posso pôr um buggle na coordenada {0},{1}: É fora do mundo"
2522
2523 #: src/plm/universe/bugglequest/BuggleWorld.java:187
2524 #, java-format
2525 msgid "Invalid buggle''s direction: {0}"
2526 msgstr "Direção inválida do buggle: {0}"
2527
2528 #: src/plm/universe/bugglequest/BuggleWorld.java:194
2529 #: src/plm/universe/bugglequest/BuggleWorld.java:201
2530 #, java-format
2531 msgid "Invalid buggle''s color name: {0}"
2532 msgstr "Nome de cor do buggle inválido: {0}"
2533
2534 #: src/plm/universe/bugglequest/BuggleWorld.java:218
2535 #, java-format
2536 msgid "Cannot define a cell on coordinate {0},{1}: that''s out of the world"
2537 msgstr "Não posso definir uma célula na coordenada {0},{1}: é fora do mundo"
2538
2539 #: src/plm/universe/bugglequest/BuggleWorld.java:231
2540 #, java-format
2541 msgid "Invalid color name: {0}"
2542 msgstr "Nome de cor inválido: {0}"
2543
2544 #: src/plm/universe/bugglequest/BuggleWorld.java:237
2545 #, java-format
2546 msgid "Expecting ''baggle'' or ''nobaggle'' but got {0} instead"
2547 msgstr "Esperava ''baggle'' ou ''nobaggle'' mas encontrei {0} no lugar"
2548
2549 #: src/plm/universe/bugglequest/BuggleWorld.java:241
2550 #, java-format
2551 msgid "Expecting ''topwall'' or ''notopwall'' but got {0} instead"
2552 msgstr "Esperava ''topwall'' ou ''notopwall'' mas encontrei {0} no lugar"
2553
2554 #: src/plm/universe/bugglequest/BuggleWorld.java:245
2555 #, java-format
2556 msgid "Expecting ''leftwall'' or ''noleftwall'' but got {0} instead"
2557 msgstr "Esperava ''leftwall'' ou ''noleftwall'' mas encontrei {0} no lugar"
2558
2559 #: src/plm/universe/bugglequest/BuggleWorld.java:255
2560 #, java-format
2561 msgid ""
2562 "The cell {0},{1} seem to be defined more than once. At least, there is two "
2563 "baggles here, which is not allowed."
2564 msgstr ""
2565 "A célula {0},{1} parece ter sido definida mais de uma vez. Pelo menos, "
2566 "existem dois baggles aqui, o que não é permitido."
2567
2568 #: src/plm/universe/bugglequest/BuggleWorld.java:271
2569 #, java-format
2570 msgid ""
2571 "Parse error. I was expecting a cell or a buggle description but got: {0}"
2572 msgstr ""
2573 "Erro de sintaxe. Esperava encontrar uma célula ou uma descrição de buggle "
2574 "mas encontrei: {0}"
2575
2576 #: src/plm/universe/bugglequest/BuggleWorld.java:576
2577 #, java-format
2578 msgid " The world''s name is {0}"
2579 msgstr " O nome do mundo é {0}"
2580
2581 #: src/plm/universe/bugglequest/BuggleWorld.java:578
2582 #, java-format
2583 msgid " There is {0} entities where {1} were expected."
2584 msgstr " Existe {0} entidades onde espera-se {1}."
2585
2586 #: src/plm/universe/bugglequest/BuggleWorld.java:582
2587 #, java-format
2588 msgid " Something is wrong about buggle ''{0}'':\n"
2589 msgstr " Tem algo errado com o buggle ''{0}'':\n"
2590
2591 #: src/plm/universe/bugglequest/BuggleWorld.java:588
2592 #, java-format
2593 msgid " In ({0},{1})"
2594 msgstr " Em ({0},{1})"
2595
2596 #: src/plm/universe/bugglequest/BuggleWorldCell.java:122
2597 msgid "There is already a baggle here."
2598 msgstr "Já existe um baggle aqui."
2599
2600 #: src/plm/universe/bugglequest/BuggleWorldCell.java:202
2601 msgid ", there shouldn't be this baggle"
2602 msgstr ", não deve ser este baggle"
2603
2604 #: src/plm/universe/bugglequest/BuggleWorldCell.java:204
2605 msgid ", there should be a baggle"
2606 msgstr ", deve ser um baggle"
2607
2608 #: src/plm/universe/bugglequest/BuggleWorldCell.java:207
2609 #, java-format
2610 msgid ", the ground should not be {0}"
2611 msgstr ", o solo não deve ser {0}"
2612
2613 #: src/plm/universe/bugglequest/BuggleWorldCell.java:209
2614 #, java-format
2615 msgid ", the ground is expected to be {0}, but it is {1}"
2616 msgstr ", espera-se um chão {0}, mas ele é {1}"
2617
2618 #: src/plm/universe/bugglequest/BuggleWorldCell.java:213
2619 #, java-format
2620 msgid ", the ground reads ''{0}'' (expected: ''{1}'')"
2621 msgstr ", o solo lê ''{0}'' (esperado: ''{1}'')"
2622
2623 #: src/plm/universe/bugglequest/BuggleWorldCell.java:216
2624 msgid ", there shouldn't be any wall at west"
2625 msgstr ", não deve haver nenhuma parede a oeste"
2626
2627 #: src/plm/universe/bugglequest/BuggleWorldCell.java:218
2628 msgid ", there should be a wall at west"
2629 msgstr ", deve haver uma parede a oeste"
2630
2631 #: src/plm/universe/bugglequest/BuggleWorldCell.java:221
2632 msgid ", there shouldn't be any wall at north"
2633 msgstr ", não deve haver nenhuma parede a norte"
2634
2635 #: src/plm/universe/bugglequest/BuggleWorldCell.java:223
2636 msgid ", there should be a wall at north"
2637 msgstr ", deve haver uma parede a norte"
2638
2639 #: src/plm/universe/bugglequest/exception/BuggleWallException.java:10
2640 msgid "Buggles cannot traverse walls"
2641 msgstr "Buggles não podem atravessar paredes"
2642
2643 #: src/plm/universe/bugglequest/exception/DontHaveBaggleException.java:10
2644 msgid "You have no baggle to drop"
2645 msgstr "Não tem baggle para soltar"
2646
2647 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:59
2648 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:232
2649 msgid "forward"
2650 msgstr "avançar"
2651
2652 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:64
2653 msgid "forward()"
2654 msgstr "forward()"
2655
2656 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:75
2657 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:231
2658 msgid "backward"
2659 msgstr "recuar"
2660
2661 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:80
2662 msgid "backward()"
2663 msgstr "backward()"
2664
2665 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:91
2666 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:233
2667 msgid "left"
2668 msgstr "esquerda"
2669
2670 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:95
2671 msgid "left()"
2672 msgstr "left()"
2673
2674 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:101
2675 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:234
2676 msgid "right"
2677 msgstr "direita"
2678
2679 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:105
2680 msgid "right()"
2681 msgstr "right()"
2682
2683 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:111
2684 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:235
2685 msgid "mark"
2686 msgstr "marcar"
2687
2688 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:117
2689 msgid "brushUp()"
2690 msgstr "brushUp()"
2691
2692 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:120
2693 msgid "brushDown()"
2694 msgstr "brushDown()"
2695
2696 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:146
2697 #, java-format
2698 msgid "setBrushColor(Color.{0})"
2699 msgstr "setBrushColor(Color.{0})"
2700
2701 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:222
2702 msgid "Wall hugging error"
2703 msgstr "Erro de hugging de parede"
2704
2705 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:223
2706 msgid "Your buggle has collided with a wall, it hurts a lot ! ='("
2707 msgstr "Seu buggle colidiu com uma parede. Isso dói muito ! ='("
2708
2709 #: src/plm/universe/bugglequest/ui/BuggleButtonPanel.java:236
2710 msgid "Brush Color"
2711 msgstr "Cor do pincel"
2712
2713 #: src/plm/universe/sort/SortingButtonPanel.java:59
2714 msgid "go"
2715 msgstr "vai"
2716
2717 #: src/plm/universe/sort/SortingButtonPanel.java:74
2718 #, java-format
2719 msgid "setValue({0},{1})"
2720 msgstr "setValue({0},{1})"
2721
2722 #: src/plm/universe/sort/SortingButtonPanel.java:78
2723 #, java-format
2724 msgid "copy({0},{1})"
2725 msgstr "copy({0},{1})"
2726
2727 #: src/plm/universe/sort/SortingButtonPanel.java:108
2728 msgid "swap"
2729 msgstr "alternar"
2730
2731 #: src/plm/universe/sort/SortingButtonPanel.java:108
2732 msgid "setValue"
2733 msgstr "setValue"
2734
2735 #: src/plm/universe/sort/SortingButtonPanel.java:108
2736 msgid "copy"
2737 msgstr "copiar"
2738
2739 #: src/plm/universe/sort/SortingWorld.java:116
2740 #, java-format
2741 msgid ""
2742 "This is very weird: There is not the same amount of values! Expected: {0}; "
2743 "Found: {1}\n"
2744 msgstr ""
2745 "Isto é muito estranho: Não tem a mesma quantidade de valores! Esperava: {0}; "
2746 "Encontrei: {1}\n"
2747
2748 #: src/plm/universe/sort/SortingWorld.java:119
2749 #, java-format
2750 msgid "Invalid read count. Expected: {0}; Found: {1}\n"
2751 msgstr "Contador de leituras inválido. Esperava: {0}; Encontrei: {1}\n"
2752
2753 #: src/plm/universe/sort/SortingWorld.java:122
2754 #, java-format
2755 msgid "Invalid write count. Expected: {0}; Found: {1}\n"
2756 msgstr "Contador de escritas inválido. Esperava: {0}; Encontrei: {1}\n"
2757
2758 #: src/plm/universe/sort/SortingWorld.java:126
2759 #, java-format
2760 msgid "Value at index {0} differs. Expected {1}; Found {2}\n"
2761 msgstr "Valor no índice {0} diverge. Esperado {1}; Encontrado {2}\n"
2762
2763 #: src/plm/universe/sort/SortingWorld.java:368
2764 #: src/plm/universe/sort/SortingWorld.java:369
2765 #, java-format
2766 msgid "Out of bounds in swap({0},{1}): {2}<0"
2767 msgstr "Fora dos limites em alternar({0},{1}): {2}<0"
2768
2769 #: src/plm/universe/sort/SortingWorld.java:370
2770 #: src/plm/universe/sort/SortingWorld.java:371
2771 #, java-format
2772 msgid "Out of bounds in swap({0},{1}): {2}>value count"
2773 msgstr "Fora dos limites em alternar({0},{1}): {2}>contador de valores"
2774
2775 #: src/plm/universe/turtles/Line.java:109
2776 msgid "x1 differs."
2777 msgstr "x1 está diferente."
2778
2779 #: src/plm/universe/turtles/Line.java:111
2780 msgid "x2 differs."
2781 msgstr "x2 está diferente."
2782
2783 #: src/plm/universe/turtles/Line.java:113
2784 msgid "y1 differs."
2785 msgstr "y1 está diferente."
2786
2787 #: src/plm/universe/turtles/Line.java:115
2788 msgid "y2 differs."
2789 msgstr "y2 está diferente."
2790
2791 #: src/plm/universe/turtles/Line.java:117
2792 msgid "The color differs."
2793 msgstr "A cor diverge."
2794
2795 #: src/plm/universe/turtles/Line.java:118
2796 msgid "I dont see the difference (please report this bug)."
2797 msgstr "Não veja a diferença (favor reportar este bug)."
2798
2799 #: src/plm/universe/turtles/Line.java:120
2800 msgid "That's not a line (please report this bug)."
2801 msgstr "Isto não é uma linha (favor reportar este bug)."
2802
2803 #: src/plm/universe/turtles/Turtle.java:224
2804 msgid ""
2805 "Sorry Dave, I cannot let you use brushDown() here. Turtles have pens, not "
2806 "brushes. Use penDown() instead."
2807 msgstr ""
2808 "Desculpe Dave, mas não posso deixá-lo usar brushDown() aqui. Tartarugas tem "
2809 "canetas, não pinceis. Use penDown() ao invés disto."
2810
2811 #: src/plm/universe/turtles/Turtle.java:228
2812 msgid ""
2813 "Sorry Dave, I cannot let you use brushUp() here. Turtles have pens, not "
2814 "brushes. Use penUp() instead."
2815 msgstr ""
2816 "Desculpe Dave, mas não posso deixá-lo usar brushUp() aqui. Tartarugas tem "
2817 "canetas, não pinceis. Use penUp() ao invés disto."
2818
2819 #: src/plm/universe/turtles/Turtle.java:409
2820 #, java-format
2821 msgid "The turtle {0} is not heading to the right direction."
2822 msgstr "A tartaruga {0} não está virada para a direção certa."
2823
2824 #: src/plm/universe/turtles/Turtle.java:411
2825 #, java-format
2826 msgid "The turtle {0} is at the right location."
2827 msgstr "A tartaruga {0} está no local correto."
2828
2829 #: src/plm/universe/turtles/TurtleWorld.java:359
2830 #, java-format
2831 msgid " There is {0} entities, but {1} entities were expected\n"
2832 msgstr " Existem {0} entidades, mas {1} eram esperadas\n"
2833
2834 #: src/plm/universe/turtles/TurtleWorld.java:388
2835 #, java-format
2836 msgid " There is {0} shapes, but only {1} shapes were expected\n"
2837 msgstr " Existem {0} formas, mas espera-se apenas {1}\n"
2838
2839 #: src/plm/universe/turtles/TurtleWorld.java:390
2840 #, java-format
2841 msgid " There is only {0} shapes, but {1} shapes were expected\n"
2842 msgstr " Existem apenas {0} formas, mas espera-se {1}\n"
2843
2844 #: src/plm/universe/turtles/TurtleWorld.java:417
2845 msgid "Superflous shapes in your solution:\n"
2846 msgstr "formas supérfluas na sua solução:\n"
2847
2848 #: src/plm/universe/turtles/TurtleWorld.java:422
2849 msgid "Missing shapes in your solution:\n"
2850 msgstr "Formas a faltar na sua solução:\n"
2851
2852 #: src/plm/universe/turtles/TurtleWorld.java:433
2853 #, java-format
2854 msgid " {0} (got {1} instead of {2})\n"
2855 msgstr " {0} (tem {1} ao invés de {2})\n"
66 msgid ""
77 msgstr ""
88 "Project-Id-Version: PLM mission texts\n"
9 "POT-Creation-Date: 2020-09-20 15:30+0200\n"
10 "PO-Revision-Date: 2020-09-20 15:26+0000\n"
9 "POT-Creation-Date: 2020-09-25 22:29+0200\n"
10 "PO-Revision-Date: 2020-09-25 20:38+0000\n"
1111 "Last-Translator: Martin Quinson <martin.quinson@ens-rennes.fr>\n"
1212 "Language-Team: French <https://hosted.weblate.org/projects/"
1313 "programmers-learning-machine/missions/fr/>\n"
10901090 "de plus près, la solution pour corriger les problèmes est inscrite dans ces "
10911091 "messages cryptiques. Vous verrez, avec un peu d'entraînement, vous vous y "
10921092 "habituerez."
1093
1094 #. type: Content of: <h3>
1095 #: src/lessons/welcome/environment/Environment.html:36
1096 msgid "But that's [!thelang]!"
1097 msgstr "Mais c'est du [!thelang] !"
1098
1099 #. type: Content of: outside any tag (error?)
1100 #: src/lessons/welcome/environment/Environment.html:37
1101 msgid ""
1102 "Currently, the PLM is configured to accept [!thelang] programs, but it can "
1103 "also accept [!java]Python or Scala[/!][!scala]Java or Python[/!][!"
1104 "python]Java or Scala[/!] programs. Either click on the language icon at the "
1105 "very bottom right of the window, or head to the <tt>Language/Computer</tt> "
1106 "menu item to change it."
1107 msgstr ""
1108 "Actuellement, la PLM est configurée pour traiter des programmes en [!thelang]"
1109 ", mais elle peut aussi gérer des programmes en [!java]Python ou "
1110 "Scala[/!][!scala]Java ou Python[/!][!python]Java ou Scala[/!]. Pour changer, "
1111 "cliquez sur l'icône du langage tout en bas à droite ou utilisez le menu <tt>"
1112 "Langage/Ordinateur</tt>."
10931113
10941114 #. type: Content of: outside any tag (error?)
10951115 #: src/lessons/welcome/instructions/Instructions.html:4
58535873 msgstr ""
58545874 "Pour arriver au résultat, vous devez écrire la méthode "
58555875 "<code>isFacingTrail()</code>, qui sera appelée automatiquement par la buggle "
5856 "à chaque pas. Votre méthode doit renvoyer "
5857 "[!python]True[/!][!java|scala]true[/!] (vrai) si on est face à une case "
5858 "verte, ou [!python]False[/!][!java|scala]false[/!] (faux) sinon. Bien sûr, "
5859 "si on est face à un mur, elle doit répondre faux sans se cogner. Il faut de "
5860 "plus que cette méthode soit <b>sans effet de bord</b>, c'est-à-dire qu'elle "
5861 "ne modifie ni la buggle qui l'appelle, ni le monde environnant."
5876 "à chaque pas. Votre méthode doit renvoyer [!python]True[/!][!java|"
5877 "scala]true[/!] (vrai) si on est face à une case verte, ou [!python]False[/!]"
5878 "[!java|scala]false[/!] (faux) sinon. Bien sûr, si on est face à un mur, elle "
5879 "doit répondre faux sans se cogner. Il faut de plus que cette méthode soit "
5880 "<b>sans effet de bord</b>, c'est-à-dire qu'elle ne modifie ni la buggle qui "
5881 "l'appelle, ni le monde environnant."
58625882
58635883 #. type: Content of: <p>
58645884 #: src/lessons/welcome/methods/slug/SlugTracking.html:14
1296912989 " gauche(90);\n"
1297012990 " spiral(0,90,12,3);\n"
1297112991
12992 #. type: Content of: outside any tag (error?)
12993 #: src/lessons/recursion/lego/spiral/Spiral.html:30
12994 msgid ""
12995 "Note that you only have to write the function, not the initial call. Each "
12996 "world will provide a specific set of initial parameters (use the combobox to "
12997 "switch to other worlds). For example, the \"Square Pyramid\" world will call "
12998 "your function as follows:"
12999 msgstr ""
13000 "Notez que vous n'avez que cette fonction à écrire, pas l'appel initial. "
13001 "Chaque monde fournira un ensemble spécifique de paramètres pour votre "
13002 "fonction. Utilisez le combobox en haut à droite pour voir les autres mondes. "
13003 "Par exemple, le monde \"Pyramide carrée\" appellera votre fonction de la "
13004 "manière suivante :"
13005
13006 #. type: Content of: <pre>
13007 #: src/lessons/recursion/lego/spiral/Spiral.html:36
13008 #, no-wrap
13009 msgid "spiral(100, 90, 0, 3);\n"
13010 msgstr "spiral(100, 90, 0, 3);\n"
13011
1297213012 #. type: Content of: <h2>
1297313013 #: src/lessons/recursion/lego/spiral/SpiralUse.html:2
1297413014 msgid "Drawing spirals"
55 msgid ""
66 msgstr ""
77 "Project-Id-Version: PLM\n"
8 "POT-Creation-Date: 2020-09-20 15:30+0200\n"
8 "POT-Creation-Date: 2020-09-25 22:29+0200\n"
99 "PO-Revision-Date: 2015-02-14 21:22+0100\n"
1010 "Last-Translator: vinnie <fz12345@gmail.com>\n"
1111 "Language-Team: Italian <>\n"
12071207 "soluzione per risolvere il vostro problema è scritta in mezzo a questi "
12081208 "criptici messaggi. Come vedrete, con un poco di abitudine, imparerete ad "
12091209 "usarli."
1210
1211 #. type: Content of: <h3>
1212 #: src/lessons/welcome/environment/Environment.html:36
1213 #, fuzzy
1214 #| msgid "Data in [!thelang]"
1215 msgid "But that's [!thelang]!"
1216 msgstr "Dati in [!thelang]"
1217
1218 #. type: Content of: outside any tag (error?)
1219 #: src/lessons/welcome/environment/Environment.html:37
1220 msgid ""
1221 "Currently, the PLM is configured to accept [!thelang] programs, but it can "
1222 "also accept [!java]Python or Scala[/!][!scala]Java or Python[/!][!"
1223 "python]Java or Scala[/!] programs. Either click on the language icon at the "
1224 "very bottom right of the window, or head to the <tt>Language/Computer</tt> "
1225 "menu item to change it."
1226 msgstr ""
12101227
12111228 #. type: Content of: outside any tag (error?)
12121229 #: src/lessons/welcome/instructions/Instructions.html:4
1241012427 " spiral(0,90,12,3);\n"
1241112428 msgstr ""
1241212429
12430 #. type: Content of: outside any tag (error?)
12431 #: src/lessons/recursion/lego/spiral/Spiral.html:30
12432 msgid ""
12433 "Note that you only have to write the function, not the initial call. Each "
12434 "world will provide a specific set of initial parameters (use the combobox to "
12435 "switch to other worlds). For example, the \"Square Pyramid\" world will call "
12436 "your function as follows:"
12437 msgstr ""
12438
12439 #. type: Content of: <pre>
12440 #: src/lessons/recursion/lego/spiral/Spiral.html:36
12441 #, no-wrap
12442 msgid "spiral(100, 90, 0, 3);\n"
12443 msgstr ""
12444
1241312445 #. type: Content of: <h2>
1241412446 #: src/lessons/recursion/lego/spiral/SpiralUse.html:2
1241512447 msgid "Drawing spirals"
66 msgid ""
77 msgstr ""
88 "Project-Id-Version: PACKAGE VERSION\n"
9 "POT-Creation-Date: 2020-09-20 15:30+0200\n"
9 "POT-Creation-Date: 2020-09-25 22:29+0200\n"
1010 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1111 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1212 "Language-Team: LANGUAGE <LL@li.org>\n"
10041004 "communication abilities, but it's not mean. If you look closer, the solution "
10051005 "to solve your issue is written somewhere in those cryptic messages. You will "
10061006 "see, with a bit of habit, we get used to it."
1007 msgstr ""
1008
1009 #. type: Content of: <h3>
1010 #: src/lessons/welcome/environment/Environment.html:36
1011 msgid "But that's [!thelang]!"
1012 msgstr ""
1013
1014 #. type: Content of: outside any tag (error?)
1015 #: src/lessons/welcome/environment/Environment.html:37
1016 msgid ""
1017 "Currently, the PLM is configured to accept [!thelang] programs, but it can "
1018 "also accept [!java]Python or Scala[/!][!scala]Java or "
1019 "Python[/!][!python]Java or Scala[/!] programs. Either click on the language "
1020 "icon at the very bottom right of the window, or head to the "
1021 "<tt>Language/Computer</tt> menu item to change it."
10071022 msgstr ""
10081023
10091024 #. type: Content of: outside any tag (error?)
97619776 " spiral(0,90,12,3);\n"
97629777 msgstr ""
97639778
9779 #. type: Content of: outside any tag (error?)
9780 #: src/lessons/recursion/lego/spiral/Spiral.html:30
9781 msgid ""
9782 "Note that you only have to write the function, not the initial call. Each "
9783 "world will provide a specific set of initial parameters (use the combobox to "
9784 "switch to other worlds). For example, the \"Square Pyramid\" world will call "
9785 "your function as follows:"
9786 msgstr ""
9787
9788 #. type: Content of: <pre>
9789 #: src/lessons/recursion/lego/spiral/Spiral.html:36
9790 #, no-wrap
9791 msgid "spiral(100, 90, 0, 3);\n"
9792 msgstr ""
9793
97649794 #. type: Content of: <h2>
97659795 #: src/lessons/recursion/lego/spiral/SpiralUse.html:2
97669796 msgid "Drawing spirals"
0 # SOME DESCRIPTIVE TITLE
1 # Copyright (C) YEAR Free Software Foundation, Inc.
2 # This file is distributed under the same license as the PACKAGE package.
3 # ssantos <ssantos@web.de>, 2020.
4 msgid ""
5 msgstr ""
6 "Project-Id-Version: PACKAGE VERSION\n"
7 "POT-Creation-Date: 2020-09-25 22:29+0200\n"
8 "PO-Revision-Date: 2020-10-11 16:51+0000\n"
9 "Last-Translator: ssantos <ssantos@web.de>\n"
10 "Language-Team: Portuguese <https://hosted.weblate.org/projects/"
11 "programmers-learning-machine/missions/pt/>\n"
12 "Language: pt\n"
13 "MIME-Version: 1.0\n"
14 "Content-Type: text/plain; charset=UTF-8\n"
15 "Content-Transfer-Encoding: 8bit\n"
16 "Plural-Forms: nplurals=2; plural=n > 1;\n"
17 "X-Generator: Weblate 4.3-dev\n"
18
19 #. type: Content of: <h1>
20 #: src/plm/universe/bugglequest/BuggleWorld.html:2
21 msgid "BuggleWorld"
22 msgstr "BuggleWorld"
23
24 #. type: Content of: outside any tag (error?)
25 #: src/plm/universe/bugglequest/BuggleWorld.html:3
26 msgid ""
27 "This world was invented by Lyn Turbak, at Wellesley College. It is full of "
28 "Buggles, little animals understanding simple orders, and offers numerous "
29 "possibilities of interaction with the world: taking or dropping objects, "
30 "paint the ground, hit walls, etc."
31 msgstr ""
32 "Este mundo foi inventado por Lyn Turbak, na Wellesley College. Está cheio de "
33 "Buggles, pequenos animais que entendem ordens simples e oferece numerosas "
34 "possiblidades de interação com o mundo: apanhar e soltar objetos, pintar o "
35 "chão, bater em paredes, etc."
36
37 #. type: Content of: <h2>
38 #: src/plm/universe/bugglequest/BuggleWorld.html:8
39 msgid "Methods understood by buggles"
40 msgstr "Métodos que os buggles entendem"
41
42 #. type: Content of: <table><tr><td>
43 #: src/plm/universe/bugglequest/BuggleWorld.html:10
44 msgid "<b>Moving</b>"
45 msgstr "<b>A mover</b>"
46
47 #. type: Content of: <table><tr><td>
48 #: src/plm/universe/bugglequest/BuggleWorld.html:10
49 msgid "(See also the note on exceptions, below)"
50 msgstr "(Veja também a nota sobre exceções, abaixo)"
51
52 #. type: Content of: <table><tr><td><b>
53 #: src/plm/universe/bugglequest/BuggleWorld.html:11
54 #: src/lessons/turmites/universe/TurmiteWorld.html:10
55 msgid "<b>Turn left"
56 msgstr "<b>Virar à esquerda"
57
58 #. type: Content of: <table><tr><td><b>
59 #: src/plm/universe/bugglequest/BuggleWorld.html:11
60 #: src/lessons/turmites/universe/TurmiteWorld.html:10
61 msgid "Turn right"
62 msgstr "Virar à direita"
63
64 #. type: Content of: <table><tr><td><b>
65 #: src/plm/universe/bugglequest/BuggleWorld.html:11
66 #: src/lessons/turmites/universe/TurmiteWorld.html:10
67 msgid "Turn back"
68 msgstr "Dar meia volta"
69
70 #. type: Content of: <table><tr><td><b>
71 #: src/plm/universe/bugglequest/BuggleWorld.html:11
72 #: src/lessons/turmites/universe/TurmiteWorld.html:10
73 msgid "Moving forward"
74 msgstr "Mover para a frente"
75
76 #. type: Content of: <table><tr><td>
77 #: src/plm/universe/bugglequest/BuggleWorld.html:11
78 #: src/lessons/turmites/universe/TurmiteWorld.html:10
79 msgid "Moving back</b>"
80 msgstr "Mover para trás</b>"
81
82 #. type: Content of: <table><tr><td>
83 #: src/plm/universe/bugglequest/BuggleWorld.html:12
84 #: src/lessons/turmites/universe/TurmiteWorld.html:11
85 msgid "[!java|c]void [/!]left()"
86 msgstr "[!java|c]void [/!]left()"
87
88 #. type: Content of: <table><tr><td>
89 #: src/plm/universe/bugglequest/BuggleWorld.html:13
90 #: src/lessons/turmites/universe/TurmiteWorld.html:11
91 msgid "[!java|c]void [/!]right()"
92 msgstr "[!java|c]void [/!]right()"
93
94 #. type: Content of: <table><tr><td>
95 #: src/plm/universe/bugglequest/BuggleWorld.html:14
96 #: src/lessons/turmites/universe/TurmiteWorld.html:11
97 msgid "[!java|c]void [/!]back()"
98 msgstr "[!java|c]void [/!]back()"
99
100 #. type: Content of: <table><tr><td>
101 #: src/plm/universe/bugglequest/BuggleWorld.html:15
102 msgid ""
103 "[!java|c]void [/!][!python|java|scala]forward()[/!][!c]stepForward()[/!] or "
104 "[!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])"
105 msgstr ""
106 "[!java|c]void [/!][!python|java|scala]forward()[/!][!c]stepForward()[/!] or "
107 "[!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])"
108
109 #. type: Content of: <table><tr><td>
110 #: src/plm/universe/bugglequest/BuggleWorld.html:16
111 msgid ""
112 "[!java|c]void [/!][!python|java|scala]backward()[/!][!c]stepBackward()[/!] "
113 "or [!java]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])"
114 msgstr ""
115 "[!java|c]void [/!][!python|java|scala]backward()[/!][!c]stepBackward()[/!] "
116 "or [!java]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])"
117
118 #. type: Content of: <table><tr><td><b>
119 #: src/plm/universe/bugglequest/BuggleWorld.html:17
120 msgid "<b>Get X coordinate"
121 msgstr "<b>Obter coordenada X"
122
123 #. type: Content of: <table><tr><td><b>
124 #: src/plm/universe/bugglequest/BuggleWorld.html:17
125 msgid "Get Y coordinate"
126 msgstr "Obter coordenada Y"
127
128 #. type: Content of: <table><tr><td><b>
129 #: src/plm/universe/bugglequest/BuggleWorld.html:17
130 msgid "Set X coordinate"
131 msgstr "Ajustar coordenada X"
132
133 #. type: Content of: <table><tr><td><b>
134 #: src/plm/universe/bugglequest/BuggleWorld.html:17
135 msgid "Set Y coordinate"
136 msgstr "Ajustar coordenada Y"
137
138 #. type: Content of: <table><tr><td>
139 #: src/plm/universe/bugglequest/BuggleWorld.html:17
140 msgid "Set position</b>"
141 msgstr "Ajustar posição</b>"
142
143 #. type: Content of: <table><tr><td>
144 #: src/plm/universe/bugglequest/BuggleWorld.html:18
145 msgid "[!java|c]int [/!]getX()[!scala]:Int[/!]"
146 msgstr "[!java|c]int [/!]getX()[!scala]:Int[/!]"
147
148 #. type: Content of: <table><tr><td>
149 #: src/plm/universe/bugglequest/BuggleWorld.html:19
150 msgid "[!java|c]int [/!]getY()[!scala]:Int[/!]"
151 msgstr "[!java|c]int [/!]getY()[!scala]:Int[/!]"
152
153 #. type: Content of: <table><tr><td>
154 #: src/plm/universe/bugglequest/BuggleWorld.html:20
155 msgid "[!java|c]void [/!]setX([!java|c]int [/!]x[!scala]:Int[/!])"
156 msgstr "[!java|c]void [/!]setX([!java|c]int [/!]x[!scala]:Int[/!])"
157
158 #. type: Content of: <table><tr><td>
159 #: src/plm/universe/bugglequest/BuggleWorld.html:21
160 msgid "[!java|c]void [/!]setY([!java|c]int [/!]y[!scala]:Int[/!])"
161 msgstr "[!java|c]void [/!]setY([!java|c]int [/!]y[!scala]:Int[/!])"
162
163 #. type: Content of: <table><tr><td>
164 #: src/plm/universe/bugglequest/BuggleWorld.html:22
165 msgid ""
166 "[!java|c]void [/!]setPos([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int "
167 "[/!]y[!scala]:Int[/!])"
168 msgstr ""
169 "[!java|c]void [/!]setPos([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int "
170 "[/!]y[!scala]:Int[/!])"
171
172 #. type: Content of: <table><tr><td>
173 #: src/plm/universe/bugglequest/BuggleWorld.html:23
174 msgid ""
175 "Note that the point (0,0) is on the top left corner, as it is often the case "
176 "in Computer Science."
177 msgstr ""
178 "Observe que o ponto (0,0) está no canto superior esquerdo, o que é comum em "
179 "ciência da computação."
180
181 #. type: Content of: <table><tr><td>
182 #: src/plm/universe/bugglequest/BuggleWorld.html:25
183 msgid "<b>Information on the buggle</b>"
184 msgstr "<b>Informações sobre o buggle</b>"
185
186 #. type: Content of: <table><tr><td><b>
187 #: src/plm/universe/bugglequest/BuggleWorld.html:26
188 msgid "<b>Get the color of the body"
189 msgstr "<b>Obter a cor do corpo"
190
191 #. type: Content of: <table><tr><td>
192 #: src/plm/universe/bugglequest/BuggleWorld.html:26
193 msgid "Set the color of the body</b>"
194 msgstr "Ajustar a cor do corpo</b>"
195
196 #. type: Content of: <table><tr><td>
197 #: src/plm/universe/bugglequest/BuggleWorld.html:27
198 msgid "[!java|c]Color [/!]getBodyColor()[!scala]:Color[/!]"
199 msgstr "[!java|c]Color [/!]getBodyColor()[!scala]:Color[/!]"
200
201 #. type: Content of: <table><tr><td>
202 #: src/plm/universe/bugglequest/BuggleWorld.html:28
203 msgid "[!java|c]void [/!]setBodyColor([!java|c]Color [/!]c[!scala]:Color[/!])"
204 msgstr "[!java|c]void [/!]setCorDoCorpo([!java|c]Cor [/!]c[!scala]:Cor[/!])"
205
206 #. type: Content of: <table><tr><td><b>
207 #: src/plm/universe/bugglequest/BuggleWorld.html:29
208 msgid "<b>Look for a wall forward"
209 msgstr "<b>Procura por uma parede à frente"
210
211 #. type: Content of: <table><tr><td>
212 #: src/plm/universe/bugglequest/BuggleWorld.html:29
213 msgid "Look for a wall backward</b>"
214 msgstr "Procura por uma parede atrás</b>"
215
216 #. type: Content of: <table><tr><td>
217 #: src/plm/universe/bugglequest/BuggleWorld.html:30
218 msgid "[!java]boolean [/!][!c]int [/!]isFacingWall()[!scala]:Boolean[/!]"
219 msgstr "[!java]boolean [/!][!c]int [/!]isFacingWall()[!scala]:Boolean[/!]"
220
221 #. type: Content of: <table><tr><td>
222 #: src/plm/universe/bugglequest/BuggleWorld.html:31
223 msgid "[!java]boolean [/!][!c]int [/!]isBackingWall()[!scala]:Boolean[/!]"
224 msgstr "[!java]boolean [/!][!c]int [/!]isBackingWall()[!scala]:Boolean[/!]"
225
226 #. type: Content of: <table><tr><td><b>
227 #: src/plm/universe/bugglequest/BuggleWorld.html:32
228 msgid "<b>Get heading"
229 msgstr "<b>Obter direção"
230
231 #. type: Content of: <table><tr><td>
232 #: src/plm/universe/bugglequest/BuggleWorld.html:32
233 msgid "Set heading</b>"
234 msgstr "Ajustar direção</b>"
235
236 #. type: Content of: <table><tr><td>
237 #: src/plm/universe/bugglequest/BuggleWorld.html:32
238 msgid "valid directions are:"
239 msgstr "direções válidas são:"
240
241 #. type: Content of: <table><tr><td>
242 #: src/plm/universe/bugglequest/BuggleWorld.html:33
243 msgid "[!java|c]Direction [/!]getDirection()[!scala]:Direction[/!]"
244 msgstr "[!java|c]Direction [/!]getDirection()[!scala]:Direction[/!]"
245
246 #. type: Content of: <table><tr><td>
247 #: src/plm/universe/bugglequest/BuggleWorld.html:34
248 msgid ""
249 "[!java|c]void [/!]setDirection([!java|c]Direction "
250 "[/!]dir[!scala]:Direction[/!])"
251 msgstr ""
252 "[!java|c]void [/!]ajustaDireção([!java|c]Direção [/!]dir[!scala]:Direção[/!])"
253
254 #. type: Content of: <table><tr><td>
255 #: src/plm/universe/bugglequest/BuggleWorld.html:35
256 msgid ""
257 "[!scala|java|python]Direction.[/!]NORTH, "
258 "[!scala|java|python]Direction.[/!]EAST, "
259 "[!scala|java|python]Direction.[/!]SOUTH and "
260 "[!scala|java|python]Direction.[/!]WEST"
261 msgstr ""
262 "[!scala|java|python]Direção.[/!]NORTE, [!scala|java|python]Direção.[/!]"
263 "LESTE, [!scala|java|python]Direção.[/!]SUL e "
264 "[!scala|java|python]Direção.[/!]OESTE"
265
266 #. type: Content of: <table><tr><td>
267 #: src/plm/universe/bugglequest/BuggleWorld.html:36
268 msgid "Check whether the buggle is currently <b>selected in the interface</b>"
269 msgstr "Verifica se o buggle está atualmente <b>selecionado na interface</b>"
270
271 #. type: Content of: <pre>
272 #: src/plm/universe/bugglequest/BuggleWorld.html:37
273 #: src/plm/universe/turtles/TurtleWorld.html:76
274 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:27
275 #, no-wrap
276 msgid "[!java]boolean [/!][!c]int [/!]isSelected()[!scala]:Boolean[/!]"
277 msgstr "[!java]boolean [/!][!c]int [/!]isSelected()[!scala]:Boolean[/!]"
278
279 #. type: Content of: <table><tr><td>
280 #: src/plm/universe/bugglequest/BuggleWorld.html:39
281 msgid "<b>About the brush</b>"
282 msgstr "<b>Sobre o pincel</b>"
283
284 #. type: Content of: <table><tr><td><b>
285 #: src/plm/universe/bugglequest/BuggleWorld.html:40
286 msgid "<b>Brush down"
287 msgstr "<b>Abaixar pincel"
288
289 #. type: Content of: <table><tr><td><b>
290 #: src/plm/universe/bugglequest/BuggleWorld.html:40
291 msgid "Brush up"
292 msgstr "Levantar pincel"
293
294 #. type: Content of: <table><tr><td>
295 #: src/plm/universe/bugglequest/BuggleWorld.html:40
296 msgid "Get brush position</b>"
297 msgstr "Obter a posição do pincel"
298
299 #. type: Content of: <table><tr><td>
300 #: src/plm/universe/bugglequest/BuggleWorld.html:41
301 msgid "[!java|c]void [/!]brushUp()"
302 msgstr "[!java|c]void [/!]brushUp()"
303
304 #. type: Content of: <table><tr><td>
305 #: src/plm/universe/bugglequest/BuggleWorld.html:42
306 msgid "[!java|c]void [/!]brushDown()"
307 msgstr "[!java|c]void [/!]brushDown()"
308
309 #. type: Content of: <table><tr><td>
310 #: src/plm/universe/bugglequest/BuggleWorld.html:43
311 msgid "[!java]boolean [/!][!c]int [/!]isBrushDown()[!scala]:Boolean[/!]"
312 msgstr "[!java]boolean [/!][!c]int [/!]isBrushDown()[!scala]:Boolean[/!]"
313
314 #. type: Content of: <table><tr><td><b>
315 #: src/plm/universe/bugglequest/BuggleWorld.html:44
316 msgid "<b>Change the brush color"
317 msgstr "<b>Muda a cor do pincel"
318
319 #. type: Content of: <table><tr><td>
320 #: src/plm/universe/bugglequest/BuggleWorld.html:44
321 msgid "Get the color of the brush</b>"
322 msgstr "Obtém a cor do pincel</b>"
323
324 #. type: Content of: <table><tr><td>
325 #: src/plm/universe/bugglequest/BuggleWorld.html:45
326 msgid "[!java|c]void [/!]setBrushColor([!java|c]Color [/!]c[!scala]:Color[/!])"
327 msgstr ""
328 "[!java|c]void [/!]setCorDoPincel([!java|c]Color [/!]c[!scala]:Color[/!])"
329
330 #. type: Content of: <table><tr><td>
331 #: src/plm/universe/bugglequest/BuggleWorld.html:46
332 msgid "[!java|c]Color [/!]getBrushColor()[!scala]:Color[/!]"
333 msgstr "[!java|c]Color [/!]getBrushColor()[!scala]:Color[/!]"
334
335 #. type: Content of: <table><tr><td>
336 #: src/plm/universe/bugglequest/BuggleWorld.html:48
337 msgid "<b>Interacting with the world</b>"
338 msgstr "<b>A interagir com o mundo</b>"
339
340 #. type: Content of: <table><tr><td>
341 #: src/plm/universe/bugglequest/BuggleWorld.html:49
342 #: src/lessons/turmites/universe/TurmiteWorld.html:15
343 msgid "<b>Get the color of the ground</b>"
344 msgstr "<b>Obtém a cor do chão</b>"
345
346 #. type: Content of: <table><tr><td>
347 #: src/plm/universe/bugglequest/BuggleWorld.html:50
348 #: src/lessons/turmites/universe/TurmiteWorld.html:15
349 msgid "[!java|c]Color [/!]getGroundColor()[!scala]:Color[/!]"
350 msgstr "[!java|c]Color [/!]getGroundColor()[!scala]:Color[/!]"
351
352 #. type: Content of: <table><tr><td><b>
353 #: src/plm/universe/bugglequest/BuggleWorld.html:52
354 msgid "<b>Look for a baggle on the ground"
355 msgstr "<b>Procura por um \"baggle\" no chão"
356
357 #. type: Content of: <table><tr><td><b>
358 #: src/plm/universe/bugglequest/BuggleWorld.html:52
359 msgid "Look for a baggle in bag"
360 msgstr "Procura por um \"baggle\" na bolsa"
361
362 #. type: Content of: <table><tr><td><b>
363 #: src/plm/universe/bugglequest/BuggleWorld.html:52
364 msgid "Pickup a baggle"
365 msgstr "Apanhar um \"baggle\""
366
367 #. type: Content of: <table><tr><td>
368 #: src/plm/universe/bugglequest/BuggleWorld.html:52
369 msgid "Drop a baggle</b>"
370 msgstr "Solta um \"baggle\"</b>"
371
372 #. type: Content of: <table><tr><td>
373 #: src/plm/universe/bugglequest/BuggleWorld.html:53
374 msgid "(see the note on exceptions)"
375 msgstr "(veja a nota sobre exceções)"
376
377 #. type: Content of: <table><tr><td>
378 #: src/plm/universe/bugglequest/BuggleWorld.html:54
379 msgid "[!java]boolean [/!][!c]int [/!]isOverBaggle()[!scala]:Boolean[/!]"
380 msgstr "[!java]boolean [/!][!c]int [/!]isOverBaggle()[!scala]:Boolean[/!]"
381
382 #. type: Content of: <table><tr><td>
383 #: src/plm/universe/bugglequest/BuggleWorld.html:55
384 msgid "[!java]boolean [/!][!c]int [/!]isCarryingBaggle()[!scala]:Boolean[/!]"
385 msgstr "[!java]boolean [/!][!c]int [/!]isCarryingBaggle()[!scala]:Boolean[/!]"
386
387 #. type: Content of: <table><tr><td>
388 #: src/plm/universe/bugglequest/BuggleWorld.html:56
389 msgid "[!java]void [/!]pickupBaggle()"
390 msgstr "[!java]void [/!]pickupBaggle()"
391
392 #. type: Content of: <table><tr><td>
393 #: src/plm/universe/bugglequest/BuggleWorld.html:57
394 msgid "[!java]void [/!]dropBaggle()"
395 msgstr "[!java]void [/!]dropBaggle()"
396
397 #. type: Content of: <table><tr><td>
398 #: src/plm/universe/bugglequest/BuggleWorld.html:58
399 #: src/plm/universe/bugglequest/BuggleWorld.html:70
400 #: src/plm/universe/bugglequest/BuggleWorld.html:71
401 #: src/plm/universe/bugglequest/BuggleWorld.html:72
402 #: src/plm/universe/bugglequest/BuggleWorld.html:73
403 #: src/plm/universe/bugglequest/BuggleWorld.html:74
404 #: src/plm/universe/bugglequest/BuggleWorld.html:75
405 #: src/plm/universe/bugglequest/BuggleWorld.html:76
406 #: src/plm/universe/bugglequest/BuggleWorld.html:77
407 #: src/plm/universe/bugglequest/BuggleWorld.html:78
408 #: src/plm/universe/bugglequest/BuggleWorld.html:79
409 #: src/plm/universe/bugglequest/BuggleWorld.html:80
410 #: src/plm/universe/bugglequest/BuggleWorld.html:81
411 #: src/plm/universe/bugglequest/BuggleWorld.html:82
412 #: src/lessons/welcome/Main.html:9 src/lessons/welcome/Main.html:92
413 #: src/lessons/welcome/Main.html:175 src/lessons/welcome/Main.html:255
414 #: src/lessons/welcome/Main.html:349 src/lessons/welcome/Main.html:429
415 #: src/lessons/welcome/Main.html:469
416 #: src/plm/universe/turtles/TurtleWorld.html:82
417 #: src/plm/universe/turtles/TurtleWorld.html:83
418 #: src/plm/universe/turtles/TurtleWorld.html:84
419 #: src/plm/universe/turtles/TurtleWorld.html:85
420 #: src/plm/universe/turtles/TurtleWorld.html:86
421 #: src/plm/universe/turtles/TurtleWorld.html:87
422 #: src/plm/universe/turtles/TurtleWorld.html:88
423 #: src/plm/universe/turtles/TurtleWorld.html:89
424 #: src/plm/universe/turtles/TurtleWorld.html:90
425 #: src/plm/universe/turtles/TurtleWorld.html:91
426 #: src/plm/universe/turtles/TurtleWorld.html:92
427 #: src/plm/universe/turtles/TurtleWorld.html:93
428 #: src/plm/universe/turtles/TurtleWorld.html:94
429 msgid "&nbsp;"
430 msgstr "&nbsp;"
431
432 #. type: Content of: <table><tr><td><b>
433 #: src/plm/universe/bugglequest/BuggleWorld.html:60
434 msgid "<b>Look for a message"
435 msgstr "<b>Procura por uma mensagem"
436
437 #. type: Content of: <table><tr><td><b>
438 #: src/plm/universe/bugglequest/BuggleWorld.html:60
439 msgid "Add a message"
440 msgstr "Adiciona uma mensagem"
441
442 #. type: Content of: <table><tr><td><b>
443 #: src/plm/universe/bugglequest/BuggleWorld.html:60
444 msgid "Read the message"
445 msgstr "Lê a mensagem"
446
447 #. type: Content of: <table><tr><td>
448 #: src/plm/universe/bugglequest/BuggleWorld.html:60
449 msgid "Erase the message</b>"
450 msgstr "Apaga a mensagem</b>"
451
452 #. type: Content of: <table><tr><td>
453 #: src/plm/universe/bugglequest/BuggleWorld.html:61
454 msgid "[!java]boolean [/!][!c]int [/!]isOverMessage()[!scala]:Boolean[/!]"
455 msgstr "[!java]boolean [/!][!c]int [/!]isOverMessage()[!scala]:Boolean[/!]"
456
457 #. type: Content of: <table><tr><td>
458 #: src/plm/universe/bugglequest/BuggleWorld.html:62
459 msgid ""
460 "[!java]void [/!]writeMessage([!java]String [/!][!c]char* "
461 "[/!]msg[!scala]:String[/!])"
462 msgstr ""
463 "[!java]void [/!]escreverMensagem([!java]String [/!][!c]char* "
464 "[/!]msg[!scala]:String[/!])"
465
466 #. type: Content of: <table><tr><td>
467 #: src/plm/universe/bugglequest/BuggleWorld.html:63
468 msgid "[!java]String [/!][!c]char* [/!]readMessage()[!scala]:String[/!]"
469 msgstr "[!java]String [/!][!c]char* [/!]readMessage()[!scala]:String[/!]"
470
471 #. type: Content of: <table><tr><td>
472 #: src/plm/universe/bugglequest/BuggleWorld.html:64
473 msgid "[!java]void [/!]clearMessage()"
474 msgstr "[!java]void [/!]clearMessage()"
475
476 #. type: Content of: <h2>
477 #: src/plm/universe/bugglequest/BuggleWorld.html:67
478 #: src/plm/universe/turtles/TurtleWorld.html:79
479 msgid "Valid colors"
480 msgstr "Cores válidas"
481
482 #. type: Content of: <table><tr><td>
483 #: src/plm/universe/bugglequest/BuggleWorld.html:69
484 #: src/plm/universe/turtles/TurtleWorld.html:81
485 msgid "Name"
486 msgstr "Nome"
487
488 #. type: Content of: <table><tr><td>
489 #: src/plm/universe/bugglequest/BuggleWorld.html:69
490 #: src/plm/universe/turtles/TurtleWorld.html:81
491 msgid "Color"
492 msgstr "Cor"
493
494 #. type: Content of: <table><tr><td>
495 #: src/plm/universe/bugglequest/BuggleWorld.html:70
496 #: src/plm/universe/turtles/TurtleWorld.html:82
497 msgid "[!scala|java|python]Color.[/!]black"
498 msgstr "[!scala|java|python]Cor.[/!]black"
499
500 #. type: Content of: <table><tr><td>
501 #: src/plm/universe/bugglequest/BuggleWorld.html:71
502 #: src/plm/universe/turtles/TurtleWorld.html:83
503 msgid "[!scala|java|python]Color.[/!]blue"
504 msgstr "[!scala|java|python]Cor.[/!]azul"
505
506 #. type: Content of: <table><tr><td>
507 #: src/plm/universe/bugglequest/BuggleWorld.html:72
508 #: src/plm/universe/turtles/TurtleWorld.html:84
509 msgid "[!scala|java|python]Color.[/!]cyan"
510 msgstr "[!scala|java|python]Cor.[/!]ciano"
511
512 #. type: Content of: <table><tr><td>
513 #: src/plm/universe/bugglequest/BuggleWorld.html:73
514 #: src/plm/universe/turtles/TurtleWorld.html:85
515 msgid "[!scala|java|python]Color.[/!]darkGray"
516 msgstr "[!scala|java|python]Cor.[/!]cinzentoEscuro"
517
518 #. type: Content of: <table><tr><td>
519 #: src/plm/universe/bugglequest/BuggleWorld.html:74
520 #: src/plm/universe/turtles/TurtleWorld.html:86
521 msgid "[!scala|java|python]Color.[/!]gray"
522 msgstr "[!scala|java|python]Cor.[/!]cinzento"
523
524 #. type: Content of: <table><tr><td>
525 #: src/plm/universe/bugglequest/BuggleWorld.html:75
526 #: src/plm/universe/turtles/TurtleWorld.html:87
527 msgid "[!scala|java|python]Color.[/!]green"
528 msgstr "[!scala|java|python]Cor.[/!]verde"
529
530 #. type: Content of: <table><tr><td>
531 #: src/plm/universe/bugglequest/BuggleWorld.html:76
532 #: src/plm/universe/turtles/TurtleWorld.html:88
533 msgid "[!scala|java|python]Color.[/!]lightGray"
534 msgstr "[!scala|java|python]Cor.[/!]cinzentoClaro"
535
536 #. type: Content of: <table><tr><td>
537 #: src/plm/universe/bugglequest/BuggleWorld.html:77
538 #: src/plm/universe/turtles/TurtleWorld.html:89
539 msgid "[!scala|java|python]Color.[/!]magenta"
540 msgstr "[!scala|java|python]Cor.[/!]magenta"
541
542 #. type: Content of: <table><tr><td>
543 #: src/plm/universe/bugglequest/BuggleWorld.html:78
544 #: src/plm/universe/turtles/TurtleWorld.html:90
545 msgid "[!scala|java|python]Color.[/!]orange"
546 msgstr "[!scala|java|python]Cor.[/!]laranja"
547
548 #. type: Content of: <table><tr><td>
549 #: src/plm/universe/bugglequest/BuggleWorld.html:79
550 #: src/plm/universe/turtles/TurtleWorld.html:91
551 msgid "[!scala|java|python]Color.[/!]pink"
552 msgstr "[!scala|java|python]Cor.[/!]rosa"
553
554 #. type: Content of: <table><tr><td>
555 #: src/plm/universe/bugglequest/BuggleWorld.html:80
556 #: src/plm/universe/turtles/TurtleWorld.html:92
557 msgid "[!scala|java|python]Color.[/!]red"
558 msgstr "[!scala|java|python]Cor.[/!]vermelho"
559
560 #. type: Content of: <table><tr><td>
561 #: src/plm/universe/bugglequest/BuggleWorld.html:81
562 #: src/plm/universe/turtles/TurtleWorld.html:93
563 msgid "[!scala|java|python]Color.[/!]white"
564 msgstr "[!scala|java|python]Cor.[/!]branco"
565
566 #. type: Content of: <table><tr><td>
567 #: src/plm/universe/bugglequest/BuggleWorld.html:82
568 #: src/plm/universe/turtles/TurtleWorld.html:94
569 msgid "[!scala|java|python]Color.[/!]yellow"
570 msgstr "[!scala|java|python]Cor.[/!]amarelo"
571
572 #. type: Content of: <h2>
573 #: src/plm/universe/bugglequest/BuggleWorld.html:85
574 msgid "Note on exceptions"
575 msgstr "Nota sobre exceções"
576
577 #. type: Content of: outside any tag (error?)
578 #: src/plm/universe/bugglequest/BuggleWorld.html:86
579 msgid ""
580 "Regular buggles throw a BuggleWallException exception if you ask them to "
581 "traverse a wall. They throw a NoBaggleUnderBuggleException exception if you "
582 "ask them to pickup a baggle from an empty cell, or a "
583 "AlreadyHaveBaggleException exception if they already carry a baggle. Trying "
584 "to drop a baggle on a cell already containing one throws an "
585 "AlreadyHaveBaggleException exception. Dropping a baggle when you have none "
586 "throws a DontHaveBaggleException."
587 msgstr ""
588 "Buggles normais lançam uma exceção BuggleWallException se os pede atravessar "
589 "uma parede. Lançam uma exceção NoBaggleUnderBuggleException se os pede "
590 "tirar um \"baggle\" de uma célula vazia, ou uma exceção "
591 "AlreadyHaveBaggleException se eles já carregam um \"baggle\". Tentar soltar "
592 "um \"baggle\" numa célula que já contém outro lança uma exceção "
593 "AlreadyHaveBaggleException. Soltar um \"baggle\" quando não tem nenhum "
594 "lança uma DontHaveBaggleException."
595
596 #. type: Content of: <p>
597 #: src/plm/universe/bugglequest/BuggleWorld.html:93
598 msgid ""
599 "SimpleBuggles (ie, the one used in first exercises) display an error message "
600 "on problem so that you don't need to know what an exception is."
601 msgstr ""
602 "SimpleBuggles (ie, aqueles usados nos primeiros exercícios) exibem uma "
603 "mensagem de erro num problema de forma que não precise saber o que é uma "
604 "exceção."
605
606 #. type: Content of: <h1>
607 #: src/plm/universe/bat/BatWorld.html:2
608 msgid "BatWorld"
609 msgstr "BatWorld"
610
611 #. type: Content of: <p>
612 #: src/plm/universe/bat/BatWorld.html:4
613 msgid ""
614 "This world is a simplistic testing environment largely inspired from the "
615 "http://codingbat.com invented by Nick Parlente."
616 msgstr ""
617 "Este mundo é um ambiente de testes simplista largamente inspirado no http://"
618 "codingbat.com criado por Nick Parlente."
619
620 #. type: Content of: <p>
621 #: src/plm/universe/bat/BatWorld.html:7
622 msgid ""
623 "The typical exercises are very short ones, aiming at improving the tactical "
624 "programming abilities of the students. That is to say that you will be "
625 "presented a quite long list of very little exercises about rather simple "
626 "things. The idea is to train you on these issues until they become automatic "
627 "to you."
628 msgstr ""
629 "Os exercícios são bem curtos e têm como objetivo melhorar as habilidades de "
630 "programação tática dos estudantes. Isto significa que irá ser apresentado a "
631 "uma longa lista de pequenos exercícios sobre coisas simples. A ideia é "
632 "treinar estes aspectos simples até que eles fiquem automáticos para si."
633
634 #. type: Content of: <p>
635 #: src/plm/universe/bat/BatWorld.html:13
636 msgid ""
637 "In contrary to the other worlds, the BatWorld does not provide any fancy "
638 "abstraction nor visualization. You have to fill a function, which gets "
639 "called for a bunch of parameter sets, and that's it."
640 msgstr ""
641 "Ao contrário dos outros mundos, o \"BatWorld\" não fornece qualquer "
642 "abstração ou visualização legal. Tem simplesmente que preencher uma função, "
643 "que é chamada com um conjunto de parâmetros e é isto."
644
645 #. type: Content of: <p>
646 #: src/plm/universe/bat/BatWorld.html:17
647 msgid ""
648 "For more information, you should refer to the CodingBat.com documentation, "
649 "which contains for example a very useful documentation on boolean operators: "
650 "http://codingbat.com/doc/ifboolean.html"
651 msgstr ""
652 "Para mais informações, deve consultar a documentação do CodingBat.com, que "
653 "contém por exemplo uma documentação sobre operadores booleanos bem útil: "
654 "http://codingbat.com/doc/ifboolean.html"
655
656 #. type: Content of: <h3>
657 #: src/lessons/welcome/Main.html:2 src/lessons/welcome/short_desc.html:2
658 msgid "First steps"
659 msgstr "Primeiros passos"
660
661 #. type: Content of: outside any tag (error?)
662 #: src/lessons/welcome/Main.html:4
663 msgid ""
664 "This first lesson will lead your first steps in programming. It is intended "
665 "for beginners. List of seen notions per exercise:"
666 msgstr ""
667 "A primeira lição vai te guiar pelos primeiros passos em programação. Ela é "
668 "feita para iniciantes. Lista de noções vistas por exercício:"
669
670 #. type: Content of: <h2>
671 #: src/lessons/welcome/Main.html:10 src/lessons/welcome/Main.html:93
672 #: src/lessons/welcome/Main.html:176 src/lessons/welcome/Main.html:256
673 #: src/lessons/welcome/Main.html:350 src/lessons/welcome/Main.html:430
674 #: src/lessons/welcome/Main.html:470
675 #: src/lessons/welcome/instructions/Instructions.html:2
676 msgid "Instructions"
677 msgstr "Instruções"
678
679 #. type: Content of: <table><tr><td>
680 #: src/lessons/welcome/Main.html:11 src/lessons/welcome/Main.html:94
681 #: src/lessons/welcome/Main.html:177 src/lessons/welcome/Main.html:257
682 #: src/lessons/welcome/Main.html:351 src/lessons/welcome/Main.html:431
683 #: src/lessons/welcome/Main.html:471
684 msgid "Comments"
685 msgstr "Comentários"
686
687 #. type: Content of: <table><tr><td>
688 #: src/lessons/welcome/Main.html:12 src/lessons/welcome/Main.html:95
689 #: src/lessons/welcome/Main.html:178 src/lessons/welcome/Main.html:258
690 #: src/lessons/welcome/Main.html:352 src/lessons/welcome/Main.html:432
691 #: src/lessons/welcome/Main.html:472
692 msgid "Conditionals/ Expressions"
693 msgstr "Condicionais/ Expressões"
694
695 #. type: Content of: <h2>
696 #: src/lessons/welcome/Main.html:13 src/lessons/welcome/Main.html:79
697 #: src/lessons/welcome/Main.html:96 src/lessons/welcome/Main.html:179
698 #: src/lessons/welcome/Main.html:259 src/lessons/welcome/Main.html:353
699 #: src/lessons/welcome/Main.html:433 src/lessons/welcome/Main.html:473
700 #: src/lessons/welcome/loopwhile/LoopWhile.html:2
701 msgid "While loops"
702 msgstr "Loops while (enquanto)"
703
704 #. type: Content of: <table><tr><td>
705 #: src/lessons/welcome/Main.html:14 src/lessons/welcome/Main.html:97
706 #: src/lessons/welcome/Main.html:180 src/lessons/welcome/Main.html:260
707 #: src/lessons/welcome/Main.html:354 src/lessons/welcome/Main.html:434
708 #: src/lessons/welcome/Main.html:474
709 msgid "Variables"
710 msgstr "Variáveis"
711
712 #. type: Content of: <h2>
713 #: src/lessons/welcome/Main.html:15 src/lessons/welcome/Main.html:98
714 #: src/lessons/welcome/Main.html:134 src/lessons/welcome/Main.html:181
715 #: src/lessons/welcome/Main.html:261 src/lessons/welcome/Main.html:355
716 #: src/lessons/welcome/Main.html:435 src/lessons/welcome/Main.html:475
717 #: src/lessons/welcome/loopfor/LoopFor.html:2
718 msgid "For loops"
719 msgstr "Loops for"
720
721 #. type: Content of: <table><tr><td>
722 #: src/lessons/welcome/Main.html:16 src/lessons/welcome/Main.html:99
723 #: src/lessons/welcome/Main.html:182 src/lessons/welcome/Main.html:262
724 #: src/lessons/welcome/Main.html:356 src/lessons/welcome/Main.html:436
725 #: src/lessons/welcome/Main.html:476
726 msgid "Do/While loops"
727 msgstr "loops Do/While (faça/enquanto)"
728
729 #. type: Content of: <h2>
730 #: src/lessons/welcome/Main.html:17 src/lessons/welcome/Main.html:100
731 #: src/lessons/welcome/Main.html:162 src/lessons/welcome/Main.html:183
732 #: src/lessons/welcome/Main.html:263 src/lessons/welcome/Main.html:357
733 #: src/lessons/welcome/Main.html:437 src/lessons/welcome/Main.html:477
734 #: src/lessons/welcome/methods/basics/Methods.html:2
735 msgid "Methods"
736 msgstr "Métodos"
737
738 #. type: Content of: <table><tr><td>
739 #: src/lessons/welcome/Main.html:18 src/lessons/welcome/Main.html:101
740 #: src/lessons/welcome/Main.html:184 src/lessons/welcome/Main.html:264
741 #: src/lessons/welcome/Main.html:358 src/lessons/welcome/Main.html:438
742 #: src/lessons/welcome/Main.html:478
743 msgid "Switch"
744 msgstr "Switch"
745
746 #. type: Content of: <table><tr><td>
747 #: src/lessons/welcome/Main.html:19 src/lessons/welcome/Main.html:102
748 #: src/lessons/welcome/Main.html:185 src/lessons/welcome/Main.html:265
749 #: src/lessons/welcome/Main.html:359 src/lessons/welcome/Main.html:439
750 #: src/lessons/welcome/Main.html:479
751 msgid "Arrays"
752 msgstr "Arrays"
753
754 #. type: Content of: <table><tr><td>
755 #: src/lessons/welcome/Main.html:23
756 msgid "Welcome in the Buggles' World"
757 msgstr "Bem-vindo ao mundo dos Buggles"
758
759 #. type: Content of: <table><tr><td>
760 #: src/lessons/welcome/Main.html:37
761 msgid "Java Instructions"
762 msgstr "Instruções Java"
763
764 #. type: Content of: <h2>
765 #: src/lessons/welcome/Main.html:51
766 #: src/lessons/welcome/instructions/InstructionsDrawG.html:2
767 msgid "Writing more complex programs"
768 msgstr "A escrever programas mais complexos"
769
770 #. type: Content of: <h2>
771 #: src/lessons/welcome/Main.html:65
772 #: src/lessons/welcome/conditions/Conditions.html:2
773 msgid "Conditional instructions"
774 msgstr "Instruções condicionais"
775
776 #. type: Content of: <h2>
777 #: src/lessons/welcome/Main.html:106
778 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:2
779 msgid "Baggle Seeking"
780 msgstr "A procurar Baggles"
781
782 #. type: Content of: <h2>
783 #: src/lessons/welcome/Main.html:120
784 #: src/lessons/welcome/variables/Variables.html:2
785 msgid "Storing and manipulating data"
786 msgstr "A armazenar e a manipular dados"
787
788 #. type: Content of: <h2>
789 #: src/lessons/welcome/Main.html:148
790 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:2
791 msgid "Do .. while loops"
792 msgstr "Loops Do .. while (faça .. enquanto)"
793
794 #. type: Content of: <h2>
795 #: src/lessons/welcome/Main.html:188
796 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:2
797 msgid "Building methodically"
798 msgstr "Construir metodicamente"
799
800 #. type: Content of: <table><tr><td>
801 #: src/lessons/welcome/Main.html:202
802 msgid "Methods returning a result"
803 msgstr "Métodos a retornar um resultado"
804
805 #. type: Content of: <h2>
806 #: src/lessons/welcome/Main.html:215
807 #: src/lessons/welcome/methods/args/MethodsArgs.html:2
808 msgid "Methods with parameters"
809 msgstr "Métodos com perâmetros"
810
811 #. type: Content of: <h2>
812 #: src/lessons/welcome/Main.html:229
813 #: src/lessons/welcome/methods/picture/PictureMono1.html:2
814 msgid "Methodically drawing"
815 msgstr "Desenhar metodicamente"
816
817 #. type: Content of: <h2>
818 #: src/lessons/welcome/Main.html:242
819 #: src/lessons/welcome/methods/picture/PictureMono2.html:2
820 msgid "Methodically drawing (only bigger)"
821 msgstr "Desenhar metodicamente (apenas grande)"
822
823 #. type: Content of: <h2>
824 #: src/lessons/welcome/Main.html:268
825 #: src/lessons/welcome/methods/picture/PictureMono3.html:2
826 msgid "Drawing bigger and bigger"
827 msgstr "Desenhar maior e maior"
828
829 #. type: Content of: <table><tr><td>
830 #: src/lessons/welcome/Main.html:281
831 msgid "Even more pattern to draw"
832 msgstr "Mais padrões para desenhar"
833
834 #. type: Content of: <table><tr><td>
835 #: src/lessons/welcome/Main.html:295
836 msgid "Buggle Dance Revolution"
837 msgstr "Buggle Dance Revolution"
838
839 #. type: Content of: <table><tr><td>
840 #: src/lessons/welcome/Main.html:309
841 msgid "Buggle Dance Revolution 2"
842 msgstr "Buggle Dance Revolution 2"
843
844 #. type: Content of: <h2>
845 #: src/lessons/welcome/Main.html:323
846 #: src/lessons/welcome/methods/slug/SlugHunting.html:2
847 msgid "Slug Hunting"
848 msgstr "Caça à lesma"
849
850 #. type: Content of: <h2>
851 #: src/lessons/welcome/Main.html:336
852 #: src/lessons/welcome/methods/slug/SlugTracking.html:2
853 msgid "Slug Tracking"
854 msgstr "Rastrear a lesma"
855
856 #. type: Content of: <h2>
857 #: src/lessons/welcome/Main.html:362 src/lessons/welcome/traversal/Snake.html:2
858 msgid "Snake World"
859 msgstr "Mundo das cobras"
860
861 #. type: Content of: <table><tr><td>
862 #: src/lessons/welcome/Main.html:376
863 msgid "Knitting and Arrays"
864 msgstr "tricô e Arrays"
865
866 #. type: Content of: <table><tr><td>
867 #: src/lessons/welcome/Main.html:390
868 msgid "Knitting, Arrays and modulos"
869 msgstr "tricô, arrays e módulos"
870
871 #. type: Content of: <h2>
872 #: src/lessons/welcome/Main.html:403
873 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:2
874 msgid "Traversal by column"
875 msgstr "Percorrer pelas colunas"
876
877 #. type: Content of: <h2>
878 #: src/lessons/welcome/Main.html:416
879 #: src/lessons/welcome/traversal/line/TraversalByLine.html:2
880 msgid "Traversal by line"
881 msgstr "Percorrer pelas linhas"
882
883 #. type: Content of: <h2>
884 #: src/lessons/welcome/Main.html:442
885 #: src/lessons/welcome/traversal/zigzag/TraversalZigZag.html:2
886 msgid "Zig-zag traversal"
887 msgstr "Percorrer em zig-zag"
888
889 #. type: Content of: <h2>
890 #: src/lessons/welcome/Main.html:455
891 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:2
892 msgid "Diagonal Traversal"
893 msgstr "Percorrer na diagonal"
894
895 #. type: Content of: <h2>
896 #: src/lessons/welcome/Main.html:483
897 msgid "Meaning of the symbols"
898 msgstr "Significado dos símbolos"
899
900 #. type: Content of: <table><tr><td>
901 #: src/lessons/welcome/Main.html:486
902 msgid "Introducing the concept"
903 msgstr "Introduzir o conceito"
904
905 #. type: Content of: <table><tr><td>
906 #: src/lessons/welcome/Main.html:489
907 msgid "Working on the concept"
908 msgstr "Trabalhar no conceito"
909
910 #. type: Content of: <table><tr><td>
911 #: src/lessons/welcome/Main.html:492
912 msgid "Concept assumed mastered"
913 msgstr "Conceito tido como dominado"
914
915 #. type: Content of: <table><tr><td>
916 #: src/lessons/welcome/Main.html:495
917 msgid "Concept not mandated by the exercise"
918 msgstr "Conceito não é obrigatório para o exercício"
919
920 #. type: Content of: <h2>
921 #: src/lessons/welcome/Main.html:501
922 msgid "What will I learn?"
923 msgstr "O que irei aprender?"
924
925 #. type: Content of: <p>
926 #: src/lessons/welcome/Main.html:502
927 msgid ""
928 "You will learn the very basics of programming. At least, you will be "
929 "presented the most important concepts, allowing you to read most simple "
930 "algorithms. You will not be able to write or read full programs because you "
931 "will still not know about objects, but you will master what is called "
932 "\"Tactical programming\", meaning that you will master the syntax enough to "
933 "not have any issue with it, allowing you to focus on the fundamental "
934 "problems of what you want to solve instead of struggling with syntactic "
935 "difficulties."
936 msgstr ""
937 "Irá aprender o básico de programação. pelo menos, irá ser apresentado aos "
938 "mais importantes conceitos, a permitir que leia a maioria dos algoritmos "
939 "simples. Não será capaz de escrever ou ler programas completos por que ainda "
940 "não saberá nada sobre objetos, mas irá dominar o que é chamado de "
941 "\"programação tática\", ou seja, vai dominar a sintaxe o suficiente para não "
942 "ter qualquer problema com ela, a permitir que foque nos problemas "
943 "funcamentais que quer resolver ao invés de se debater com dificuldades de "
944 "sintaxe."
945
946 #. type: Content of: <p>
947 #: src/lessons/welcome/short_desc.html:3
948 msgid ""
949 "This first lesson will lead your first steps in programming. It is intended "
950 "for beginners."
951 msgstr ""
952 "Esta primeira lição vai guiar-lo pelos primeiros passos em programação. Ela "
953 "foi feita para iniciantes."
954
955 #. type: Content of: <p>
956 #: src/lessons/welcome/short_desc.html:6
957 msgid ""
958 "If you are not sure, go for this lesson that will teach you the bases of "
959 "programming."
960 msgstr ""
961 "Se está perdido, venha para esta lição que ela irá te ensinar as bases da "
962 "programação."
963
964 #. type: Content of: <h2>
965 #: src/lessons/welcome/environment/Environment.html:3
966 msgid "Welcome to the PLM"
967 msgstr "Bem-vindo ao PLM"
968
969 #. type: Content of: <p>
970 #: src/lessons/welcome/environment/Environment.html:5
971 msgid ""
972 "The goal of this first exercise is to instruct your buggle to move forward "
973 "by one step. Switch between the views on the right for more "
974 "info. <i>World</i> depicts the world as it is now, while <i>Objective</i> "
975 "depicts what you should get."
976 msgstr ""
977 "O objectivo deste primeiro exercício é instruir o seu buggle para avançar um "
978 "passo. Alterne entre as vistas à direita para mais informações. O <i>Mundo</"
979 "i> retrata o mundo como é agora, enquanto o <i>Objetivo</i> retrata o que "
980 "deve obter."
981
982 #. type: Content of: <h3>
983 #: src/lessons/welcome/environment/Environment.html:10
984 msgid "My <i>buggle</i>? What is this??"
985 msgstr "O que é o meu <i>buggle</i>?"
986
987 #. type: Content of: <p>
988 #: src/lessons/welcome/environment/Environment.html:12
989 msgid ""
990 "Buggles are little animals obeying any order you may give them. Currently, "
991 "you must use the [!thelang/] programming language for that, but you can "
992 "change the language from the menu, or by clicking the icon in the status "
993 "bar."
994 msgstr ""
995 "Os buggles são pequenos animais que obedecem todas as suas ordens. "
996 "Atualmente, deve usar a linguagem de programação [!thelang/] para isso, mas "
997 "pode mudar a linguagem a partir do menu, ou a clicar no ícone na barra de "
998 "estado."
999
1000 #. type: Content of: <h3>
1001 #: src/lessons/welcome/environment/Environment.html:17
1002 msgid "How to proceed?"
1003 msgstr "Como proceder?"
1004
1005 #. type: Content of: <p>
1006 #: src/lessons/welcome/environment/Environment.html:19
1007 msgid "Write your program in the \"Code\" pane. It should read as follows:"
1008 msgstr ""
1009 "Escreva o seu programa no painel \"Código\". Deve ser lido da seguinte forma:"
1010
1011 #. type: Content of: <pre>
1012 #: src/lessons/welcome/environment/Environment.html:20
1013 #: src/lessons/welcome/instructions/Instructions.html:53
1014 #, no-wrap
1015 msgid "[!java|scala|python]forward()[!java];[/!][/!][!c]stepForward();[/!]"
1016 msgstr "[!java|scala|python]forward()[!java];[/!][/!][!c]stepForward();[/!]"
1017
1018 #. type: Content of: outside any tag (error?)
1019 #: src/lessons/welcome/environment/Environment.html:21
1020 #: src/lessons/welcome/loopfor/LoopFor.html:57
1021 #: src/lessons/welcome/bdr/BDR.html:189
1022 msgid "[!java|c]"
1023 msgstr "[!java|c]"
1024
1025 #. type: Content of: <p>
1026 #: src/lessons/welcome/environment/Environment.html:21
1027 msgid ""
1028 "Do not forget the final <code>;</code> which tells the compiler that the "
1029 "instruction is over (yes, computers are so dumb that they cannot "
1030 "<i>guess</i> obvious stuff like this)."
1031 msgstr ""
1032 "Não se esqueça do <code>;</code> final que diz ao compilador que a instrução "
1033 "está encerrada (sim, o computador é tão bobo que não consegue <i>adivinhar</"
1034 "i> coisas óbvias como isto)."
1035
1036 #. type: Content of: outside any tag (error?)
1037 #: src/lessons/welcome/environment/Environment.html:23
1038 #: src/lessons/welcome/variables/Variables.html:78
1039 #: src/lessons/welcome/variables/Variables.html:152
1040 #: src/lessons/welcome/loopfor/LoopFor.html:80
1041 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:54
1042 #: src/lessons/welcome/loopdowhile/Poucet2.html:25
1043 #: src/lessons/welcome/array/basics/Array1.html:183
1044 #: src/lessons/welcome/array/basics/Array1.html:209
1045 #: src/lessons/welcome/methods/args/MethodsArgs.html:66
1046 #: src/lessons/welcome/methods/picture/MethodsPicture.html:40
1047 #: src/lessons/welcome/bdr/BDR.html:61 src/lessons/welcome/bdr/BDR.html:196
1048 #: src/lessons/welcome/bdr/BDR2.html:130
1049 #: src/lessons/turmites/langton/Langton.html:32
1050 #: src/lessons/turmites/helloturmite/HelloTurmite.html:65
1051 #: src/lessons/sort/basic/comb/AlgCombSort.html:39
1052 #: src/lessons/recursion/cons/universe/ConsWorld.html:35
1053 #: src/lessons/recursion/cons/Length.html:8
1054 #: src/lessons/recursion/lego/square/FourSquare.html:46
1055 #: src/lessons/maze/pledge/PledgeMaze.html:68
1056 #: src/lessons/welcome/bat/bool1/Max1020.html:6
1057 msgid "[/!]"
1058 msgstr "[/!]"
1059
1060 #. type: Content of: <p>
1061 #: src/lessons/welcome/environment/Environment.html:25
1062 msgid "Once done, click on Run to execute your code."
1063 msgstr "Quando feito, clique em Executar para executar o seu código."
1064
1065 #. type: Content of: <p>
1066 #: src/lessons/welcome/environment/Environment.html:27
1067 msgid ""
1068 "If your code contains errors, that's perfectly OK: Even talented programmers "
1069 "struggle on their code. The computer will display error messages in the "
1070 "console to help you fixing them. These messages may sound scary at first "
1071 "glance, but don't panic. The compiler is only somehow limited in its "
1072 "communication abilities, but it's not mean. If you look closer, the solution "
1073 "to solve your issue is written somewhere in those cryptic messages. You will "
1074 "see, with a bit of habit, we get used to it."
1075 msgstr ""
1076 "Se o seu código contém erros, tudo bem: até os programadores talentosos "
1077 "lutam com o seu código. O computador exibirá mensagens de erro na consola "
1078 "para o ajudar a corrigi-los. Estas mensagens podem parecer assustadoras à "
1079 "primeira vista, mas não entre em pânico. O compilador é apenas de alguma "
1080 "forma limitado nas suas habilidades de comunicação, mas não é mau. Se olhar "
1081 "mais de perto, a solução para resolver o seu problema está escrita em algum "
1082 "lugar nessas mensagens crípticas. Verá, com um pouco de hábito, que nos "
1083 "acostumamos a isso."
1084
1085 #. type: Content of: <h3>
1086 #: src/lessons/welcome/environment/Environment.html:36
1087 msgid "But that's [!thelang]!"
1088 msgstr "Mas isso é [!thelang]!"
1089
1090 #. type: Content of: outside any tag (error?)
1091 #: src/lessons/welcome/environment/Environment.html:37
1092 msgid ""
1093 "Currently, the PLM is configured to accept [!thelang] programs, but it can "
1094 "also accept [!java]Python or Scala[/!][!scala]Java or "
1095 "Python[/!][!python]Java or Scala[/!] programs. Either click on the language "
1096 "icon at the very bottom right of the window, or head to the "
1097 "<tt>Language/Computer</tt> menu item to change it."
1098 msgstr ""
1099 "Atualmente, o PLM está configurado para aceitar programas [!thelang], mas "
1100 "também pode aceitar programas [!java]Python ou Scala[/!][!scala]Java ou "
1101 "Python[/!][!python]Java ou Scala[/!]. Clique no ícone da linguagem no canto "
1102 "inferior direito da janela, ou vá para o item de menu <tt>Language/Computer</"
1103 "tt> para mudá-lo."
1104
1105 #. type: Content of: outside any tag (error?)
1106 #: src/lessons/welcome/instructions/Instructions.html:4
1107 msgid ""
1108 "Congratulations! You just wrote your first program! You got the idea now: "
1109 "programming is nothing more than giving simple instructions to the computer "
1110 "that blindly apply them. The main difficulty is to explain stuff to "
1111 "something as stupid as a computer..."
1112 msgstr ""
1113 "Parabéns! Acaba de escrever o seu primeiro programa! Agora captou a ideia: "
1114 "programar é nada mais que dar instruções simples ao computador, que as "
1115 "realiza cegamente. A maior dificuldade é explicar tudo para algo tão idiota "
1116 "quanto um computador..."
1117
1118 #. type: Content of: <p>
1119 #: src/lessons/welcome/instructions/Instructions.html:9
1120 msgid ""
1121 "Our second program will be a bit more complicated, but not much. The goal "
1122 "for your buggle is simply to draw a house (a box), and hide inside. Check "
1123 "the objective world to see exactly what this means."
1124 msgstr ""
1125 "O nosso segundo programa vai ser um pouco mais complicado, mas não muito. O "
1126 "objetivo do seu buggle é simplesmente desenhar uma casa (uma caixa) e "
1127 "esconder-se dentro dela. Confira o mundo objetivo para ver exatamente o que "
1128 "isso significa."
1129
1130 #. type: Content of: <p>
1131 #: src/lessons/welcome/instructions/Instructions.html:14
1132 msgid ""
1133 "For that, you will need <code>forward()</code>, <code>left()</code> and "
1134 "<code>right()</code>. Use your brush to mark the ground as you walk. Start "
1135 "marking the ground with <code>brushDown()</code>, and stop it with "
1136 "<code>brushUp()</code> afterward (e.g., to enter your house without marking "
1137 "its ground)."
1138 msgstr ""
1139 "Para isso, vai precisar de <code>forward()</code>, <code>left()</code> e "
1140 "<code>right()</code>. Use o seu pincel para marcar o chão enquanto anda. "
1141 "Comece a marcar o chão com <code>brushDown()</code> e pare com "
1142 "<code>brushUp()</code> depois (por exemplo, para entrar na sua casa sem "
1143 "marcar o chão)."
1144
1145 #. type: Content of: <h3>
1146 #: src/lessons/welcome/instructions/Instructions.html:20
1147 msgid "What exactly is a program?"
1148 msgstr "O que exatamente é um programa?"
1149
1150 #. type: Content of: <p>
1151 #: src/lessons/welcome/instructions/Instructions.html:22
1152 msgid ""
1153 "Programs are mainly suites of method calls, which are no more than a list of "
1154 "simple orders given to the machine. It is very similar to a recipe stating "
1155 "<i>Melt the chocolate pieces, add sugar, cool the mix and serve</i>. "
1156 "[!thelang] wants to have the instructions separated by semi-columns "
1157 "(;)[!python|scala] or by new lines[/!], and followed by parenthesis. Our "
1158 "little receipe would thus be written in the following way[!python|scala] "
1159 "(you can also add semi-columns at the end of the lines, but this is not "
1160 "mandatory)[/!]."
1161 msgstr ""
1162 "Os programas são principalmente conjuntos de chamadas de métodos, que não "
1163 "são mais que uma lista de ordens simples dadas à máquina. É como uma receita "
1164 "que diz <i>Derreter os pedaços de chocolate, adicionar açúcar, esfriar a "
1165 "mistura e servir</i>. [!thelang] quer ter as instruções separadas por "
1166 "ponto-e-virgula (;)[!python|scala] ou por novas linhas[/!], seguidas de "
1167 "parênteses. A nossa pequena receita seria assim escrita da seguinte "
1168 "forma[!python|scala] (também pode adicionar ponto-e-virgula no final das "
1169 "linhas, mas isso não é obrigatório)[/!]."
1170
1171 #. type: Content of: <pre>
1172 #: src/lessons/welcome/instructions/Instructions.html:33
1173 #, no-wrap
1174 msgid ""
1175 "meltTheChocolatePieces()[!java|c];[/!]\n"
1176 "addSugar()[!java|c];[/!]\n"
1177 "coolMix()[!java|c];[/!]\n"
1178 "serve()[!java|c];[/!]\n"
1179 msgstr ""
1180 "meltTheChocolatePieces()[!java|c];[/!]\n"
1181 "addSugar()[!java|c];[/!]\n"
1182 "coolMix()[!java|c];[/!]\n"
1183 "serve()[!java|c];[/!]\n"
1184
1185 #. type: Content of: <p>
1186 #: src/lessons/welcome/instructions/Instructions.html:39
1187 msgid ""
1188 "Do not write it all on one line only even if the computer would accept it "
1189 "[!python|scala](provided that you don't omit the semi-columns)[/!]. This is "
1190 "a <b>really bad idea</b>, hindering the readability. <i>Programs must be "
1191 "written for people to read, and only incidentally for machines to "
1192 "execute,</i> as said Harold Abelson."
1193 msgstr ""
1194 "Não escreva tudo numa só linha, mesmo que o computador o aceite "
1195 "[!python|scala](desde que não omita ponto-e-virgulas)[/!]. Esta é uma "
1196 "<b>péssima idéia</b>, que dificulta a legibilidade. <i>Programas devem ser "
1197 "escritos para pessoas as lerem e apenas incidentalmente para as máquinas "
1198 "executarem,</i> como disse Harold Abelson."
1199
1200 #. type: Content of: <p>
1201 #: src/lessons/welcome/instructions/Instructions.html:46
1202 msgid ""
1203 "There is a limited set of instructions that buggles understand, and we will "
1204 "eventually learn how to define new ones. For now, there is a method for each "
1205 "button of the interactive control panel. To achieve the same effect than the "
1206 "<b>forward</b> button (making the buggle moving one step forward), you need "
1207 "to write the following in the editor:"
1208 msgstr ""
1209 "Há um conjunto limitado de instruções que os buggles entendem e "
1210 "eventualmente aprenderemos a definir novas instruções. Por enquanto, existe "
1211 "um método para cada botão do painel de controle interativo. Para alcançar o "
1212 "mesmo efeito que o botão <b>forward</b> (a fazer o buggle mover um passo à "
1213 "frente), precisa escrever o seguinte no editor:"
1214
1215 #. type: Content of: <p>
1216 #: src/lessons/welcome/instructions/Instructions.html:54
1217 msgid ""
1218 "Likewise, to achieve the same effect than the "
1219 "<b>[!java|scala|python]backward[/!][!c]stepBackward[/!]</b>, <b>left</b> and "
1220 "<b>right</b> buttons, you need to use respectively:"
1221 msgstr ""
1222 "Da mesma forma, para obter o mesmo efeito que os botões "
1223 "<b>[!java|scala|python]recuar[/!][!c]recuarUmPasso[/!]</b>, <b>esquerda</b> "
1224 "e <b>direita</b>, precisa respetivamente:"
1225
1226 #. type: Content of: <pre>
1227 #: src/lessons/welcome/instructions/Instructions.html:58
1228 #, no-wrap
1229 msgid ""
1230 "backward()[!java|c];[/!]\n"
1231 "left()[!java|c];[/!]\n"
1232 "right()[!java|c];[/!]\n"
1233 msgstr ""
1234 "backward()[!java|c];[/!]\n"
1235 "left()[!java|c];[/!]\n"
1236 "right()[!java|c];[/!]\n"
1237
1238 #. type: Content of: <p>
1239 #: src/lessons/welcome/instructions/Instructions.html:63
1240 msgid ""
1241 "The <b>mark</b> button is a bit particular, since it correspond to two "
1242 "methods: the first one moves the pen up while the second moves it down."
1243 msgstr ""
1244 "O botão <b>marcar</b> é diferente, pois corresponde a dois métodos: o "
1245 "primeiro move a caneta para cima e o segundo move a caneta para baixo."
1246
1247 #. type: Content of: <pre>
1248 #: src/lessons/welcome/instructions/Instructions.html:67
1249 #, no-wrap
1250 msgid ""
1251 "brushUp()[!java|c];[/!]\n"
1252 "brushDown()[!java|c];[/!]\n"
1253 msgstr ""
1254 "brushUp()[!java|c];[/!]\n"
1255 "brushDown()[!java|c];[/!]\n"
1256
1257 #. type: Content of: <p>
1258 #: src/lessons/welcome/instructions/Instructions.html:71
1259 msgid ""
1260 "The buggle offers other methods, that are presented from the \"Help/about "
1261 "this world\" menu and will be introduced on need."
1262 msgstr ""
1263 "O buggle tem outros métodos, que estão no menu \"Ajuda/sobre este mundo\" e "
1264 "serão introduzidos quando forem necessários."
1265
1266 #. type: Content of: outside any tag (error?)
1267 #: src/lessons/welcome/instructions/InstructionsDrawG.html:3
1268 msgid ""
1269 "Now that we know how to draw things on the board, we'll enjoy this ability "
1270 "and draw a beautiful G on the board (check Objective panel for details on "
1271 "what is expected)."
1272 msgstr ""
1273 "Agora que sabemos como desenhar coisas no tabuleiro, vamos aproveitar esta "
1274 "habilidade e desenhar um belo G (Veja o painel de Objetivo para detalhes)."
1275
1276 #. type: Content of: <p>
1277 #: src/lessons/welcome/instructions/InstructionsDrawG.html:7
1278 msgid ""
1279 "When you write a quite complex program, it is sometimes useful to <b>add "
1280 "comments</b> to simplify the code reviews afterward. Here for example, it's "
1281 "quite easy to get lost in the drawing process, and you may want to add "
1282 "comments like <i>vertical bar done</i> or <i>finished drawing the G. Time to "
1283 "move back to initial position</i>. Commenting your code is almost mandatory "
1284 "if you (or someone else) want to read it afterward, although over-commenting "
1285 "(describing obvious stuff) is a bad idea as the important idea get lost in "
1286 "the noise."
1287 msgstr ""
1288 "Quando escreve um programa bem complexo, por vezes é útil <b>adicionar "
1289 "comentários</b> para simplificar uma posterior revisão do código. Aqui, por "
1290 "exemplo, é fácil se perder no processo de desenho e podeadicionar "
1291 "comentários como <i>barra vertical desenhada</i> ou <i>terminei de desenhar "
1292 "o G. hora de voltar para posição inicial</i>. Comentar o seu código é quase "
1293 "obrigatório se (ou mais alguém) quiser lê-lo depois, embora comentar demais ("
1294 "a descrever coisas óbvias) é ruim pois as ideias importantes se perdem no "
1295 "meio do ruído."
1296
1297 #. type: Content of: <p>
1298 #: src/lessons/welcome/instructions/InstructionsDrawG.html:15
1299 msgid ""
1300 "There is [!java]three[/!][!python|scala|c]two[/!] types of comments in "
1301 "[!thelang], instructing the "
1302 "[!java|scala|c]compiler[/!][!python]interpreter[/!] to not read the text you "
1303 "add for humans:"
1304 msgstr ""
1305 "Existem [!java]três[/!][!python|scala|c]dois[/!] tipos de comentários em "
1306 "[!thelang], que instruem o "
1307 "[!java|scala|c]compilador[/!][!python]interpretador[/!] a não ler o texto "
1308 "que adiciona para humanos:"
1309
1310 #. type: Content of: <ul><li>
1311 #: src/lessons/welcome/instructions/InstructionsDrawG.html:19
1312 msgid ""
1313 "<b>Comments on a single line</b>. When the "
1314 "[!java|scala|c]compiler[/!][!python]interpreter[/!] encounters the symbol "
1315 "[!java|scala|c]//[/!][!python]#[/!], it ignores the end of the line."
1316 msgstr ""
1317 "<b>Comentários de uma única linha</b>. Quando o "
1318 "[!java|scala|c]compilador[/!][!python]interpretador[/!] encontra o símbolo "
1319 "[!java|scala|c]//[/!][!python]#[/!], ignora o resto da linha."
1320
1321 #. type: Content of: <ul><li>
1322 #: src/lessons/welcome/instructions/InstructionsDrawG.html:21
1323 msgid ""
1324 "<b>Comments on several lines</b>. The "
1325 "[!java|scala|c]compiler[/!][!python]interpreter[/!] ignores anything placed "
1326 "between [!java|scala|c]the symbols /* and */ even if they are placed on "
1327 "differing lines.[/!] [!python]a line beginning with ''' until the next line "
1328 "ending with '''.[/!]"
1329 msgstr ""
1330 "<b>Comentários em várias linhas</b>. O "
1331 "[!java|scala|c]compilador[/!][!python]interpretador[/!] ignora tudo entre "
1332 "[!java|scala|c]os símbolos /* e */ mesmo quando eles são postos em linhas "
1333 "diferentes.[/!] [!python]uma linha a comaçar com ''' até a próxima linha "
1334 "terminado com '''.[/!]"
1335
1336 #. type: Content of: <pre>
1337 #: src/lessons/welcome/instructions/InstructionsDrawG.html:28
1338 #, no-wrap
1339 msgid ""
1340 "methodCallReadByThe[!java|scala|c]Compiler[/!][!python]Interpreter[/!]()[!java|c];[/!] "
1341 "<span class=\"comment\">[!java|scala|c]//[/!][!python]#[/!] all this is "
1342 "ignored</span>\n"
1343 "otherCall()[!java|c];[/!] [!java|scala|c]<span class=\"comment\">/* This "
1344 "is</span>\n"
1345 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
1346 "<span class=\"comment\"> also ignored */</span>[/!]\n"
1347 "[!python]<span class=\"comment\">''' This is</span>\n"
1348 "<span class=\"comment\">also ignored '''</span>[/!]\n"
1349 "yetAnotherCall()[!java|c];[/!]\n"
1350 msgstr ""
1351 "methodCallReadByThe[!java|scala|c]Compiler[/!][!python]Interpreter[/!]()[!jav"
1352 "a|c];[/!] <span class=\"comment\">[!java|scala|c]//[/!][!python]#[/!] tudo "
1353 "isto é ignorado</span>\n"
1354 "otherCall()[!java|c];[/!] [!java|scala|c]<span class=\"comment\">/* Isto "
1355 "também </span>\n"
1356 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp"
1357 "; <span class=\"comment\"> é ignorado */</span>[/!]\n"
1358 "[!python]<span class=\"comment\">''' Isto também</span>\n"
1359 "<span class=\"comment\">é ignorado '''</span>[/!]\n"
1360 "yetAnotherCall()[!java|c];[/!]\n"
1361
1362 #. type: Content of: <p>
1363 #: src/lessons/welcome/instructions/InstructionsDrawG.html:35
1364 msgid ""
1365 "There is a third kind of comments in Java, between /** and */, which are "
1366 "read by a specific program called JavaDoc to generate automatically the "
1367 "documentation explaining how to use the code. These comments must follow a "
1368 "very precise formalism."
1369 msgstr ""
1370 "Existe um terceiro tipo de comentário em Java, entre /** e */, que é lido "
1371 "por um programa específico chamado JavaDoc para gerar automaticamente a "
1372 "documentação a explicar como usar o código. Estes comentários devem seguir "
1373 "um formalismo bem preciso."
1374
1375 #. type: Content of: <p>
1376 #: src/lessons/welcome/instructions/InstructionsDrawG.html:40
1377 msgid ""
1378 "The comments on several lines are often used to document how to use the "
1379 "code, while others are more used to describe how this code works."
1380 msgstr ""
1381 "Os comentários de várias linhas são frequentemente usados para documentar "
1382 "como usar o código, enquanto os outros são usados para descrever como este "
1383 "código funciona."
1384
1385 #. type: Content of: outside any tag (error?)
1386 #: src/lessons/welcome/conditions/Conditions.html:4
1387 msgid ""
1388 "Programs made of simple suite of instructions similar to previous exercise "
1389 "are quite boring. They always do the same thing, and cannot react to "
1390 "external conditions. A <b>conditional</b> let the program adapt by doing "
1391 "something like <i>if it's raining, take an umbrella</i>."
1392 msgstr ""
1393 "Programas feitos simplesmente de um conjunto de instruções similares ao do "
1394 "exercício anterior são bastante chatos. Sempre fazem a mesma coisa e não "
1395 "reagem a condições externas. Um <b>condicional</b> faz o programa se adaptar "
1396 "a fazer coisas do tipo <i>se está a chover, leve um guarda-chuva</i>."
1397
1398 #. type: Content of: <p>
1399 #: src/lessons/welcome/conditions/Conditions.html:9
1400 msgid "The [!thelang] syntax is the following:"
1401 msgstr "A sintaxe de [!thelang] é a seguinte:"
1402
1403 #. type: Content of: <pre>
1404 #: src/lessons/welcome/conditions/Conditions.html:11
1405 #, no-wrap
1406 msgid ""
1407 "[!java|scala|c]if (<b>condition</b>) {\n"
1408 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue();</b>\n"
1409 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue();</b>\n"
1410 "}[/!][!python]if <b>condition</b>:\n"
1411 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue()</b>\n"
1412 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue()</b>[/!]\n"
1413 "<b>whatToDoAnyway()[!java|c];[/!]</b>"
1414 msgstr ""
1415 "[!java|scala|c]if (<b>condição</b>) {\n"
1416 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue();</b>\n"
1417 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue();</b>\n"
1418 "}[/!][!python]if <b>condição</b>:\n"
1419 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue()</b>\n"
1420 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue()</b>[/!]\n"
1421 "<b>whatToDoAnyway()[!java|c];[/!]</b>"
1422
1423 #. type: Content of: <p>
1424 #: src/lessons/welcome/conditions/Conditions.html:19
1425 msgid ""
1426 "If the condition is true, the code of the next block will be executed and "
1427 "then it will continue with the rest of the code. If the condition is false, "
1428 "the next block is ignored and the execution continues after it. The "
1429 "conditional block can contain several instructions, it can even contain "
1430 "other tests, along with their sub-blocks."
1431 msgstr ""
1432 "Se a condição for verdade, o código do próximo bloco será executado e então "
1433 "o resto do código continua. Se a condição for falsa, o próximo bloco é "
1434 "ignorado e a execução continua depois disto. O bloco condicional pode conter "
1435 "várias instruções, pode até mesmo conter outros testes, com os próprios sub-"
1436 "testes dele."
1437
1438 #. type: Content of: <p>
1439 #: src/lessons/welcome/conditions/Conditions.html:23
1440 msgid ""
1441 "In this example, the instructions <code>whatToDoIfTrue()</code> and "
1442 "<code>whatToDoNextIfTrue()</code> will be executed if and only if the "
1443 "condition is true, while the instruction <code>whatToDoAnyway()</code> will "
1444 "be executed whether or not the condition is true."
1445 msgstr ""
1446 "Neste exemplo, as instruções <code>whatToDoIfTrue()</code> e "
1447 "<code>whatToDoNextIfTrue()</code> serão executadas se e somente se a "
1448 "condição for verdadeira, mas a instrução <code>whatToDoAnyway()</code> vai "
1449 "ser executada se a condição for verdadeira ou não."
1450
1451 #. type: Content of: <p>
1452 #: src/lessons/welcome/conditions/Conditions.html:28
1453 msgid ""
1454 "In [!thelang], the blocks of code are [!java|scala|c]enclosed between curly "
1455 "brackets: a { sign opens the block, while a } sign closes it. White spaces "
1456 "are not important[/!][!java|c].[/!][!scala], provided that your instructions "
1457 "are still separated with a semi-column or an end of line.[/!] "
1458 "[!java|scala|c]It is still very important to correctly indent your code to "
1459 "keep it readable.[/!] [!python]marked by the indentation: every lines that "
1460 "are a bit shifted to the right with white spaces belong to the block. Quite "
1461 "often, people use 4 spaces for indentation, but it works if you use more or "
1462 "less spaces. Simply, any lines of the block must use the same amount of "
1463 "spaces. The end of Python code blocks are not marked by any specific char. "
1464 "Indenting lines starts a block and unindenting ends it. Do not forget the "
1465 "colon (:) at the end of the <code>if</code> line, python needs it to know "
1466 "that a new block begins. The fact that python relies on indentation to "
1467 "delimit blocks is a very good property for beginners: it will force you to "
1468 "adhere to strict code presentation standards.[/!] It is very easy to get "
1469 "lost in your own code if it's not properly indented, so you want to clean it "
1470 "up so that working on your code remains pleasant and productive."
1471 msgstr ""
1472 "Em [!thelang], os blocos de código são [!java|scala|c]envolvidos entre "
1473 "chaves: um { abre o bloco e um } fecha-o. Espaços em branco não são "
1474 "importantes[/!][!java|c].[/!][!scala], uma vez que as suas instruções ainda "
1475 "estejam separadas com um ponto-e-vírgula ou um fim-de-linha.[/!] "
1476 "[!java|scala|c]Ainda assim é muito importante indentar corretamente o seu "
1477 "código para mantê-lo legível.[/!] [!python]marcados pela indentação: todas "
1478 "as linhas que estiverem um pouco deslocadas para a direita com espaços "
1479 "pertencem ao bloco. Frequentemente se usam 4 espaços para indentação, mas "
1480 "funciona se usar mais ou menos espaços. A resumir, quaisquer linhas do bloco "
1481 "devem usar a mesma quantidade de espaços. O fim do bloco de código Python "
1482 "não é marcado por nenhum caractere específico. Indentar linhas começa um "
1483 "bloco e parar de indentar termina o bloco. Não se esqueça do dois-pontos (:) "
1484 "no final da linha do <code>if</code>, python precisa dele para saber que um "
1485 "novo bloco vai começar. O fato de que python se baseia em indentação para "
1486 "delimitar blocos é uma ótima propriedade para iniciantes: vai forçá-lo a "
1487 "aderir a padrões de apresentação de código estritos.[/!] É muito fácil se "
1488 "perder no seu próprio código se não for corretamente indentado, então "
1489 "precisa deixá-lo bem-arrumado para que trabalhar nele continue a ser "
1490 "agradável e produtivo."
1491
1492 #. type: Content of: <p>
1493 #: src/lessons/welcome/conditions/Conditions.html:44
1494 msgid ""
1495 "All indentations of a given block must be consistent, and it is not possible "
1496 "to cut a block. The two following codes are incorrect and will raise errors."
1497 msgstr ""
1498 "Todas as indentações de um dado bloco devem ser consistentes e não é "
1499 "possível cortar um bloco. os dois códigos a seguir estão incorretos e devem "
1500 "resultar em erro."
1501
1502 #. type: Content of: <pre>
1503 #: src/lessons/welcome/conditions/Conditions.html:47
1504 #, no-wrap
1505 msgid ""
1506 "if <b>condition</b>:\n"
1507 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>\n"
1508 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span "
1509 "class=\"comment\"># one space too much </span>\n"
1510 "<b>whatToDoAnyway()</b>\n"
1511 msgstr ""
1512 "if <b>condição</b>:\n"
1513 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>\n"
1514 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span class=\"comment\">#"
1515 " um espaço a mais </span>\n"
1516 "<b>whatToDoAnyway()</b>\n"
1517
1518 #. type: Content of: <pre>
1519 #: src/lessons/welcome/conditions/Conditions.html:52
1520 #, no-wrap
1521 msgid ""
1522 "if <b>condition</b>:\n"
1523 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>\n"
1524 "<b>whatToDoAnyway()</b>\n"
1525 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span class=\"comment\"># this "
1526 "block is not hanging to a condition line</span>\n"
1527 msgstr ""
1528 "se <b>condição</b>:\n"
1529 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>\n"
1530 "<b>whatToDoAnyway()</b>\n"
1531 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span class=\"comment\"># este "
1532 "bloco não está condicionado a uma linha de condição</span>\n"
1533
1534 #. type: Content of: <p>
1535 #: src/lessons/welcome/conditions/Conditions.html:58
1536 msgid ""
1537 "The condition must be a "
1538 "<code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code> "
1539 "expression. The inner block of code will get executed if the expression is "
1540 "evaluated to <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> "
1541 "and it will be ignored if it is "
1542 "<code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code>. "
1543 "[!python|scala|java]<code>[!java|scala]true[/!][!python]True[/!]</code> and "
1544 "<code>[!java|scala]false[/!][!python]False[/!]</code> are constant values "
1545 "defined by [!thelang] directly, just as 0 or 1 in mathematics.[/!]"
1546 msgstr ""
1547 "A condição deve ser uma expressão "
1548 "<code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code>. O "
1549 "bloco interno do código será executado se a expressão for calculada como "
1550 "<code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> e será ignorado "
1551 "se for <code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code>. "
1552 "[!python|scala|java]<code>[!java|scala]true[/!][!python]True[/!]</code> e "
1553 "<code>[!java|scala]false[/!][!python]False[/!]</code> são valores constantes "
1554 "definidos por [!thelang] diretamente, assim como 0 ou 1 na matemática.[/!]"
1555
1556 #. type: Content of: <p>
1557 #: src/lessons/welcome/conditions/Conditions.html:64
1558 msgid ""
1559 "The condition can be a "
1560 "<code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code> "
1561 "variable (we will come back on variables in a later exercise, don't worry) "
1562 "or an arithmetic test, such as <code>x == 5</code>, which checks whether the "
1563 "current value of <code>x</code> is 5, or such as <b>!=</b> (checking "
1564 "inequality, that is, returning "
1565 "[!c]1[/!][!java|scala]true[/!][!python]True[/!] only if the left-hand side "
1566 "is different from the right-hand side), <b>&lt;</b> (smaller than), "
1567 "<b>&gt;</b> (larger than), <b>&lt;=</b> (smaller or equal to), <b>&gt;=</b> "
1568 "(larger or equal to)."
1569 msgstr ""
1570 "A condição pode ser uma variável "
1571 "<code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code> (vamos "
1572 "voltar a falar de variáveis num próximo exercício, não se preocupe) ou um "
1573 "teste aritmético, como <code>x == 5</code>, que verifica se o valor atual de "
1574 "<code>x</code> é 5, ou algo como <b>!=</b> (a verificar inequação, ou seja, "
1575 "a retornar [!c]1[/!][!java|scala]true[/!][!python]True[/!] apenas se o lado "
1576 "esquerdo é diferente do lado direito), <b>&lt;</b> (menor que), <b>&gt;</b> ("
1577 "maior que), <b>&lt;=</b> (menor ou igual a), <b>&gt;=</b> (maior ou igual a)."
1578
1579 #. type: Content of: <p>
1580 #: src/lessons/welcome/conditions/Conditions.html:71
1581 msgid ""
1582 "Beware of the classical trap, which consists in testing the equality of a "
1583 "variable using = instead of ==. Hopefully, the "
1584 "[!java|scala|c]compiler[/!][!python]interpreter[/!] detects this problem "
1585 "most of the time, but it could get trapped is some cases (such as when you "
1586 "are affecting a [!c]int[/!][!java|python|scala]boolean[/!] variable). So "
1587 "you'd better to be careful..."
1588 msgstr ""
1589 "Cuidado com um erro clássico, que é verificar a igualdade da variável a usar "
1590 "= no lugar de ==. Ainda bem que o "
1591 "[!java|scala|c]compilador[/!][!python]interpretador[/!] detecta este "
1592 "problema na maior parte das vezes, mas às vezes passa (como quando está a "
1593 "atribuir valor a uma variável [!c]int[/!][!java|python|scala]booleana[/!]). "
1594 "Então é bom ter cuidado..."
1595
1596 #. type: Content of: <p>
1597 #: src/lessons/welcome/conditions/Conditions.html:76
1598 msgid ""
1599 "The condition can also be a call to some particular methods returning a "
1600 "boolean. For example, the <code>isFacingWall()</code> method of the buggle "
1601 "returns [!c]1[/!][!java|python|scala]true[/!] if the buggle is facing a "
1602 "wall, and [!c]0[/!][!java|python|scala]false[/!] in the other case."
1603 msgstr ""
1604 "A condição pode também ser uma chamada para alguns métodos particulares que "
1605 "retornam booleano. Por exemplo, o método <code>isFacingWall()</code> do "
1606 "buggle retorna [!c]1[/!][!java|python|scala]true[/!] se o buggle está a "
1607 "olhar para uma parede e false caso contrário."
1608
1609 #. type: Content of: <p>
1610 #: src/lessons/welcome/conditions/Conditions.html:80
1611 msgid ""
1612 "Finally, a condition can be composed of several sub-conditions connected by "
1613 "boolean operations:"
1614 msgstr ""
1615 "Finalmente, uma condição pode ser composta de várias sub-condições "
1616 "conectadas por operadores booleanos:"
1617
1618 #. type: Content of: <ul><li>
1619 #: src/lessons/welcome/conditions/Conditions.html:83
1620 msgid ""
1621 "<code>cond1 [!java|scala|c]&&[/!][!python]and[/!] cond2</code> is true when "
1622 "<tt>cond1</tt> <b>and</b> <tt>cond2</tt> are both true (if <tt>cond1</tt> is "
1623 "false, <tt>cond2</tt> is not even evaluated as we already know that the "
1624 "conjunction of both propositions cannot be true)."
1625 msgstr ""
1626 "<code>cond1 [!java|scala|c]&&[/!][!python]and[/!] cond2</code> é true quando "
1627 "<tt>cond1</tt> <b>e</b> <tt>cond2</tt> são ambos trues (se <tt>cond1</tt> é "
1628 "false, <tt>cond2</tt> não é nem sequer calculado pois sabe-se previamente "
1629 "que a conjunção das duas proposições não pode ser verdadeira)."
1630
1631 #. type: Content of: <ul><li>
1632 #: src/lessons/welcome/conditions/Conditions.html:86
1633 msgid ""
1634 "<code>cond1 [!java|scala|c]||[/!][!python]or[/!] cond2</code> is true if "
1635 "<tt>cond1</tt> <b>or</b> <tt>cond2</tt> is true (if <tt>cond1</tt> is true, "
1636 "<tt>cond2</tt> is not even evaluated as we already know that the disjunction "
1637 "of both propositions cannot be false)."
1638 msgstr ""
1639 "<code>cond1 [!java|scala|c]||[/!][!python]or[/!] cond2</code> é true se "
1640 "<tt>cond1</tt> <b>ou</b> <tt>cond2</tt> é true (se <tt>cond1</tt> é true, "
1641 "<tt>cond2</tt> não é nem sequer calculada pois já se sabe que a disjunção de "
1642 "ambas as proposições não pode ser verdadeira)."
1643
1644 #. type: Content of: <ul><li>
1645 #: src/lessons/welcome/conditions/Conditions.html:89
1646 msgid ""
1647 "<code>[!java|scala|c]![/!][!python]not [/!]cond</code> is true if "
1648 "<tt>cond</tt> is false."
1649 msgstr ""
1650 "<code>[!java|scala|c]![/!][!python]not [/!]cond</code> é verdadeira se "
1651 "<tt>cond</tt> é falsa."
1652
1653 #. type: Content of: <ul><li>
1654 #: src/lessons/welcome/conditions/Conditions.html:90
1655 msgid ""
1656 "When the expression becomes complicated, it is better to add parenthesis to "
1657 "force the order of evaluation. Do not hesitate to add more parenthesis to "
1658 "remove any ambiguities that may appear in an expression."
1659 msgstr ""
1660 "Quando a expressão se torna complicada, é melhor adicionar parêntesis para "
1661 "forçar a ordem de cálculo. Não hesite em adicionar mais parêntesis para "
1662 "remover ambiguidades que apareçam na expressão."
1663
1664 #. type: Content of: <p>
1665 #: src/lessons/welcome/conditions/Conditions.html:94
1666 msgid ""
1667 "Last, it is possible to specify what to do when the condition is false using "
1668 "the following syntax. In this case, the instruction "
1669 "<code>whatToDoIfItsFalse</code> will be executed only if the condition is "
1670 "false."
1671 msgstr ""
1672 "Por fim, é possível especificar o que fazer quando a condição é falsa a usar "
1673 "a seguinte sintaxe. Neste caso, a instrução <code>oQueFazerSeForFalso</code> "
1674 "será executada apenas se a condição for falsa."
1675
1676 #. type: Content of: <pre>
1677 #: src/lessons/welcome/conditions/Conditions.html:97
1678 #, no-wrap
1679 msgid ""
1680 "[!java|scala|c]if (<b>condition</b>) {\n"
1681 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue();</b>\n"
1682 "} else {\n"
1683 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse();</b>\n"
1684 "}[/!][!python]if (<b>condition</b>):\n"
1685 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue()</b>\n"
1686 "else:\n"
1687 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse()</b>[/!]"
1688 msgstr ""
1689 "[!java|scala|c]if (<b>condição</b>) {\n"
1690 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue();</b>\n"
1691 "} else {\n"
1692 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse();</b>\n"
1693 "}[/!][!python]if (<b>condição</b>):\n"
1694 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue()</b>\n"
1695 "else:\n"
1696 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse()</b>[/!]"
1697
1698 #. type: Content of: <p>
1699 #: src/lessons/welcome/conditions/Conditions.html:106
1700 msgid ""
1701 "Don't forget the colon (:) after the else, it is indicating that a new block "
1702 "is beginning."
1703 msgstr ""
1704 "Não se esqueça do dois-pontos (:) depois do else, indica que um novo bloco "
1705 "está a começar."
1706
1707 #. type: Content of: <h3>
1708 #: src/lessons/welcome/conditions/Conditions.html:109
1709 #: src/lessons/welcome/loopwhile/LoopWhile.html:35
1710 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:9
1711 #: src/lessons/welcome/variables/Variables.html:119
1712 #: src/lessons/welcome/loopfor/LoopFor.html:82
1713 #: src/lessons/welcome/methods/basics/Methods.html:96
1714 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:38
1715 #: src/lessons/welcome/methods/returning/MethodsReturning.html:50
1716 #: src/lessons/welcome/methods/args/MethodsArgs.html:70
1717 #: src/lessons/welcome/methods/slug/SlugHunting.html:19
1718 #: src/lessons/welcome/methods/slug/SlugTracking.html:24
1719 #: src/lessons/welcome/bdr/BDR.html:151 src/lessons/welcome/bdr/BDR2.html:132
1720 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:18
1721 #: src/lessons/maze/pledge/PledgeMaze.html:37
1722 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:23
1723 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:22
1724 msgid "Exercise goal"
1725 msgstr "Objetivo do exercício"
1726
1727 #. type: Content of: outside any tag (error?)
1728 #: src/lessons/welcome/conditions/Conditions.html:109
1729 msgid ""
1730 "<a name=\"Objectives\"/> If the buggle is facing a wall, you must move one "
1731 "step back. If not, you must move one step forward. To detect whether you are "
1732 "facing a wall, simply use the <code>isFacingWall()</code> built-in, that "
1733 "every buggle understands."
1734 msgstr ""
1735 "<a name=\"Objectives\"/> Se o buggle está de cara para uma parede, deve "
1736 "mover um passo para trás. Se não, deve mover um passo para frente. Para "
1737 "detetar se está de cara para uma parede, simplesmente use a função pré-"
1738 "fabricada <code>isFacingWall()</code>, que todos os buggles entendem."
1739
1740 #. type: Content of: <p>
1741 #: src/lessons/welcome/conditions/Conditions.html:116
1742 msgid ""
1743 "This exercise is a bit different: your code has to work for several buggles, "
1744 "each of them being in a specific initial condition. The same code will be "
1745 "executed for each of them."
1746 msgstr ""
1747 "Este exercício é um pouco diferente: o seu código tem que funcionar para "
1748 "vários buggles, cada um a começar numa posição diferente. O mesmo código "
1749 "será executado para cada um deles."
1750
1751 #. type: Content of: <p>
1752 #: src/lessons/welcome/conditions/Conditions.html:120
1753 msgid ""
1754 "When your program works, move forward to the next exercise, that is hidden "
1755 "in a sub-tree of the selection window."
1756 msgstr ""
1757 "Quando o seu programa funcionar, vá ao próximo exercício, que está escondido "
1758 "numa sub-árvore da janela de seleção."
1759
1760 #. type: Content of: <p>
1761 #: src/lessons/welcome/loopwhile/LoopWhile.html:4
1762 msgid ""
1763 "In addition to conditionals, another handy construction is the ability to "
1764 "repeat an action while a specific condition does not appear. A while loop is "
1765 "used for that, with the following syntax."
1766 msgstr ""
1767 "Além dos condicionais, outra construção bem útil é a habilidade de repetir "
1768 "uma ação enquanto uma condição específica não acontece. Um loop 'while' é "
1769 "usado para isto, com a seguinte sintaxe."
1770
1771 #. type: Content of: <pre>
1772 #: src/lessons/welcome/loopwhile/LoopWhile.html:8
1773 #, no-wrap
1774 msgid ""
1775 "[!java|scala|c]while (<b>condition</b>) {\n"
1776 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>;\n"
1777 "}[/!][!python]while <b>condition</b>:\n"
1778 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>[/!]"
1779 msgstr ""
1780 "[!java|scala|c]while (<b>condição</b>) {\n"
1781 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>;\n"
1782 "}[/!][!python]while <b>condição</b>:\n"
1783 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>[/!]"
1784
1785 #. type: Content of: <p>
1786 #: src/lessons/welcome/loopwhile/LoopWhile.html:13
1787 msgid ""
1788 "The inner bloc is then executed again and again, as long as the condition "
1789 "remains true. More specifically, the buggle tests the value of the "
1790 "condition. If it's false, it ignores the bloc and continue below. If it's "
1791 "true, it executes the bloc. After that, it tests the condition. If it's now "
1792 "false (for example because the moves of the block made us facing the wall), "
1793 "it now ignores the bloc and continue. If it's still true, it execute the "
1794 "bloc and reevaluate the condition. It does so as long as the condition "
1795 "remains true."
1796 msgstr ""
1797 "O bloco interno é então executado várias e várias vezes, enquanto a condição "
1798 "se mantiver verdadeira. Mais especificamente, o buggle testa o valor da "
1799 "condição. Se for falsa, ignora o bloco e continua abaixo. Se for verdadeira, "
1800 "executa o bloco. Depois disto, testa a condição. Se agora for falsa (por "
1801 "exemplo, porque os movimentos do bloco nos deixaram de cara à parede), agora "
1802 "ignora o bloco e continua. Se ainda for true, executa o bloco e reavalia a "
1803 "condição. Faz isto enquanto a condição se mantém verdadeira."
1804
1805 #. type: Content of: <p>
1806 #: src/lessons/welcome/loopwhile/LoopWhile.html:20
1807 msgid ""
1808 "Naturally, if the chosen action does not modify the value of the condition, "
1809 "the buggle will do the action endlessly. The <b>stop</b> button of the "
1810 "interface becomes then handy. To test this, you can try to type the "
1811 "following code in the editor:"
1812 msgstr ""
1813 "Naturalmente, se a ação escolhida não modifica o valor da condição, o buggle "
1814 "vai fazer a ação infinitamente. O botão <b>stop</b> na interface se torna "
1815 "útil nestes casos. Para testar isto, pode tentar digitar o seguinte código "
1816 "no editor:"
1817
1818 #. type: Content of: <pre>
1819 #: src/lessons/welcome/loopwhile/LoopWhile.html:25
1820 #, no-wrap
1821 msgid ""
1822 "[!java|scala]while (true) {\n"
1823 "&nbsp;&nbsp;&nbsp;&nbsp;left();\n"
1824 "}[/!][!c]while (1) {\n"
1825 "&nbsp;&nbsp;&nbsp;&nbsp;left();\n"
1826 "}[/!][!python]while True:\n"
1827 "&nbsp;&nbsp;&nbsp;&nbsp;left()[/!]"
1828 msgstr ""
1829 "[!java|scala]while (true) {\n"
1830 "&nbsp;&nbsp;&nbsp;&nbsp;left();\n"
1831 "}[/!][!c]while (1) {\n"
1832 "&nbsp;&nbsp;&nbsp;&nbsp;left();\n"
1833 "}[/!][!python]while True:\n"
1834 "&nbsp;&nbsp;&nbsp;&nbsp;left()[/!]"
1835
1836 #. type: Content of: <p>
1837 #: src/lessons/welcome/loopwhile/LoopWhile.html:32
1838 msgid ""
1839 "This will let the buggle turn left as long as "
1840 "<code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> remains true "
1841 "(ie, endlessly), or until you stop it manually using the stop button."
1842 msgstr ""
1843 "Isto vai fazer o buggle virar à esquerda enquanto "
1844 "<code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> permanecer true "
1845 "(ou seja, infinitamente), ou até que pare manualmente a usar o botão parar."
1846
1847 #. type: Content of: outside any tag (error?)
1848 #: src/lessons/welcome/loopwhile/LoopWhile.html:36
1849 msgid ""
1850 "You now have to write some code so that your buggles move forward until they "
1851 "encounter a wall. The idea is thus to do something like:"
1852 msgstr ""
1853 "Agora tem que escrever algum código para os seus buggles se moverem para a "
1854 "frente até que eles encontrem uma parede. A ideia é então fazer algo assim:"
1855
1856 #. type: Content of: <pre>
1857 #: src/lessons/welcome/loopwhile/LoopWhile.html:39
1858 #, no-wrap
1859 msgid ""
1860 "while we are not facing a wall, do:\n"
1861 "&nbsp;&nbsp;moveForward()"
1862 msgstr ""
1863 "Enquanto não estiver de cara para uma parede, faça:\n"
1864 "&nbsp;&nbsp;moveForward()"
1865
1866 #. type: Content of: <p>
1867 #: src/lessons/welcome/loopwhile/LoopWhile.html:42
1868 msgid ""
1869 "Look at the documentation (in \"Help/About this world\") for the full list "
1870 "of buggles' methods."
1871 msgstr ""
1872 "Procure na documentação (em \"Ajuda/Sobre este mundo\") para a lista "
1873 "completa dos métodos dos buggles."
1874
1875 #. type: Content of: <p>
1876 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:3
1877 msgid ""
1878 "The buggle world can sometimes contain some <i>baggles</i>, which are little "
1879 "biscuits that buggles can carry from one point to another. For that, they "
1880 "have to use specific methods such as <code>isOverBaggle(), "
1881 "isCarryingBaggle(), pickupBaggle()</code> or "
1882 "<code>dropBaggle()</code>. Check their documentation in \"Help/About this "
1883 "world\" for more details."
1884 msgstr ""
1885 "O mundo dos buggles pode algumas vezes conter alguns <i>baggles</i>, que são "
1886 "pequenos biscoitos que os buggles podem carregar de um ponto a outro. Para "
1887 "isto, eles têm que usar métodos específicos como <code>isOverBaggle(), "
1888 "isCarryingBaggle(), pickupBaggle()</code> ou <code>pickupBaggle()</code>. "
1889 "Verifique a documentação deles em \"Ajuda/Sobre este mundo\" para mais "
1890 "detalhes."
1891
1892 #. type: Content of: <p>
1893 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:11
1894 msgid ""
1895 "Let each buggle find its baggle by adapting the code you wrote in previous "
1896 "exercise (copy/paste what you've done before if you want)."
1897 msgstr ""
1898 "Deixe cada buggle encontrar o baggle dele por adaptar o código que escreveu "
1899 "no exercício anterior (copie e cole o que fez antes se quiser)."
1900
1901 #. type: Content of: <p>
1902 #: src/lessons/welcome/variables/Variables.html:3
1903 msgid ""
1904 "The programs we wrote so far are missing a fundamental point in computing. "
1905 "Actually, it is all about processing <b>data</b> through specific "
1906 "<b>instructions</b>. In the buggle world, the main data are a bit hidden "
1907 "behind the graphical representation, but that's no reason to never "
1908 "manipulate some data explicitly."
1909 msgstr ""
1910 "Os programas que escrevemos até agora não tem um ponto fundamental da "
1911 "computação. Na verdade, é sobre processar <b>dados</b> através de "
1912 "<b>instruções</b> específicas. No mundo dos buggles, os dados principais "
1913 "estão escondidos atrás de uma representação gráfica, mas isto não é motivo "
1914 "para nunca manipular alguns dados explicitamente."
1915
1916 #. type: Content of: <h3>
1917 #: src/lessons/welcome/variables/Variables.html:9
1918 msgid "Data in [!thelang]"
1919 msgstr "Dados em [!thelang]"
1920
1921 #. type: Content of: <p>
1922 #: src/lessons/welcome/variables/Variables.html:10
1923 msgid ""
1924 "In a program, you can use several <i>types</i> of data, such as integers or "
1925 "strings of chars. If you want to use a data several times, you need to store "
1926 "it within a <i>variable</i>, which is a memory cell containing a value: you "
1927 "put your data (say the value '5') in the variable (say 'length'), and you "
1928 "can retrieve it later when you need it. That's very similar to a box of "
1929 "label 'gift' in which you would put some stuff, like a bottle of perfume "
1930 "\"Channel N°5\"."
1931 msgstr ""
1932 "Num programa, pode usar vários <i>tipos</i> de dados, tais como números "
1933 "inteiros ou cadeias de caracteres, ou caracteres. Se quiser usar um dado "
1934 "várias vezes, precisa armazená-la numa <i>variável</i>, que é uma célula de "
1935 "memória a conter um valor: põe o seu dado (digamos o valor '5') na variável ("
1936 "digamos 'comprimento') e pode recuperá-la mais tarde quando precisar dela. "
1937 "Isto é muito similar a uma caixa com o rótulo 'presente' na qual pode pôr "
1938 "alguma coisa, como um perfume \"Channel N°5\"."
1939
1940 #. type: Content of: <h3>
1941 #: src/lessons/welcome/variables/Variables.html:17
1942 msgid "Variable declarations"
1943 msgstr "Declaração de variáveis"
1944
1945 #. type: Content of: <p>
1946 #: src/lessons/welcome/variables/Variables.html:19
1947 msgid ""
1948 "<b>Declaring</b> (ie, creating) a variable in [!thelang], is very "
1949 "simple. You just need to write [!java]its type, a space, and the variable "
1950 "name.[/!] [!scala]the <code>var</code> keyword, the variable name, a column "
1951 "(:) and the variable type an equal sign (=) and an initial value.[/!] "
1952 "[!python]the variable name, an equal sign (=) and an initial value.[/!] The "
1953 "variable name is the label to retrieve it afterward[!python].[/!] "
1954 "[!java|scala] while the type is the kind of data that this variable accepts "
1955 "to store.[/!] It is forbidden to use spaces in variable names. You can name "
1956 "a variable <code>stepAmount</code> if you want, but <code>step amount</code> "
1957 "is not a valid name."
1958 msgstr ""
1959 "<b>Declarar</b> (ie, criar) uma variável em [!thelang], é muito simples. "
1960 "Simplesmente escreve [!java]o tipo dele, um espaço e o nome da variável.[/!] "
1961 "[!scala]a palavra-chave <code>var</code>, o nome da variável, um dois-pontos "
1962 "(:) e o tipo da variável, um sinal de igualdade (=) e um valor inicial.[/!] "
1963 "[!python]o nome da variável, um sinal de igual (=) e um valor inicial.[/!] O "
1964 "nome da variável é o rótulo para recuperar ela depois[!python].[/!] "
1965 "[!java|scala] enquanto o tipo é o tipo de dado que a variável aceita "
1966 "guardar.[/!] É proibido usar espaços em nomes de variáveis. Pode nomear uma "
1967 "variável <code>quantidadeDePassos</code> se quiser, mas <code>quantidade de "
1968 "passos</code> não é um nome válidos."
1969
1970 #. type: Content of: outside any tag (error?)
1971 #: src/lessons/welcome/variables/Variables.html:29
1972 msgid "[!c|java]"
1973 msgstr "[!c|java]"
1974
1975 #. type: Content of: <p>
1976 #: src/lessons/welcome/variables/Variables.html:30
1977 msgid ""
1978 "So, to create a variable named <b>x</b> intended to contain integers, one "
1979 "should write:"
1980 msgstr ""
1981 "Então, para criar uma variável chamada <b>x</b> para guardar inteiros, deve "
1982 "escrever:"
1983
1984 #. type: Content of: <pre>
1985 #: src/lessons/welcome/variables/Variables.html:31
1986 #, no-wrap
1987 msgid "int x;"
1988 msgstr "int x;"
1989
1990 #. type: Content of: <p>
1991 #: src/lessons/welcome/variables/Variables.html:32
1992 msgid ""
1993 "If you want, you can specify the initial value of the variable by adding an "
1994 "equal sign (=) followed by the value after the declaration."
1995 msgstr ""
1996 "Se quiser, pode especificar o valor inicial da variável a adicionar um "
1997 "símbolo de igual (=) seguido do valor depois da declaração."
1998
1999 #. type: Content of: <pre>
2000 #: src/lessons/welcome/variables/Variables.html:34
2001 #, no-wrap
2002 msgid "int x=5;"
2003 msgstr "int x=5;"
2004
2005 #. type: Content of: outside any tag (error?)
2006 #: src/lessons/welcome/variables/Variables.html:35
2007 #: src/lessons/welcome/variables/Variables.html:69
2008 msgid "[/!] [!python]"
2009 msgstr "[/!] [!python]"
2010
2011 #. type: Content of: <p>
2012 #: src/lessons/welcome/variables/Variables.html:38
2013 msgid ""
2014 "So, if you want that the variable contains 5 as initial value, you should "
2015 "type:"
2016 msgstr ""
2017 "Então se quiser que a variável tenha o valor inicial de 5, deve digitar:"
2018
2019 #. type: Content of: <pre>
2020 #: src/lessons/welcome/variables/Variables.html:39
2021 #, no-wrap
2022 msgid "x = 5"
2023 msgstr "x = 5"
2024
2025 #. type: Content of: <ul><li>
2026 #: src/lessons/welcome/variables/Variables.html:40
2027 #: src/lessons/welcome/loopfor/LoopFor.html:68
2028 #: src/lessons/welcome/bdr/BDR2.html:83
2029 #: src/lessons/recursion/cons/universe/ConsWorld.html:34
2030 msgid "[/!] [!scala]"
2031 msgstr "[/!] [!scala]"
2032
2033 #. type: Content of: <p>
2034 #: src/lessons/welcome/variables/Variables.html:43
2035 msgid ""
2036 "So, to create a variable named <b>x</b> intended to contain integers with 42 "
2037 "as initial value, one should write:"
2038 msgstr ""
2039 "Logo, para criar uma variável chamada <b>x</b> que vai guardar inteiros e "
2040 "com 42 como valor inicial, deve escrever:"
2041
2042 #. type: Content of: <pre>
2043 #: src/lessons/welcome/variables/Variables.html:44
2044 #, no-wrap
2045 msgid "var x:Int = 42"
2046 msgstr "var x:Int = 42"
2047
2048 #. type: Content of: <p>
2049 #: src/lessons/welcome/variables/Variables.html:45
2050 msgid ""
2051 "In most cases, the compiler is able to guess the type of the variable from "
2052 "the initialization value, and you can omit it:"
2053 msgstr ""
2054 "Na maioria dos casos, o compilador é capaz de adivinhar o tipo da variável "
2055 "baseado no valor inicial e pode omitir o tipo:"
2056
2057 #. type: Content of: <pre>
2058 #: src/lessons/welcome/variables/Variables.html:46
2059 #, no-wrap
2060 msgid "var x = 42"
2061 msgstr "var x = 42"
2062
2063 #. type: Content of: <p>
2064 #: src/lessons/welcome/variables/Variables.html:47
2065 msgid ""
2066 "You still have to specify if you use some generic values as an "
2067 "initialization, such as the very particular value <code>null</code>, which "
2068 "type happens to be ambiguous. Even when the type is clear, you can still "
2069 "specify it if you prefer. So you want that the variable contains 5 as "
2070 "initial value, you should type:"
2071 msgstr ""
2072 "Ainda tem que especificar se usa alguns valores genéricos como uma "
2073 "inicialização, tais como o valor muito especial <code>null</code>, cujo tipo "
2074 "parece ser ambíguo. Mesmo quando o tipo é claro, ainda pode especificar o "
2075 "tipo se preferir. Portanto, se quiser que a variável contenha 5 como valor "
2076 "inicial, deve digitar:"
2077
2078 #. type: Content of: <pre>
2079 #: src/lessons/welcome/variables/Variables.html:50
2080 #, no-wrap
2081 msgid ""
2082 "var x: Int = 5 <span class=\"comment\">// I can define the type if I want "
2083 "to</span>\n"
2084 "var y = 10 <span class=\"comment\">// or I can omit the type if I "
2085 "prefer</span>"
2086 msgstr ""
2087 "var x: Int = 5 <span class=\"comment\">// Posso definir o tipo se "
2088 "quiser</span>\n"
2089 "var y = 10 <span class=\"comment\">// ou posso omitir o tipo se "
2090 "preferir</span>"
2091
2092 #. type: Content of: outside any tag (error?)
2093 #: src/lessons/welcome/variables/Variables.html:52
2094 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:39
2095 msgid "[/!] [!java|scala|c]"
2096 msgstr "[/!] [!java|scala|c]"
2097
2098 #. type: Content of: <p>
2099 #: src/lessons/welcome/variables/Variables.html:55
2100 msgid ""
2101 "As you can see, the variables are <b>typed</b> in [!thelang], which means "
2102 "that they are somehow specialized: A given variable can only store data of a "
2103 "given type; Don't even think of storing numbers in a variable that is "
2104 "tailored for letters! The [!thelang] language is said to be <b>statically "
2105 "typed</b>."
2106 msgstr ""
2107 "Como pode ver, as variáveis são <b>tipadas</b> em [!thelang], que significa "
2108 "que elas são de certa forma especializadas: Uma dada variável pode armazenar "
2109 "apenas dados de um tipo; nem pense em guardar números numa variável que é "
2110 "feita para letras! Dizemos que a linguagem [!thelang] é <b>estaticamente "
2111 "tipada</b>."
2112
2113 #. type: Content of: <p>
2114 #: src/lessons/welcome/variables/Variables.html:58
2115 msgid ""
2116 "Other languages (such as Python) are less picky and allow you to store any "
2117 "kind of data in any variable, without restriction (those languages are said "
2118 "to be <b>dynamically typed</b>). This seems easier at the first glance, but "
2119 "this kind of restriction allows the compiler to catch more logic errors for "
2120 "you, which is also good. In some sense, Python is easier to write but errors "
2121 "can sneak in more easily than in [!thelang]."
2122 msgstr ""
2123 "Outras linguages (como Python) são menos charas e permitem que guarde "
2124 "qualquer tipo de dado em qualquer variável, sem restrições (estas linguagens "
2125 "são ditas <b>dinamicamente tipadas</b>). Parecem mais fáceis à primeira "
2126 "vista, mas este tipo de restrição permite que o compilador perceba mais "
2127 "erros de lógica para você, o que é bom. Num certo sentido, Python é mais "
2128 "fácil de escrever mas os erros surgem com mais frequencia do que em "
2129 "[!thelang]."
2130
2131 #. type: Content of: <p>
2132 #: src/lessons/welcome/variables/Variables.html:62
2133 msgid "Here are some existing types in [!thelang]:"
2134 msgstr "Aqui estão alguns dos tipos em [!thelang]:"
2135
2136 #. type: Content of: <ul><li>
2137 #: src/lessons/welcome/variables/Variables.html:64
2138 msgid "<b>[!java|c]int[/!][!scala]Int[/!]</b>, for integers;"
2139 msgstr "<b>[!java|c]int[/!][!scala]Int[/!]</b>, para inteiros;"
2140
2141 #. type: Content of: <ul><li>
2142 #: src/lessons/welcome/variables/Variables.html:65
2143 msgid "<b>[!java|c]double[/!][!scala]Double[/!]</b>, for dot numbers;"
2144 msgstr "<b>[!java|c]double[/!][!scala]Double[/!]</b>, para números com vírgula;"
2145
2146 #. type: Content of: <ul><li>
2147 #: src/lessons/welcome/variables/Variables.html:66
2148 msgid ""
2149 "<b>[!c]int[/!][!java]boolean[/!][!scala]Boolean[/!]</b>, for booleans that "
2150 "are values being either [!c]1[/!][!java|scala]true[/!] or "
2151 "[!c]0[/!][!java|scala]false[/!];"
2152 msgstr ""
2153 "<b>[!c]int[/!][!java]boolean[/!][!scala]Boolean[/!]</b>, para booleanos, que "
2154 "são valores ou [!c]1[/!][!java|scala]true[/!] ou "
2155 "[!c]0[/!][!java|scala]false[/!];"
2156
2157 #. type: Content of: <ul><li>
2158 #: src/lessons/welcome/variables/Variables.html:67
2159 msgid "<b>[!c]char*[/!][!java|scala]String[/!]</b>, for char strings."
2160 msgstr ""
2161 "<b>[!c]char*[/!][!java|scala]String[/!]</b>, para cadeias de caracteres."
2162
2163 #. type: Content of: <p>
2164 #: src/lessons/welcome/variables/Variables.html:72
2165 msgid ""
2166 "As you can see, the variables are not <b>typed</b> in Python, which means "
2167 "that they are not specialized in any type of data. A given variable store "
2168 "any type of data of a given type: you can store a number in a variable and "
2169 "later on store a number in the same variable. The values themselves are "
2170 "still typed, but not the variable. Python is said to be <b>dynamically "
2171 "typed</b>."
2172 msgstr ""
2173 "Como pode ver, as variáveis não são <b>digitadas</b> em Python, o que "
2174 "significa que elas não são especializadas em nenhum tipo de dado. Uma "
2175 "determinada variável armazena qualquer tipo de dado de um determinado tipo: "
2176 "pode armazenar um número numa variável e, mais tarde, armazenar um número na "
2177 "mesma variável. Os valores ainda são digitados, mas não a variável. Diz-se "
2178 "que Python é de <b>tipagem dinâmica</b>."
2179
2180 #. type: Content of: <p>
2181 #: src/lessons/welcome/variables/Variables.html:75
2182 msgid ""
2183 "Other languages (such as Java, Scala or C) are much more picky and prevent "
2184 "you to mix data types in a given variable (they are said to be <b>statically "
2185 "typed</b>). This seems annoying at the first glance, but this kind of "
2186 "restriction allows the compiler to catch more logic errors for you, which is "
2187 "also good. In some sense, Python is easier to write but errors can sneak in "
2188 "more easily."
2189 msgstr ""
2190 "Outras linguagens (como Java, Scala ou C), são muito mais exigentes e "
2191 "impedem que misture tipos de dados numa certa variável (dizemos que elas são "
2192 "<b>esticamente tipadas</b>). Isto parece inconveniente à primeira vista, mas "
2193 "este tipo de restrição permite que o compilador capture mais erros de lógica "
2194 "para você, o que também é bom. Num certo sentido, Python é mais fácil de "
2195 "escrever mas erros podem surgir mais facilmente."
2196
2197 #. type: Content of: <p>
2198 #: src/lessons/welcome/variables/Variables.html:81
2199 msgid ""
2200 "If you know that the value of your \"variable\" will never change (eg "
2201 "because it contains the screen size or some other constant value), then you "
2202 "should make it a <b>value</b> instead of a variable. Simply change the "
2203 "<code>var</code> keyword with the <code>val</code> one. The compiler can "
2204 "then check your actions and catch your error when you inadvertently modify "
2205 "the value. More interestingly, the compiler can produce faster code in some "
2206 "cases."
2207 msgstr ""
2208 "Se sabe que o valor da sua \"variável\" nunca vai mudar (eg quando ela "
2209 "contém o tamanho do ecrã ou outro valor constante), então deve fazer dela um "
2210 "<b>valor</b> ao invés de uma variável. Simplesmente mude a palavra-chave "
2211 "<code>var</code> para <code>val</code>. O compilador pode então verificar as "
2212 "suas ações e capturar o seu erro quando inadvertidamente modificar o valor. "
2213 "Mais interessante ainda, o compilador pode produzir código mais rápido em "
2214 "alguns casos."
2215
2216 #. type: Content of: <p>
2217 #: src/lessons/welcome/variables/Variables.html:86
2218 msgid ""
2219 "Variables work very similarly for strings, floating point numbers and "
2220 "boolean values."
2221 msgstr ""
2222 "Variáveis funcionam muito parecido com cadeias, números com vírgula e "
2223 "valores booleanos."
2224
2225 #. type: Content of: <pre>
2226 #: src/lessons/welcome/variables/Variables.html:88
2227 #, no-wrap
2228 msgid ""
2229 "char* name = \"Martin Quinson\";\n"
2230 "double height=1.77; <span class=\"comment\">// in meters</span>\n"
2231 "int married=1;<span class=\"comment\">// 1 means \"true\"; \"false\" would "
2232 "be written 0</span>"
2233 msgstr ""
2234 "char* nome = \"Martin Quinson\";\n"
2235 "double altura=1.77; <span class=\"comment\">// em metros</span>\n"
2236 "int casado=1;<span class=\"comment\">// 1 significa \"verdadeiro\"; false é "
2237 "0</span>"
2238
2239 #. type: Content of: <pre>
2240 #: src/lessons/welcome/variables/Variables.html:93
2241 #, no-wrap
2242 msgid ""
2243 "String name = \"Martin Quinson\";\n"
2244 "double height=1.77; <span class=\"comment\">// in meters</span>\n"
2245 "boolean married=true;<span class=\"comment\">// the contrary would be "
2246 "written \"false\"</span>"
2247 msgstr ""
2248 "Cadeia nome = \"Martin Quinson\";\n"
2249 "double altura=1.77; <span class=\"comment\">// em metros</span>\n"
2250 "boolean casado=true;<span class=\"comment\">// o contrário se escreve \"false"
2251 "\"</span>"
2252
2253 #. type: Content of: <pre>
2254 #: src/lessons/welcome/variables/Variables.html:97
2255 #, no-wrap
2256 msgid ""
2257 "val name:String = \"Martin Quinson\"; <span class=\"comment\">// this cannot "
2258 "be modified (it's a value)</span>\n"
2259 "var height: Double = 1.77; <span class=\"comment\">// in meters</span>\n"
2260 "var married = true; <span class=\"comment\">// the contrary would be written "
2261 "\"false\"</span>\n"
2262 "<span class=\"comment\">// Scala knows that 'true' is a Boolean value, no "
2263 "need to repeat it here</span>"
2264 msgstr ""
2265 "val nome:String = \"Martin Quinson\"; <span class=\"comment\">// isto não "
2266 "pode ser modificado (é um valor)</span>\n"
2267 "var altura: Double = 1.77; <span class=\"comment\">// em metros</span>\n"
2268 "var casado = true; <span class=\"comment\">// o contrário se escreve \"false"
2269 "\"</span>\n"
2270 "<span class=\"comment\">// Scala sabe que 'true' é um valor Booleano, não "
2271 "precisa repetir</span>"
2272
2273 #. type: Content of: <pre>
2274 #: src/lessons/welcome/variables/Variables.html:102
2275 #, no-wrap
2276 msgid ""
2277 "firstName = \"Martin\"\n"
2278 "lastName = 'Quinson' <span class=\"comment\"># both single and double quote "
2279 "work here</span>\n"
2280 "motto = \"I never finish anyth' (but I keep trying)\" <span "
2281 "class=\"comment\"># having single quote within double quote is fine</span> "
2282 "\n"
2283 "height=1.77 <span class=\"comment\"># in meters</span>\n"
2284 "married=True <span class=\"comment\"># the contrary would be written "
2285 "\"False\"</span>"
2286 msgstr ""
2287 "firstName = \"Martin\"\n"
2288 "lastName = 'Quinson' <span class=\"comment\"># aspas e aspas simples "
2289 "funcionam aqui</span>\n"
2290 "frase = \"uma gota d'água é sempre melhor que nada\" <span class=\"comment\""
2291 "># uma aspas simples entre aspas duplas vale</span> \n"
2292 "altura=1.77 <span class=\"comment\"># em metros</span>\n"
2293 "casado=True <span class=\"comment\"># o contrário se escreve \"False\"</span>"
2294
2295 #. type: Content of: <h3>
2296 #: src/lessons/welcome/variables/Variables.html:108
2297 msgid "Affectations"
2298 msgstr "Atribuições"
2299
2300 #. type: Content of: <p>
2301 #: src/lessons/welcome/variables/Variables.html:110
2302 msgid ""
2303 "Once your variable is declared, you can <b>affect</b> a new value to it "
2304 "later in the program. That's really easy:"
2305 msgstr ""
2306 "Uma vez que a sua variável está declarada, pode lhe <b>atribuir</b> um novo "
2307 "valor mais tarde no programa. Isto é bem fácil:"
2308
2309 #. type: Content of: <pre>
2310 #: src/lessons/welcome/variables/Variables.html:111
2311 #, no-wrap
2312 msgid "x = 3[!java|c];[/!]"
2313 msgstr "x = 3[!java|c];[/!]"
2314
2315 #. type: Content of: <p>
2316 #: src/lessons/welcome/variables/Variables.html:113
2317 msgid ""
2318 "To the right of the equal symbol, you can put an arithmetic expression "
2319 "containing constants, variables and operations."
2320 msgstr ""
2321 "À esquerda do símbolo de igual pode pôr uma expressão aritmética a conter "
2322 "constantes, variáveis e operações."
2323
2324 #. type: Content of: <pre>
2325 #: src/lessons/welcome/variables/Variables.html:115
2326 #, no-wrap
2327 msgid ""
2328 "x = 3 + 2[!java|c];[/!]\n"
2329 "x = 3 * x[!java|c];[/!]\n"
2330 "[!java|scala|python]greeting = \"Hello \"+name[!java];[/!] <span "
2331 "class=\"comment\">[!python]#[/!][!scala|java]//[/!] + is (also) the "
2332 "operation to concatenate (ie, to join) strings[/!]</span>"
2333 msgstr ""
2334 "x = 3 + 2[!java|c];[/!]\n"
2335 "x = 3 * x[!java|c];[/!]\n"
2336 "[!java|scala|python]saudação = \"Oi \"+nome[!java];[/!] <span class=\"comment"
2337 "\">[!python]#[/!][!scala|java]//[/!] + é (também) a operação para concatenar "
2338 "(ie, para juntar) cadeias[/!]</span>"
2339
2340 #. type: Content of: outside any tag (error?)
2341 #: src/lessons/welcome/variables/Variables.html:120
2342 msgid ""
2343 "It is now time to do more challenging exercises, don't you think? The "
2344 "objective is now to move forward until you find a baggle, pick it up, and "
2345 "then move back to your initial location before dropping the baggle."
2346 msgstr ""
2347 "Agora vamos fazer exercícios mais desafiantes, certo? O objetivo agora é "
2348 "mover para a frente até encontrar um baggle, apanhar-lo e mover para trás "
2349 "até a localização inicial antes de sotar o baggle."
2350
2351 #. type: Content of: <h3>
2352 #: src/lessons/welcome/variables/Variables.html:125
2353 msgid "How to do this?"
2354 msgstr "Como fazer isto?"
2355
2356 #. type: Content of: <p>
2357 #: src/lessons/welcome/variables/Variables.html:126
2358 msgid ""
2359 "To solve this problem, you have to decompose it in easier sub-parts. For "
2360 "example, you may want to do the following steps:"
2361 msgstr ""
2362 "Para resolver este problema, tem que decompor-lo em sub-partes menores. Por "
2363 "exemplo, pode fazer os passos seguintes:"
2364
2365 #. type: Content of: <p><ol><li>
2366 #: src/lessons/welcome/variables/Variables.html:129
2367 msgid "Move forward until located over a baggle"
2368 msgstr "Mover para a frente até se pôr sobre um baggle"
2369
2370 #. type: Content of: <p><ol><li>
2371 #: src/lessons/welcome/variables/Variables.html:130
2372 msgid "Pickup the baggle"
2373 msgstr "Apanhar o baggle"
2374
2375 #. type: Content of: <p><ol><li>
2376 #: src/lessons/welcome/variables/Variables.html:131
2377 msgid "Move backward of the same amount of steps than done in first step"
2378 msgstr "Mover para trás a mesma quantidade de passos que deu no primeiro passo"
2379
2380 #. type: Content of: <p><ol><li>
2381 #: src/lessons/welcome/variables/Variables.html:132
2382 msgid "Drop back the baggle"
2383 msgstr "Soltar o baggle de novo"
2384
2385 #. type: Content of: <p>
2386 #: src/lessons/welcome/variables/Variables.html:135
2387 msgid ""
2388 "Naturally, it is impossible to do the right amount of steps backward at step "
2389 "3 if you didn't count the amount of steps done in the first phase. You can "
2390 "use a variable for that, which can be named <code>stepAmount</code>."
2391 msgstr ""
2392 "Naturalmente, é impossível dar a quantidade certa de passos para trás no "
2393 "passo 3 se não contou a quantidade de passos dados na primeira fase. Pode "
2394 "usar uma variável para isto, que pode ser chamada "
2395 "<code>quantidadeDePassos</code>."
2396
2397 #. type: Content of: <p>
2398 #: src/lessons/welcome/variables/Variables.html:139
2399 msgid ""
2400 "Create an integer variable before phase 1, initialize it to 0, and each time "
2401 "you move one step forward, increment its value by one (<code>stepAmount = "
2402 "stepAmount + 1;</code>[!java|c] or <code>stepAmount++;</code>, both syntaxes "
2403 "being equivalent[/!]). Such variable which takes every values of a given "
2404 "range is often called a <b>stepper</b>."
2405 msgstr ""
2406 "Crie uma variável inteira antes da fase 1, inicie ela com 0 e a cada vez que "
2407 "der um passo para frente, incremente ela de um (<code>quantidadeDePassos = "
2408 "quantidadeDePassos + 1;</code>[!java] ou <code>quantidadeDePassos++;</code>, "
2409 "ambas as sintaxes são equivalentes[/!]). Tais variáveis que obtèm cada "
2410 "valor de um dado intervalo são normalmente chamadas de <b>stepper</b>."
2411
2412 #. type: Content of: outside any tag (error?)
2413 #: src/lessons/welcome/variables/Variables.html:145
2414 msgid "[!python|scala]"
2415 msgstr "[!python|scala]"
2416
2417 #. type: Content of: <p>
2418 #: src/lessons/welcome/variables/Variables.html:146
2419 msgid ""
2420 "If you know Java or other languages, you will probably try to use the "
2421 "<code>++</code> operator to increment the variable, but it's not allowed in "
2422 "[!thelang]. This is because it would be difficult to define this operator "
2423 "for every data types. For example, what should ++ do when applied to a "
2424 "Complex value or to a String? The problem does not occur in Java as "
2425 "<code>int</code> is not an object but a primitive type. (if you don't know "
2426 "the <code>++</code>, just ignore this paragraph: it does not exist in "
2427 "[!thelang])"
2428 msgstr ""
2429 "Se conhece Java ou outras linguagens, provavelmente vai tentar usar o "
2430 "operador <code>++</code> para incrementar a variável, mas isto não é "
2431 "permitido em [!thelang]. Isto é por que seria difícil definir este operador "
2432 "para todos os tipos de dados. Por exemplo, o que faria ++ quando aplicado a "
2433 "um valor complexo ou a uma cadeia? O problema não ocorre em Java, pois "
2434 "<code>int</code> não é um objeto e sim um tipo primitivo. (se não conhece o "
2435 "<code>++</code>, simplesmente ignore este parágrafo: fnão existe em "
2436 "[!thelang])"
2437
2438 #. type: Content of: <p>
2439 #: src/lessons/welcome/variables/Variables.html:154
2440 msgid ""
2441 "Then, phase 3 consists in simply creating a new integer variable "
2442 "<code>doneSteps</code> initialized to 0, and do one step backward as long as "
2443 "<code>doneSteps</code> is not equal to <code>stepAmount</code>, incrementing "
2444 "<code>doneSteps</code> each time. The <code>!=</code> operator should be "
2445 "used to test the inequality (whether some values are NOT equal)."
2446 msgstr ""
2447 "Então, a fase 3 consiste em simplesmente criar uma nova variável inteira "
2448 "<code>passosDados</code> iniciada como 0 e dar um passos para trás enquanto "
2449 "<code>passosDados</code> não for igual a <code>quantidadeDePassos</code>, a "
2450 "aumentar <code>passosDados</code> a cada vez. O operador <code>!=</code> "
2451 "deve ser usado para testar a inequação (quando um valor NÃO É igual)."
2452
2453 #. type: Content of: <p>
2454 #: src/lessons/welcome/variables/Variables.html:161
2455 msgid "It's your turn now!"
2456 msgstr "Agora é a sua vez!"
2457
2458 #. type: Content of: <h2>
2459 #: src/lessons/welcome/variables/RunFour.html:2
2460 msgid "Run Four bases"
2461 msgstr "Ande quatro bases"
2462
2463 #. type: Content of: <p>
2464 #: src/lessons/welcome/variables/RunFour.html:4
2465 msgid ""
2466 "Today is a great day for the buggles: the Big Buggles' Race begun. It's a "
2467 "traditional competition in which young buggles prove their value to the "
2468 "tribe. Both force and intelligence is exercised: you have to rush forward, "
2469 "but stop as soon as you reach your fourth baggle. Please help the buggles "
2470 "to move forward while counting the baggles and to determine when to stop."
2471 msgstr ""
2472 "Hoje é um grande dia para os buggles: a grande corrida dos Buggles começou. "
2473 "Esta é uma competição tradicional na qual jovens buggles mostram o valor "
2474 "deles para a tribo. Tanto força quanto inteligência são exercitados: tem que "
2475 "correr, mas parar assim que alcançar o quarto baggle. Por favor, ajude os "
2476 "buggles a se moverem para frente enquanto conta os baggles e determina "
2477 "quando parar."
2478
2479 #. type: Content of: <h2>
2480 #: src/lessons/welcome/variables/RunHalf.html:2
2481 msgid "The Four Halves run"
2482 msgstr "A corrida dos quatro meios"
2483
2484 #. type: Content of: <p>
2485 #: src/lessons/welcome/variables/RunHalf.html:4
2486 msgid ""
2487 "Here is the second day of the Big Buggles' Race. As previously, you have to "
2488 "run forward until you reach the right cell to stop on. But this time, you "
2489 "have to reach the cell where the amount of baggles you saw is the double of "
2490 "the orange cells plus 1. In other words, the following condition must "
2491 "become true: <code>2 * baggles = orangeCells + 1</code>."
2492 msgstr ""
2493 "Chegamos ao segundo dia da grande corrida dos Buggles. Como antes, tem que "
2494 "correr até alcançar a célula certa para parar. Mas desta vez, tem que "
2495 "alcançar a célula onde a quantidade de baggles que viu é o dobro da "
2496 "quantidade de células laranjas mais 1. Em outras palavras, a seguinte "
2497 "condição deve se tornar verdadeira <code>2 * baggles = célulasLaranjas + "
2498 "1</code>."
2499
2500 #. type: Content of: <p>
2501 #: src/lessons/welcome/variables/RunHalf.html:10
2502 msgid ""
2503 "You can determine whether you are over a orange cell with the "
2504 "<code>isOverOrange()</code> method."
2505 msgstr ""
2506 "Pode determinar quando está sobre uma célula laranja com o método "
2507 "<code>isOverOrange()</code>."
2508
2509 #. type: Content of: <p>
2510 #: src/lessons/welcome/loopfor/LoopFor.html:4
2511 msgid ""
2512 "While loops are well adapted to situations where you want to achieve an "
2513 "action while a condition stays true, but it is less adapted to achieve a "
2514 "given action a predetermined amount of time. For example, when we wanted to "
2515 "move <code>stepAmount</code> steps backward in a previous exercise, we had "
2516 "to create a new variable, initialize it, and move backward while "
2517 "incrementing this variable until it became equal to <code>stepAmount</code>."
2518 msgstr ""
2519 "loops 'while' são bem adaptados a situações onde precise realizar uma ação "
2520 "enquanto uma condição se mantém verdadeira, mas são menos preparados para "
2521 "realizar uma ação numa quantidade predeterminada. Por exemplo, quando nos "
2522 "quisemos mover <code>quantidadeDePassos</code> para trás num exercício "
2523 "anterior, tivemos que criar uma nova variável, inicializar ela e mover para "
2524 "trás enquanto aumentávamos esta variável até ela se tornar igual a "
2525 "<code>quantidadeDePassos</code>."
2526
2527 #. type: Content of: <p>
2528 #: src/lessons/welcome/loopfor/LoopFor.html:11
2529 msgid ""
2530 "In such situations, <code>for</code> loops become handy. Their syntax is the "
2531 "following:"
2532 msgstr ""
2533 "Em tais situações, loops <code>for</code> se tornam úteis. As sintaxes delas "
2534 "são as seguintes:"
2535
2536 #. type: Content of: <pre>
2537 #: src/lessons/welcome/loopfor/LoopFor.html:13
2538 #, no-wrap
2539 msgid ""
2540 "[!java|c]for (<b>initializing</b>; <b>condition</b>; <b>incrementing</b>) "
2541 "{\n"
2542 " <b>action</b>();\n"
2543 "}[/!][!python]for <b>variable</b> in <b>sequence of values</b>:\n"
2544 " <b>action</b>()[/!][!scala] for (<b>variable</b> &lt;- <b>firstValue</b> "
2545 "to <b>lastValue</b>) { \n"
2546 " <b>action</b>();\n"
2547 "}[/!]"
2548 msgstr ""
2549 "[!java|c]for (<b>inicialização</b>; <b>condição</b>; <b>incremento</b>) {\n"
2550 " <b>ação</b>();\n"
2551 "}[/!][!python]for <b>variável</b> in <b>sequência-de-valores</b>:\n"
2552 " <b>ação</b>()[/!][!scala] for (<b>variável</b> &lt;- <b>primeiroValor</"
2553 "b> to <b>últimoValor</b>) { \n"
2554 " <b>ação</b>();\n"
2555 "}[/!]"
2556
2557 #. type: Content of: <p>
2558 #: src/lessons/welcome/loopfor/LoopFor.html:20
2559 msgid ""
2560 "For example to repeat the loop body <code>n</code> times, [!python] it is "
2561 "handy to use the instruction <code>range(n)</code> to generate the sequence "
2562 "n integer value from 0 to n-1.[/!] [!java|scala|c] one should write:[/!]"
2563 msgstr ""
2564 "Por exemplo, para repetir o corpo do loop <code>n</code> vezes, [!python] é "
2565 "útil usar a instrução <code>range(n)</code> para gerar a sequência de n "
2566 "valores inteiros de 0 a n-1.[/!] [!java|scala|c] deve escrever:[/!]"
2567
2568 #. type: Content of: <pre>
2569 #: src/lessons/welcome/loopfor/LoopFor.html:23
2570 #, no-wrap
2571 msgid ""
2572 "[!java]for (int stepper=0; stepper&lt;n; stepper++) {\n"
2573 " <b>action</b>();\n"
2574 "}[/!][!c]int stepper;\n"
2575 "for (stepper=0; stepper&lt;n; stepper++) {\n"
2576 " <b>action</b>();\n"
2577 "}[/!][!python]for <b>stepper</b> in <b>range(n)</b>:\n"
2578 " <b>action</b>()[/!][!scala] for (<b>stepper</b> &lt;- <b>1</b> to "
2579 "<b>n</b>) { \n"
2580 " <b>action</b>();\n"
2581 "}[/!]"
2582 msgstr ""
2583 "[!java]for (int iterador=0; iterador&lt;n; iterador++) {\n"
2584 " <b>ação</b>();\n"
2585 "}[/!][!c]int iterador;\n"
2586 "for (iterador=0; iterador&lt;n; iterador++) {\n"
2587 " <b>ação</b>();\n"
2588 "}[/!][!python]for <b>iterador</b> in <b>range(n)</b>:\n"
2589 " <b>ação</b>()[/!][!scala] for (<b>iterador</b> &lt;- <b>1</b> to "
2590 "<b>n</b>) { \n"
2591 " <b>ação</b>();\n"
2592 "}[/!]"
2593
2594 #. type: Content of: <p>
2595 #: src/lessons/welcome/loopfor/LoopFor.html:33
2596 msgid ""
2597 "This code is then equivalent to the following one from the computer point of "
2598 "view. From the programmer point of view, one form or the other can make the "
2599 "source code easier to read, depending on the situation. You should chose "
2600 "wisely in each situation whether you want to use a for loop or a while "
2601 "loop. Your uttermost goal should remain to keep your code simple and easy to "
2602 "read, to ensure that your day remain pleasant and productive."
2603 msgstr ""
2604 "Este código é então equivalente ao seguinte do ponto de vista do computador. "
2605 "Do ponto de vista do programador, uma forma ou outra pode ser mais difícil "
2606 "ou mais fácil de ler, a depender da situação. Deve escolher sabiamente em "
2607 "qual situação usar um loop for ou um loop while. O seu objetivo principal "
2608 "deve ser manter o seu código simples e fácil de ler, para garantir que o seu "
2609 "dia seja agradável e produtivo."
2610
2611 #. type: Content of: <pre>
2612 #: src/lessons/welcome/loopfor/LoopFor.html:41
2613 #, no-wrap
2614 msgid ""
2615 "[!java|c]int stepper = 0;\n"
2616 "while (stepper &lt; n) {\n"
2617 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action</b>();\n"
2618 "&nbsp;&nbsp;&nbsp;&nbsp;<b>stepper++</b>;\n"
2619 "}[/!][!python]stepper=0\n"
2620 "while stepper &lt; n: \n"
2621 " action()\n"
2622 " stepper = stepper + 1[/!][!scala]\n"
2623 "var stepper = 1\n"
2624 "while (stepper &lt;= n) {\n"
2625 " <b>action</b>()\n"
2626 " stepper = stepper + 1\n"
2627 "}[/!]"
2628 msgstr ""
2629 "[!java|c]int iterador = 0;\n"
2630 "while (iterador &lt; n) {\n"
2631 "&nbsp;&nbsp;&nbsp;&nbsp;<b>ação</b>();\n"
2632 "&nbsp;&nbsp;&nbsp;&nbsp;<b>iterador++</b>;\n"
2633 "}[/!][!python]iterador=0\n"
2634 "while iterador &lt; n: \n"
2635 " ação()\n"
2636 " iterador = iterador + 1[/!][!scala]\n"
2637 "var iterador = 1\n"
2638 "while (iterador &lt;= n) {\n"
2639 " <b>ação</b>()\n"
2640 " iterador = iterador + 1\n"
2641 "}[/!]"
2642
2643 #. type: Content of: <p>
2644 #: src/lessons/welcome/loopfor/LoopFor.html:55
2645 msgid "In that case, the <code>for</code> loop is easier to read, don't you think?"
2646 msgstr "Neste caso, o loop <code>for</code> é fácil de ler, não acha?"
2647
2648 #. type: Content of: <p>
2649 #: src/lessons/welcome/loopfor/LoopFor.html:58
2650 msgid ""
2651 "It is possible to build more advanced <tt>for</tt> loops since any valid "
2652 "instruction can be used as initialization, condition and incrementing "
2653 "instruction. The following example is a bit extreme as there is no need for "
2654 "a loop body to move the buggle forward until it reaches the wall, but it "
2655 "works well: all the work is done in the condition and incrementing "
2656 "instruction."
2657 msgstr ""
2658 "É possível construir loops <tt>for</tt> mais avançados já que qualquer "
2659 "instrução válida pode ser usada como inicialização, condição e instrução de "
2660 "incrementação. O exemplo seguinte é um pouco extremo, pois não existe "
2661 "necessidade para um corpo de loop mover um buggle para frente até alcançar a "
2662 "parede, mas funciona bem: todo o trabalho é feito nas instruções de condição "
2663 "e incremento."
2664
2665 #. type: Content of: <pre>
2666 #: src/lessons/welcome/loopfor/LoopFor.html:64
2667 #, no-wrap
2668 msgid ""
2669 "for (; !isFacingWall() ; forward()) { \n"
2670 " <span class=\"comment\">/* nothing in the loop body */</span>\n"
2671 "}\n"
2672 "<span class=\"comment\">/* the buggle now faces a wall */</span>"
2673 msgstr ""
2674 "for (; !isFacingWall() ; forward()) { \n"
2675 " <span class=\"comment\">/* nada no corpo do loop */</span>\n"
2676 "}\n"
2677 "<span class=\"comment\">/* o buggle agora está de cara para uma parede "
2678 "*/</span>"
2679
2680 #. type: Content of: <p>
2681 #: src/lessons/welcome/loopfor/LoopFor.html:71
2682 msgid ""
2683 "If you want to nest several loops, you can do it on one line in Scala. This "
2684 "means that the two following chunks are equivalent:"
2685 msgstr ""
2686 "Se quer aninhar vários loops, pode fazer-lo numa linha no Scala. Isto "
2687 "significa que os dois blocos seguintes são equivalentes:"
2688
2689 #. type: Content of: <pre>
2690 #: src/lessons/welcome/loopfor/LoopFor.html:72
2691 #, no-wrap
2692 msgid ""
2693 "for (stepper1 &lt;- 1 to n) {\n"
2694 " for (stepper2 &lt;- 1 to m) {\n"
2695 " actions()\n"
2696 " }\n"
2697 "}"
2698 msgstr ""
2699 "for (iterador1 &lt;- 1 to n) {\n"
2700 " for (iterador2 &lt;- 1 to m) {\n"
2701 " ações()\n"
2702 " }\n"
2703 "}"
2704
2705 #. type: Content of: <pre>
2706 #: src/lessons/welcome/loopfor/LoopFor.html:77
2707 #, no-wrap
2708 msgid ""
2709 "for (stepper1 &lt;- 1 to n; stepper2 &lt;- 1 to m) { <span "
2710 "class=\"comment\">// Simply separate both loop conditions with a "
2711 "semi-column</span>\n"
2712 " actions()\n"
2713 "}"
2714 msgstr ""
2715 "for (iterador1 &lt;- 1 to n; iterador2 &lt;- 1 to m) { <span class=\"comment"
2716 "\">// Simplesmente separe as duas condições de loop com um "
2717 "ponto-e-vírgula</span>\n"
2718 " ações()\n"
2719 "}"
2720
2721 #. type: Content of: <p>
2722 #: src/lessons/welcome/loopfor/LoopFor.html:83
2723 msgid ""
2724 "You now have to redo the same exercise than previously (move forward until "
2725 "being over a baggle, pick it up, move back to your original location, drop "
2726 "the baggle), but using a <code>for</code> loop instead of a "
2727 "<code>while</code> loop to move back to the initial location."
2728 msgstr ""
2729 "Agora tem que refazer o mesmo exercício de antes (mover para frente até "
2730 "estar sobre um baggle, pegá-lo, mover para trás até a localização original, "
2731 "soltar o baggle), mas a usar um loop <code>for</code> no lugar de um loop "
2732 "<code>while</code> para mover de volta ao local inicial."
2733
2734 #. type: Content of: <p>
2735 #: src/lessons/welcome/loopfor/LoopFor.html:88
2736 msgid "Once done, you can proceed to next exercise."
2737 msgstr "Uma vez feito, pode seguir ao próximo exercício."
2738
2739 #. type: Content of: <h2>
2740 #: src/lessons/welcome/loopfor/LoopStairs.html:2
2741 msgid "Stairway to Heaven"
2742 msgstr "Uma escadaria para o Céu"
2743
2744 #. type: Content of: <p>
2745 #: src/lessons/welcome/loopfor/LoopStairs.html:4
2746 msgid ""
2747 "Your buggle feels a bit depressed today, but it's currently facing a magic "
2748 "stair: It leads directly to heaven, and each time you walk on it, joyful "
2749 "colors spur all around."
2750 msgstr ""
2751 "O seu buggle está um pouco deprimido hoje, mas está em frente de uma escada "
2752 "mágica: ela leva diretamente ao paraíso e cada vez que anda nela, belas "
2753 "cores surgem de todos os lados."
2754
2755 #. type: Content of: <p>
2756 #: src/lessons/welcome/loopfor/LoopStairs.html:7
2757 msgid ""
2758 "Your goal is to take this stair, one step after the other. First devise the "
2759 "four instructions you have to give you buggle to take one stair step, and "
2760 "then put them in a loop to take the whole stair."
2761 msgstr ""
2762 "O seu objetivo é subir a escada, um passo de cada vez. Primeiro \"devise\" "
2763 "as quatro instruções que tem que dar ao buggle para subir um degrau e então "
2764 "ponha-a num loop para subir toda a escada."
2765
2766 #. type: Content of: <p>
2767 #: src/lessons/welcome/loopfor/LoopStairs.html:11
2768 msgid ""
2769 "Before that, walk a bit forward to reach that stair, and ensure that you are "
2770 "in the right situation for your loop content to run properly. And once you "
2771 "reach the heaven, take some steps in your new home. Meanwhile, you just "
2772 "have to walk your way, the colors appear automagically."
2773 msgstr ""
2774 "Antes disto, ande um pouco para a frente para alcançar a escada e certifique-"
2775 "se de estar na situação certa para que o que o loop faz seja feito "
2776 "corretamente. E uma vez alcançado o Céu, dê uns passos no seu novo lar. "
2777 "Enquanto isto, deve apenas seguir o seu caminho, as cores aparecem "
2778 "automagicamente."
2779
2780 #. type: Content of: <h2>
2781 #: src/lessons/welcome/loopfor/LoopCourse.html:2
2782 msgid "Training Buggle"
2783 msgstr "Treinar o Buggle"
2784
2785 #. type: Content of: <p>
2786 #: src/lessons/welcome/loopfor/LoopCourse.html:4
2787 msgid ""
2788 "Today, your buggle wants to get some serious exercise: It wants to run 'till "
2789 "the track burns! Its super-shoes are just perfect to run like hell, but "
2790 "unfortunately, they can actually damage the track on the long run..."
2791 msgstr ""
2792 "Hoje o seu buggle quer fazer exercício seriamente: quer correr até tocar "
2793 "fogo na trilha! Os super-sapatos deles são perfeitos para correr loucamente, "
2794 "mas infelizmente, podem estragar seriamente a trilha a longo prazo..."
2795
2796 #. type: Content of: <p>
2797 #: src/lessons/welcome/loopfor/LoopCourse.html:7
2798 msgid ""
2799 "Your goal is to run the track 10 times, no matter what happens. Even if the "
2800 "track suffers, you <b>really HAVE</b> to take that run. Remember, the track "
2801 "has four sides, that take eight steps each to run along. Now go, and show "
2802 "them what these super shoes can do."
2803 msgstr ""
2804 "O seu objetivo é percorrer a trilha 10 vezes, não importa o que aconteça. "
2805 "Mesmo se a trilha \"suffers\", <b>TEM MESMO</b> que fazer esta corrida. "
2806 "Lembre-se, a triha tem quatro lados, cada lado com oito passos. Agora vá e "
2807 "mostre-lhe o que os seus super-sapatos podem fazer."
2808
2809 #. type: Content of: <p>
2810 #: src/lessons/welcome/loopfor/LoopCourse.html:12
2811 msgid ""
2812 "You don't have to do anything particular with regard of the colors: your "
2813 "shoes will do it for you. Just take that run!"
2814 msgstr ""
2815 "Não tem que fazer nada de particular com respeito às cores: os seus sapatos "
2816 "vão fazer isto para si. Apenas corra!"
2817
2818 #. type: Content of: <h2>
2819 #: src/lessons/welcome/loopfor/LoopCourseForest.html:2
2820 msgid "Outdoor Training Buggle"
2821 msgstr "Treinamento ao ar livre do Buggle"
2822
2823 #. type: Content of: <p>
2824 #: src/lessons/welcome/loopfor/LoopCourseForest.html:4
2825 msgid ""
2826 "Well, our last training didn't went that well. The track actually burned, "
2827 "and we are now banned from there. This time, our buggle decided to practice "
2828 "outdoor, in the middle of the forest, with its good old shoes instead. The "
2829 "problem is that you have to be careful to not fall into water. The track on "
2830 "which you can run is rather narrow: One side is now 4 steps forward, 2 steps "
2831 "to the left, 4 steps to the right, 2 steps to the right, 4 steps to the "
2832 "left, and you want to run 7 around."
2833 msgstr ""
2834 "Bem, nosso último treino teve um probleminha. A trilha tocou fogo e fomos "
2835 "banidos de lá. Desta vez, nosso buggle decidiu praticar ao ar livre, no meio "
2836 "da floresta, com os sapatos velhos deles. O problema é que tem que ser "
2837 "cuidadoso para não cair na água. A trilha onde corre é estreita: \"One side "
2838 "is now\" 4 passos para a frente, 2 passos para a esquerda, 4 passos para a "
2839 "direita, 2 passos para a direita, 4 passos para a esquerda, \"and you want "
2840 "to run 7 around\"."
2841
2842 #. type: Content of: <p>
2843 #: src/lessons/welcome/loopfor/LoopCourseForest.html:10
2844 msgid ""
2845 "Oh crap, running on the grass seems to destroy it too! So just take your 7 "
2846 "loops around the garden, and move along to the next exercise before anyone "
2847 "notices the damage you made..."
2848 msgstr ""
2849 "Putz, correr na grama destrói a grama também! Então dê apenas 7 voltas no "
2850 "jardim e depois vá ao próximo exercício antes que alguém perceba o estrago "
2851 "que fez..."
2852
2853 #. type: Content of: <p>
2854 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:4
2855 msgid ""
2856 "Some cells of the world are yellow, but your buggle cannot stand being in "
2857 "such cells. Write the necessary code to move forward until the ground gets "
2858 "white. For that, use the provided method <code>isGroundWhite()</code>."
2859 msgstr ""
2860 "Algumas células do mundo são amarelas, mas o seu buggle não pode ficar sobre "
2861 "estas células. Escreva o código necessário para mover para a frente até que "
2862 "o chão fique branco. Para isto use o método fornecido "
2863 "<code>isGroundWhite()</code>."
2864
2865 #. type: Content of: <p>
2866 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:8
2867 msgid ""
2868 "The trick is that most buggles of this world are currently on this yellow "
2869 "ground that they dislike so much. That is why they are in panic, and every "
2870 "buggle rushes one cell forward, even the buggle that was not on a yellow "
2871 "cell at first. In other worlds, even if the ground is white on the first "
2872 "cell, you still want to move forward to the next cell."
2873 msgstr ""
2874 "O truque é que a maioria dos buggles deste mundo ficam sobre o chão amarelo "
2875 "que eles não gostam. é por isto que eles estão em pânico e cada buggle "
2876 "\"rushes\" uma célula para a frente, mesmo aqueles que não estavam numa "
2877 "célula amarela no começo. Em outras palavras, mesmo se o chão for branco na "
2878 "primeira célula, ainda vai mover para a próxima célula."
2879
2880 #. type: Content of: <p>
2881 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:13
2882 msgid "The general idea is to do something like:"
2883 msgstr "A ideia geral é fazer algo como:"
2884
2885 #. type: Content of: <pre>
2886 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:14
2887 #, no-wrap
2888 msgid "move forward until located in a white cell"
2889 msgstr "Mover para a frente até estar numa célula branca"
2890
2891 #. type: Content of: <p>
2892 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:16
2893 msgid ""
2894 "The main difficulty is that we want this loop body to be executed once, even "
2895 "we are already on a white cell. It would be easy to do so by duplicating "
2896 "the loop content before the actual loop, but this would be a bad idea: code "
2897 "duplication is a <b>very</b> bad habit, and you should <b>always</b> avoid "
2898 "it."
2899 msgstr ""
2900 "A coisa mais difícil é que queremos executar o corpo do loop uma vez, mesmo "
2901 "se já estivermos numa célula branca. Isto é fácil a duplicar o código do "
2902 "loop'antes do loop em si, mas esta é uma má ideia: diplicação de código é um "
2903 "hábito <b>muito</b> ruim e deve evitar isto <b>sempre</b>."
2904
2905 #. type: Content of: <p>
2906 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:20
2907 msgid ""
2908 "Code duplication easily turns code maintenance into a nightmare: reading the "
2909 "code becomes difficult as the reader must ensure that no slight difference "
2910 "exist between the versions. Debugging the code becomes difficult, as bugs "
2911 "have to be fixed in all versions. Actually, every modification of the code "
2912 "becomes difficult. So, really, you should <b>always</b> strive to not "
2913 "duplicate your code if you can avoid. And the good news is that you always "
2914 "can..."
2915 msgstr ""
2916 "Duplicação de código faz da manutenção de código um pesadelo rapidamente: é "
2917 "fdifícil ler o código e o leitor tem que garantir que nenhuma pequena "
2918 "diferença exista entre as versões. Depurar o código se torna difícil, pois "
2919 "os bugs devem ser consertados em todas as versões. Na verdade, cada "
2920 "modificação do código se torna difícil. Então, na verdade, deve <b>sempre</"
2921 "b> se esforçar para não duplicar o seu código sempre que possível. Mas a boa "
2922 "notícia é que sempre pode..."
2923
2924 #. type: Content of: <h3>
2925 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:25
2926 msgid "Executing the loop body at least once"
2927 msgstr "A executar o corpo do loop pelo menos uma vez"
2928
2929 #. type: Content of: outside any tag (error?)
2930 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:26
2931 #: src/lessons/welcome/loopdowhile/Poucet2.html:19
2932 #: src/lessons/welcome/array/basics/Array1.html:100
2933 #: src/lessons/turmites/helloturmite/HelloTurmite.html:54
2934 #: src/lessons/maze/pledge/PledgeMaze.html:59
2935 msgid "[!python]"
2936 msgstr "[!python]"
2937
2938 #. type: Content of: <p>
2939 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:27
2940 msgid ""
2941 "Some languages have specific constructs for that, but not the Python "
2942 "language. No problem, we can do it on our own! A good way is to have a "
2943 "dedicated variable indicating whether we are taking the loop for the first "
2944 "time or not, as follows."
2945 msgstr ""
2946 "Algumas linguagens tem construções específicas para isto, mas não a "
2947 "linguagem Python. Sem problemas, podemos fazer isto nós mesmos! Uma boa "
2948 "forma é ter uma variável dedicada a indicar se estamos a entrar no loop a "
2949 "primeira vez ou não, como segue."
2950
2951 #. type: Content of: <pre>
2952 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:31
2953 #, no-wrap
2954 msgid ""
2955 "firstTime = True\n"
2956 "while firstTime or (other conditions):\n"
2957 " firstTime = False\n"
2958 " (loop body)\n"
2959 msgstr ""
2960 "primeiraVez = True\n"
2961 "while primeiraVez or (outras condições):\n"
2962 " primeiraVez = False\n"
2963 " (corpo do loop)\n"
2964
2965 #. type: Content of: <p>
2966 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:37
2967 msgid ""
2968 "When <code>firstTime</code> is true, the loop body is executed even if the "
2969 "other conditions would imply the contrary. Once the loop body has been "
2970 "executed once, it is set to false and never impact again the decision to "
2971 "enter the body or not."
2972 msgstr ""
2973 "Quando <code>primeiraVez</code> é true, o corpo do loop é executado mesmo se "
2974 "as outras condições digam o contrário. uma vez que o loop tenha sido "
2975 "executado uma vez, esta variável vira false e nunca mais impacta na decisão "
2976 "de entrar ou não no loop."
2977
2978 #. type: Content of: <p>
2979 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:43
2980 msgid ""
2981 "In a <tt>while</tt> loop, the condition is evaluated before anything else, "
2982 "and if it's false, the loop body is never evaluated. Sometimes (although not "
2983 "that often), you would prefer the loop body to get evaluated at least once, "
2984 "even if the condition is initially false. For that, a variation of the "
2985 "<tt>while</tt> loop gets used, using the following syntax in [!thelang]. "
2986 "[!java|c]Do not forget the semi-column (;) after the condition, it is "
2987 "mandatory.[/!]"
2988 msgstr ""
2989 "Num loop <tt>while</tt>, a condição é calculada antes de qualquer coisa e se "
2990 "for falsa, o corpo do loop nunca é executado. Algumas vezes (mas não muito "
2991 "frequentemente), pode preferir que o corpo do loop seja executado pelo menos "
2992 "uma vez, mesmo se a condição seja inicialmente falsa. Para isto, uma "
2993 "variação do loop <tt>while</tt> é usada, com a seguinte sintaxe em [!thelang]"
2994 ". [!java|c]Não se esqueça do ponto-e-vírgula (;) depois da condição, que é "
2995 "obrigatório.[/!]"
2996
2997 #. type: Content of: <p><pre>
2998 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:51
2999 #, no-wrap
3000 msgid ""
3001 "do {\n"
3002 " <b>action()</b>[!java];[/!]\n"
3003 "} while (<b>condition</b>)[!java];[/!]"
3004 msgstr ""
3005 "do {\n"
3006 " <b>ação()</b>[!java];[/!]\n"
3007 "} while (<b>condição</b>)[!java];[/!]"
3008
3009 #. type: Content of: <h2>
3010 #: src/lessons/welcome/loopdowhile/Poucet1.html:2
3011 msgid "Tracks of buggles"
3012 msgstr "Trilhas de buggles"
3013
3014 #. type: Content of: <p>
3015 #: src/lessons/welcome/loopdowhile/Poucet1.html:4
3016 msgid ""
3017 "Your buggle got lost in a strange maze, and you must help it to find the "
3018 "exit that is represented in orange. You cannot simply explain the path to "
3019 "the exit in something like "
3020 "<code>right();forward();forward();forward()</code> because you have to save "
3021 "two buggles at the same time, that are lost in similar but not identical "
3022 "worlds. You can switch to the other world by using the combobox above the "
3023 "world representation (where it's written 'Deep Forest' right now), and "
3024 "selecting the other entry (that should read 'Deeper Forest')."
3025 msgstr ""
3026 "O seu buggle perdeu-se num estranho labirinto e deve ajudá-lo a achar a "
3027 "saída que está representada em laranja. Não pode simplesmente explicar o "
3028 "caminho para a saída com algo do tipo "
3029 "<code>right();forward();forward();forward()</code> por que tem que gravar "
3030 "dois buggles ao mesmo tempo, que estão presos em mundos similares, mas não "
3031 "iguais. Pode alternar para o outro mundo a usar o combobox acima da "
3032 "representação do mundo (onde está escrito 'Floresta Fechada' agora) e "
3033 "selecionar a outra entrada (que deve ler 'Floresta Mais Fechada')."
3034
3035 #. type: Content of: <p>
3036 #: src/lessons/welcome/loopdowhile/Poucet1.html:10
3037 msgid ""
3038 "The good news is that the path to the exit is written on the ground. As you "
3039 "can see, the world is made of several corridors, with baggles on the "
3040 "ground. After each corridor, you should turn left if the corridor contains "
3041 "three baggels or more, and you have to turn right if there is only 2 baggles "
3042 "or less."
3043 msgstr ""
3044 "A boa nova é que o caminho para a saída está desenhado no chão. Como pode "
3045 "ver, o mundo é feito de vários corredores, com baggles no chão. Depois de "
3046 "cada corredor, deve virar à esquerda se o corredor tiver três baggels ou "
3047 "mais e virar a direita se tiver apenas 2 ou menos baggles."
3048
3049 #. type: Content of: <p>
3050 #: src/lessons/welcome/loopdowhile/Poucet1.html:14
3051 msgid ""
3052 "You should count exactly 5 cells per corridor, from intersection to "
3053 "intersection. Consider in your count the intersection ending the corridor "
3054 "but not the intersection before the corridor."
3055 msgstr ""
3056 "Deve contar exatamente 5 células por corredor, de intersecção a "
3057 "intersecção. Considere na sua contagem a intersecção terminar o corredor, "
3058 "mas não a intersecção antes do corredor."
3059
3060 #. type: Content of: <p>
3061 #: src/lessons/welcome/loopdowhile/Poucet1.html:18
3062 msgid ""
3063 "So, the general form of your code must be something like \"while I did not "
3064 "find the exit, take the next corridor to decide whether I should turn left "
3065 "or right at the next intersection\". You can determine whether you are on "
3066 "the exit cell (that is orange) with the provided <code>exitReached()</code> "
3067 "method."
3068 msgstr ""
3069 "Logo, a forma geral do seu código deve ser algo como \"enquanto não "
3070 "encontrar a saída, escolha o próximo corredor para decidir se vira à esqueda "
3071 "ou à direita na próxima intersecção\". Pode determinar se está na célula de "
3072 "saída (que é laranja) com o método <code>exitReached()</code> fornecido."
3073
3074 #. type: Content of: <p>
3075 #: src/lessons/welcome/loopdowhile/Poucet1.html:22
3076 msgid ""
3077 "To take one corridor, you simply have to run from one intersection to "
3078 "another while counting the baggles you see on your path. That's easy: there "
3079 "is 5 steps in each corridors so a simple <code>for</code> loop suffices."
3080 msgstr ""
3081 "Para entrar num corredor, tem que simplesmente correr de uma intersecção "
3082 "para outra enquanto conta os baggles que vê no seu caminho. Isto é fácil: "
3083 "existem 5 passos em cada corredor, de forma que um simples loop <code>for</"
3084 "code> resolve."
3085
3086 #. type: Attribute 'alt' of: <p><div>
3087 #: src/lessons/welcome/loopdowhile/Poucet1.html:26
3088 msgid "I cannot imagine how to count the baggles I see."
3089 msgstr "Não consigo imaginar como contar os baggles que vejo."
3090
3091 #. type: Content of: <p><div>
3092 #: src/lessons/welcome/loopdowhile/Poucet1.html:27
3093 msgid ""
3094 "You need a variable that is initialized to 0, and incremented each time you "
3095 "see a baggle on the ground. A variable used this way is often called "
3096 "<i>counter</i>."
3097 msgstr ""
3098 "Precisa de uma variável que é inicializada em 0 e incrementada cada vez que "
3099 "vê um baggle no chão. Uma variável usada desta forma é frequentemente "
3100 "chamada de <i>contador</i>."
3101
3102 #. type: Content of: <p><div>
3103 #: src/lessons/welcome/loopdowhile/Poucet1.html:29
3104 msgid "Don't forget to reset your counter to 0 at the beginning of each corridor!"
3105 msgstr ""
3106 "Não se esqueça de resetar o seu contador para 0 no começo de cada corredor!"
3107
3108 #. type: Content of: <p>
3109 #: src/lessons/welcome/loopdowhile/Poucet1.html:32
3110 msgid ""
3111 "Oh, and when you reach the exit, don't forget to take an extra step to "
3112 "actually exit the maze!"
3113 msgstr ""
3114 "Ah, e quando chegar na saída, não se esqueça de dar um passo a mais para "
3115 "sair de fato do labirinto!"
3116
3117 #. type: Content of: <h2>
3118 #: src/lessons/welcome/loopdowhile/Poucet2.html:2
3119 msgid "More buggles tracks"
3120 msgstr "Mais rastros de buggles"
3121
3122 #. type: Content of: <p>
3123 #: src/lessons/welcome/loopdowhile/Poucet2.html:4
3124 msgid ""
3125 "Hu oh! Your buggle got lost again in the same kind of maze, but this time, "
3126 "the corridors are not always of the same size. Since there is no way to know "
3127 "the length of the corridor before taking it, a <code>for</code> will not "
3128 "suffice anymore. Instead, you will have to change your inner loop to use a "
3129 "<code>while</code> loop, using the method <code>crossing()</code> that tells "
3130 "whether your buggle currently stands on an intersection."
3131 msgstr ""
3132 "Uau! O seu buggle perdeu-se novamente no mesmo tipo de labirinto, mas desta "
3133 "vez, os corredores nem sempre são do mesmo tamanho. Porque não há como saber "
3134 "a comprimento do corredor antes de tomá-lo, um <code>for</code> não será "
3135 "mais suficiente. Ao invés disso, terá que mudar o seu loop interno para usar "
3136 "um loop <code>while</code>, a usar o método <code>crossing()</code> que diz "
3137 "se o seu buggle está atualmente numa intersecção."
3138
3139 #. type: Content of: <p>
3140 #: src/lessons/welcome/loopdowhile/Poucet2.html:10
3141 msgid ""
3142 "The extra complexity is that at the beginning of a corridor, you obviously "
3143 "stand on an intersection, but you still want to move on. [!java|scala|c]For "
3144 "that, the easiest is to use a <code>do / while</code> loop instead of a "
3145 "regular <code>while</code> loop to move until the next intersection.[/!] "
3146 "[!python]For that, use an extra variable indicating whether you already "
3147 "entered the corridor, as follows. This will ensure that you execute the loop "
3148 "body at least once (when <code>firstTime</code> is true) before we actually "
3149 "use the value returned by <code>crossing()</code> to determine to continue "
3150 "or not.[/!]"
3151 msgstr ""
3152 "A complexidade adicional é que no início de um corredor, obviamente está num "
3153 "cruzamento, mas ainda quer seguir. [!java|scala|c]Para isso, o mais fácil é "
3154 "usar um loop <code>do / while</code> em vez de um loop regular <code>while</"
3155 "code> para mover até a próxima intersecção.[/!] [!python]Para isso, use uma "
3156 "variável adicional para indicar se já entrou no corredor, como a seguir. "
3157 "Isto assegurará que execute o corpo do loop pelo menos uma vez (quando "
3158 "<code>firstTime</code> for true) antes de usarmos o valor retornado por "
3159 "<code>crossing()</code> para determinar se devemos continuar ou não.[/!]"
3160
3161 #. type: Content of: <pre>
3162 #: src/lessons/welcome/loopdowhile/Poucet2.html:20
3163 #, no-wrap
3164 msgid ""
3165 "firstTime = True\n"
3166 "while firstTime or not crossing():\n"
3167 " firstTime = False\n"
3168 " (loop body)\n"
3169 msgstr ""
3170 "primeiraVez = True\n"
3171 "while primeiraVez or not crossing():\n"
3172 " primeiraVez = False\n"
3173 " (corpo do loop)\n"
3174
3175 #. type: Content of: <p>
3176 #: src/lessons/welcome/loopdowhile/Poucet2.html:27
3177 msgid "With that new trick, your buggle should exit this maze quite easily."
3178 msgstr ""
3179 "Com esse novo truque, o seu buggle deve sair desse labirinto muito "
3180 "facilmente."
3181
3182 #. type: Content of: <h1>
3183 #: src/lessons/welcome/array/basics/Array1.html:2
3184 msgid "[!java|scala]Arrays[/!][!python]Lists[/!] and Knotting"
3185 msgstr "[!java|scala]Arrays[/!][!python]Lists[/!] e nós"
3186
3187 #. type: Content of: outside any tag (error?)
3188 #: src/lessons/welcome/array/basics/Array1.html:4
3189 msgid ""
3190 "The goal of this exercise is to reproduce the pattern of the first row in "
3191 "the other rows with a shift of one cell (see the Objective tab for "
3192 "details). The biggest difference between this exercise and the others we had "
3193 "on patterns is that you have to read the pattern (on first row) before "
3194 "reproducing it. You cannot do otherwise because the same code will be "
3195 "executed on three different worlds, each of them having a specific pattern."
3196 msgstr ""
3197 "O objetivo deste exercício é reproduzir o padrão da primeira linha nas "
3198 "outras linhas com um deslocamento de uma célula (veja a guia Objetivo para "
3199 "detalhes). A maior diferença entre este exercício e os outros sobre padrões "
3200 "é que tem que ler o padrão (na primeira linha) antes de reproduzí-lo. Não "
3201 "pode fazer de outro jeito por que o mesmo código será executado em três "
3202 "mundos diferentes, cada um com um próprio padrão."
3203
3204 #. type: Content of: <p>
3205 #: src/lessons/welcome/array/basics/Array1.html:12
3206 msgid ""
3207 "One solution is to read the next cell, and go copy it in position before "
3208 "coming back to read the second cell. But since it is forbidden to use the "
3209 "methods to teleport the buggle to a specific position (<code>setPos()</code> "
3210 "and similar), this approach will be a pain to implement."
3211 msgstr ""
3212 "Uma solução é ler a próxima célula e copiá-la à posição antes de voltar para "
3213 "ler a segunda célula. Mas já que é proibido usar os métodos de "
3214 "teletransporte de buggle para uma posição específica (<code>setPos()</code> "
3215 "e similares), esta abordagem seria muito difícil de implementar."
3216
3217 #. type: Content of: <p>
3218 #: src/lessons/welcome/array/basics/Array1.html:17
3219 msgid ""
3220 "The simplest is to store the sequence of colors that constitute the whole "
3221 "pattern in an [!java|scala]<b>array</b>[/!][!python]<b>list</b>[/!]. But "
3222 "before we can do so, we should learn a bit what "
3223 "[!java|scala]arrays[/!][!python]lists[/!] are."
3224 msgstr ""
3225 "O mais simples é armazenar a sequência de cores que constituem o padrão "
3226 "inteiro numa [!java|scala]<b>array</b>[/!][!python]<b>list</b>[/!]. Mas "
3227 "antes de fazer isto, devemos aprender um pouco sobre o que "
3228 "[!java|scala]arrays[/!][!python]lists[/!] são."
3229
3230 #. type: Content of: <h2>
3231 #: src/lessons/welcome/array/basics/Array1.html:21
3232 msgid "[!java|scala]Arrays[/!][!python]List[/!]"
3233 msgstr "[!java|scala]Arrays[/!][!python]List[/!]"
3234
3235 #. type: Content of: <p>
3236 #: src/lessons/welcome/array/basics/Array1.html:23
3237 msgid ""
3238 "[!java|scala]An array[/!][!python]A list[/!] is an ordered sequence of "
3239 "variables that go together. It is somehow similar to a shelve where each "
3240 "level can store a separate value. Each variable of the sequence is "
3241 "identified by its position, and can store a specific value. [!java|scala]All "
3242 "cells of the array must store values of the same type because arrays are "
3243 "homogeneous in [!thelang]. It is possible to trick this restriction by using "
3244 "the datatype <code>[!java]Object[/!][!scala]Any[/!]</code> that can contain "
3245 "[!java]almost[/!] any other datatype. [!java]Primitive types such as the "
3246 "ones we saw so far (int, boolean, double, char, etc) cannot be stored in an "
3247 "Object variable, but their objectified counter-part (Integer, Boolean, "
3248 "Double, Char, Boolean, etc) can.[/!] It is however a good practice to make "
3249 "the type of an array as specific as possible, i.e., if you plan to store "
3250 "some integers in your array, make it an array of integers, not of "
3251 "[!java]Object[/!][!scala]Any[/!].[/!] [!python]Lists can even mix values of "
3252 "differing types, such as integer values in some cells and colors in other "
3253 "cells.[/!]"
3254 msgstr ""
3255 "[!java|scala]Uma array[/!][!python]Uma list[/!] é uma sequência ordenada de "
3256 "variáveis que ficam juntas. é similar a uma estante onde em cada prateleira "
3257 "se coloca um valor separado. Cada variável da sequência é identificada pela "
3258 "posição dela e pode armazenar um valor específico. [!java|scala]todas as "
3259 "células da array devem armazenar valores do mesmo tipo por que arrays são "
3260 "homogêneas em [!thelang]. É possível burlar esta restrição a usar tipos de "
3261 "dados <code>[!java]Object[/!][!scala]Any[/!]</code> que contenham "
3262 "[!java]praticamente[/!] qualquer outro tipo de dados. [!java]Tipos "
3263 "primitivos como aqueles que vimos anteriormente (int, boolean, double, char, "
3264 "etc) não podem ser armazenados numa variável Object, mas suas contrapartidas "
3265 "objetificadas (Integer, Boolean, Double, Char, Boolean, etc) podem.[/!] "
3266 "Entretanto, é boa prática fazer o tipo de uma array o mais específico "
3267 "possível, p.ex., se planea armazenar alguns inteiros na sua array, faça dela "
3268 "uma array de inteiros, não de [!java]Object[/!][!scala]Any[/!].[/!] [!python]"
3269 "Lists podematé mesmo misturar valores de diferentes tipos, como valores "
3270 "inteiros em algumas células e cores em outras células.[/!]"
3271
3272 #. type: Content of: <p>
3273 #: src/lessons/welcome/array/basics/Array1.html:40
3274 msgid ""
3275 "T is the [!java|scala]array[/!][!python]list[/!]'s name, "
3276 "[!java|python]T[0][/!][!scala]T(0)[/!] is the name of the first cell, "
3277 "[!java|python]T[1][/!][!scala]T(1)[/!] the name of the second cell, "
3278 "[!java|python]T[2][/!][!scala]T(2)[/!] the third one, etc. And yes, the "
3279 "first cell is numbered [!java|python]T[0][/!][!scala]T(0)[/!] while the last "
3280 "one of [!java|scala]an array[/!][!python]a list[/!] of size N is "
3281 "[!java|python]T[N-1][/!][!scala]T(N-1)[/!]. It may seem funny to count "
3282 "starting from 0 and not from 1 as usual, but some historical reasons make it "
3283 "unavoidable here."
3284 msgstr ""
3285 "T é o nome da [!java|scala]array[/!][!python]list[/!], "
3286 "[!java|python]T[0][/!][!scala]T(0)[/!] é o nome da primeira célula, "
3287 "[!java|python]T[1][/!][!scala]T(1)[/!] é o nome da segunda célula, "
3288 "[!java|python]T[2][/!][!scala]T(2)[/!] da terceira e etc. E sim, a primeira "
3289 "célula é numerada [!java|python]T[0][/!][!scala]T(0)[/!] e a última de uma "
3290 "[!java|scala]array[/!][!python]list[/!] de tamanho N é "
3291 "[!java|python]T[N-1][/!][!scala]T(N-1)[/!]. Pode parecer estranho contar a "
3292 "partir de 0 e não de 1 como normalmente, mas por motivos históricos isto "
3293 "agora é inevitável."
3294
3295 #. type: Content of: <h3>
3296 #: src/lessons/welcome/array/basics/Array1.html:48
3297 msgid "Basic usage"
3298 msgstr "Uso básico"
3299
3300 #. type: Content of: <p>
3301 #: src/lessons/welcome/array/basics/Array1.html:50
3302 msgid ""
3303 "We can use an integer variable <i>i</i> to access with "
3304 "[!java|python]T[i][/!][!scala]T(i)[/!] to the cells: when the value of "
3305 "<i>i</i> is 0, then [!java|python]T[i][/!][!scala]T(i)[/!] accesses "
3306 "[!java|python]T[0][/!][!scala]T(0)[/!]; when the value of <i>i</i> is 10, "
3307 "then [!java|python]T[i][/!][!scala]T(i)[/!] accesses "
3308 "[!java|python]T[10][/!][!scala]T(10)[/!]. <i>i</i> is said to be the "
3309 "<b>index</b> in T. <code>[!java|python]T[i][/!][!scala]T(i)[/!]</code> can "
3310 "be used just like any variable. We can set a new value:"
3311 msgstr ""
3312 "Podemos usar uma variável inteira <i>i</i> para acessar com "
3313 "[!java|python]T[i][/!][!scala]T(i)[/!] as células: quando o valor de <i>i</"
3314 "i> é 0, [!java|python]T[i][/!][!scala]T(i)[/!] acessa "
3315 "[!java|python]T[0][/!][!scala]T(0)[/!]; quando o valor de <i>i</i> é 10, "
3316 "[!java|python]T[i][/!][!scala]T(i)[/!] acessa "
3317 "[!java|python]T[10][/!][!scala]T(10)[/!]. Sizemos que <i>i</i> é o "
3318 "<b>índice</b> em T. <code>[!java|python]T[i][/!][!scala]T(i)[/!]</code> pode "
3319 "ser usada simplesmente como qualquer variável. Podemos configurar um novo "
3320 "valor:"
3321
3322 #. type: Content of: <pre>
3323 #: src/lessons/welcome/array/basics/Array1.html:58
3324 #, no-wrap
3325 msgid "[!java|python]T[i][/!][!scala]T(i)[/!] = 78[!java];[/!]"
3326 msgstr "[!java|python]T[i][/!][!scala]T(i)[/!] = 78[!java];[/!]"
3327
3328 #. type: Content of: <p>
3329 #: src/lessons/welcome/array/basics/Array1.html:60
3330 msgid "We can retrieve and use its value:"
3331 msgstr "Podemos recuperar e usar valor dele:"
3332
3333 #. type: Content of: <pre>
3334 #: src/lessons/welcome/array/basics/Array1.html:61
3335 #, no-wrap
3336 msgid "x = [!java|python]T[i][/!][!scala]T(i)[/!][!java];[/!]"
3337 msgstr "x = [!java|python]T[i][/!][!scala]T(i)[/!][!java];[/!]"
3338
3339 #. type: Content of: <p>
3340 #: src/lessons/welcome/array/basics/Array1.html:63
3341 msgid "We can test this value:"
3342 msgstr "Podemos testar este valor:"
3343
3344 #. type: Content of: <pre>
3345 #: src/lessons/welcome/array/basics/Array1.html:64
3346 #, no-wrap
3347 msgid ""
3348 "if ([!java|python]T[i][/!][!scala]T(i)[/!] > 0) "
3349 "[!scala|java]{[/!][!python]:[/!]\n"
3350 " [!java|scala]//[/!][!python]#[/!] instructions...\n"
3351 "[!java|scala]}[/!]"
3352 msgstr ""
3353 "if ([!java|python]T[i][/!][!scala]T(i)[/!] > 0) "
3354 "[!scala|java]{[/!][!python]:[/!]\n"
3355 " [!java|scala]//[/!][!python]#[/!] instruções...\n"
3356 "[!java|scala]}[/!]"
3357
3358 #. type: Content of: <p>
3359 #: src/lessons/welcome/array/basics/Array1.html:68
3360 msgid ""
3361 "It is very easy to traverse the whole "
3362 "[!scala|java]array[/!][!python]list[/!], for example to initialize each "
3363 "cells."
3364 msgstr ""
3365 "É muito fácil percorrer toda a [!scala|java]array[/!][!python]list[/!], por "
3366 "exemplo para iniciar as células."
3367
3368 #. type: Content of: <pre>
3369 #: src/lessons/welcome/array/basics/Array1.html:71
3370 #, no-wrap
3371 msgid ""
3372 "[!java]for (int i = 0; i&lt;T.length; i++) {[/!][!python]for i in "
3373 "range(len(T)):[/!][!scala]for (i &lt;- 0 to T.length-1) {[/!]\n"
3374 " [!java|python]T[i][/!][!scala]T(i)[/!] = 3[!java];[/!]\n"
3375 "[!java|scala]}[/!]"
3376 msgstr ""
3377 "[!java]for (int i = 0; i&lt;T.length; i++) {[/!][!python]for i in "
3378 "range(len(T)):[/!][!scala]for (i &lt;- 0 to T.length-1) {[/!]\n"
3379 " [!java|python]T[i][/!][!scala]T(i)[/!] = 3[!java];[/!]\n"
3380 "[!java|scala]}[/!]"
3381
3382 #. type: Content of: <p>
3383 #: src/lessons/welcome/array/basics/Array1.html:75
3384 msgid ""
3385 "[!java|scala]The notation <code>T.length</code> retrieves the length of the "
3386 "array T,[/!] [!python]The function <code>len()</code> retrieves the length "
3387 "of the list T,[/!] allowing to build a classical for loop easily. "
3388 "[!python]Actually, the <code>len()</code> function is much more generic and "
3389 "can be used to retrieve the length of many objects. Applied to strings for "
3390 "example, it returns the amount of chars in this string.[/!] [!scala]Don't "
3391 "forget to start at <code>0</code> and stop at <code>T.length-1</code> "
3392 "instead of <code>1</code> to <code>T.length</code> however.[/!]"
3393 msgstr ""
3394 "[!java|scala]A notação <code>T.length</code> recupera o comprimento (length) "
3395 "da array T,[/!] [!python]A função <code>len()</code> recupera o comprimento "
3396 "da lista T,[/!] a permitir que se construa um loop clássico facilmente. "
3397 "[!python]Na verdade, a função <code>len()</code> é muito mais genérica e "
3398 "pode ser usada para recuperar o comprimento de muitos objetos. Aplicada numa "
3399 "cadeia, por exemplo, ela retorna a quantidade de caracteres na cadeia.[/!] "
3400 "[!scala]Não se esqueça de começar em <code>0</code> e terminar em <code>T."
3401 "length-1</code> ao invés de ir de <code>1</code> até <code>T."
3402 "length</code>.[/!]"
3403
3404 #. type: Content of: <p>
3405 #: src/lessons/welcome/array/basics/Array1.html:83
3406 msgid ""
3407 "If you just want to iterate over the values of T without keeping track of "
3408 "their index, you can simply write:"
3409 msgstr ""
3410 "Se quer simplesmente iterar nos valores de T sem controlar o índice, pode "
3411 "simplesmente escrever:"
3412
3413 #. type: Content of: <pre>
3414 #: src/lessons/welcome/array/basics/Array1.html:84
3415 #, no-wrap
3416 msgid ""
3417 "[!java]for (int i: T) {[/!][!scala]for (i &lt;- T) {[/!][!python]for i in "
3418 "T:[/!]\n"
3419 " action()[!java];[/!]\n"
3420 "[!java|scala]}[/!]"
3421 msgstr ""
3422 "[!java]for (int i: T) {[/!][!scala]for (i &lt;- T) {[/!][!python]for i in "
3423 "T:[/!]\n"
3424 " ação()[!java];[/!]\n"
3425 "[!java|scala]}[/!]"
3426
3427 #. type: Content of: <p>
3428 #: src/lessons/welcome/array/basics/Array1.html:87
3429 msgid ""
3430 "[!java]This construct is called an <i>extended loop</i> in Java. The "
3431 "variable <i>i</i> takes all values of the set located to the right of the "
3432 "colon (:), one after the other.[/!] [!python|scala]This is actually very "
3433 "similar to the previous construct. Simply, "
3434 "<code>[!python]range(n)[/!][!scala]i to j[/!]</code> returns a set of "
3435 "integers over which the for construct iterates. Actually, [!thelang] offers "
3436 "much more elegant ways to traverse [!python]lists[/!][!scala]arrays[/!] and "
3437 "other data collections, but this should be the topic of a specific set of "
3438 "exercises (that are still to be written in PLM).[/!]"
3439 msgstr ""
3440 "[!java]Esta construção é chamada um <i>loop extendido</i> em Java. A "
3441 "variável <i>i</i> assume todos os valores do conjunto localizado a direita "
3442 "do dois-pontos (:), um depois do outro.[/!] [!python|scala]Isto é na verdade "
3443 "muito similar à construção anterior. Simplesmente, "
3444 "<code>[!python]range(n)[/!][!scala]i to j[/!]</code> retorna um conjunto de "
3445 "inteiros sobre os quais o loop for itera. Na verdade, [!thelang] oferece "
3446 "formas muito mais elegantes de percorrer [!python]lists[/!][!scala]arrays[/!]"
3447 " e outras coleções de dados, mas isto fica para um conjunto específico de "
3448 "exercícios (que ainda será escrito no PLM).[/!]"
3449
3450 #. type: Content of: <h3>
3451 #: src/lessons/welcome/array/basics/Array1.html:98
3452 msgid "Declaring [!python]a list[/!][!java|scala]an array[/!]"
3453 msgstr "Declarar uma [!python]list[/!][!java|scala]array[/!]"
3454
3455 #. type: Content of: <p>
3456 #: src/lessons/welcome/array/basics/Array1.html:101
3457 msgid ""
3458 "If you know beforehand the content of your list, you can affect these values "
3459 "all together. Just put them between square braces and separated by commas "
3460 "as follows:"
3461 msgstr ""
3462 "Se sabe antecipadamente o conteúdo da sua lista, pode atribuir os valores "
3463 "todos juntos. Ponha eles simplesmente entre colchetes e separados por "
3464 "vírgulas como segue:"
3465
3466 #. type: Content of: <pre>
3467 #: src/lessons/welcome/array/basics/Array1.html:104
3468 #, no-wrap
3469 msgid ""
3470 "L = [1, 3, 5, 7, 9] \n"
3471 "<span class=\"comment\"># L is now an array of 5 values, all of them being "
3472 "integers</span>"
3473 msgstr ""
3474 "L = [1, 3, 5, 7, 9] \n"
3475 "<span class=\"comment\"># L agora é uma array de 5 valores, todos eles "
3476 "inteiros</span>"
3477
3478 #. type: Content of: <p>
3479 #: src/lessons/welcome/array/basics/Array1.html:106
3480 msgid ""
3481 "Otherwise, you probably want to create an empty list and then append each "
3482 "values separately to the list:"
3483 msgstr ""
3484 "Por outro lado, provavelmente vai criar uma lista vazia e depois anexar-la "
3485 "os valores separadamente:"
3486
3487 #. type: Content of: <pre>
3488 #: src/lessons/welcome/array/basics/Array1.html:108
3489 #, no-wrap
3490 msgid ""
3491 "L2 = [] \n"
3492 "<span class=\"comment\"># L2 is now an empty list</span>\n"
3493 "L2.append(1)\n"
3494 "L2.append(3)\n"
3495 "L2.append(5)\n"
3496 "L2.append(7)\n"
3497 "L2.append(9) \n"
3498 "<span class=\"comment\"># Its content is now the same as L previously</span>"
3499 msgstr ""
3500 "L2 = [] \n"
3501 "<span class=\"comment\"># neste momento, L2 é uma lista vazia</span>\n"
3502 "L2.append(1)\n"
3503 "L2.append(3)\n"
3504 "L2.append(5)\n"
3505 "L2.append(7)\n"
3506 "L2.append(9) \n"
3507 "<span class=\"comment\"># E agora o seu conteúdo é igual ao de L, vista "
3508 "antes</span>"
3509
3510 #. type: Content of: outside any tag (error?)
3511 #: src/lessons/welcome/array/basics/Array1.html:116
3512 #: src/lessons/turmites/helloturmite/HelloTurmite.html:61
3513 msgid "[/!] [!java|scala]"
3514 msgstr "[/!] [!java|scala]"
3515
3516 #. type: Content of: <p>
3517 #: src/lessons/welcome/array/basics/Array1.html:119
3518 msgid ""
3519 "To declare a variable named <b>T</b> that can store an array of integers, "
3520 "one should write:"
3521 msgstr ""
3522 "Para declarar uma variável chamada <b>T</b> que pode guardar uma array de "
3523 "inteiros, deve escrever:"
3524
3525 #. type: Content of: <pre>
3526 #: src/lessons/welcome/array/basics/Array1.html:120
3527 #, no-wrap
3528 msgid "[!java]int[] T;[/!][!scala]var T:Array[Int][/!]"
3529 msgstr "[!java]int[] T;[/!][!scala]var T:Array[Int][/!]"
3530
3531 #. type: Content of: <p>
3532 #: src/lessons/welcome/array/basics/Array1.html:122
3533 msgid ""
3534 "[!java]<code>int</code> means that the elements of the array are of type "
3535 "integer; <code>[]</code> means that we are speaking of an array and "
3536 "<code>T</code> is the name of the variable. For historical reasons, this "
3537 "can also be written as <code>int T[]</code> (with the [] after the variable "
3538 "name), but this is less readable and should probably be avoided.[/!] "
3539 "[!scala]The <code>[Int]</code> notation specializes the Array type (that is "
3540 "generic), specifying that each cell of this array is an integer. An array of "
3541 "booleans would simply by written <code>Array[Boolean]</code>.[/!]"
3542 msgstr ""
3543 "[!java]<code>int</code> significa que os elementos da array são do tipo "
3544 "inteiro; <code>[]</code> significa que estamos a falar de uma array e "
3545 "<code>T</code> é o nome da variável. Por motivos históricos, também pode ser "
3546 "escrito como <code>int T[]</code> (com o [] depois do nome da variável), mas "
3547 "como assim é menos legível, é melhor evitar esta forma.[/!] [!scala]A "
3548 "notação <code>[Int]</code> especializa o tipo Array (que é genérico), a "
3549 "especificar que cada célula desta array é um inteiro. Um array de booleanos "
3550 "deve ser escrito simplesmente como <code>Array[Boolean]</code>.[/!]"
3551
3552 #. type: Content of: <h3>
3553 #: src/lessons/welcome/array/basics/Array1.html:130
3554 msgid "Allocating an array"
3555 msgstr "Alocar uma array"
3556
3557 #. type: Content of: <p>
3558 #: src/lessons/welcome/array/basics/Array1.html:132
3559 msgid ""
3560 "Declaring a variable <code>T</code> that stores an array only reserve the "
3561 "<b>name</b> <code>T</code> for later use, but not the memory area to store "
3562 "the cells. The array is not initialized yet: it does not have any "
3563 "value. What would <code>[!java]T[4][/!][!scala]T(4)[/!]</code> mean if we "
3564 "didn't say that the array is 5 cells long?"
3565 msgstr ""
3566 "Declarar uma variável <code>T</code> que armazena uma array apenas reserva o "
3567 "<b>nome</b> <code>T</code> para uso futuro, mas não reserva a área de "
3568 "memória para armazenar as células. A array ainda não está inicializada: ela "
3569 "não tem qualquer valor. O que significa "
3570 "<code>[!java]T[4][/!][!scala]T(4)[/!]</code> se ainda não dissemos que a "
3571 "array tem 5 células?"
3572
3573 #. type: Content of: <p>
3574 #: src/lessons/welcome/array/basics/Array1.html:137
3575 msgid "First and foremost, we have to give a value to <code>T</code>:"
3576 msgstr "Primeiramente, temos que dar um valor a <code>T</code>:"
3577
3578 #. type: Content of: <pre>
3579 #: src/lessons/welcome/array/basics/Array1.html:138
3580 #, no-wrap
3581 msgid "[!java]T = new int[10];[/!][!scala]var T = new Array[Int](10)[/!]"
3582 msgstr "[!java]T = new int[10];[/!][!scala]var T = new Array[Int](10)[/!]"
3583
3584 #. type: Content of: <p>
3585 #: src/lessons/welcome/array/basics/Array1.html:140
3586 msgid ""
3587 "<code>new</code> means that we want to create something, and "
3588 "<code>[!java]int[10][/!][!scala]Array[Int](10)[/!]</code> means that it is "
3589 "an array of 10 integer values. In return, an array of 10 integer cells is "
3590 "created in memory, and the <code>T</code> variable <b>references</b> this "
3591 "array."
3592 msgstr ""
3593 "<code>new</code> (novo) significa que queremos criar algo e "
3594 "<code>[!java]int[10][/!][!scala]Array[Int](10)[/!]</code> significa que é "
3595 "uma array de 10 valores inteiros. Como resultado, uma array de 10 células "
3596 "para valores inteiros é criada na memória e a variável <code>T</code> <b>faz "
3597 "referência</b> a esta array."
3598
3599 #. type: Content of: <p>
3600 #: src/lessons/welcome/array/basics/Array1.html:145
3601 msgid ""
3602 "The size of an array is fixed and cannot be changed after the creation of "
3603 "the array. The size of a <code>T</code> array can be retrieve by consulting "
3604 "the variable <code>T.length</code>."
3605 msgstr ""
3606 "O tamanho de uma array é fixo e não pode ser mudado depois da criação da "
3607 "array. O tamanho de uma array <code>T</code> pode ser recuperado ao se "
3608 "consultar a variável <code>T.length</code>."
3609
3610 #. type: Content of: <p>
3611 #: src/lessons/welcome/array/basics/Array1.html:149
3612 msgid ""
3613 "While allocating, you can specify the size with a variable: "
3614 "<code>[!java]int[] T = new int[i];[/!][!scala]var T = new "
3615 "Array[Int](i);[/!]</code> In this case, the array's size will be set to the "
3616 "value of <code>i</code> <i>when <code>new</code> gets called</i>. The size "
3617 "of the array still cannot be modified: even if the variable <code>i</code> "
3618 "changes afterward, the size remains to the value given when it was "
3619 "allocated. [!java]Also, it is forbidden to write something like <code>int "
3620 "T[10];</code> when declaring the variable. You are required to use the "
3621 "<code>new</code> instruction to allocate it, as in <code>int[] T = new "
3622 "int[10];</code> [/!]"
3623 msgstr ""
3624 "Ao alocar pode especificar o tamanho com uma variável: <code>[!java]int[] T "
3625 "= new int[i];[/!][!scala]var T = new Array[Int](i);[/!]</code> Neste caso, o "
3626 "tamanho da array será ajustado para o valor de <code>i</code> <i>quando "
3627 "<code>new</code> for chamado</i>. O tamanho da array ainda não pode ser "
3628 "modificado: mesmo se a variável <code>i</code> mudar depois disto, o tamanho "
3629 "permanece o do valor dado no momento da alocação. [!java]Além disto, é "
3630 "proibido escrever algo como <code>int T[10];</code> no momento de declarar a "
3631 "variável. Deve usar a instrução <code>new</code> para alocar o array, como "
3632 "em <code>int[] T = new int[10];</code> [/!]"
3633
3634 #. type: Content of: <h4>
3635 #: src/lessons/welcome/array/basics/Array1.html:157
3636 msgid "Declaration and initialization"
3637 msgstr "Declaração e inicialização"
3638
3639 #. type: Content of: <p>
3640 #: src/lessons/welcome/array/basics/Array1.html:158
3641 msgid ""
3642 "If you know beforehand the content of your array, you can declare, allocate "
3643 "and initialize it in one shoot:"
3644 msgstr ""
3645 "Se sabe previamente o conteúdo da sua array, pode declarar, alocar e "
3646 "inicializar-la toda de uma vez:"
3647
3648 #. type: Content of: <pre>
3649 #: src/lessons/welcome/array/basics/Array1.html:159
3650 #, no-wrap
3651 msgid ""
3652 "[!java]int[] T = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };[/!][!scala]var T = "
3653 "Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)[/!]"
3654 msgstr ""
3655 "[!java]int[] T = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };[/!][!scala]var T = Array("
3656 "1, 2, 3, 4, 5, 6, 7, 8, 9, 10)[/!]"
3657
3658 #. type: Content of: <p>
3659 #: src/lessons/welcome/array/basics/Array1.html:161
3660 msgid ""
3661 "To know the size of the array to allocate, the compiler counts the provided "
3662 "values. This code is equivalent to:"
3663 msgstr ""
3664 "Para saber o tamanho da array para alocar, o compilador conta os valores "
3665 "dados. Este código é equivalente a:"
3666
3667 #. type: Content of: <pre>
3668 #: src/lessons/welcome/array/basics/Array1.html:163
3669 #, no-wrap
3670 msgid ""
3671 "[!java]int[] T = new int[10];\n"
3672 "T[0] = 1;\n"
3673 "T[1] = 2;\n"
3674 "...\n"
3675 "T[9] = 10;[/!][!scala]var T = new Array[Int](10);\n"
3676 "T(0) = 1\n"
3677 "T(1) = 2\n"
3678 "...\n"
3679 "T(9) = 10[/!]"
3680 msgstr ""
3681 "[!java]int[] T = new int[10];\n"
3682 "T[0] = 1;\n"
3683 "T[1] = 2;\n"
3684 "...\n"
3685 "T[9] = 10;[/!][!scala]var T = new Array[Int](10);\n"
3686 "T(0) = 1\n"
3687 "T(1) = 2\n"
3688 "...\n"
3689 "T(9) = 10[/!]"
3690
3691 #. type: Content of: <p>
3692 #: src/lessons/welcome/array/basics/Array1.html:173
3693 msgid "It is also equivalent to:"
3694 msgstr "também é equivalente a:"
3695
3696 #. type: Content of: <pre>
3697 #: src/lessons/welcome/array/basics/Array1.html:174
3698 #, no-wrap
3699 msgid ""
3700 "[!java]int[] T = new int[10];\n"
3701 "for (int i=0; i&lt;T.length; i++) {\n"
3702 " T[i] = i+1;\n"
3703 "}[/!][!scala]var T = new Array[Int](10);\n"
3704 "for (i &lt;- 0 to T.length-1) {\n"
3705 " T(i) = i+1\n"
3706 "}[/!]"
3707 msgstr ""
3708 "[!java]int[] T = new int[10];\n"
3709 "for (int i=0; i&lt;T.length; i++) {\n"
3710 " T[i] = i+1;\n"
3711 "}[/!][!scala]var T = new Array[Int](10);\n"
3712 "for (i &lt;- 0 to T.length-1) {\n"
3713 " T(i) = i+1\n"
3714 "}[/!]"
3715
3716 #. type: Content of: <h3>
3717 #: src/lessons/welcome/array/basics/Array1.html:185
3718 msgid "[!python]Lists[/!][!scala|java]Arrays[/!] and method parameters"
3719 msgstr "[!python]Lists[/!][!scala|java]Arrays[/!] e parâmetros de métodos"
3720
3721 #. type: Content of: <p>
3722 #: src/lessons/welcome/array/basics/Array1.html:186
3723 msgid ""
3724 "It is perfectly OK to pass [!python]a list[/!][!java|scala]an array[/!] to a "
3725 "method as a parameter. This method can then use this parameter as if it "
3726 "were defined locally:"
3727 msgstr ""
3728 "Não há nenhum problema em passar uma [!python]list[/!][!java|scala]array[/!] "
3729 "para um método como parâmetro. Este método pode então usar este parâmetro "
3730 "como se fosse definido localmente:"
3731
3732 #. type: Content of: <pre>
3733 #: src/lessons/welcome/array/basics/Array1.html:188
3734 #, no-wrap
3735 msgid ""
3736 "[!java]boolean has42First(int[] array) {\n"
3737 " return array[0] == 42;\n"
3738 "}[/!][!python]def has42First(list):\n"
3739 " return list[0] == 42[/!][!scala]def has42First(array:Array[Int]):Boolean = "
3740 "{\n"
3741 " return array(0) == 42\n"
3742 "}[/!]"
3743 msgstr ""
3744 "[!java]boolean has42First(int[] array) {\n"
3745 " return array[0] == 42;\n"
3746 "}[/!][!python]def has42First(list):\n"
3747 " return list[0] == 42[/!][!scala]def has42First(array:Array[Int]):Boolean = "
3748 "{\n"
3749 " return array(0) == 42\n"
3750 "}[/!]"
3751
3752 #. type: Content of: <p>
3753 #: src/lessons/welcome/array/basics/Array1.html:195
3754 msgid "On the caller side, that also very simple:"
3755 msgstr "No lado de quem invoca também é bastante simples:"
3756
3757 #. type: Content of: <pre>
3758 #: src/lessons/welcome/array/basics/Array1.html:196
3759 #, no-wrap
3760 msgid ""
3761 "[!java]int[] tab = new int[10];[/!][!scala]var tab = new Array[Int] "
3762 "(10)[/!][!python]tab = [1, 3, 5, 7, 9][/!]\n"
3763 "[!java|scala]<span class=\"comment\">// Values initialization "
3764 "omitted</span>\n"
3765 "[/!]if (has42First(tab))[!java|scala] {[/!][!python]:[/!]\n"
3766 " <span class=\"comment\">[!java|scala]//[/!][!python]#[/!] do "
3767 "something</span>\n"
3768 "[!java|scala]}[/!]"
3769 msgstr ""
3770 "[!java]int[] tab = new int[10];[/!][!scala]var tab = new Array[Int] "
3771 "(10)[/!][!python]tab = [1, 3, 5, 7, 9][/!]\n"
3772 "[!java|scala]<span class=\"comment\">// inicialização de valores "
3773 "omitida</span>\n"
3774 "[/!]if (has42First(tab))[!java|scala] {[/!][!python]:[/!]\n"
3775 " <span class=\"comment\">[!java|scala]//[/!][!python]#[/!] faz algo</span>"
3776 "\n"
3777 "[!java|scala]}[/!]"
3778
3779 #. type: Content of: outside any tag (error?)
3780 #: src/lessons/welcome/array/basics/Array1.html:202
3781 #: src/lessons/turmites/langton/Langton.html:21
3782 msgid "[!java]"
3783 msgstr "[!java]"
3784
3785 #. type: Content of: <p>
3786 #: src/lessons/welcome/array/basics/Array1.html:203
3787 msgid ""
3788 "If you want to allocate and initialize the array in one shoot, that's a bit "
3789 "more complicated as the compiler has to know the type of the parameter you "
3790 "are creating. For that, use the following (ugly) construct:"
3791 msgstr ""
3792 "Se quer alocar e inicializar o array de uma vez só, é um pouco mais "
3793 "complicado pois o compilador terá que saber o tipo do parâmetro queestá a "
3794 "criar. Para isto, use a seguinte construção (feia):"
3795
3796 #. type: Content of: <pre>
3797 #: src/lessons/welcome/array/basics/Array1.html:206
3798 #, no-wrap
3799 msgid ""
3800 "if (has42First( new int[] {1, 3, 5, 7, 9} ) {\n"
3801 " <span class=\"comment\">// do something</span>\n"
3802 "}"
3803 msgstr ""
3804 "if (has42First( new int[] {1, 3, 5, 7, 9} ) {\n"
3805 " <span class=\"comment\">// faz algo</span>\n"
3806 "}"
3807
3808 #. type: Content of: <p>
3809 #: src/lessons/welcome/array/basics/Array1.html:211
3810 msgid ""
3811 "Methods can also return [!java|scala]arrays[/!][!python]lists[/!] as result "
3812 "without any complication. Here is a method that returns [!java|scala]an "
3813 "array[/!][!python]a list[/!] of the requested size, filled with 42s."
3814 msgstr ""
3815 "Métodos também podem retornar [!java|scala]arrays[/!][!python]lists[/!] como "
3816 "resultado sem nenhuma complicação. Aqui está um método que retorna uma "
3817 "[!java|scala]array[/!][!python]list[/!] do tamanho pedido, preenchido com "
3818 "42s."
3819
3820 #. type: Content of: <pre>
3821 #: src/lessons/welcome/array/basics/Array1.html:214
3822 #, no-wrap
3823 msgid ""
3824 "[!java]int[] fill42(int size) {\n"
3825 " int[] res = new int[size];\n"
3826 " for (int i=0; i&lt;size; i++) \n"
3827 " res[i] = 42;\n"
3828 " return res;\n"
3829 "}[/!][!scala]def fill42(size:Int):Array[Int] = {\n"
3830 " var res = new Array[int] (size)\n"
3831 " for (i &lt;- 0 to size -1) {\n"
3832 " res(i) = 42;\n"
3833 " }\n"
3834 " return res;\n"
3835 "}[/!][!python]def fill42(size):\n"
3836 " res = []\n"
3837 " for i in range(size):\n"
3838 " res.append(42)\n"
3839 " return res[/!]"
3840 msgstr ""
3841 "[!java]int[] fill42(int size) {\n"
3842 " int[] res = new int[size];\n"
3843 " for (int i=0; i&lt;size; i++) \n"
3844 " res[i] = 42;\n"
3845 " return res;\n"
3846 "}[/!][!scala]def fill42(size:Int):Array[Int] = {\n"
3847 " var res = new Array[int] (size)\n"
3848 " for (i &lt;- 0 to size -1) {\n"
3849 " res(i) = 42;\n"
3850 " }\n"
3851 " return res;\n"
3852 "}[/!][!python]def fill42(size):\n"
3853 " res = []\n"
3854 " for i in range(size):\n"
3855 " res.append(42)\n"
3856 " return res[/!]"
3857
3858 #. type: Content of: <h3>
3859 #: src/lessons/welcome/array/basics/Array1.html:231
3860 #: src/lessons/recursion/lego/square/FourSquare.html:48
3861 #: src/lessons/recursion/hanoi/HanoiBoard.html:21
3862 msgid "Goal of this exercise"
3863 msgstr "Objetivo deste exercício"
3864
3865 #. type: Content of: <p>
3866 #: src/lessons/welcome/array/basics/Array1.html:233
3867 msgid "At least! After this long explanation, we can come back to the exercise."
3868 msgstr "Finalmente! Depois desta longa explicação, podemos voltar ao exercício."
3869
3870 #. type: Content of: <p>
3871 #: src/lessons/welcome/array/basics/Array1.html:234
3872 msgid ""
3873 "Your mission is rather simple actually. Your code should save the color "
3874 "pattern observed on the first row into [!java|scala]an array[/!][!python]a "
3875 "list[/!]. [!python]The easiest is to create an empty list, and then "
3876 "<code>append()</code> the colors one after the others as you read them (with "
3877 "<code>getGroundColor()</code>).[/!] [!java|scala]For that, you should "
3878 "declare and allocate an array of <code>Color</code>. Beware, there is "
3879 "several worlds, of differing size; use <code>getWorldHeight()</code> to "
3880 "retrieve the size of the current world. Once the array allocated, fill it "
3881 "by reading the ground color in each locations (with "
3882 "<code>getGroundColor()</code>).[/!]"
3883 msgstr ""
3884 "A sua missão é bastante simples, na verdade. O seu código deve guardar o "
3885 "padrão de cores observado na primeira linha numa "
3886 "[!java|scala]array[/!][!python]list[/!]. [!python]O mais fácil é criar uma "
3887 "lista vazia e depois usar <code>append()</code>para adicionar as cores uma "
3888 "por uma à medida que for a ler elas (com <code>getGroundColor()</code>).[/!] "
3889 "[!java|scala]Para isto, deve declarar e alocar uma array de <code>Cor</"
3890 "code>. Mas atencção, existem vários mundos, de diferentes tamanhos; use "
3891 "<code>getWorldHeight()</code> para recuperar o tamanho do mundo atual. Uma "
3892 "que a array esteja alocada, preencha ela a ler a cor do chão em cada um dos "
3893 "pontos (com <code>getGroundColor()</code>).[/!]"
3894
3895 #. type: Content of: <p>
3896 #: src/lessons/welcome/array/basics/Array1.html:242
3897 msgid ""
3898 "Once you managed to read and save the pattern on the first row, you have to "
3899 "reapply the pattern on every rows, for example by executing "
3900 "<code>getWorldHeight()</code> times a method written specifically for this."
3901 msgstr ""
3902 "Uma vez que conseguiu ler e gravar o padrão na primeira linha, tem que "
3903 "reaplicar o padrão nas outras linhas, por exemplo a executar "
3904 "<code>getWorldHeight()</code> vezes um método escrito especificamente para "
3905 "isto."
3906
3907 #. type: Content of: <h1>
3908 #: src/lessons/welcome/array/basics/Array2.html:2
3909 msgid "[!java|scala]Arrays[/!][!python]Lists[/!], Knotting and Modulos"
3910 msgstr "[!java|scala]Arrays[/!][!python]Lists[/!], Nós e Módulos"
3911
3912 #. type: Content of: <p>
3913 #: src/lessons/welcome/array/basics/Array2.html:4
3914 msgid ""
3915 "This exercise is similar to the previous one: you have to reproduce the "
3916 "color pattern of the first cell into the other ones."
3917 msgstr ""
3918 "Este exercício é similar ao anterior: tem que reproduzir o padrão de cores "
3919 "da primeira célula para as outras."
3920
3921 #. type: Content of: <p>
3922 #: src/lessons/welcome/array/basics/Array2.html:7
3923 msgid ""
3924 "The first difference is that the world is bordered of walls: you thus have "
3925 "to slightly modify your trajectory to ensure that the buggle does not crash "
3926 "into a wall. The simpler for that is to handle the first cell out of the "
3927 "<code>for</code> loop and do only <code>getWorldHeight()-1</code> steps in "
3928 "the loop."
3929 msgstr ""
3930 "A primeira diferença é que o mundo é cercado de muros: portanto tem que "
3931 "modificar levemente a sua trajetória para garantir que o buggle não bata num "
3932 "muro. O jeito mais simples é manipular a primeira célula fora do loop "
3933 "<code>for</code> e fazer apenas <code>getWorldHeight()-1</code> passos no "
3934 "loop."
3935
3936 #. type: Content of: <p>
3937 #: src/lessons/welcome/array/basics/Array2.html:13
3938 msgid ""
3939 "The other difference is that the offset to apply between columns is not "
3940 "fixed, but written on the first cell of each column. To get the info as an "
3941 "integer, we can use:"
3942 msgstr ""
3943 "A outra diferença é que o deslocamento para aplicar entre as colunas não é "
3944 "fixo, mas está escrito na primeira célula de cada coluna. Para obter a "
3945 "informação como um inteiro, podemos usar:"
3946
3947 #. type: Content of: <pre>
3948 #: src/lessons/welcome/array/basics/Array2.html:17
3949 #, no-wrap
3950 msgid ""
3951 "[!java]int offset = Integer.parseInt(readMessage())[/!][!python]offset = "
3952 "int( readMessage() )[/!][!scala]val offset = readMessage().toInt[/!]"
3953 msgstr ""
3954 "[!java]int deslocamento = Integer.parseInt(readMessage())[/!][!python]"
3955 "deslocamento = int( readMessage() )[/!][!scala]val deslocamento = "
3956 "readMessage().toInt[/!]"
3957
3958 #. type: Content of: <p>
3959 #: src/lessons/welcome/array/basics/Array2.html:19
3960 msgid ""
3961 "<code>readMessage()</code> gets the message on the ground as a "
3962 "[!java|scala]String[/!][!python]string[/!], while "
3963 "<code>[!java]Integer.parseInt(str)[/!][!scala]str.toInt[/!][!python]int(str)[/!]</code> "
3964 "transforms the string <code>str</code> into an integer by <i>reading</i> it."
3965 msgstr ""
3966 "<code>readMessage()</code> obtém a mensagem no chão como uma "
3967 "[!java|scala]String[/!][!python]string[/!], enquanto <code>[!java]Integer."
3968 "parseInt(str)[/!][!scala]str.toInt[/!][!python]int(str)[/!]</code> "
3969 "transforma a cadeia <code>str</code> num inteiro ao <i>ler</i> ela."
3970
3971 #. type: Content of: <p>
3972 #: src/lessons/welcome/array/basics/Array2.html:23
3973 msgid ""
3974 "Then, to pick the right color, the easier is to use the <code>%</code> "
3975 "(modulo) operator. For example, <code>(i + 5) % size</code> allows to "
3976 "retrieve the <code>i</code>th cell of an array of size <code>size</code> "
3977 "with an offset of <code>5</code>."
3978 msgstr ""
3979 "Então, para escolher a cor certa, o mais fácil é usar o operador <code>%</"
3980 "code> (operador módulo). Por exemplo, <code>(i + 5) % tam</code> serve para "
3981 "recuperar a <code>i</code>-ésima célula de uma array de tamanho <code>tam</"
3982 "code> com um deslocamento de <code>5</code>."
3983
3984 #. type: Content of: <p>
3985 #: src/lessons/welcome/array/basics/Array2.html:28
3986 msgid "You're up."
3987 msgstr "Agora é consigo."
3988
3989 #. type: Content of: <h1>
3990 #: src/lessons/welcome/array/search/IndexOfValue.html:2
3991 msgid "Searching for a given value"
3992 msgstr "Procurar por um dado valor"
3993
3994 #. type: Content of: <p>
3995 #: src/lessons/welcome/array/search/IndexOfValue.html:4
3996 msgid ""
3997 "The goal of this exercise is to search the cell of a given value, and return "
3998 "its position."
3999 msgstr ""
4000 "O objetivo deste exercício é procurar a célula de um dado valor e retornar a "
4001 "posição dela."
4002
4003 #. type: Content of: <p>
4004 #: src/lessons/welcome/array/search/IndexOfValue.html:6
4005 msgid ""
4006 "To that extend, you should fill the method <code>indexOf()</code>, which "
4007 "parameters are the array to explore, and the value to search. If the value "
4008 "<code>lookingFor</code> is not in the array <code>tab</code>, the method "
4009 "should return -1."
4010 msgstr ""
4011 "Para isto, deve preencher o método <code>indexOf()</code>, cujos parâmetros "
4012 "são a array a ser explorada e o valor a ser procurado. Se o valor "
4013 "<code>lookingFor</code> não está na array <code>tab</code>, o método deve "
4014 "retornar -1."
4015
4016 #. type: Content of: <p>
4017 #: src/lessons/welcome/array/search/IndexOfValue.html:10
4018 msgid ""
4019 "The idea of the algorithm is to sweep over the whole array, checking the "
4020 "value of each cell. If it's the searched value, you should return the index "
4021 "of the cell currently checked."
4022 msgstr ""
4023 "A ideia do algoritmo é varrer toda a array, a verificar o valor de cada "
4024 "célula. Se for o valor procurado, deve retornar o índice da célula que está "
4025 "a ser verificada."
4026
4027 #. type: Content of: <p>
4028 #: src/lessons/welcome/array/search/IndexOfValue.html:14
4029 msgid ""
4030 "Remember that indices begin at 0 and not at 1. So, if there is 3 cells, "
4031 "their indices will be 0, 1 and 2. There would not be any cell numbered 3."
4032 msgstr ""
4033 "Lembre-se que os índices começam com 0 e não com 1. Logo, se houverem 3 "
4034 "células, os índices delas serão 0, 1 e 2. Não vai haver nenhuma célula "
4035 "numerada com 3."
4036
4037 #. type: Content of: <p>
4038 #: src/lessons/welcome/array/search/IndexOfValue.html:17
4039 msgid ""
4040 "Remember also that the amount of cells in an array can be retrieved using "
4041 "the <code>length</code> attribute. So, if your array is called "
4042 "<code>tab</code>, its size can be retrieved as <code>tab.length</code>. "
4043 "Note that there is no () after <code>length</code>. An attribute is a sort "
4044 "of variable embedded in another object (here, the array)."
4045 msgstr ""
4046 "Lembre-se também que a quantidade de células numa array pode ser recuperada "
4047 "a usar o atributo <code>length</code>. Portanto, se a sua array é chamada "
4048 "<code>tab</code>, o tamanho dela será recuperado como <code>tab.length</"
4049 "code>. Observe que não existe um () depois de <code>length</code>. Um "
4050 "atributo é como uma variável dentro de outro objeto (no caso, a array)."
4051
4052 #. type: Content of: <p>
4053 #: src/lessons/welcome/array/search/IndexOfValue.html:22
4054 msgid "So, the last value of an array is given by <code>tab[tab.length - 1]</code>."
4055 msgstr ""
4056 "Logo, o último valor de uma array é dado por <code>tab[tab.length - "
4057 "1]</code>."
4058
4059 #. type: Content of: <p>
4060 #: src/lessons/welcome/array/search/IndexOfValue.html:24
4061 msgid ""
4062 "Remember also that the amount of cells in an array can be retrieved with the "
4063 "<code>len()</code> function. So, if your array is called <code>tab</code>, "
4064 "its size can be retrieved as <code>len(tab)</code>."
4065 msgstr ""
4066 "Lembre-se também que a quantidade de células numa array pode ser recuperada "
4067 "com a função <code>len()</code>. Logo, se a sua array é chamada <code>tab</"
4068 "code>, o tamanho dela pode ser recuperado como <code>len(tab)</code>."
4069
4070 #. type: Content of: <p>
4071 #: src/lessons/welcome/array/search/IndexOfValue.html:28
4072 msgid "So, the last value of an array is given by <code>tab[ len(tab) - 1]</code>."
4073 msgstr ""
4074 "Logo, o último valor de uma array é dado por <code>tab[ len(tab) - 1]</code>."
4075
4076 #. type: Content of: <h1>
4077 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:2
4078 msgid "Index of the maximum value"
4079 msgstr "ìndice do valor máximo"
4080
4081 #. type: Content of: <p>
4082 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:4
4083 msgid ""
4084 "In this exercise, you must compute the index of the tab cell containing the "
4085 "biggest value."
4086 msgstr ""
4087 "Neste exercício, deve calcular o índice da célula da tab a conter o maior "
4088 "valor."
4089
4090 #. type: Content of: <p>
4091 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:6
4092 msgid ""
4093 "For that, fill the <code>indexOfMaximum()</code> method. Its parameter is "
4094 "the array to explore. Should the array contain the searched value several "
4095 "times, you should return the index of the first occurrence."
4096 msgstr ""
4097 "Para isto, complete o método <code>indexOfMaximum()</code>. O parâmetro dele "
4098 "é a array para explorar. Caso a array contenha o valor procurado várias "
4099 "vezes, deve retornar o índice da primeira ocorrência."
4100
4101 #. type: Content of: <p>
4102 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:10
4103 msgid ""
4104 "To solve this exercise, you should sweep over the whole array. For each "
4105 "value, if it's bigger than the biggest value you saw so far, you must save "
4106 "this new champion and its position. You will thus need 2 extra variables; "
4107 "the initial value of the champion could be the value of the first cell."
4108 msgstr ""
4109 "Para resolver este exercício, deve varrer a array completamente. Para cada "
4110 "valor, se for maior que o maior até o momento, este passa a ser o novo maior "
4111 "e guarda o valor e a posição dele. Precisa de 2 variáveis adicionais; o "
4112 "valor inicial do maior pode ser o valor da primeira célula."
4113
4114 #. type: Content of: <h1>
4115 #: src/lessons/welcome/array/search/AverageValue.html:2
4116 msgid "Average value"
4117 msgstr "Valor médio"
4118
4119 #. type: Content of: <p>
4120 #: src/lessons/welcome/array/search/AverageValue.html:5
4121 msgid ""
4122 "The objective of this exercise is to compute the average value of the "
4123 "integer values stored in an array."
4124 msgstr ""
4125 "O objetivo deste exercício é calcular o valor médio dos valores inteiros "
4126 "armazenados numa array."
4127
4128 #. type: Content of: <p>
4129 #: src/lessons/welcome/array/search/AverageValue.html:7
4130 msgid ""
4131 "You have to fill the body of the method <code>average()</code> which takes "
4132 "as parameter the array of integers of which it computes and returns the "
4133 "average value. Please note that this method must return an integer."
4134 msgstr ""
4135 "Tem que preencher o corpo do método <code>average()</code> que leva como "
4136 "parâmetro a array de inteiros da qual calcula e retorna o valor médio. Por "
4137 "favor note que este método deve retornar um inteiro."
4138
4139 #. type: Content of: <p>
4140 #: src/lessons/welcome/array/search/AverageValue.html:9
4141 msgid ""
4142 "To compute the average value of an integer, it is necessary to traverse the "
4143 "whole array and to compute the sum of all its values (so you will need a "
4144 "variable to store this temporary result), then you have to divide this sum "
4145 "by the size of the array."
4146 msgstr ""
4147 "para calcular o valor médio de um inteiro, é necessário percorrer toda a "
4148 "array e calcular a soma de todos os valores (logo, precisa de uma variável "
4149 "para armazenar este valor temporário) e por fim dividir esta soma pelo "
4150 "tamanho da array."
4151
4152 #. type: Content of: <p>
4153 #: src/lessons/welcome/array/search/AverageValue.html:11
4154 msgid ""
4155 "In Java, you can get the size of an array <code>myarray</code> by consulting "
4156 "its <code>length</code> attribute (in other words, "
4157 "<code>myarray.length</code>). Notice that there is no parenthesis after "
4158 "<code>length</code>."
4159 msgstr ""
4160 "Em Java, pode obter o tamanho de uma array <code>minhaarray</code> ao "
4161 "consultar o atributo <code>length</code> (tamanho) dele (em outras palavras, "
4162 "<code>minhaarray.length</code>). Observe que não existe parêntesis depois do "
4163 "<code>length</code>."
4164
4165 #. type: Content of: <p>
4166 #: src/lessons/welcome/array/search/AverageValue.html:16
4167 msgid ""
4168 "In python, retrieving the size of an array <code>myarray</code> is as easy "
4169 "as calling <code>len(myarray)</code>."
4170 msgstr ""
4171 "Em python, recuperar o tamanho de uma array <code>minhaarray</code> é tão "
4172 "fácil como chamar <code>len(myarray)</code>."
4173
4174 #. type: Content of: <h1>
4175 #: src/lessons/welcome/array/search/MaxValue.html:2
4176 msgid "Maximal value"
4177 msgstr "Valor maximal"
4178
4179 #. type: Content of: <p>
4180 #: src/lessons/welcome/array/search/MaxValue.html:4
4181 msgid ""
4182 "In this exercise, you must compute the maximal value contained in an array. "
4183 "For that, fill the <code>maximum()</code> method, which parameter is the "
4184 "array to explore."
4185 msgstr ""
4186 "Neste exercício, deve calcular o valor maximal contido numa array. Para "
4187 "isto, preencha o método <code>maximum()</code>, cujo parâmetro é a array "
4188 "para explorar."
4189
4190 #. type: Content of: <p>
4191 #: src/lessons/welcome/array/search/MaxValue.html:8
4192 msgid ""
4193 "To compute this value, sweep over the whole parameter. For each value, if "
4194 "it's bigger than the biggest value you saw so far, you must save this value "
4195 "somewhere to remember it afterward. You thus need an extra variable, which "
4196 "can be initialized to the value of the first array cell."
4197 msgstr ""
4198 "Para calcular este valor, percorra o parâmetro todo. Para cada valor, se for "
4199 "maior que o maior valor até o momento, deve gravar este valor em algum lugar "
4200 "para lembrar dele mais tarde. Vai precisar então de uma variável adicional, "
4201 "que pode ser iniciada para o valor da primeira célula do array."
4202
4203 #. type: Content of: <h1>
4204 #: src/lessons/welcome/array/search/OccurrenceOfValue.html:2
4205 msgid "Occurrence of a value"
4206 msgstr "Ocorrência de um valor"
4207
4208 #. type: Content of: <p>
4209 #: src/lessons/welcome/array/search/OccurrenceOfValue.html:4
4210 msgid ""
4211 "In this exercise, you must compute the amount of occurrences of a given "
4212 "value in an array (that is, the amount of time that this value appears in "
4213 "the array). For that, fill the <code>occurrences()</code> method, which "
4214 "returns the number of occurrence of <code>lookingFor</code> in "
4215 "<code>tab</code>."
4216 msgstr ""
4217 "Neste exercício, deve calcular a quantidade de ocorrências de um dado valor "
4218 "numa array (ou seja, a quantidade de tempo que este valor aparece na array). "
4219 "Para isto, preencha o método <code>occurrences()</code>, que retorna a "
4220 "quantidade de ocorrências de <code>lookingFor</code> em <code>tab</code>."
4221
4222 #. type: Content of: <p>
4223 #: src/lessons/welcome/array/search/OccurrenceOfValue.html:9
4224 msgid ""
4225 "To compute this value, simply sweep over the array counting for the amount "
4226 "of cells containing the searched value. You thus need an extra variable for "
4227 "that."
4228 msgstr ""
4229 "Para calcular este valor, simplesmente percorra a array a contar a "
4230 "quantidade de células a conter o valor procurado. Vai precisar de uma "
4231 "variável adicional para isso."
4232
4233 #. type: Content of: <h1>
4234 #: src/lessons/welcome/array/search/Extrema.html:2
4235 msgid "Maxima and Minima"
4236 msgstr "Máximo e Mínimo"
4237
4238 #. type: Content of: outside any tag (error?)
4239 #: src/lessons/welcome/array/search/Extrema.html:4
4240 msgid ""
4241 "In this exercise, you must return the difference between the maxima (i.e., "
4242 "the largest value of the array) and the minima (i.e., its smallest "
4243 "value). The returned value is then a positive number. Beware, you can only "
4244 "do one traversal of the array to gather all informations that you need."
4245 msgstr ""
4246 "Neste exercício, deve retornar a diferença entre o máximo (p.ex., o maior "
4247 "valor da array) e o mínimo (p.ex., o menor valor). O valor retornado é então "
4248 "um número positivo. Mas atenção, só pode percorrer o array uma vez para "
4249 "obter todas as informações de que necessita."
4250
4251 #. type: Content of: <h1>
4252 #: src/lessons/welcome/array/search/SecondMaxValue.html:2
4253 msgid "Second Biggest Value"
4254 msgstr "Segundo Maior Valor"
4255
4256 #. type: Content of: <p>
4257 #: src/lessons/welcome/array/search/SecondMaxValue.html:4
4258 msgid ""
4259 "In this exercise, you must compute the second maximal value contained in an "
4260 "array, i.e. the value that becomes the maximum if you remove every instance "
4261 "of the current maximum from the array."
4262 msgstr ""
4263 "Neste exercício, deve calcular o segundo valor maximal contido numa array, "
4264 "ou seja o valor que se torna máximo se remover cada instância do máximo "
4265 "atual da array."
4266
4267 #. type: Content of: <p>
4268 #: src/lessons/welcome/array/search/SecondMaxValue.html:7
4269 msgid ""
4270 "As usual, you should gather the information in only one traversal of the "
4271 "array. You can assume that the second biggest value actual exists (there is "
4272 "at least two distinct values in the array), and that all values in the array "
4273 "are greater than [!python] -100000000.[/!] "
4274 "[!java|scala]<code>Integer.MIN_VALUE</code> (which is the smallest "
4275 "representable integer existing in [!thelang]).[/!]"
4276 msgstr ""
4277 "Como normalmente, deve obter informações em apenas uma passagem pela array. "
4278 "Pode assumir que o segundo maior valor \"actual\" existe (existe pelo menos "
4279 "dois valores distintos na array) e que todos os valores na array são maiores "
4280 "que [!python] -100000000.[/!] [!java|scala]<code>Integer.MIN_VALUE</code> ("
4281 "que é o menor inteiro representável que existe em [!thelang]).[/!]"
4282
4283 #. type: Content of: <h1>
4284 #: src/lessons/welcome/array/array123/Array123.html:2
4285 msgid "Array123"
4286 msgstr "Array123"
4287
4288 #. type: Content of: outside any tag (error?)
4289 #: src/lessons/welcome/array/array123/Array123.html:3
4290 msgid ""
4291 "Given an array of integers, return true if .. 1, 2, 3, .. appears in the "
4292 "array somewhere."
4293 msgstr ""
4294 "Dada uma array de inteiros, retorna true se .. 1, 2, 3, .. aparece em algum "
4295 "lugar da array."
4296
4297 #. type: Content of: <p>
4298 #: src/lessons/welcome/array/array123/Array123.html:5
4299 #: src/lessons/welcome/array/array667/Array667.html:8
4300 #: src/lessons/welcome/array/arraycount9/ArrayCount9.html:5
4301 #: src/lessons/welcome/array/arrayfront9/ArrayFront9.html:5
4302 #: src/lessons/welcome/array/notriples/NoTriples.html:8
4303 #: src/lessons/welcome/array/has271/Has271.html:10
4304 #: src/lessons/welcome/bat/bool1/Close10.html:8
4305 #: src/lessons/welcome/bat/bool1/Diff21.html:6
4306 #: src/lessons/welcome/bat/bool1/HasTeen.html:7
4307 #: src/lessons/welcome/bat/bool1/IcyHot.html:6
4308 #: src/lessons/welcome/bat/bool1/In1020.html:6
4309 #: src/lessons/welcome/bat/bool1/In3050.html:6
4310 #: src/lessons/welcome/bat/bool1/LoneTeen.html:7
4311 #: src/lessons/welcome/bat/bool1/Main.html:12
4312 #: src/lessons/welcome/bat/bool1/Makes10.html:6
4313 #: src/lessons/welcome/bat/bool1/Max1020.html:8
4314 #: src/lessons/welcome/bat/bool1/MonkeyTrouble.html:8
4315 #: src/lessons/welcome/bat/bool1/NearHundred.html:8
4316 #: src/lessons/welcome/bat/bool1/ParotTrouble.html:9
4317 #: src/lessons/welcome/bat/bool1/PosNeg.html:6
4318 #: src/lessons/welcome/bat/bool1/SleepIn.html:8
4319 #: src/lessons/welcome/bat/bool1/SumDouble.html:6
4320 #: src/lessons/welcome/bat/bool2/AlarmClock.html:12
4321 #: src/lessons/welcome/bat/bool2/AnswerCell.html:9
4322 #: src/lessons/welcome/bat/bool2/BlueTicket.html:11
4323 #: src/lessons/welcome/bat/bool2/CaughtSpeeding.html:12
4324 #: src/lessons/welcome/bat/bool2/CigarParty.html:10
4325 #: src/lessons/welcome/bat/bool2/DateFashion.html:13
4326 #: src/lessons/welcome/bat/bool2/GreenTicket.html:10
4327 #: src/lessons/welcome/bat/bool2/In1To10.html:9
4328 #: src/lessons/welcome/bat/bool2/InOrderEqual.html:10
4329 #: src/lessons/welcome/bat/bool2/InOrder.html:9
4330 #: src/lessons/welcome/bat/bool2/LastDigit2.html:9
4331 #: src/lessons/welcome/bat/bool2/LessBy10.html:6
4332 #: src/lessons/welcome/bat/bool2/Main.html:7
4333 #: src/lessons/welcome/bat/bool2/MaxMod5.html:10
4334 #: src/lessons/welcome/bat/bool2/NearTen.html:9
4335 #: src/lessons/welcome/bat/bool2/RedTicket.html:10
4336 #: src/lessons/welcome/bat/bool2/SortaSum.html:8
4337 #: src/lessons/welcome/bat/bool2/SquirrelPlay.html:11
4338 #: src/lessons/welcome/bat/bool2/TeaParty.html:12
4339 #: src/lessons/welcome/bat/bool2/TeenSum.html:9
4340 #: src/lessons/welcome/bat/bool2/TwoAsOne.html:6
4341 #: src/lessons/welcome/bat/bool2/WithoutDoubles.html:9
4342 #: src/lessons/bat/string1/Main.html:10 src/lessons/bat/string1/AltPairs.html:5
4343 #: src/lessons/bat/string1/FrontTimes.html:8
4344 #: src/lessons/bat/string1/Last2.html:9
4345 #: src/lessons/bat/string1/StringBits.html:5
4346 #: src/lessons/bat/string1/StringMatch.html:9
4347 #: src/lessons/bat/string1/StringSplosion.html:5
4348 #: src/lessons/bat/string1/StringTimes.html:5
4349 #: src/lessons/bat/string1/StringX.html:7
4350 #: src/lessons/bat/string1/StringYak.html:8
4351 msgid ""
4352 "This exercise was converted to PLM from the excellent exercising site "
4353 "http://codingbat.com/"
4354 msgstr ""
4355 "Este exercício foi convertido para o PLM do excelente sítio de exercícios "
4356 "http://codingbat.com/"
4357
4358 #. type: Content of: <h1>
4359 #: src/lessons/welcome/array/array667/Array667.html:2
4360 msgid "Array667"
4361 msgstr "Array667"
4362
4363 #. type: Content of: outside any tag (error?)
4364 #: src/lessons/welcome/array/array667/Array667.html:3
4365 msgid ""
4366 "Given an array of integers, return the number of times that two 6's are next "
4367 "to each other in the array. Also count instances where the second \"6\" is "
4368 "actually a 7."
4369 msgstr ""
4370 "Dada uma array de inteiros, retorna a quantidade de vezes no qual dois 6 "
4371 "estão vizinhos na array. Também conta as instâncias onde o segundo \"6\" é, "
4372 "na verdade um 7."
4373
4374 #. type: Content of: <h1>
4375 #: src/lessons/welcome/array/arraycount9/ArrayCount9.html:2
4376 msgid "ArrayCount9"
4377 msgstr "ArrayCount9"
4378
4379 #. type: Content of: outside any tag (error?)
4380 #: src/lessons/welcome/array/arraycount9/ArrayCount9.html:3
4381 msgid "Given an array of integers, return the number of 9's in the array."
4382 msgstr "Dada uma array de inteiros, retorna a quantidade de 9's na array."
4383
4384 #. type: Content of: <h1>
4385 #: src/lessons/welcome/array/arrayfront9/ArrayFront9.html:2
4386 msgid "ArrayFront9"
4387 msgstr "ArrayFront9"
4388
4389 #. type: Content of: outside any tag (error?)
4390 #: src/lessons/welcome/array/arrayfront9/ArrayFront9.html:3
4391 msgid ""
4392 "Given an array of integers, return true if one of the first 4 elements in "
4393 "the array is a 9. The array length may be less than 4."
4394 msgstr ""
4395 "Dada uma array de inteiros, retorna true se um dos primeiros 4 elementos na "
4396 "array é um 9. O comprimento da array pode ser menor que 4."
4397
4398 #. type: Content of: <h1>
4399 #: src/lessons/welcome/array/notriples/NoTriples.html:2
4400 msgid "NoTriples"
4401 msgstr "NenhumaTripla"
4402
4403 #. type: Content of: outside any tag (error?)
4404 #: src/lessons/welcome/array/notriples/NoTriples.html:3
4405 msgid ""
4406 "Given an array of integers, we'll say that a triple is a value appearing 3 "
4407 "times in a row in the array. Return true if the array does not contain any "
4408 "triples."
4409 msgstr ""
4410 "Dada uma array de inteiros, digamos que uma tripla é um valor que aparece 3 "
4411 "vezes seguidas na array. Retorne true se a array não contém nenhuma tripla."
4412
4413 #. type: Content of: <h1>
4414 #: src/lessons/welcome/array/has271/Has271.html:2
4415 msgid "Has271"
4416 msgstr "Has271"
4417
4418 #. type: Content of: <p>
4419 #: src/lessons/welcome/array/has271/Has271.html:3
4420 msgid ""
4421 "Given an array of integers, return true if it contains a 2, 7, 1 pattern -- "
4422 "a value, followed by the value plus 5, followed by the initial value minus "
4423 "1. So, 2,7,1 is such a pattern because 7 is 5+2 and 1 is 2-1. 3,8,2 is also "
4424 "such a pattern."
4425 msgstr ""
4426 "Dada uma array de inteiros, retorne true se ela contém um padrão 2, 7, 1 -- "
4427 "um valor, seguido dele mais 5, seguinte dele menos 1. Então, 2,7,1 é um "
4428 "exemplo deste padrão pois 7 é 5+2 e 1 é 2-1. 3,8,2 é outro exemplo."
4429
4430 #. type: Content of: <p>
4431 #: src/lessons/welcome/array/has271/Has271.html:7
4432 msgid ""
4433 "Additionally the 271 counts even if the \"1\" differs by 2 or less from the "
4434 "correct value."
4435 msgstr ""
4436 "Acicionalmente, o 271 \"counts even\" se o \"1\" difere por 2 ou menos do "
4437 "valor correto."
4438
4439 #. type: Content of: <h1>
4440 #: src/lessons/welcome/array/golomb/Golomb.html:2
4441 msgid "Golomb sequence"
4442 msgstr "sequência de Golomb"
4443
4444 #. type: Content of: outside any tag (error?)
4445 #: src/lessons/welcome/array/golomb/Golomb.html:4
4446 msgid ""
4447 "The Golomb sequence is a non-decreasing integer sequence where a(n) is the "
4448 "number of times that n occurs in the sequence, with a(1) = 1."
4449 msgstr ""
4450 "A sequência de Golomb é uma sequência de inteiros não decrescente onde a(n) "
4451 "é a quantidade de vezes que n ocorre na sequência, com a(1) = 1."
4452
4453 #. type: Content of: <p>
4454 #: src/lessons/welcome/array/golomb/Golomb.html:7
4455 msgid ""
4456 "Since a(1)=1, it means that 1 occurs only once in the sequence, so a(2) must "
4457 "be different. Since the sequence is non-decreasing, a(2) must be greater "
4458 "than 1. Since a(2)>1, the digit 2 must appear more than one time in the "
4459 "sequence. So a(2)=2."
4460 msgstr ""
4461 "Como a(1)=1, significa que 1 ocorre apenas uma vez na sequência, então a(2) "
4462 "deve ser diferente. Uma vez que a sequência é não-decrescente, a(2) deve ser "
4463 "maior que 1. Como a(2)>1, o dígito 2 deve aparecer mais de uma vez na "
4464 "sequência. Logo, a(2)=2."
4465
4466 #. type: Content of: <p>
4467 #: src/lessons/welcome/array/golomb/Golomb.html:12
4468 msgid ""
4469 "Since a(2)=2, there is two 2 in the sequence, so we know the value of "
4470 "a(3). And so on for the other values of the sequence."
4471 msgstr ""
4472 "Como a(2)=2, existem duas ocorrências de 2 na sequência, logo sabemos o "
4473 "valor de a(3). E assim por diante para os outros valores da sequência."
4474
4475 #. type: Content of: <p>
4476 #: src/lessons/welcome/array/golomb/Golomb.html:15
4477 msgid "Write a function that computes the Nth element of the sequence."
4478 msgstr "Escreva uma função que calcule o N-ésimo elemento da sequência."
4479
4480 #. type: Content of: <h1>
4481 #: src/lessons/welcome/array/island/Island.html:2
4482 msgid "Buggles' Island"
4483 msgstr "Ilha dos Buggles"
4484
4485 #. type: Content of: outside any tag (error?)
4486 #: src/lessons/welcome/array/island/Island.html:4
4487 msgid ""
4488 "You just received the traveling notes of your old aunt who traveled accross "
4489 "the country of the Buggles' Islands. She wrote down the altitude every "
4490 "kilometer during her trip, resulting in a sequence of numbers as follows."
4491 msgstr ""
4492 "Acaba de receber as anotações de viagem da sua tia velha que atravessou o "
4493 "país das Ilhas dos Buggles. Ela escreveu a altitude a cada quilômetro "
4494 "durante a viagem, a resultar numa sequência de números como segue."
4495
4496 #. type: Content of: <pre>
4497 #: src/lessons/welcome/array/island/Island.html:9
4498 #, no-wrap
4499 msgid "0 0 1 1 2 2 1 1 0 1 2 2 1 1 0"
4500 msgstr "0 0 1 1 2 2 1 1 0 1 2 2 1 1 0"
4501
4502 #. type: Content of: <p>
4503 #: src/lessons/welcome/array/island/Island.html:11
4504 msgid "Here is a cut of the islands on that path:"
4505 msgstr "Aqui está um corte das ilhas por este caminho:"
4506
4507 #. type: Content of: <pre>
4508 #: src/lessons/welcome/array/island/Island.html:14
4509 #, no-wrap
4510 msgid ""
4511 " /***\\ /*\\ &lt;-- 2 meters above the see level\n"
4512 " /***********\\ /*******\\ &lt;-- 1 meter above the see level\n"
4513 "*************************** &lt;-- see level\n"
4514 "| | | | | | | | | | | | | |\n"
4515 "0 0 1 1 2 2 1 1 0 1 2 1 1 0 &lt;-- altitude on each point\n"
4516 msgstr ""
4517 " /***\\ /*\\ &lt;-- 2 metros acima do nível do mar\n"
4518 " /***********\\ /*******\\ &lt;-- 1 metro acima do nível do mar\n"
4519 "*************************** &lt;-- nível do mar\n"
4520 "| | | | | | | | | | | | | |\n"
4521 "0 0 1 1 2 2 1 1 0 1 2 1 1 0 &lt;-- altitude em cada ponto\n"
4522
4523 #. type: Content of: <p>
4524 #: src/lessons/welcome/array/island/Island.html:21
4525 msgid "This example is constituted of four levels of island:"
4526 msgstr "Este exemplo é constituído de quatro níveis de ilhas:"
4527
4528 #. type: Content of: <ul><li>
4529 #: src/lessons/welcome/array/island/Island.html:24
4530 msgid "1 1 2 2 1 1 (the island on the left)"
4531 msgstr "1 1 2 2 1 1 (a ilha da esquerda)"
4532
4533 #. type: Content of: <ul><li>
4534 #: src/lessons/welcome/array/island/Island.html:25
4535 msgid "2 2 (the mountain topping the left island)"
4536 msgstr "2 2 (o topo da montanha da ilha da esquerda)"
4537
4538 #. type: Content of: <ul><li>
4539 #: src/lessons/welcome/array/island/Island.html:26
4540 msgid "1 2 1 1 (the right island)"
4541 msgstr "1 2 1 1 (a ilha da direita)"
4542
4543 #. type: Content of: <ul><li>
4544 #: src/lessons/welcome/array/island/Island.html:27
4545 msgid "2 (the mountain on the right)"
4546 msgstr "2 (a montanha da direita)"
4547
4548 #. type: Content of: <p>
4549 #: src/lessons/welcome/array/island/Island.html:30
4550 msgid "This can also be visualized this way:"
4551 msgstr "Isto também pode ser visualizado desta forma:"
4552
4553 #. type: Content of: <pre>
4554 #: src/lessons/welcome/array/island/Island.html:32
4555 #, no-wrap
4556 msgid "0 0(1 1(2 2)1 1)0(1(2)1 1)0"
4557 msgstr "0 0(1 1(2 2)1 1)0(1(2)1 1)0"
4558
4559 #. type: Content of: <p>
4560 #: src/lessons/welcome/array/island/Island.html:34
4561 msgid ""
4562 "Could you write a little program to compute the amount of levels in a given "
4563 "sequence of altitudes? Actually, there is an iterative and a recursive "
4564 "solution to that problem."
4565 msgstr ""
4566 "Poderia escrever um pequeno programa que calculasse a quantidade de níveis "
4567 "numa dada sequência de altitudes? Na verdade, existem uma solução iterativa "
4568 "e uma recursiva para este problema."
4569
4570 #. type: Content of: <p>
4571 #: src/lessons/welcome/methods/basics/Methods.html:5
4572 msgid ""
4573 "We will now write our own methods. It somehow comes down to extending the "
4574 "buggle vocabulary by teaching it new tricks."
4575 msgstr ""
4576 "Vamos agora escrever nossos próprios métodos. Isto é como extender o "
4577 "vocabulário do buggle a ensinar novos truques."
4578
4579 #. type: Content of: <p>
4580 #: src/lessons/welcome/methods/basics/Methods.html:8
4581 msgid ""
4582 "For example, we saw in a previous exercise how to ask the buggle to go get "
4583 "the baggle in front of it, and bring it back. If there is several baggles on "
4584 "the board, and if we want to bring all of them on the bottom line, you have "
4585 "to repeat this code several times, or include it in a loop. In any case, you "
4586 "should avoid to duplicate your code to keep it pleasant to read and easily "
4587 "understandable. It would be better if the buggle could obey an "
4588 "<code>goAndGet()</code> order just like it understands a "
4589 "<code>[!c]stepForward()[/!][!scala|java|python]forward()[/!]</code> one."
4590 msgstr ""
4591 "Por exemplo, vimos num exercício anterior como pedir ao buggle para apanhar "
4592 "o baggle à frente dele e trazê-lo de volta. Se existem vários baggles no "
4593 "tabuleiro e se queremos trazê-los todos à linha de baixo, tem que repetir "
4594 "este código várias vezes, ou incluí-lo num loop. Em qualquer caso, deve "
4595 "evitar duplicar o seu código para mantê-lo agradável de ler e fácil de "
4596 "entender. Será melhor se o buggle puder obedecer uma ordem "
4597 "<code>goAndGet()()</code> assim como entende uma "
4598 "<code>[!c]stepForward()[/!][!scala|java|python]forward()[/!]</code>."
4599
4600 #. type: Content of: <h3>
4601 #: src/lessons/welcome/methods/basics/Methods.html:16
4602 msgid "Defining methods"
4603 msgstr "Definir métodos"
4604
4605 #. type: Content of: <p>
4606 #: src/lessons/welcome/methods/basics/Methods.html:18
4607 msgid ""
4608 "The [!thelang] syntax to write a simple method called <code>goAndGet</code> "
4609 "is the following:"
4610 msgstr ""
4611 "A sintaxe de [!thelang] para escrever um método simples chamado "
4612 "<code>goAndGet()</code> é a seguinte:"
4613
4614 #. type: Content of: <pre>
4615 #: src/lessons/welcome/methods/basics/Methods.html:20
4616 #, no-wrap
4617 msgid ""
4618 "[!java|c]void goAndGet() {[/!][!python]def goAndGet():[/!][!scala]def "
4619 "goAndGet() {[/!]\n"
4620 " actions()[!java|c];[/!]\n"
4621 " to()[!java|c];[/!]\n"
4622 " do()[!java|c];[/!]\n"
4623 "[!java|scala|c]}[/!]"
4624 msgstr ""
4625 "[!java|c]void goAndGet()() {[/!][!python]def goAndGet()():[/!][!scala]def "
4626 "goAndGet()() {[/!]\n"
4627 " ações()[!java|c];[/!]\n"
4628 " ações()[!java|c];[/!]\n"
4629 " eMaisAções()[!java|c];[/!]\n"
4630 "[!java|scala|c]}[/!]"
4631
4632 #. type: Content of: <p>
4633 #: src/lessons/welcome/methods/basics/Methods.html:26
4634 msgid ""
4635 "The method body [!java|scala|c](between curly braces)[/!][!python](the "
4636 "indented block)[/!] will be executed when we call the method later on (that "
4637 "is, when we write <code>goAndGet()</code> somewhere in our code). This "
4638 "method body can contain as many instructions as you want, and any "
4639 "construction we saw so far (for, while, if, etc). [!java|c]The "
4640 "<code>void</code> keyword means that this method does not return any "
4641 "result. For example, the <code>isOverBaggle()</code> method does return a "
4642 "result, which is a [!c]int[/!][!java]boolean[/!] indicating whether or not "
4643 "the buggle is located over a baggle. We will soon learn to define such "
4644 "methods too. For now, just write <code>void</code> at this location.[/!]"
4645 msgstr ""
4646 "O corpo do método [!java|scala](entre chaves)[/!][!python](o bloco "
4647 "indentado)[/!] será executado quando chamarmos o método mais tarde (ou seja, "
4648 "quando escrevermos <code>goAndGet()()</code> em algum lugar do código). Este "
4649 "corpo do método pode conter tantas instruções quantas quiser e as "
4650 "construções que quisermos (for, while, if, etc). [!java]A palavra-chave "
4651 "<code>void</code> significa que este método não retorna qualquer resultado. "
4652 "Por exemplo, o método <code>isOverBaggle()</code> retorna um resultado, que "
4653 "é um booleano a indicar se o buggle está ou não localizado sobre um baggle. "
4654 "Vamos em breve aprender a definir tais métodos também. Por agora, apenas "
4655 "escreva <code>void</code> neste local.[/!]"
4656
4657 #. type: Content of: <h3>
4658 #: src/lessons/welcome/methods/basics/Methods.html:39
4659 msgid "Documenting methods"
4660 msgstr "Documentar métodos"
4661
4662 #. type: Content of: <p>
4663 #: src/lessons/welcome/methods/basics/Methods.html:41
4664 msgid ""
4665 "You should strive to document your code to keep it readable. When you write "
4666 "it, its purpose and limitations are clear to you, but most of the time, this "
4667 "does not last for long. You will soon forget about the details of every "
4668 "specific method, and this day you will be happy to read its "
4669 "documentation. In the following example, we use the specific formalism of "
4670 "[!java]javadoc[/!][!scala]scaladoc[/!][!python]pydoc[/!], a program that "
4671 "extracts the documentation of [!thelang] source code to produce html "
4672 "pages. The main advantage is that it allows to keep the documentation near "
4673 "to the code. So, when you change your code, you have less chances to forget "
4674 "to update the documentation."
4675 msgstr ""
4676 "Deve esforçar-se para documentar o seu código para mantê-lo legível. Quando "
4677 "escreve código, fica claro o objetivo e as limitações, mas na maioria das "
4678 "vezes, isto é esquecido. Rapidamente esquecerá dos detalhes de cada método "
4679 "específico e vai chegar o dia em que ficará feliz em ler a documentação. No "
4680 "exemplo seguinte, usamos o formalismo específico de "
4681 "[!java]javadoc[/!][!scala]scaladoc[/!][!python]pydoc[/!], um programa que "
4682 "extrai a documentação do código-fonte de [!thelang] e produz páginas html. A "
4683 "principal vantagem é que permite que a documentação fique junto ao código. "
4684 "Então, quando mudar o código, tem menos chances de esquecer de atualizar a "
4685 "documentação."
4686
4687 #. type: Content of: <p>
4688 #: src/lessons/welcome/methods/basics/Methods.html:50
4689 msgid ""
4690 "[!java|scala][!java]javadoc[/!][!scala]scaladoc[/!] comments begin with the "
4691 "<code>/**</code> marker (with two asterisks). They must be placed right "
4692 "before the method they document for the tool to find them.[/!] "
4693 "[!python]pydoc comments should be placed at the beginning of the method body "
4694 "so that the tool finds them. They should be placed between "
4695 "<code>\"\"\"</code>, which mark multi-line strings in python.[/!] The first "
4696 "line should be a brief description of what this method does while any "
4697 "subsequent lines should provide any important details about the method."
4698 msgstr ""
4699 "comentários em [!java|scala][!java]javadoc[/!][!scala]scaladoc[/!] começam "
4700 "com a marca <code>/**</code> (com dois asteriscos). Eles devem ser postos "
4701 "exatamente antes do método que documentam para a ferramenta encontrá-los.[/!]"
4702 " [!python]comentários pydoc devem ser postos no começo do corpo do método de "
4703 "forma que a ferramenta possa encontrá-los. Eles devem ser postos entre <code>"
4704 "\"\"\"</code>, que marcam cadeias multilinhas em python.[/!] A primeira "
4705 "linha deve ser uma breve descrição do que o método faz enquanto as linhas "
4706 "subsequentes devem fornecer qualquer detalhes importantes sobre o método."
4707
4708 #. type: Content of: <pre>
4709 #: src/lessons/welcome/methods/basics/Methods.html:59
4710 #, no-wrap
4711 msgid ""
4712 "[!java|scala]/**\n"
4713 " * Go, retrieves the baggle in front of the buggle, and brings it back \n"
4714 " *\n"
4715 " * Does not check for walls, so be careful to not call it when walls are "
4716 "present.\n"
4717 " */[/!]\n"
4718 "[!java]void goAndGet() {[/!]\n"
4719 "[!scala]def goAndGet() {[/!]\n"
4720 "[!python]def goAndGet():\n"
4721 " \"\"\"Go, retrieves the baggle in front of the buggle, and brings it "
4722 "back.\n"
4723 "\n"
4724 " Does not check for walls, so be careful to not call it when walls are "
4725 "present.\"\"\"[/!]\n"
4726 " actions()[!java];[/!]\n"
4727 " to()[!java];[/!]\n"
4728 " do()[!java];[/!]\n"
4729 "[!java|scala]}[/!]"
4730 msgstr ""
4731 "[!java|scala]/**\n"
4732 " * Força, recupera o baggle em frente do buggle e traz de volta \n"
4733 " *\n"
4734 " * Não verifica se tem paredes, então cuidado para não chamá-lo quando "
4735 "paredes estiverem presentes.\n"
4736 " */[/!]\n"
4737 "[!java]void goAndGet()() {[/!]\n"
4738 "[!scala]def goAndGet()() {[/!]\n"
4739 "[!python]def goAndGet()():\n"
4740 " \"\"\"Vai, recupera o baggle em frente do buggle e traz de volta.\n"
4741 "\n"
4742 " Não verifica se tem paredes, então cuidado para não o chamar quando uma "
4743 "parede estiver presente.\"\"\"[/!]\n"
4744 " ações()[!java];[/!]\n"
4745 " to()[!java];[/!]\n"
4746 " do()[!java];[/!]\n"
4747 "[!java|scala]}[/!]"
4748
4749 #. type: Content of: <h3>
4750 #: src/lessons/welcome/methods/basics/Methods.html:75
4751 msgid "Naming conventions"
4752 msgstr "Convenções de nomes"
4753
4754 #. type: Content of: <p>
4755 #: src/lessons/welcome/methods/basics/Methods.html:76
4756 msgid ""
4757 "Most programming language forbid the use of spaces in method and variable "
4758 "identifiers (=their names). Accented letters are sometimes allowed (as in "
4759 "[!thelang]), but they can lead to portability issues between operating "
4760 "systems and should thus be avoided when possible."
4761 msgstr ""
4762 "A maioria das linguagens de programação proíbe o uso de espaços em "
4763 "indentificadores de métodos e variáveis (=seus nomes). Letras acentuadas "
4764 "são algumas vezes permitidas (como em [!thelang]), mas elas geram problemas "
4765 "de portabilidade entre sistemas operacionais e devem ser evitadas sempre que "
4766 "possível."
4767
4768 #. type: Content of: <p>
4769 #: src/lessons/welcome/methods/basics/Methods.html:80
4770 msgid ""
4771 "Across all programming languages, there is two main conventions to name "
4772 "variables and methods. The first one, consists in concatenating all words "
4773 "with only the first letter of each word in upper case. \"go and get\" "
4774 "becomes goAndGet(). It is called CamelCase because identifiers written this "
4775 "way graphically remind of a camel back. The other convention, called "
4776 "snake_case, is to write every words in lower case, separated with "
4777 "underscores symbols (_). \"go and get\" becomes go_and_get()."
4778 msgstr ""
4779 "Entre todas as linguagens de programação, existem duas convenções para "
4780 "nomear variáveis e métodos. A primeira, consiste em concatenar todas as "
4781 "palavras com apenas a primeria letra de cada palavra em maiúscula. \"vai e "
4782 "apanha\" torna-se goAndGet(). Isto é chamado \"CamelCase\" por que "
4783 "identificadores escritos desta forma parecem graficamente com as costas de "
4784 "um camelo. A outra convenção, chamada \"snake_case\", é escrever todas as "
4785 "palavras em minúsculas, separadas com sublinhados (_). \"vai e apanha\" se "
4786 "torna vai_e_apanha()."
4787
4788 #. type: Content of: <p>
4789 #: src/lessons/welcome/methods/basics/Methods.html:87
4790 msgid ""
4791 "Which convention to use is the topic of heated discussion across developers, "
4792 "but each programming language has its own habits. In Python, Perl and the C "
4793 "language, the snake_case is often used for methods and variables. Java and "
4794 "Scala prefer the lowerCamelCase (the very first letter is lower case) for "
4795 "that."
4796 msgstr ""
4797 "Que convenção usar é o tópico de discussões acaloradas entre programadores, "
4798 "mas cada linguagem de programação tem os próprios hábitos deles. Em Python, "
4799 "Perl e C, o snake_case é normalmente usado para métodos e variáveis. Java e "
4800 "Scala preferemo lowerCamelCase (só a primeira letra inicial é minúscula) "
4801 "para isto."
4802
4803 #. type: Content of: <p>
4804 #: src/lessons/welcome/methods/basics/Methods.html:91
4805 msgid ""
4806 "The CamelCase convention is used everywhere in PLM because this program is "
4807 "written in Java itself, so we kept our habits when adding new languages. But "
4808 "the fact that the Python bindings of PLM use the CamelCase instead of the "
4809 "snake_case is considered as a bug that we will fix in further releases."
4810 msgstr ""
4811 "A convenção CamelCase é sempre usada no PLM por que este programa foi "
4812 "escrito em Java, então mantivemos o hábito quando inserimos novas "
4813 "linguagens. Mas o fato de os vínculos Python do PLM usarem CamelCase e não "
4814 "snake_case é considerado um bug que será corrigido em algum lançamento "
4815 "futuro."
4816
4817 #. type: Content of: <p>
4818 #: src/lessons/welcome/methods/basics/Methods.html:97
4819 msgid ""
4820 "The goal of this exercise is to write a method called "
4821 "<code>goAndGet()</code> which does the same than in a previous exercises "
4822 "(move forward until over a baggle, pick it up, move back to initial "
4823 "position, drop baggle)."
4824 msgstr ""
4825 "O objetivo deste exercício é escrever um método chamado <code>goAndGet()()</"
4826 "code> que faça a mesma coisa que foi feita num exercício anterior (vai para "
4827 "a frente até estar sobre um baggle, apanha-o, vai para trás até a posição "
4828 "inicial e solta o baggle)."
4829
4830 #. type: Content of: <p>
4831 #: src/lessons/welcome/methods/basics/Methods.html:101
4832 msgid ""
4833 "This exercise is a bit different because you will not write all of the code "
4834 "executed by the buggle. Instead, you should only write one method that get "
4835 "called automagically added when you click on <b>Start</b>. Your buggle calls "
4836 "your <code>goAndGet()</code> method on each row, until the baggle is "
4837 "found. [!python|scala]The code for that is already provided under the "
4838 "<code>goAndGet()</code> method, but you probably don't want to change "
4839 "it.[/!] [!java]You don't need to write the code calling "
4840 "<code>goAndGet()</code> yourself. It's automagically there already, even if "
4841 "you cannot see it.[/!]"
4842 msgstr ""
4843 "Este exercício é um pouco diferente por que não vai precisar escrever todo o "
4844 "código executado pelo buggle. Ao invés disto, deve apenas escrever um método "
4845 "que será chamado automagicamente quando clica em <b>Iniciar</b>. O seu "
4846 "buggle vai chamar o seu método <code>goAndGet()()</code> em cada linha, até "
4847 "que o baggle seja encontrado. [!python|scala]O código para isto já está "
4848 "pronto no método <code>goAndGet()()</code>, mas provavelmente não vai mudar "
4849 "isto. [/!] [!java]Não precisa escrever o código chamado <code>goAndGet()()</"
4850 "code>. Já está lá automaticamente, mesmo se não possa vê-lo.[/!]"
4851
4852 #. type: Content of: <p>
4853 #: src/lessons/welcome/methods/basics/Methods.html:110
4854 msgid ""
4855 "But for that to work, you have to actually write this "
4856 "<code>goAndGet()</code> method now."
4857 msgstr ""
4858 "Mas para isto funcionar, tem na verdade que escrever este método "
4859 "<code>goAndGet()</code> agora."
4860
4861 #. type: Content of: outside any tag (error?)
4862 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:4
4863 msgid ""
4864 "We now would like to teach the buggle to build a doghouse. The naive "
4865 "approach consists in directly writing the needed code as follows. This "
4866 "works because the buggle of this exercise leaves a red path as it moves."
4867 msgstr ""
4868 "Agora queremos ensinar ao buggle como construir uma casa de cachorro. A "
4869 "abordagem simplória consiste em escrever diretamente o código necessário "
4870 "como segue. Isto funciona por que o buggle deste exercício deixa um caminho "
4871 "vermelho à medida em que anda."
4872
4873 #. type: Content of: <pre>
4874 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:8
4875 #, no-wrap
4876 msgid ""
4877 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4878 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4879 "left()[!java|c];[/!]\n"
4880 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4881 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4882 "left()[!java|c];[/!]\n"
4883 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4884 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4885 "left()[!java|c];[/!]\n"
4886 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4887 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4888 "left()[!java|c];[/!]"
4889 msgstr ""
4890 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4891 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4892 "left()[!java|c];[/!]\n"
4893 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4894 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4895 "left()[!java|c];[/!]\n"
4896 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4897 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4898 "left()[!java|c];[/!]\n"
4899 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4900 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
4901 "left()[!java|c];[/!]"
4902
4903 #. type: Content of: <p>
4904 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:21
4905 msgid ""
4906 "It becomes harder when we want to draw two doghouses: we have to rewrite the "
4907 "same code twice, which is not really handy. When the code becomes a bit long "
4908 "as this one, it becomes easier to see why we insist since a while on the "
4909 "pure evilness that code duplication represents. Indeed, if you realize that "
4910 "an error sneaked into a code that you copied at several locations, you will "
4911 "have to fix it several times. And mind your back if you forget one of these "
4912 "locations."
4913 msgstr ""
4914 "Vai ficar mais difícil se tivermos que desenhar duas casas de cachorro: "
4915 "teremos que reescrever o mesmo código duas vezes, o que não é muito prático. "
4916 "Quando o código se torna um pouco longo como este, torna-se fácil ver por "
4917 "que insistimos já tem um tempinho namais pura maldade que duplicação de "
4918 "código representa. Na verdade, imagine um erro que se infiltrou no código "
4919 "que copiou para vários lugares, vai ter que corrigir várias vezes. E ai de "
4920 "se esquercer de corrigir num destes lugares."
4921
4922 #. type: Content of: <p>
4923 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:27
4924 msgid ""
4925 "There is even a name to this good principle in programming: DRY/SPOT, which "
4926 "means \"Don't Repeat Yourself / Single Point Of Truth\". The latter part "
4927 "means that each information must be written in only one location of your "
4928 "program to avoid the differing locations to get out of synch when you modify "
4929 "your code."
4930 msgstr ""
4931 "Existe até um nome para esta boa prática de programação: DRY/SPOT, que em "
4932 "inglês significa \"Don't Repeat Yourself / Single Point Of Truth\" (não se "
4933 "repita/ponto único de confiança). A última parte significa que cada "
4934 "informação deve ser escrita em apenas um local do seu programa para evitar "
4935 "que diferentes locais fiquem desincronizados quando modificar o código."
4936
4937 #. type: Content of: <p>
4938 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:32
4939 msgid ""
4940 "So, let's apply this good principle and <b>factorize our code</b>, ie to "
4941 "write it only once, for example in a method. You should even to go further "
4942 "by factorizing the method body with a <code>for</code> loop, as seen "
4943 "previously. If you do it correctly (what you should), you can use the "
4944 "method <code>left()</code> only once."
4945 msgstr ""
4946 "Portanto, vamos aplicar este bom princípio de programação e <b>fatorizar o "
4947 "nosso código</b>, p.ex. escrevê-lo apenas uma vez, por exemplo num método. "
4948 "Pode ir até mais longe a fatorizar o corpo do método com um loop <code>for</"
4949 "code>, como visto anteriormente. Se o faz corretamente (o que se espera), dá "
4950 "para usar o método <code>left()</code> apenas uma vez."
4951
4952 #. type: Content of: <p>
4953 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:39
4954 msgid ""
4955 "The goal of this exercise is to write a method called <code>dogHouse</code> "
4956 "achieving the same result than the code above, but with a for loop to keep "
4957 "it short. The buggle will call your creation to create several dog houses "
4958 "around its world."
4959 msgstr ""
4960 "O objetivo deste exercício é escrever um método chamado "
4961 "<code>casaDeCachorro</code> que faz a mesma coisa que o código acima, mas "
4962 "com um loop for para mantê-lo curto. O buggle vai chamar a sua criação para "
4963 "construir várias casas de cachorro neste mundo."
4964
4965 #. type: Content of: outside any tag (error?)
4966 #: src/lessons/welcome/methods/picture/PictureMono1.html:4
4967 #: src/lessons/welcome/methods/picture/MethodsPicture.html:4
4968 msgid ""
4969 "In this exercise, we will reproduce the geometric drawing that you can see "
4970 "in the \"Objective\" tab."
4971 msgstr ""
4972 "Neste exercício, vamos reproduzir o desenho geométrico que pode ver na guia "
4973 "\"Objetivo\"."
4974
4975 #. type: Content of: <p>
4976 #: src/lessons/welcome/methods/picture/PictureMono1.html:7
4977 #: src/lessons/welcome/methods/picture/MethodsPicture.html:7
4978 msgid ""
4979 "Your goal (here and in any well written program) is to write the simplest "
4980 "possible code. For that, you have to decompose your work in sub-steps, and "
4981 "write a specific method for each sub-step."
4982 msgstr ""
4983 "O seu objetivo (aqui e em qualquer programa bem escrito) é escrever o código "
4984 "mais simples possível. Para isto, tem que decompor o seu trabalho em sub-"
4985 "passos e escrever métodos específicos para cada sub-passo."
4986
4987 #. type: Content of: <p>
4988 #: src/lessons/welcome/methods/picture/PictureMono1.html:11
4989 msgid ""
4990 "If you observe carefully the picture to draw, it is constituted of four "
4991 "parts depicting a sort of V. A possible decomposition is to write a method "
4992 "in charge of drawing a V from the current position. Its prototype can be: "
4993 "<code>[!java|c]void [/!]makeV()</code>"
4994 msgstr ""
4995 "Se observar cuidadosamente a figura que tem que desenhar, ela é constituída "
4996 "de quatro partes a descrever um V. Uma decomposição possível é escrever um "
4997 "método responsável por escrever um V a partir da posição atual. O protótipo "
4998 "dele pode ser: <code>[!java|c]void [/!]makeV()</code>"
4999
5000 #. type: Content of: <p>
5001 #: src/lessons/welcome/methods/picture/PictureMono1.html:16
5002 msgid ""
5003 "In this method, you should use the methods <code>brushUp()</code> and "
5004 "<code>brushDown()</code> to mark the ground (you may want to factorize this "
5005 "in another method). It may be wise to write the <code>makeV()</code> so that "
5006 "it places directly the buggle in position for the next V."
5007 msgstr ""
5008 "Neste método, deve usar os métodos <code>brushUp()</code> e "
5009 "<code>brushDown()</code> para marcar o chão (se quiser, faça um método só "
5010 "para isto). É uma decisão inteligente escrever <code>makeV()</code> para pôr "
5011 "o buggle diretamente em posição ao próximo V."
5012
5013 #. type: Content of: <p>
5014 #: src/lessons/welcome/methods/picture/PictureMono1.html:21
5015 msgid ""
5016 "Your turn. Your code should not be longer than 4 lines (not counting "
5017 "<code>makeV</code>)..."
5018 msgstr ""
5019 "É a sua vez. O seu código não deve ser maior que 4 linhas (sem contar "
5020 "<code>fazerV</code>)..."
5021
5022 #. type: Content of: outside any tag (error?)
5023 #: src/lessons/welcome/methods/picture/PictureMono2.html:4
5024 msgid ""
5025 "We will now reproduce an even bigger geometrical drawing. Once again, you "
5026 "can see the model by clicking on the \"Objective\" tab."
5027 msgstr ""
5028 "Vamos agora reproduzir um desenho geométrico ainda maior. Novamente,pode ver "
5029 "o modelo a clicar na guia \"Objetivo\"."
5030
5031 #. type: Content of: <p>
5032 #: src/lessons/welcome/methods/picture/PictureMono2.html:7
5033 msgid ""
5034 "You can naturally reuse all the code you typed in previous exercise (select "
5035 "the other exercise, do Ctrl-C, come back to the code of this exercise, do "
5036 "Ctrl-V)."
5037 msgstr ""
5038 "Pode naturalmente reutilizar todo o código que digitou em exercícios "
5039 "anteriores (selecione o outro exercício, faça Ctrl-C, volte para o código "
5040 "deste exercício e faça Ctrl-V)."
5041
5042 #. type: Content of: <p>
5043 #: src/lessons/welcome/methods/picture/PictureMono2.html:11
5044 msgid ""
5045 "But you want to keep your code as simple as possible. For that, define new "
5046 "methods to deal simply with the repetitions in the pattern. For example, a "
5047 "method <code>makePattern()</code> achieving the pattern of previous example "
5048 "seems to be a good idea (but this may not be enough)."
5049 msgstr ""
5050 "Mas quer manter o seu código tão simples quanto possível. Para isto, defina "
5051 "novos métodos para lidar simplesmente com as repetições no padrão. Por "
5052 "exemplo, um método <code>makePattern()</code> a fazer o padrão do exemplo "
5053 "anterior parece ser uma boa ideia (mas pode não ser o suficiente)."
5054
5055 #. type: Content of: <p>
5056 #: src/lessons/welcome/methods/picture/PictureMono2.html:16
5057 msgid ""
5058 "Why don't you give it a shot? The main code method shouldn't take more than "
5059 "2 lines (included in a for loop)"
5060 msgstr ""
5061 "Por que não tentar? O método do código principal não deve levar mais de 2 "
5062 "linhas (incluindo o loop for)"
5063
5064 #. type: Content of: outside any tag (error?)
5065 #: src/lessons/welcome/methods/picture/PictureMono3.html:4
5066 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:4
5067 msgid ""
5068 "As you can imagine, you have to reproduce the geometric drawing depicted in "
5069 "the \"Objectives\" tab. As you can see, it is even bigger than the previous "
5070 "one."
5071 msgstr ""
5072 "Como pode imaginar, vai ter que reproduzir o desenho geométrico descrito na "
5073 "guia \"Objetivos\". Como pode ver, é até maior do que o anterior."
5074
5075 #. type: Content of: <p>
5076 #: src/lessons/welcome/methods/picture/PictureMono3.html:8
5077 msgid ""
5078 "You thus have to declare even more methods to use the repetitions of the "
5079 "pattern and factorize your code. Your turn..."
5080 msgstr ""
5081 "Portanto tem que declarar até mais métodos para usar as repetições do padrão "
5082 "e fatorar o seu código. É a sua vez..."
5083
5084 #. type: Content of: <h1>
5085 #: src/lessons/welcome/methods/returning/MethodsReturning.html:2
5086 #: src/lessons/lightbot/Board06Func.html:2
5087 msgid "Functions"
5088 msgstr "Funções"
5089
5090 #. type: Content of: <p>
5091 #: src/lessons/welcome/methods/returning/MethodsReturning.html:4
5092 msgid ""
5093 "Quite often, you want to write a method that compute some value and returns "
5094 "it. Methods returning results are called <b>functions</b>. Writing a "
5095 "function is not really harder than writing a simple method. [!java|c]You "
5096 "simply have to specify the data type of expected results before the function "
5097 "name (where we previously had <code>void</code>).[/!] [!scala]You simply "
5098 "have to add a colon (:) after the parenthesis and write the type of data "
5099 "that your function will return, and add an equal sign (=). This syntax is "
5100 "actually rather close to defining a variable, with its type, that is "
5101 "actually a function.[/!] You can use the <code>return</code> instruction "
5102 "anywhere in your function body to specify that the computation is done (the "
5103 "function is not further executed), and that the result is the value "
5104 "following the <code>return</code> keyword."
5105 msgstr ""
5106 "Frequentemente, vai escrever um método que calcula algum valor e o retorna. "
5107 "Métodos a retornar resultados são chamados <b>funções</b>. Escrever uma "
5108 "função não é realmente mais difícil do que escrever um simples método. "
5109 "[!java|c]Simplesmente tem que especificar o tipo de dados do resultado "
5110 "esperado entes do nome da função (onde previamente tínhamos "
5111 "<code>void</code>).[/!] [!scala]Simplesmente tem que adicionar um dois-"
5112 "pontos (:) depois do parêntesis e escrever o tipo de dados que a função dele "
5113 "vai retornar e adicionar um símbolo de igualdade (=). Esta sintaxe é na "
5114 "verdade mais próxima de definir uma variável, com o tipo dela, do que na "
5115 "verdade escrever uma função.[/!] Pode usar a instrução <code>return</code> "
5116 "em qualquer lugar do corpo da sua função para especificar que o cálculo foi "
5117 "feito (a função não continuará a ser executada) e que o resultado é o valor "
5118 "que acompanha a palavra-chave <code>return</code>."
5119
5120 #. type: Content of: <pre>
5121 #: src/lessons/welcome/methods/returning/MethodsReturning.html:14
5122 #, no-wrap
5123 msgid ""
5124 "[!java|c]double pi() {[/!][!scala]def pi(): Double = {[/!][!python]def "
5125 "pi():[/!]\n"
5126 " return 3.14159[!java|c];[/!]\n"
5127 "[!java|scala|c]}[/!]"
5128 msgstr ""
5129 "[!java|c]double pi() {[/!][!scala]def pi(): Double = {[/!][!python]def "
5130 "pi():[/!]\n"
5131 " return 3.14159[!java|c];[/!]\n"
5132 "[!java|scala|c]}[/!]"
5133
5134 #. type: Content of: <p>
5135 #: src/lessons/welcome/methods/returning/MethodsReturning.html:18
5136 msgid ""
5137 "Actually, you can also use that <code>return</code> keyword in methods that "
5138 "do not return any result, to interupt the computation. Of course, you should "
5139 "not provide any value to return in that case."
5140 msgstr ""
5141 "Na verdade, também pode usar a palavra-chave <code>return</code> em métodos "
5142 "que não retornam qualquer resultado, para interromper o cálculo. Obviamente "
5143 "que nestes casos não passa nenhum valor para retornar."
5144
5145 #. type: Content of: <p>
5146 #: src/lessons/welcome/methods/returning/MethodsReturning.html:21
5147 msgid ""
5148 "It is possible to have several <code>return</code> instructions in several "
5149 "branches of a conditional. In fact, it is forbidden to have any execution "
5150 "path of your body without any <code>return</code>, or to write some code "
5151 "after the <code>return</code> instruction. Indeed, if the machine reaches "
5152 "the end of the function without finding any <code>return</code>, it cannot "
5153 "know what actual value to give back to the function caller. Moreover, "
5154 "<code>return</code> interrupts immediately the function execution (why "
5155 "bother looking further when you know the function result?). So, if there is "
5156 "some code after a <code>return</code>, it must be an error and the compiler "
5157 "warns you."
5158 msgstr ""
5159 "É possível ter várias instruções <code>return</code> em várias ramificações "
5160 "de um condicional. De fato, é proibido ter um caminho de execução no corpo "
5161 "da função sem nenhum <code>return</code>, ou escrever algum código depois da "
5162 "instrução <code>return</code>. Na verdade, se a máquina alcança o fim da "
5163 "função sem encontrar qualquer <code>return</code>, ela não sabe o real valor "
5164 "que deve retornar a quem chamou a função. Além disto, o <code>return</code> "
5165 "interrompe imediatamente a execução da função (por que se preocupar a olhar "
5166 "além quando sabe o resultado da função?). Então, se existe algum código "
5167 "depois de um <code>return</code>, deve ser um erro e o compilador irá te "
5168 "alertar disto."
5169
5170 #. type: Content of: <pre>
5171 #: src/lessons/welcome/methods/returning/MethodsReturning.html:32
5172 #, no-wrap
5173 msgid ""
5174 "[!java|scala|c][!java]boolean [/!][!c]int [/!][!scala]def "
5175 "[/!]isFrontFree()[!scala]:Boolean =[/!] {\n"
5176 " if (isFacingWall() == [!java|scala]true[/!][!c]1[/!]) {\n"
5177 " return [!java|scala]false[/!][!c]0[/!];\n"
5178 " <span class=\"comment\">/* no code allowed here */</span>\n"
5179 " } else {\n"
5180 " return [!java|scala]true[/!][!c]1[/!];\n"
5181 " <span class=\"comment\">/* here neither */</span>\n"
5182 " }\n"
5183 " <span class=\"comment\">/* even here, forget it */</span>\n"
5184 "}[/!][!python]def isFrontFree():\n"
5185 " if isFacingWall() == True:\n"
5186 " return False\n"
5187 " <span class=\"comment\"># no code allowed here</span>\n"
5188 " else\n"
5189 " return True\n"
5190 " <span class=\"comment\"># here neither</span>\n"
5191 "<span class=\"comment\"># even here, forget it</span>[/!]"
5192 msgstr ""
5193 "[!java|scala|c][!java]boolean [/!][!c]int [/!][!scala]def "
5194 "[/!]isFrontFree()[!scala]:Boolean =[/!] {\n"
5195 " if (isFacingWall() == [!java|scala]true[/!][!c]1[/!]) {\n"
5196 " return [!java|scala]false[/!][!c]0[/!];\n"
5197 " <span class=\"comment\">/* proibido pôr código aqui */</span>\n"
5198 " } else {\n"
5199 " return [!java|scala]true[/!][!c]1[/!];\n"
5200 " <span class=\"comment\">/* nem aqui */</span>\n"
5201 " }\n"
5202 " <span class=\"comment\">/* e nem mesmo aqui. desista */</span>\n"
5203 "}[/!][!python]def livreEmFrente():\n"
5204 " if isFacingWall() == True:\n"
5205 " return False\n"
5206 " <span class=\"comment\"># proibido pôr código aqui</span>\n"
5207 " else\n"
5208 " return True\n"
5209 " <span class=\"comment\"># nem aqui</span>\n"
5210 "<span class=\"comment\"># e nem mesmo aqui, desista</span>[/!]"
5211
5212 #. type: Content of: outside any tag (error?)
5213 #: src/lessons/welcome/methods/returning/MethodsReturning.html:50
5214 msgid ""
5215 "You will once again write a function that the buggle will use. Its name must "
5216 "be <code>haveBaggle</code>, and it returns a boolean value indicating "
5217 "whether the row in front of the buggle contains a baggle or not. The buggle "
5218 "will use it to search the first row containing a baggle, and stop here."
5219 msgstr ""
5220 "Vai mais uma vez escrever uma função que o buggle vai usar. O nome dela deve "
5221 "ser <code>temBaggle</code> e retorna um valor booleano a indicar se a linha "
5222 "na frente do buggle contém um baggle ou não. O buggle vai usar isto para "
5223 "buscar a primeira linha a conter um baggle e parar nela."
5224
5225 #. type: Content of: <p>
5226 #: src/lessons/welcome/methods/returning/MethodsReturning.html:55
5227 msgid ""
5228 "The easier for this function is to use a boolean variable called "
5229 "<code>seenBaggle</code> indicating whether or not we saw a baggle so "
5230 "far. Its initial value is "
5231 "'[!python]False[/!][!scala|java]false[/!][!c]0[/!]'."
5232 msgstr ""
5233 "A forma fácil de fazer esta função é usar uma variável booleana chamada "
5234 "<code>baggleAvistado</code> a indicar se vimos ou não um baggle até o "
5235 "momento. O valor inicial é "
5236 "'[!python]False[/!][!scala|java]false[/!][!c]0[/!]'."
5237
5238 #. type: Content of: <p>
5239 #: src/lessons/welcome/methods/returning/MethodsReturning.html:59
5240 msgid ""
5241 "Then, move 6 steps forward (the world contains 7 cells and we already are on "
5242 "one of them). For each cell, if it contains a baggle, we store true in "
5243 "<code>sawBaggle</code> (and we don't do anything but moving forward if not)."
5244 msgstr ""
5245 "Então mova 6 passos para frente (o mundo contém 7 células e já estamos numa "
5246 "delas). Para cada célula, se ela contiver um baggle, vamos guardar true em "
5247 "<code>baggleVisto</code> (e se não, vamos simplesmente andar para frente)."
5248
5249 #. type: Content of: <p>
5250 #: src/lessons/welcome/methods/returning/MethodsReturning.html:63
5251 msgid ""
5252 "At the end, we move back by 6 steps, and we return the value of "
5253 "<code>seenBaggle</code> to the caller."
5254 msgstr ""
5255 "No final, vamos nos mover 6 passos para trás e retornar o valor de "
5256 "<code>baggleVisto</code> para quem chamou o método."
5257
5258 #. type: Content of: <p>
5259 #: src/lessons/welcome/methods/returning/MethodsReturning.html:66
5260 msgid ""
5261 "Note that the used buggle provides some hidden code that will call your "
5262 "<code>haveBaggle</code> function on each column, moving automatically "
5263 "between columns. It is thus very important that your <code>haveBaggle</code> "
5264 "function have no side effect: the position (and orientation) at the end of "
5265 "your code must be the one observed at the beginning of this code. It will "
5266 "move in between to seek for the baggle, but come back to the column start."
5267 msgstr ""
5268 "Observe que o buggle usado fornece código oculto que irá chamar a sua função "
5269 "<code>haveBaggle</code> em cada coluna, movendo automaticamente entre "
5270 "colunas. Portanto, é muito importante que a sua função <code>haveBaggle</"
5271 "code> não tenha nenhum efeito colateral: a posição (e orientação) no final "
5272 "do seu código deve ser a observada no início deste código. Ela moverá entre "
5273 "elas para buscar a baggle, mas volta para o início da coluna."
5274
5275 #. type: Content of: <p>
5276 #: src/lessons/welcome/methods/returning/MethodsReturning.html:73
5277 msgid ""
5278 "Also, this exercise is a bit different since there is two initial worlds, "
5279 "each with a specific objective. Your code must work for each of "
5280 "them. Observe that the world selection scrolling menu (right below the speed "
5281 "slider) allows to switch the observed world."
5282 msgstr ""
5283 "Além disso, este exercício é um pouco diferente, pois existem dois mundos "
5284 "iniciais, cada um com um objetivo específico. O seu código deve funcionar "
5285 "para cada um deles. Observe que o menu de rolagem de seleção de mundos (logo "
5286 "abaixo do controle deslizante de velocidade) permite mudar o mundo observado."
5287
5288 #. type: Content of: <p>
5289 #: src/lessons/welcome/methods/returning/MethodsReturning.html:78
5290 msgid "When your function <code>haveBaggle</code> works, proceed to next exercise."
5291 msgstr ""
5292 "Quando a sua função <code>temBaggle</code> funcionar, siga ao próximo "
5293 "exercício."
5294
5295 #. type: Content of: <p>
5296 #: src/lessons/welcome/methods/args/MethodsArgs.html:4
5297 msgid ""
5298 "Don't you get tired of writing again and again the code to move by a fixed "
5299 "amount of steps? On the other hand, writing <tt>forward2()</tt>, "
5300 "<tt>forward3()</tt>, <tt>forward4()</tt>, as well as <tt>backward2()</tt>, "
5301 "<tt>backward3()</tt>, <tt>backward4()</tt>, and so on does not really help, "
5302 "to say the less."
5303 msgstr ""
5304 "Não está cansado de escrever o mesmo código várias vezes para se mover uma "
5305 "certa quantidade de passos? Por outro lado, escrever <tt>forward2()</tt>, "
5306 "<tt>forward3()</tt>, <tt>forward4()</tt>, assim como <tt>backward2()</tt>, "
5307 "<tt>backward3()</tt>, <tt>backward4()</tt> e etc também não ajudam, para "
5308 "dizer o mínimo."
5309
5310 #. type: Content of: <p>
5311 #: src/lessons/welcome/methods/args/MethodsArgs.html:10
5312 msgid ""
5313 "Luckily, it is possible to pass <b>parameters</b> to your methods. You have "
5314 "to specify their type and name between the parenthesis after the method "
5315 "name. Then, you can use them in the method body as if it were variables "
5316 "defined in there, and which initial value is what the caller specified."
5317 msgstr ""
5318 "Felizmente, é possível passar <b>parâmetros</b> para os seus métodos. Tem "
5319 "que especificar o tipo e nome entre parêntesis depois do nome do método. "
5320 "Então, pode usá-los no corpo do método como se eles fossem variáveis "
5321 "definidas lá e com valores iniciais que o \"caller\" especificou."
5322
5323 #. type: Content of: <pre>
5324 #: src/lessons/welcome/methods/args/MethodsArgs.html:15
5325 #, no-wrap
5326 msgid ""
5327 "[!java|c]double [/!]divideByTwo([!java|c]double [/!]x[!scala]: "
5328 "Double[/!])[!scala]: Double =[/!] [!java|scala|c]{[/!][!python]:[/!]\n"
5329 " return x / 2[!java|c];[/!]\n"
5330 "[!scala|java|c]}[/!]"
5331 msgstr ""
5332 "[!java|c]double [/!]dividirPorDois([!java|c]double [/!]x[!scala]: "
5333 "Double[/!])[!scala]: Double =[/!] [!java|scala|c]{[/!][!python]:[/!]\n"
5334 " return x / 2[!java|c];[/!]\n"
5335 "[!scala|java|c]}[/!]"
5336
5337 #. type: Content of: <p>
5338 #: src/lessons/welcome/methods/args/MethodsArgs.html:19
5339 msgid ""
5340 "As caller, you have to specify the initial value of this \"variables\" "
5341 "between the call's parenthesis."
5342 msgstr ""
5343 "Como o \"caller\", deve especificar o valor inicial destas \"variáveis\" "
5344 "entre parêntesis na chamada."
5345
5346 #. type: Content of: <pre>
5347 #: src/lessons/welcome/methods/args/MethodsArgs.html:21
5348 #, no-wrap
5349 msgid "[!java|c]double [/!][!scala]val [/!]result = divideByTwo(3.14)[!java|c];[/!]"
5350 msgstr ""
5351 "[!java|c]double [/!][!scala]val [/!]result = dividirPorDois(3."
5352 "14)[!java|c];[/!]"
5353
5354 #. type: Content of: <p>
5355 #: src/lessons/welcome/methods/args/MethodsArgs.html:23
5356 msgid ""
5357 "If you want several parameters, you need to separate them with comas (,) "
5358 "both in the declaration and calls."
5359 msgstr ""
5360 "Se quiser vários parâmetros, precisa separar-os com vírgulas (,) tanto na "
5361 "declaração quanto na chamada."
5362
5363 #. type: Content of: <pre>
5364 #: src/lessons/welcome/methods/args/MethodsArgs.html:26
5365 #, no-wrap
5366 msgid ""
5367 "[!java|c]double divide(double x, double y) {[/!]\n"
5368 "[!scala]def divide(x:Double, y:Double): Double = {[/!]\n"
5369 "[!python]def divide(x, y):[/!]\n"
5370 " return x / y[!java|c];[/!]\n"
5371 "[!java|scala|c]}[/!]"
5372 msgstr ""
5373 "[!java|c]double dividir(double x, double y) {[/!]\n"
5374 "[!scala]def dividir(x:Double, y:Double): Double = {[/!]\n"
5375 "[!python]def dividir(x, y):[/!]\n"
5376 " return x / y[!java|c];[/!]\n"
5377 "[!java|scala|c]}[/!]"
5378
5379 #. type: Content of: <pre>
5380 #: src/lessons/welcome/methods/args/MethodsArgs.html:31
5381 #, no-wrap
5382 msgid ""
5383 "[!java|c]double res = divide(3.14 , 1.5);[/!]\n"
5384 "[!scala]val res = divide(3.14 , 1.5)[/!]\n"
5385 "[!python]res = divide(3.14 , 1.5)[/!]"
5386 msgstr ""
5387 "[!java|c]double res = dividir(3.14 , 1.5);[/!]\n"
5388 "[!scala]val res = dividir(3.14 , 1.5)[/!]\n"
5389 "[!python]res = dividir(3.14 , 1.5)[/!]"
5390
5391 #. type: Content of: outside any tag (error?)
5392 #: src/lessons/welcome/methods/args/MethodsArgs.html:35
5393 #: src/lessons/welcome/methods/picture/MethodsPicture.html:35
5394 msgid "[!java|scala]"
5395 msgstr "[!java|scala]"
5396
5397 #. type: Content of: <p>
5398 #: src/lessons/welcome/methods/args/MethodsArgs.html:36
5399 msgid ""
5400 "In [!thelang], you can declare several methods of the same name as long as "
5401 "they don't have the same <b>signature</b>, that is, the same amount of "
5402 "parameters and the same parameters' types."
5403 msgstr ""
5404 "Em [!thelang], pode declarar vários métodos de mesmo nome desde que eles não "
5405 "tenham a mesma <b>assinatura</b>, ou seja, a mesma quantidade e tipo de "
5406 "parâmetros."
5407
5408 #. type: Content of: <pre>
5409 #: src/lessons/welcome/methods/args/MethodsArgs.html:40
5410 #, no-wrap
5411 msgid ""
5412 "[!java]double max(double x, double y)[/!][!scala]def max(x:Double, "
5413 "y:Double): Double =[/!] {\n"
5414 " if (x > y) {\n"
5415 " return x;\n"
5416 " }\n"
5417 " return y;\n"
5418 "}[!java]int max(int x, int y)[/!][!scala]def max(x:Int, y:Int): Int =[/!] "
5419 "{\n"
5420 " if (x > y) {\n"
5421 " return x;\n"
5422 " }\n"
5423 " return y;\n"
5424 "}\n"
5425 "[!java]int max(int x, int y; int z)[/!][!scala]def max(x:Int, y:Int, z:Int): "
5426 "Int =[/!] {\n"
5427 " if (x > y && x > z) {\n"
5428 " return x;\n"
5429 " }\n"
5430 " if (y > z) {\n"
5431 " return y;\n"
5432 " }\n"
5433 " return z;\n"
5434 "}"
5435 msgstr ""
5436 "[!java]double max(double x, double y)[/!][!scala]def max(x:Double, y:Double):"
5437 " Double =[/!] {\n"
5438 " if (x > y) {\n"
5439 " return x;\n"
5440 " }\n"
5441 " return y;\n"
5442 "}[!java]int max(int x, int y)[/!][!scala]def max(x:Int, y:Int): Int =[/!] {\n"
5443 " if (x > y) {\n"
5444 " return x;\n"
5445 " }\n"
5446 " return y;\n"
5447 "}\n"
5448 "[!java]int max(int x, int y; int z)[/!][!scala]def max(x:Int, y:Int, z:Int): "
5449 "Int =[/!] {\n"
5450 " if (x > y && x > z) {\n"
5451 " return x;\n"
5452 " }\n"
5453 " if (y > z) {\n"
5454 " return y;\n"
5455 " }\n"
5456 " return z;\n"
5457 "}"
5458
5459 #. type: Content of: <p>
5460 #: src/lessons/welcome/methods/args/MethodsArgs.html:61
5461 msgid ""
5462 "Observe that we omitted the <tt>else</tt> branches of each <tt>if</tt>. It "
5463 "works anyway because a <tt>return</tt> interrupts the method execution. If "
5464 "we arrive to the last line of "
5465 "<code>[!java]max(int,int)[/!][!scala]max(Int,Int):Int[/!]</code>, we know "
5466 "that <code>x&lt;=y</code> because otherwise, the <tt>return</tt> of line 2 "
5467 "would have stopped the execution."
5468 msgstr ""
5469 "Observe que omitimos os ramos <tt>else</tt> de cada <tt>if</tt>. Isto "
5470 "funciona de qualquer jeito por que um <tt>return</tt> interrompe a execução "
5471 "do método. Se chegarmos à última linha de "
5472 "<code>[!java]max(int,int)[/!][!scala]max(Int,Int):Int[/!]</code>, vamos "
5473 "saber que <code>x&lt;=y</code> por que de outra forma, o <tt>return</tt> da "
5474 "linha 2 deveria ter parado a execução."
5475
5476 #. type: Content of: <p>
5477 #: src/lessons/welcome/methods/args/MethodsArgs.html:71
5478 msgid ""
5479 "This time, you have to write a <code> [!java|c]move(int "
5480 "stepCount,[!java]boolean[/!][!c]int[/!] forward)[/!] [!scala]move(stepCount: "
5481 "Int,forward: Boolean)[/!] [!python]move(stepCount,forward)[/!] </code> "
5482 "method which moves forward by <code>stepCount</code> steps if "
5483 "<code>forward</code> is true, and moves back of that amount of steps if the "
5484 "boolean is false."
5485 msgstr ""
5486 "Agora vai ter que escrever um método <code> [!java|c]mover(int "
5487 "contaPassos,[!java]boolean[/!][!c]int[/!] forward)[/!] "
5488 "[!scala]mover(contaPassos: Int,forward: Boolean)[/!] "
5489 "[!python]mover(contaPassos,forward)[/!] </code> que move para a frente "
5490 "<code>contaPassos</code> passos se <code>forward</code> for true e move para "
5491 "trás a mesmas quantidade de passos se o booleano for false."
5492
5493 #. type: Content of: <p>
5494 #: src/lessons/welcome/methods/args/MethodsArgs.html:79
5495 msgid ""
5496 "This time, there is only one world but seven buggles, all sharing the same "
5497 "code. This code should not be really problematic for you to write, "
5498 "actually."
5499 msgstr ""
5500 "Desta vez existe apenas um mundo mas sete buggles, todos a compartilhar o "
5501 "mesmo código. Este código não deve te dar muito trabalho para escrever, na "
5502 "verdade."
5503
5504 #. type: Content of: <h2>
5505 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:2
5506 msgid "Flower Pot"
5507 msgstr "Vaso de Flores"
5508
5509 #. type: Content of: <p>
5510 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:4
5511 msgid ""
5512 "Your buggle decided to flower a bit the pot it lives in. You have to help it "
5513 "reproducing the drawing of its dreams (check the \"Objective\" tab to see "
5514 "it)."
5515 msgstr ""
5516 "O seu buggle decidiu plantar umas flores no pote onde vive. Tem que ajudá-lo "
5517 "a reproduzir o desenho dos sonhos dele (verifique a guia \"Objetivo\" para "
5518 "ver o sonho)."
5519
5520 #. type: Content of: <p>
5521 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:7
5522 msgid ""
5523 "For that, you have to write a <code>growFlowers()</code> method that does "
5524 "not take any parameter and does not return any result. You could probably "
5525 "make it without defining this method, but this is part of the assignment."
5526 msgstr ""
5527 "Para isso, tem que escrever um método <code>growFlowers()</code> que não "
5528 "toma nenhum parâmetro e não retorna nenhum resultado. Provavelmente poderia "
5529 "fazê-lo sem definir este método, mas isto é parte da atribuição."
5530
5531 #. type: Content of: <p>
5532 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:11
5533 msgid ""
5534 "Also, you should try to decompose this complex drawing in sub-steps so that "
5535 "your code remains short and easy to read. A method to draw one flower of the "
5536 "color passed in parameter sounds like a good start, but it is probably not "
5537 "enough."
5538 msgstr ""
5539 "Além disso, deve tentar decompor este desenho complexo em sub-passos para "
5540 "que o seu código permaneça curto e fácil de ler. Um método para desenhar uma "
5541 "flor da cor passada no parâmetro parece um bom começo, mas provavelmente não "
5542 "é suficiente."
5543
5544 #. type: Content of: <p>
5545 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:15
5546 msgid ""
5547 "For your information, this drawing uses five colors that are listed below. "
5548 "[!java|scala|c]The data type of these constants is <code>Color</code>, that "
5549 "naturally describes a particular color.[/!]"
5550 msgstr ""
5551 "Para sua informação, este desenho usa cinco cores que estão listadas "
5552 "abaixo. [!java|scala|c]o tipo de dados destas constantes é <code>Cor</"
5553 "code>, que naturalmente descreve uma cor particular.[/!]"
5554
5555 #. type: Content of: <ul><li>
5556 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:20
5557 msgid "<code>[!scala|java|python]Color.[/!]RED</code>"
5558 msgstr "<code>[!scala|java|python]Cor.[/!]VERMELHO</code>"
5559
5560 #. type: Content of: <ul><li>
5561 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:21
5562 msgid "<code>[!scala|java|python]Color.[/!]PINK</code>"
5563 msgstr "<code>[!scala|java|python]Cor.[/!]ROSA</code>"
5564
5565 #. type: Content of: <ul><li>
5566 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:22
5567 msgid "<code>[!scala|java|python]Color.[/!]CYAN</code>"
5568 msgstr "<code>[!scala|java|python]Cor.[/!]CIANO</code>"
5569
5570 #. type: Content of: <ul><li>
5571 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:23
5572 msgid "<code>[!scala|java|python]Color.[/!]ORANGE</code>"
5573 msgstr "<code>[!scala|java|python]Cor.[/!]LARANJA</code>"
5574
5575 #. type: Content of: <ul><li>
5576 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:24
5577 msgid "<code>[!scala|java|python]Color.[/!]GREEN</code>"
5578 msgstr "<code>[!scala|java|python]Cor.[/!]VERDE</code>"
5579
5580 #. type: Content of: <ul><li>
5581 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:25
5582 msgid "<code>[!scala|java|python]Color.[/!]YELLOW</code>"
5583 msgstr "<code>[!scala|java|python]Cor.[/!]AMARELO</code>"
5584
5585 #. type: Content of: <h2>
5586 #: src/lessons/welcome/methods/flowerpot/FlowerCase.html:2
5587 msgid "Flower Display Case"
5588 msgstr "Vitrine de flores"
5589
5590 #. type: Content of: <p>
5591 #: src/lessons/welcome/methods/flowerpot/FlowerCase.html:4
5592 msgid ""
5593 "Whao! That's not a little pot anymore! That's a huge large flower display "
5594 "case! Your buggle can't help but starts flowering this gorgeous place. You "
5595 "should help it to prevent that it bumps into a wall..."
5596 msgstr ""
5597 "Uau! isto não é mais um potinho! É uma grande vitrine de flores! O seu "
5598 "buggle mal pode esperar para começar a florir este belo lugar. Deve ajudá-lo "
5599 "a não bater nas paredes..."
5600
5601 #. type: Content of: <p>
5602 #: src/lessons/welcome/methods/flowerpot/FlowerCase.html:8
5603 msgid "PS: the newly used color is <code>Color.BLUE</code>."
5604 msgstr "PS: a cor recentemente usada é <code>Cor.AZUL</code>."
5605
5606 #. type: Content of: <h2>
5607 #: src/lessons/welcome/methods/picture/MethodsPicture.html:2
5608 msgid "Colorful drawing"
5609 msgstr "Desenho colorido"
5610
5611 #. type: Content of: <p>
5612 #: src/lessons/welcome/methods/picture/MethodsPicture.html:11
5613 msgid ""
5614 "If you observe carefully the picture to draw, it is constituted of four "
5615 "parts depicting a sort of V using a different color. A possible "
5616 "decomposition is to write a method in charge of drawing a V of the specified "
5617 "color from the current position. Its prototype can be:"
5618 msgstr ""
5619 "Se observar cuidadosamente a figura para pintar, é constituída de quatro "
5620 "partes a descrever um tipo de V a usar uma cor diferente. Uma decomposição "
5621 "possível é escrever um método responsável por pintar um V de uma cor "
5622 "específica a partir da posição atual. O protótipo dela pode ser:"
5623
5624 #. type: Content of: <pre>
5625 #: src/lessons/welcome/methods/picture/MethodsPicture.html:15
5626 #, no-wrap
5627 msgid ""
5628 "[!java|c]void [/!]makeV([!java|c]Color [/!]c[!scala]: Color[/!])[!python] "
5629 "<span class=\"comment\"># parameter c is of type Color</span>[/!]"
5630 msgstr ""
5631 "[!java|c]void [/!]fazerV([!java|c]Cor [/!]c[!scala]: Cor[/!])[!python] "
5632 "<span class=\"comment\"># parâmetro c é do tipo Cor</span>[/!]"
5633
5634 #. type: Content of: <p>
5635 #: src/lessons/welcome/methods/picture/MethodsPicture.html:17
5636 msgid ""
5637 "The <code>Color</code> data type naturally describes a particular "
5638 "color. Your code should probably call <code>makeV</code> with the following "
5639 "arguments (a different color for each call):"
5640 msgstr ""
5641 "O tipo de dados <code>Cor</code> descreve obviamente uma cor particular. O "
5642 "seu código provavelmente vai chamar <code>fazerV</code> com os seguintes "
5643 "argumentos (uma cor diferente para cada chamada):"
5644
5645 #. type: Content of: <ul><li>
5646 #: src/lessons/welcome/methods/picture/MethodsPicture.html:21
5647 msgid "[!java|scala|python]Color.[/!]YELLOW"
5648 msgstr "[!java|scala|python]Cor.[/!]AMARELO"
5649
5650 #. type: Content of: <ul><li>
5651 #: src/lessons/welcome/methods/picture/MethodsPicture.html:22
5652 msgid "[!java|scala|python]Color.[/!]RED"
5653 msgstr "[!java|scala|python]Cor.[/!]VERMELHO"
5654
5655 #. type: Content of: <ul><li>
5656 #: src/lessons/welcome/methods/picture/MethodsPicture.html:23
5657 msgid "[!java|scala|python]Color.[/!]BLUE"
5658 msgstr "[!java|scala|python]Cor.[/!]AZUL"
5659
5660 #. type: Content of: <ul><li>
5661 #: src/lessons/welcome/methods/picture/MethodsPicture.html:24
5662 msgid "[!java|scala|python]Color.[/!]GREEN"
5663 msgstr "[!java|scala|python]Cor.[/!]VERDE"
5664
5665 #. type: Content of: <p>
5666 #: src/lessons/welcome/methods/picture/MethodsPicture.html:27
5667 msgid ""
5668 "In <code>makeV()</code>, you should use the <code>setBrushColor()</code> "
5669 "method (predefined in the buggle) to change the color of the buggle's brush, "
5670 "as well as <code>brushUp()</code> and <code>brushDown()</code> to change the "
5671 "brush position."
5672 msgstr ""
5673 "Em <code>makeV()</code>, deve usar o método <code>setBrushColor()</code> "
5674 "(pré-definido no buggle) para mudar a cor do pincel do buggle, assim como "
5675 "<code>brushUp()</code> e <code>brushDown()</code> para mudar a posição do "
5676 "pincel."
5677
5678 #. type: Content of: <p>
5679 #: src/lessons/welcome/methods/picture/MethodsPicture.html:32
5680 msgid ""
5681 "It may be wise to write the <code>makeV()</code> so that it places directly "
5682 "the buggle in position for the next V."
5683 msgstr ""
5684 "É recomendável escrever o código do <code>makeV()</code> de forma que deixe "
5685 "o buggle na posição ao próximo V."
5686
5687 #. type: Content of: <p>
5688 #: src/lessons/welcome/methods/picture/MethodsPicture.html:36
5689 msgid ""
5690 "Your turn now. I'm sure you can imagine the other methods you need to keep "
5691 "your code simple and pleasant to read. Complete the method "
5692 "<code>run()</code> that should be called automatically (once). [!java]the "
5693 "<code>public</code> keyword means more or less that anybody can call this "
5694 "method, which is good because the PLM infrastructure calls it directly.[/!]"
5695 msgstr ""
5696 "Agora é a sua vez. Tenho certeza de que pode imaginar os outros métodos "
5697 "necessários para manter o seu código simples e agradável de ler. Complete o "
5698 "método <code>run()</code> que será chamado automaticamente (uma vez). "
5699 "[!java]a palavra-chave <code>public</code> significa mais ou menos que todo "
5700 "o mundo pode chamar este método, o que é bom, pois a infraestrutura do PLM "
5701 "chama-o diretamente.[/!]"
5702
5703 #. type: Content of: <h2>
5704 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:2
5705 msgid "Larger colorful drawing"
5706 msgstr "Um desenho colorido maior"
5707
5708 #. type: Content of: <p>
5709 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:8
5710 msgid ""
5711 "You thus have to declare even more methods to use the repetitions of the "
5712 "pattern and factorize your code. Another solution is to <i>parametrize</i> "
5713 "your functions to reuse the code you wrote previously by changing the size."
5714 msgstr ""
5715 "Agora tem que declarar ainda mais métodos para usar as repetições de padrões "
5716 "e fatorizar o seu código. Outra soução é <i>parametrizar</i> as suas funções "
5717 "para reusar o código que escreveu previamente a mudar o tamanho."
5718
5719 #. type: Content of: <p>
5720 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:13
5721 #: src/lessons/welcome/traversal/Snake.html:40
5722 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:50
5723 #: src/lessons/welcome/traversal/line/TraversalByLine.html:11
5724 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:11
5725 #: src/lessons/welcome/traversal/zigzag/TraversalZigZag.html:7
5726 msgid "Your turn..."
5727 msgstr "É asua vez..."
5728
5729 #. type: Content of: <h2>
5730 #: src/lessons/welcome/methods/picture/PatternPicture.html:2
5731 msgid "Another Colorful Pattern"
5732 msgstr "Outro padrão colorido"
5733
5734 #. type: Content of: outside any tag (error?)
5735 #: src/lessons/welcome/methods/picture/PatternPicture.html:4
5736 msgid ""
5737 "Here is yet another exercise where you have to reproduce the pattern "
5738 "provided in the \"Objective\" tab."
5739 msgstr ""
5740 "Aqui está outro exercício onde tem que reproduzir o padrão fornecido na guia "
5741 "\"Objetivo\"."
5742
5743 #. type: Content of: <p>
5744 #: src/lessons/welcome/methods/picture/PatternPicture.html:7
5745 msgid ""
5746 "This one is a bit more difficult than the one seen previously. Look for "
5747 "repeating patterns, even if the color changes, and write a method drawing "
5748 "each of them."
5749 msgstr ""
5750 "Este é um pouco mais difícil do que o anterior. Procure por padrões de "
5751 "repetição, mesmo se a cor mudar e escreva um método a desenhar cada um deles."
5752
5753 #. type: Content of: <p>
5754 #: src/lessons/welcome/methods/picture/PatternPicture.html:11
5755 #: src/lessons/lander/lvl1_lander_101/Lander101.html:42
5756 msgid "Good luck!"
5757 msgstr "Boa Sorte!"
5758
5759 #. type: Content of: <p>
5760 #: src/lessons/welcome/methods/slug/SlugHunting.html:4
5761 msgid ""
5762 "Now that your <code>isFacingTrail()</code> method is working, it's time to "
5763 "write the code to organize the hunting party. Copy/paste your code from the "
5764 "previous exercise, and complete the <code>hunt()</code> method."
5765 msgstr ""
5766 "Agora que o seu método <code>isFacingTrail()</code> está a funcionar, é hora "
5767 "de escrever o código para organizar a festa da caçada. Copie-e-cole o seu "
5768 "código do exercício anterior e complete o método <code>hunt()</code>."
5769
5770 #. type: Content of: <p>
5771 #: src/lessons/welcome/methods/slug/SlugHunting.html:8
5772 msgid ""
5773 "Following a track is not very difficult: move forward as long as you have "
5774 "the track in front of you. If there is not track in front of you anymore, "
5775 "check whether the rest of the track is on your left or on your right, and "
5776 "follow it further."
5777 msgstr ""
5778 "Seguir uma trilha não é difícil: avance até ter a trilha à sua frente. Se "
5779 "não houver trilha mais trilha à sua frente, verifique se o restante da "
5780 "trilha está à sua esquerda ou à sua direita e vá nesta direção."
5781
5782 #. type: Content of: <p>
5783 #: src/lessons/welcome/methods/slug/SlugHunting.html:12
5784 msgid ""
5785 "To ensure that you don't mix the track you come from with the one in front "
5786 "of you, the easier is to erase the track when you follow it. Use the method "
5787 "<code>brushDown()</code> to put your brush down and mark the ground, and "
5788 "<code>brushUp()</code> to move it up again."
5789 msgstr ""
5790 "Para garantir que não misture o caminho de onde veio com o para aonde vai, o "
5791 "fácil é apagar o caminho por onde passa. Use o método <code>brushDown()</"
5792 "code> para abaixar o seu pincel e marcar o chão e <code>brushUp()</code> "
5793 "para levantá-lo de novo."
5794
5795 #. type: Content of: <p>
5796 #: src/lessons/welcome/methods/slug/SlugHunting.html:16
5797 msgid ""
5798 "Finally, do not forget to capture your prey once you found it (using "
5799 "<code>pickupBaggle()</code>)."
5800 msgstr ""
5801 "Finalmente, não se esqueça de capturar a sua presa quando encontrá-la (a "
5802 "usar <code>pickupBaggle()</code>)."
5803
5804 #. type: Content of: outside any tag (error?)
5805 #: src/lessons/welcome/methods/slug/SlugHunting.html:20
5806 msgid ""
5807 "<a name=\"Objectives\"> Complete the <code>hunt()</code> method. You "
5808 "probably want to copy over the <code>isFacingTrail()</code> method that you "
5809 "wrote in previous exercise. </a>"
5810 msgstr ""
5811 "<a name=\"Objetivos\"> Complete o método <code>hunt()</code>. Não gostaria "
5812 "de copiar o método <code>isFacingTrail()</code> que escreveu no exercício "
5813 "anterior?</a>"
5814
5815 #. type: Content of: <p>
5816 #: src/lessons/welcome/methods/slug/SlugTracking.html:4
5817 msgid ""
5818 "Your buggle is super happy! It just found the green dribbling trail, "
5819 "certainly left by a big yummy slug. At its end, the buggle is certain to "
5820 "entertain itself with this appetizing slug (represented as a baggle)."
5821 msgstr ""
5822 "O seu buggle está super-feliz! Acabou de encontrar o rastro verde e úmido, "
5823 "certamente deixado por um apetitosa e grande lesma. No final dele, o buggle "
5824 "tem certeza de que vai se divertir com est deliciosa lesma (representada por "
5825 "um baggle)."
5826
5827 #. type: Content of: <p>
5828 #: src/lessons/welcome/methods/slug/SlugTracking.html:8
5829 msgid ""
5830 "To reach that goal, you had to write a method <tt>isFacingTrail</tt> that "
5831 "will be called automatically by the buggle on each step. Your method should "
5832 "return [!python]True[/!][!java|scala]true[/!] if facing a green cell, or "
5833 "[!python]False[/!][!java|scala]false[/!] if not. Of course, if we are facing "
5834 "a wall, it should return false without bumping into it. You should make sure "
5835 "that this method has no <b>side effect</b>, i.e. that it does not change the "
5836 "state of the calling buggle nor of its world."
5837 msgstr ""
5838 "Para atingir esse objetivo, teve que escrever um método <tt>isFacingTrail</"
5839 "tt> que será chamado automaticamente pelo buggle a cada passo. O seu método "
5840 "deve retornar [!python]True[/!][!java|scala]true[/!] se estiver diante de "
5841 "uma célula verde, ou [!python]False[/!][!java|scala]false[/!] se não "
5842 "estiver. Claro, se estivermos de frente para uma parede, deve retornar false "
5843 "sem esbarrar nela. Deve ter certeza de que este método não tem <b>efeitos "
5844 "colaterais</b>, ou seja, que não muda o estado do buggle chamado nem do "
5845 "mundo dele."
5846
5847 #. type: Content of: <p>
5848 #: src/lessons/welcome/methods/slug/SlugTracking.html:14
5849 msgid ""
5850 "Your tool to that end is the <code>getGroundColor()</code> that returns the "
5851 "color of the current cell. Just go to the cell you want to test and run that "
5852 "function. [!java]You cannot test whether this color is equal to "
5853 "<code>Color.green</code> with an <code>==</code> sign but instead you have "
5854 "to write something like "
5855 "<code>getGroundColor().equals(Color.green)</code>. This is because green is "
5856 "an <i>object</i> in Java, and <code>.equals()</code> is the way to go to "
5857 "test equality between Java objects.[/!] [!python|scala|c]So you just have to "
5858 "test whether the returned color is equal to the value "
5859 "<code>[!scala|python]Color.green[/!][!c]GREEN[/!]</code>, that represents "
5860 "the green color.[/!]"
5861 msgstr ""
5862 "A sua ferramenta para este objetivo é o <code>getGroundColor()</code> que "
5863 "retorna a cor da célula atual. Simplesmente vá à célula que quer testar e "
5864 "execute esta função. [!java]Não pode testar se esta cor é igual a <code>Cor."
5865 "verde</code> com um símbolo de <code>==</code> mas sim escrever algo como "
5866 "<code>getGroundColor().equals(Cor.verde)</code>. Isto acontece por que verde "
5867 "é um <i>objeto</i> em Java e <code>.equals()</code> é a forma de testar "
5868 "igualdade entre objetos Java.[/!] [!python|scala]Então tem que testar se a "
5869 "cor retornada é igual ao valor <code>Cor.verde</code>, que representa "
5870 "verde.[/!]"
5871
5872 #. type: Content of: <p>
5873 #: src/lessons/welcome/methods/slug/SlugTracking.html:25
5874 msgid ""
5875 "Complete the <code>isFacingTrail()</code> method (which gets called "
5876 "automatically)."
5877 msgstr ""
5878 "Complete o método <code>isFacingTrail()</code> (que será chamado "
5879 "automaticamente)."
5880
5881 #. type: Content of: <h2>
5882 #: src/lessons/welcome/methods/slug/SlugSnail.html:2
5883 msgid "Slugs and Snails"
5884 msgstr "Lesmas e Caracóis"
5885
5886 #. type: Content of: <p>
5887 #: src/lessons/welcome/methods/slug/SlugSnail.html:4
5888 msgid ""
5889 "Yuhu! This time, your buggle found the tracks of much more preys! In the "
5890 "first world, that's a yummy Kitty Slug (leaving a pink trail) while on the "
5891 "second world, that's a big fat snail that awaits your buggle at the end of "
5892 "the orange trail."
5893 msgstr ""
5894 "Iuhu! Desta vez, o seu buggle encontrou trilhas com muitas presas! No "
5895 "primeiro mundo, era uma bela lesma deliciosa (que deixava um rastro rosa) e "
5896 "no segundo mundo, uma grande e o caracol gordo que esperava o seu buggle no "
5897 "final do rastro laranja."
5898
5899 #. type: Content of: <p>
5900 #: src/lessons/welcome/methods/slug/SlugSnail.html:8
5901 msgid ""
5902 "You have to copy/paste your code again, and change it so that your methods "
5903 "take the color of the trail to follow as a parameter. Beside of this, your "
5904 "code should work as earlier."
5905 msgstr ""
5906 "Tem que copiar/colar o seu código de novo e mudá-lo de forma que os seus "
5907 "métodos fiquem com a cor do rastro para seguir como um parâmetro. E mesmo "
5908 "assim, o seu código deve funcionar como antes."
5909
5910 #. type: Content of: <p>
5911 #: src/lessons/welcome/methods/slug/SlugSnail.html:11
5912 msgid ""
5913 "Don't get lost on false leads! <code>The hunt()</code> method was given a "
5914 "parameter to tell you which color to follow (and it is not the same in all "
5915 "worlds). Add a parameter to your <code>isFacingTrail()</code> method to only "
5916 "follow the requested color, as the other colors lead to dead ends..."
5917 msgstr ""
5918 "Cuidado para não seguir pistas falsas! O método <code>hunt()</code> recebe "
5919 "um parâmetro para dizer que cor seguir (e não é o mesmo em todos os mundos). "
5920 "Adicione um parâmetro ao seu método <code>isFacingTrail()</code> para apenas "
5921 "seguir a cor requisitada, pois as outras cores vão levar a becos..."
5922
5923 #. type: Content of: <h2>
5924 #: src/lessons/welcome/bdr/BDR.html:2
5925 msgid "Buggle Dance Revolution (BDR)"
5926 msgstr "Buggle Dance Revolution (BDR)"
5927
5928 #. type: Content of: <p>
5929 #: src/lessons/welcome/bdr/BDR.html:4
5930 msgid ""
5931 "After these races, it's time to party! For that, we will teach the buggles "
5932 "to play Dance Revolution, this game beloved of some students: The player has "
5933 "to move the feet on the carpet according to the instructions presented on "
5934 "the screen, and following the music. But before that, we have some details "
5935 "to study first."
5936 msgstr ""
5937 "Depois destas corridas, é hora de festejar! Para isto, vamos ensinar os "
5938 "buggles a jogar Dance Revolution, este jogo amado por alguns estudantes: O "
5939 "jogador tem que mover os pés num carpete de acordo com as instruções "
5940 "apresentadas no ecrã e seguir a música. Mas antes disto, temos alguns "
5941 "detalhes para estudar primeiro."
5942
5943 #. type: Content of: outside any tag (error?)
5944 #: src/lessons/welcome/bdr/BDR.html:9 src/lessons/welcome/bdr/BDR2.html:4
5945 #: src/lessons/recursion/lego/square/FourSquare.html:28
5946 msgid "[!java|scala|c]"
5947 msgstr "[!java|scala|c]"
5948
5949 #. type: Content of: <h3>
5950 #: src/lessons/welcome/bdr/BDR.html:10
5951 msgid "Conditionals without curly braces"
5952 msgstr "Condicionais sem colchetes"
5953
5954 #. type: Content of: <p>
5955 #: src/lessons/welcome/bdr/BDR.html:12
5956 msgid ""
5957 "There is one detail we omitted about the conditional syntax: if a branch "
5958 "contains only one instruction, then the curly braces become optional. So, "
5959 "the two chunk of code are equivalent:"
5960 msgstr ""
5961 "Existe um detalhe que omitimos sobre a sintaxe do condicional: se um ramo "
5962 "contém apenas uma instrução, então o colchetes se torna opcional. Portanto, "
5963 "estes dois pedaços de código são equivalentes:"
5964
5965 #. type: Content of: <pre>
5966 #: src/lessons/welcome/bdr/BDR.html:16
5967 #, no-wrap
5968 msgid ""
5969 "if (<b>condition</b>) {\n"
5970 " <b>whatToDoIfTheConditionIsTrue();</b>\n"
5971 "} else {\n"
5972 " <b>whatToDoElse();</b>\n"
5973 "}"
5974 msgstr ""
5975 "if (<b>condição</b>) {\n"
5976 " <b>oQueFazerSeACondiçãoÉVerdadeira();</b>\n"
5977 "} else {\n"
5978 " <b>oQueFazerCasoContrário();</b>\n"
5979 "}"
5980
5981 #. type: Content of: <pre>
5982 #: src/lessons/welcome/bdr/BDR.html:21
5983 #, no-wrap
5984 msgid ""
5985 "if (<b>condition</b>) \n"
5986 " <b>whatToDoIfTheConditionIsTrue();</b>\n"
5987 "else\n"
5988 " <b>whatToDoElse();</b>"
5989 msgstr ""
5990 "if (<b>condição</b>) \n"
5991 " <b>oQueFazerSeACondiçãoÉVerdadeira();</b>\n"
5992 "else\n"
5993 " <b>oQueFazerCasoContrário();</b>"
5994
5995 #. type: Content of: <p>
5996 #: src/lessons/welcome/bdr/BDR.html:26
5997 msgid ""
5998 "Actually, you can do the same for loops body that are reduced to one "
5999 "instruction only. But beware, this becomes dangerous if you chain the "
6000 "<tt>if</tt> instructions like this:"
6001 msgstr ""
6002 "Na verdade, pode fazer o mesmo em corpos de loop que se reduzem a apenas uma "
6003 "instrução. Mas cuidado, isto torna-se perigoso se cadeiar as instruções "
6004 "<tt>if</tt> como a seguir:"
6005
6006 #. type: Content of: <pre>
6007 #: src/lessons/welcome/bdr/BDR.html:28
6008 #, no-wrap
6009 msgid ""
6010 "if (isOverBaggle()) \n"
6011 " if (x == 5)\n"
6012 " left();\n"
6013 "else // Do not write it this way, it's misleading!\n"
6014 " right(); \n"
6015 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
6016 msgstr ""
6017 "if (isOverBaggle()) \n"
6018 " if (x == 5)\n"
6019 " left();\n"
6020 "else // Não escreva desta forma, é enganoso!\n"
6021 " right(); \n"
6022 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
6023
6024 #. type: Content of: <p>
6025 #: src/lessons/welcome/bdr/BDR.html:35
6026 msgid ""
6027 "You think that <code>right()</code> refers to the first <code>if</code> and "
6028 "get executed when <code>isOverBaggle()</code> returns false, but in fact, it "
6029 "refers to the second one <code>if</code> and will be executed when "
6030 "<code>isOverBaggle()</code> returns true and <code>x != 5</code>. Yes, "
6031 "despite the indentation, the buggle understands the previous code as "
6032 "follows:"
6033 msgstr ""
6034 "Pensa que <code>right()</code> se refere ao primeiro <code>if</code> e será "
6035 "executado quando <code>isOverBaggle()</code> retorna false, mas, na verdade, "
6036 "refere-se ao segundo <code>if</code> e será executado quando "
6037 "<code>isOverBaggle()</code> retorna true e <code>x != 5</code>. Sim, apesar "
6038 "da indentação, o buggle entende o código anterior da seguinte forma:"
6039
6040 #. type: Content of: <pre>
6041 #: src/lessons/welcome/bdr/BDR.html:42
6042 #, no-wrap
6043 msgid ""
6044 "if (isOverBaggle()) \n"
6045 " if (x == 5)\n"
6046 " left();\n"
6047 " else\n"
6048 " right();\n"
6049 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
6050 msgstr ""
6051 "if (isOverBaggle()) \n"
6052 " if (x == 5)\n"
6053 " left();\n"
6054 " else\n"
6055 " right();\n"
6056 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
6057
6058 #. type: Content of: <p>
6059 #: src/lessons/welcome/bdr/BDR.html:49
6060 msgid ""
6061 "In [!thelang] the computer connects a <tt>else</tt> branch to the closest "
6062 "<tt>if</tt>. If you find it ambiguous, you should add more braces than "
6063 "strictly necessary. Computers don't even look at the indentation in "
6064 "[!thelang]. The previous code could even be written as follows and lead to "
6065 "the same result."
6066 msgstr ""
6067 "Em [!thelang] o computador conecta um ramo <tt>else</tt> ao <tt>if</tt> mais "
6068 "próximo. Se o achar ambíguo, deve adicionar mais aspas do que estritamente "
6069 "necessário. Os computadores nem sequer olham para a indentação em [!thelang]"
6070 ". O código anterior pode até ser escrito da seguinte forma e levar ao mesmo "
6071 "resultado."
6072
6073 #. type: Content of: <pre>
6074 #: src/lessons/welcome/bdr/BDR.html:55
6075 #, no-wrap
6076 msgid ""
6077 "if (isOverBaggle()) if (x == 5) left(); else right(); "
6078 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
6079 msgstr ""
6080 "if (isOverBaggle()) if (x == 5) left(); else right(); "
6081 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
6082
6083 #. type: Content of: <p>
6084 #: src/lessons/welcome/bdr/BDR.html:57
6085 msgid ""
6086 "But for humans, <b>you really want to indent your code correctly "
6087 "correctly</b>. For example if you want a professor to review or even grade "
6088 "your code, if you want to reuse your own code later, or even if you need to "
6089 "debug it. That is right: you need to write readable code for your own "
6090 "comfort."
6091 msgstr ""
6092 "Mas para humanos, <b>realmente é melhor indentar o seu código corretamente</"
6093 "b>. Por exemplo, se quer que um professor reveja ou mesmo avalie o seu "
6094 "código, se quer reutilizar o seu próprio código mais tarde, ou mesmo se "
6095 "precisa depurá-lo. Isso é certo: precisa escrever um código legível para o "
6096 "seu próprio conforto."
6097
6098 #. type: Content of: <h3>
6099 #: src/lessons/welcome/bdr/BDR.html:63
6100 msgid "Chaining conditionals"
6101 msgstr "Encadear condicionais"
6102
6103 #. type: Content of: <p>
6104 #: src/lessons/welcome/bdr/BDR.html:65
6105 msgid "You sometimes want to ask the buggle something similar to:"
6106 msgstr "Algumas vezes quer perguntar o buggle algo similar a:"
6107
6108 #. type: Content of: <pre>
6109 #: src/lessons/welcome/bdr/BDR.html:66
6110 #, no-wrap
6111 msgid ""
6112 "if it's raining, take an umbrella;\n"
6113 "if not, and if it's a hot day, take a bottle of water;\n"
6114 "if not and if it's July 4th, take an American flag"
6115 msgstr ""
6116 "se está a chover, leve um guarda-chuva;\n"
6117 "se não e se está quente, leve uma garrafa de água;\n"
6118 "se não e se hoje é 4 de Julho, leve uma bandeira dos estados unidos"
6119
6120 #. type: Content of: <p>
6121 #: src/lessons/welcome/bdr/BDR.html:70
6122 msgid ""
6123 "The trap is that we want at most one of these actions to be taken. That is "
6124 "to say, if it's raining a very hot July 4th, we don't want the buggle to get "
6125 "outside with an umbrella, some water and a flag, but simply with an "
6126 "umbrella. The following code is thus WRONG."
6127 msgstr ""
6128 "A armadilha é que queremos que pelo menos uma destas ações sejam feitas. É "
6129 "como dizer, se está a chover num 4 de Julho quente, não queremos que o "
6130 "buggle vá para fora com um guarda-chuva, água e um bandeira, mas "
6131 "simplesmente com um guarda-chuva. O código seguinte está, então, ERRADO."
6132
6133 #. type: Content of: <pre>
6134 #: src/lessons/welcome/bdr/BDR.html:75
6135 #, no-wrap
6136 msgid ""
6137 "[!scala|c|java]if (rainy())\n"
6138 " takeUmbrella();\n"
6139 "if (hot())\n"
6140 " takeWater();\n"
6141 "if (todayIsJuly4th())\n"
6142 " takeFlag();[/!][!python]if rainy():\n"
6143 " takeUmbrella()\n"
6144 "if hot():\n"
6145 " takeWater()\n"
6146 "if todayIsJuly4th():\n"
6147 " takeFlag()[/!]"
6148 msgstr ""
6149 "[!scala|c|java]if (chuvoso())\n"
6150 " pegueGuarda-Chuva();\n"
6151 "if (quente())\n"
6152 " pegueAgua();\n"
6153 "if (hoje4Julho())\n"
6154 " pegueBandeira();[/!][!python]if aChover():\n"
6155 " pegueGuarda-Chuva()\n"
6156 "if quente():\n"
6157 " pegueAgua()\n"
6158 "if hoje4Julho():\n"
6159 " pegueBandeira()[/!]"
6160
6161 #. type: Content of: <p>
6162 #: src/lessons/welcome/bdr/BDR.html:88
6163 msgid ""
6164 "Indeed, since the conditions are evaluated one after the other, there is a "
6165 "risk that you go to the July 4th march on a rainy day. Instead, we should "
6166 "use something like this to ensure that once we found a true condition, we "
6167 "won't evaluate the next ones."
6168 msgstr ""
6169 "Na verdade, já que as condições são calculadas uma depois da outra, existe "
6170 "um risco de que vá sair no die 4 de Julho num dia chuvoso. Na verdade, "
6171 "devemos usar algo como isto para garantir que uma vez que encontremos a "
6172 "condição verdadeira, não passemos às próximas."
6173
6174 #. type: Content of: <pre>
6175 #: src/lessons/welcome/bdr/BDR.html:93
6176 #, no-wrap
6177 msgid ""
6178 "[!java|scala|c]if (rainy()) {\n"
6179 " takeUmbrella();\n"
6180 "} else {\n"
6181 " if (hotDay()) {\n"
6182 " takeWater();\n"
6183 " } else {\n"
6184 " if (todayIsJuly4th()) {\n"
6185 " takeFlag();\n"
6186 " }\n"
6187 " }\n"
6188 "}[/!][!python]if rainy():\n"
6189 " takeUmbrella()\n"
6190 "else:\n"
6191 " if hotDay():\n"
6192 " takeWater()\n"
6193 " else:\n"
6194 " if todayIsJuly4th():\n"
6195 " takeFlag()[/!]"
6196 msgstr ""
6197 "[!java|scala|c]if (chuvoso()) {\n"
6198 " levarGuardaChuva();\n"
6199 "} else {\n"
6200 " if (diaQuente()) {\n"
6201 " levarAgua();\n"
6202 " } else {\n"
6203 " if (jogoDaCopa()) {\n"
6204 " levarBandeira();\n"
6205 " }\n"
6206 " }\n"
6207 "}[/!][!python]if chuvoso():\n"
6208 " levarGuardaChuva()\n"
6209 "else:\n"
6210 " if diaQuente():\n"
6211 " levarAgua()\n"
6212 " else:\n"
6213 " if jogoDaCopa():\n"
6214 " levarBandeira()[/!]"
6215
6216 #. type: Content of: <p>
6217 #: src/lessons/welcome/bdr/BDR.html:113
6218 msgid ""
6219 "Unfortunately, such a cascade of conditionals is quite difficult to read. It "
6220 "is better to [!java|scala|c]omit the curly braces for the <tt>else</tt> "
6221 "statements. Some languages even introduce a specific construct for these "
6222 "<tt>else if</tt>, but not [!thelang].[/!] [!python]change the sub-blocks "
6223 "using the <code>elif</code> keyword to mark explicitly these \"else if\" "
6224 "branches.[/!]"
6225 msgstr ""
6226 "Infelizmente, tal cascata de condicionais é bastante difícil de ler. É "
6227 "melhor [!java|scala|c]omitir as chaves para as assertivas <tt>else</tt>. "
6228 "Algumas linguagens até mesmo introduzem uma construção específica para estes "
6229 "<tt>else if</tt>, mas não [!thelang].[/!] [!python]mudar os sub-blocos a "
6230 "usar a palavra-chave <code>elif</code> para marcar explicitamente estes "
6231 "ramos \"else if\".[/!]"
6232
6233 #. type: Content of: <pre>
6234 #: src/lessons/welcome/bdr/BDR.html:120
6235 #, no-wrap
6236 msgid ""
6237 "[!c|java|scala]if (rainy()) { \n"
6238 " takeUmbrella();\n"
6239 "} else if (hotDay()) {\n"
6240 " takeWater();\n"
6241 "} else if (todayIsJuly4th()) {\n"
6242 " takeFlag();\n"
6243 "}[/!][!python]if rainy():\n"
6244 " takeUmbrella()\n"
6245 "elif hotDay():\n"
6246 " takeWater()\n"
6247 "elif todayIsJuly4th():\n"
6248 " takeFlag()[/!]"
6249 msgstr ""
6250 "[!c|java|scala]if (chuvoso()) { \n"
6251 " levarGuardaChuva();\n"
6252 "} else if (diaQuente()) {\n"
6253 " levarAgua();\n"
6254 "} else if (jogoDaCopa()) {\n"
6255 " levarBandeira();\n"
6256 "}[/!][!python]if chuvoso():\n"
6257 " levarGuardaChuva()\n"
6258 "elif diaQuente():\n"
6259 " levarAgua()\n"
6260 "elif jogoDaCopa():\n"
6261 " levarBandeira()[/!]"
6262
6263 #. type: Content of: <h3>
6264 #: src/lessons/welcome/bdr/BDR.html:133
6265 msgid "Graffiti in the Buggle World"
6266 msgstr "Grafitagem no mundo dos Buggles"
6267
6268 #. type: Content of: <p>
6269 #: src/lessons/welcome/bdr/BDR.html:135
6270 msgid ""
6271 "Buggles can tag graffitis on the ground of their world. For that, they use "
6272 "the four following methods:"
6273 msgstr ""
6274 "Os buggles podem grafitar no chão do mundo deles. Para isto, use os quatro "
6275 "métodos seguintes:"
6276
6277 #. type: Content of: <ul><li>
6278 #: src/lessons/welcome/bdr/BDR.html:139
6279 msgid ""
6280 "<code>[!c]int[/!][!java]boolean[/!] "
6281 "isOverMessage()[!scala]:Boolean[/!]</code>: returns "
6282 "<code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> if and only if "
6283 "there is a message on the ground."
6284 msgstr ""
6285 "<code>[!c]int[/!][!java]boolean[/!] "
6286 "isOverMessage()[!scala]:Boolean[/!]</code>: returns "
6287 "<code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> se e somente se "
6288 "existe uma mensagem no chão."
6289
6290 #. type: Content of: <ul><li>
6291 #: src/lessons/welcome/bdr/BDR.html:142
6292 msgid ""
6293 "<code>[!c]char*[/!][!java]String[/!] readMessage()[!scala]: "
6294 "String[/!]</code>: returns the message written on the ground (or an empty "
6295 "string if nothing is written)."
6296 msgstr ""
6297 "<code>[!c]char*[/!][!java]String[/!] readMessage()[!scala]: "
6298 "String[/!]</code>: retorna a mensagem lida no chão (ou uma cadeia vazia se "
6299 "não há nada escrito)."
6300
6301 #. type: Content of: <ul><li>
6302 #: src/lessons/welcome/bdr/BDR.html:144
6303 msgid ""
6304 "<code>[!java|c]void[/!] writeMessage([!c]char*[/!][!java]String "
6305 "[/!]msg[!scala]: String[/!])</code>: writes the specified message down on "
6306 "the ground. If there is already a message on the ground, the new content is "
6307 "added at the end of the existing message."
6308 msgstr ""
6309 "<code>[!java|c]void[/!] escreverMensagem([!c]char*[/!][!java]String "
6310 "[/!]msg[!scala]: String[/!])</code>: escreve a mensagem especificada no "
6311 "chão. Se já existe uma mensagem no chão, a nova é adicionada no final da "
6312 "mensagem existente."
6313
6314 #. type: Content of: <ul><li>
6315 #: src/lessons/welcome/bdr/BDR.html:147
6316 msgid ""
6317 "<code>[!java|c]void [/!]clearMessage()</code>: clears what is written on the "
6318 "ground."
6319 msgstr ""
6320 "<code>[!java|c]void [/!]clearMessage()</code>: limpa o que está escrito no "
6321 "chão."
6322
6323 #. type: Content of: outside any tag (error?)
6324 #: src/lessons/welcome/bdr/BDR.html:151
6325 msgid ""
6326 "The goal is then to organize a BDR game between the buggles by teaching them "
6327 "to move according to the instructions written on the ground. These "
6328 "instructions are messages written on the ground, with the following "
6329 "signification:"
6330 msgstr ""
6331 "O objetivo é então organizar um jogo de BDR entre os buggles a ensinar eles "
6332 "a se mover de acordo com as instruções escritas no chão. Estas instruções "
6333 "são mensagens escritas no chão, com o seguinte significado:"
6334
6335 #. type: Content of: <table><tr><td>
6336 #: src/lessons/welcome/bdr/BDR.html:157 src/lessons/welcome/bdr/BDR2.html:139
6337 msgid "Message"
6338 msgstr "Mensagem"
6339
6340 #. type: Content of: <table><tr><td>
6341 #: src/lessons/welcome/bdr/BDR.html:158 src/lessons/welcome/bdr/BDR2.html:140
6342 msgid "What to do"
6343 msgstr "O que fazer"
6344
6345 #. type: Content of: <table><tr><td>
6346 #: src/lessons/welcome/bdr/BDR.html:159
6347 msgid "Mnemonic"
6348 msgstr "Mnemônico"
6349
6350 #. type: Content of: <table><tr><td>
6351 #: src/lessons/welcome/bdr/BDR.html:161 src/lessons/welcome/bdr/BDR2.html:142
6352 msgid "[!java|c]'R'[/!][!scala|python]\"R\"[/!]"
6353 msgstr "[!java|c]'R'[/!][!scala|python]\"R\"[/!]"
6354
6355 #. type: Content of: <table><tr><td>
6356 #: src/lessons/welcome/bdr/BDR.html:161 src/lessons/welcome/bdr/BDR2.html:142
6357 msgid "Turn right and move one step forward"
6358 msgstr "Vire a direita (R de right) e mova um passo a frente"
6359
6360 #. type: Content of: <table><tr><td>
6361 #: src/lessons/welcome/bdr/BDR.html:161
6362 msgid "Right"
6363 msgstr "Direita"
6364
6365 #. type: Content of: <table><tr><td>
6366 #: src/lessons/welcome/bdr/BDR.html:162 src/lessons/welcome/bdr/BDR2.html:143
6367 msgid "[!java|c]'L'[/!][!scala|python]\"L\"[/!]"
6368 msgstr "[!java|c]'L'[/!][!scala|python]\"L\"[/!]"
6369
6370 #. type: Content of: <table><tr><td>
6371 #: src/lessons/welcome/bdr/BDR.html:162 src/lessons/welcome/bdr/BDR2.html:143
6372 msgid "Turn left and move one step forward"
6373 msgstr "Vire a esquerda e mova um passo a frente"
6374
6375 #. type: Content of: <table><tr><td>
6376 #: src/lessons/welcome/bdr/BDR.html:162
6377 msgid "Left"
6378 msgstr "Esquerda"
6379
6380 #. type: Content of: <table><tr><td>
6381 #: src/lessons/welcome/bdr/BDR.html:163 src/lessons/welcome/bdr/BDR2.html:144
6382 msgid "[!java|c]'I'[/!][!scala|python]\"I\"[/!]"
6383 msgstr "[!java|c]'I'[/!][!scala|python]\"I\"[/!]"
6384
6385 #. type: Content of: <table><tr><td>
6386 #: src/lessons/welcome/bdr/BDR.html:163
6387 msgid "Turn back (U-turn) and move one step forward"
6388 msgstr "Vire para trás (meia-volta) e mova um passo a frente"
6389
6390 #. type: Content of: <table><tr><td>
6391 #: src/lessons/welcome/bdr/BDR.html:163
6392 msgid "Inverse"
6393 msgstr "Inversa"
6394
6395 #. type: Content of: <table><tr><td>
6396 #: src/lessons/welcome/bdr/BDR.html:165 src/lessons/welcome/bdr/BDR2.html:146
6397 msgid "[!java|c]'A'[/!][!scala|python]\"A\"[/!]"
6398 msgstr "[!java|c]'A'[/!][!scala|python]\"A\"[/!]"
6399
6400 #. type: Content of: <table><tr><td>
6401 #: src/lessons/welcome/bdr/BDR.html:165 src/lessons/welcome/bdr/BDR2.html:146
6402 msgid "Move one step forward"
6403 msgstr "Mova um passo a frente"
6404
6405 #. type: Content of: <table><tr><td>
6406 #: src/lessons/welcome/bdr/BDR.html:165
6407 msgid "First letter of the alphabet"
6408 msgstr "Primeira letra do alfabeto"
6409
6410 #. type: Content of: <table><tr><td>
6411 #: src/lessons/welcome/bdr/BDR.html:166 src/lessons/welcome/bdr/BDR2.html:147
6412 msgid "[!java|c]'B'[/!][!scala|python]\"B\"[/!]"
6413 msgstr "[!java|c]'B'[/!][!scala|python]\"B\"[/!]"
6414
6415 #. type: Content of: <table><tr><td>
6416 #: src/lessons/welcome/bdr/BDR.html:166 src/lessons/welcome/bdr/BDR2.html:147
6417 msgid "Move two steps forward"
6418 msgstr "Mova dois passos a frente"
6419
6420 #. type: Content of: <table><tr><td>
6421 #: src/lessons/welcome/bdr/BDR.html:166
6422 msgid "Second letter of the alphabet"
6423 msgstr "Segunda letra do alfabeto"
6424
6425 #. type: Content of: <table><tr><td>
6426 #: src/lessons/welcome/bdr/BDR.html:167 src/lessons/welcome/bdr/BDR2.html:148
6427 msgid "[!java|c]'C'[/!][!scala|python]\"C\"[/!]"
6428 msgstr "[!java|c]'C'[/!][!scala|python]\"C\"[/!]"
6429
6430 #. type: Content of: <table><tr><td>
6431 #: src/lessons/welcome/bdr/BDR.html:167 src/lessons/welcome/bdr/BDR2.html:148
6432 msgid "Move three steps forward"
6433 msgstr "Mova três passos a frente"
6434
6435 #. type: Content of: <table><tr><td>
6436 #: src/lessons/welcome/bdr/BDR.html:167
6437 msgid "Third letter of the alphabet"
6438 msgstr "Terceira letra do alfabeto"
6439
6440 #. type: Content of: <table><tr><td>
6441 #: src/lessons/welcome/bdr/BDR.html:169 src/lessons/welcome/bdr/BDR2.html:153
6442 msgid "[!java|c]'Z'[/!][!scala|python]\"Z\"[/!]"
6443 msgstr "[!java|c]'Z'[/!][!scala|python]\"Z\"[/!]"
6444
6445 #. type: Content of: <table><tr><td>
6446 #: src/lessons/welcome/bdr/BDR.html:169 src/lessons/welcome/bdr/BDR2.html:153
6447 msgid "Move one step backward"
6448 msgstr "Mova um passo para trás"
6449
6450 #. type: Content of: <table><tr><td>
6451 #: src/lessons/welcome/bdr/BDR.html:169
6452 msgid "One letter before the end of the alphabet"
6453 msgstr "última letra do alfabeto"
6454
6455 #. type: Content of: <table><tr><td>
6456 #: src/lessons/welcome/bdr/BDR.html:170 src/lessons/welcome/bdr/BDR2.html:154
6457 msgid "[!java|c]'Y'[/!][!scala|python]\"Y\"[/!]"
6458 msgstr "[!java|c]'Y'[/!][!scala|python]\"Y\"[/!]"
6459
6460 #. type: Content of: <table><tr><td>
6461 #: src/lessons/welcome/bdr/BDR.html:170 src/lessons/welcome/bdr/BDR2.html:154
6462 msgid "Move two steps backward"
6463 msgstr "Mova dois passos para trás"
6464
6465 #. type: Content of: <table><tr><td>
6466 #: src/lessons/welcome/bdr/BDR.html:170
6467 msgid "Two letters before the end of the alphabet"
6468 msgstr "penúltima letra do alfabeto"
6469
6470 #. type: Content of: <table><tr><td>
6471 #: src/lessons/welcome/bdr/BDR.html:171 src/lessons/welcome/bdr/BDR2.html:155
6472 msgid "[!java|c]'X'[/!][!scala|python]\"X\"[/!]"
6473 msgstr "[!java|c]'X'[/!][!scala|python]\"X\"[/!]"
6474
6475 #. type: Content of: <table><tr><td>
6476 #: src/lessons/welcome/bdr/BDR.html:171 src/lessons/welcome/bdr/BDR2.html:155
6477 msgid "Move three steps backward"
6478 msgstr "Mova três passos para trás"
6479
6480 #. type: Content of: <table><tr><td>
6481 #: src/lessons/welcome/bdr/BDR.html:171
6482 msgid "Three letters before the end of the alphabet"
6483 msgstr "Antepenúltima letra do alfabeto"
6484
6485 #. type: Content of: <table><tr><td>
6486 #: src/lessons/welcome/bdr/BDR.html:172 src/lessons/welcome/bdr/BDR2.html:159
6487 msgid "<i>(anything else)</i>"
6488 msgstr "<i>(qualquer outra coisa)</i>"
6489
6490 #. type: Content of: <table><tr><td>
6491 #: src/lessons/welcome/bdr/BDR.html:172 src/lessons/welcome/bdr/BDR2.html:159
6492 msgid "Stop dancing."
6493 msgstr "Parar de dançar."
6494
6495 #. type: Content of: <h3>
6496 #: src/lessons/welcome/bdr/BDR.html:175
6497 msgid "Indications"
6498 msgstr "Indicações"
6499
6500 #. type: Content of: outside any tag (error?)
6501 #: src/lessons/welcome/bdr/BDR.html:177
6502 msgid ""
6503 "This exercise may seem a bit complex at the first glance, but it comes down "
6504 "to summarizing the information of the table in a sequence of conditionals."
6505 msgstr ""
6506 "Este exercício pode parecer um pouco complexo à primeira vista, mas ele vem "
6507 "a resumir a informação na tabela numa sequência de condicionais."
6508
6509 #. type: Content of: <p>
6510 #: src/lessons/welcome/bdr/BDR.html:180
6511 msgid ""
6512 "You have to keep dancing as long as there is some dancing steps to do, i.e., "
6513 "as long as we are in a cell which content is described in the table. The "
6514 "easier for that is to use a boolean variable (<code>finished</code>) as "
6515 "termination condition to a <code>while</code> loop. It should be "
6516 "initialized to "
6517 "<code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code>, and switched "
6518 "to <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> as soon as "
6519 "the buggle find a cell with a value not described in the table. Thus, the "
6520 "loop will stop and the program will terminate."
6521 msgstr ""
6522 "Tem que se manter a dançar enquanto houverem passos de dança para fazer, "
6523 "p.ex., enquanto estivermos numa célula cujo conteúdo esteja contido na "
6524 "tabela. a forma mais fácil de fazer isto é a usar uma variável booleana "
6525 "(<code>terminou</code>) como condição de término para o loop <code>while</"
6526 "code>. Ela deve ser iniciada como "
6527 "<code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code> e trocada "
6528 "para <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> assim que "
6529 "o buggle encontre uma célula com um valor não descrito na tabela. Assim, o "
6530 "loop pára e o programa termina."
6531
6532 #. type: Content of: <p>
6533 #: src/lessons/welcome/bdr/BDR.html:190
6534 msgid ""
6535 "Another subtlety is that detecting if strings are equals is a bit annoying "
6536 "in [!thelang]. So, we use the <code>char getIndication[!c]Bdr[/!]()</code> "
6537 "instead of <code>[!java]String[/!][!c]char*[/!] readMessage()</code>. This "
6538 "method, only known by the buggles of this exercise, returns the first char "
6539 "of the message written on the ground (or ' ' -- the space char -- if nothing "
6540 "is written down). It enables to work with chars instead of strings, that is "
6541 "much simpler in [!thelang]."
6542 msgstr ""
6543 "Outro detalhe é que detetar se cadeias são iguais é um pouco chato em Java. "
6544 "Então, usamos o <code>char getIndication[!c]Bdr[/!]()</code> ao invés do "
6545 "<code>[!java]String[/!][!c]char*[/!] readMessage()</code>. Este método, "
6546 "conhecido apenas pelos buggles deste exercício, retorna o primeiro caractere "
6547 "da mensagem escrita no chão (ou ' ' -- o caractere para espaço -- se não tem "
6548 "nada escrito). Ele ativa que se trabalhe com caracteres ao invés de cadeias, "
6549 "que é muito mais simples em [!thelang]."
6550
6551 #. type: Content of: <h3>
6552 #: src/lessons/welcome/bdr/BDR.html:198
6553 msgid "Tips and Hints"
6554 msgstr "Dicas"
6555
6556 #. type: Content of: outside any tag (error?)
6557 #: src/lessons/welcome/bdr/BDR.html:200
6558 msgid ""
6559 "If you fail to understand why the buggle does not execute the expected "
6560 "steps, try adding <code>brushDown()</code> in your method. This asks the "
6561 "buggle to put down a brush leaving a trail when it moves. It should help you "
6562 "understanding its trajectory, but do not forget to remove this call when you "
6563 "want to test whether your code is a valid solution to the exercise: you are "
6564 "asked to let the buggle dance, not to vandalize the dance floor."
6565 msgstr ""
6566 "Se não entendeu por que o buggle não fez os passos esperados, tente "
6567 "adicionar <code>brushDown()</code> no seu método. Isto pede ao buggle para "
6568 "abaixar um pincel a deixar um rastro por onde passar. Isto pode ajudá-lo a "
6569 "entender a trajetória dele, mas não se esqueça de remover esta chamada "
6570 "quando quiser testar se o seu código é uma solução válida para o exercício: "
6571 "pode fazer o buggle dançar, mas não pichar a pista de dança."
6572
6573 #. type: Content of: <p>
6574 #: src/lessons/welcome/bdr/BDR.html:207
6575 msgid "When your program finally works, move on to the next exercise."
6576 msgstr "Quando seu programa finalmente funcionar, vá ao próximo exercício."
6577
6578 #. type: Content of: <h2>
6579 #: src/lessons/welcome/bdr/BDR2.html:2
6580 msgid "Buggle Dance Revolution 2 (BDR2)"
6581 msgstr "Buggle Dance Revolution 2 (BDR2)"
6582
6583 #. type: Content of: <p>
6584 #: src/lessons/welcome/bdr/BDR2.html:5
6585 msgid ""
6586 "BDR is cool, but it's a bit chaotic. First, the buggles giggle in any "
6587 "directions, and then the code you had to write to let them move is rather "
6588 "difficult to read. Here is a new BDR world where the buggle will dance a "
6589 "gentle circle. We will benefit this tranquillity to clean up a bit our code "
6590 "thanks to the new constructs we will introduce."
6591 msgstr ""
6592 "BDR é legal, mas um pouco caótico. Primeiro, os buggles balançam em todas as "
6593 "direções, o que faz com que o código que tenha que escrever para fazê-los se "
6594 "mover seja um pouco difícil de ler. Apresentamos agora um novo mundo DBR "
6595 "onde os buggles dançam num suave círculo. Vamos aproveitar esta "
6596 "tranquilidade para limpar um pouco nosso código graças a novas construções "
6597 "que vamos introduzir."
6598
6599 #. type: Content of: <h3>
6600 #: src/lessons/welcome/bdr/BDR2.html:11
6601 msgid "[!java|c]<code>switch</code> conditionals[/!][!scala]Pattern matching[/!]"
6602 msgstr ""
6603 "[!java|c]condicionais <code>switch</code>[/!][!scala]busca de padrões[/!]"
6604
6605 #. type: Content of: <p>
6606 #: src/lessons/welcome/bdr/BDR2.html:13
6607 msgid ""
6608 "The hardest part of previous code is certainly the conditional "
6609 "cascading. Somewhere in your code, you certainly had something similar to:"
6610 msgstr ""
6611 "A parte mais difícil do código anterior é comn certeza a cascata de "
6612 "condicionais. Em algum ponto do seu código, certamente tem algo como isto:"
6613
6614 #. type: Content of: <pre>
6615 #: src/lessons/welcome/bdr/BDR2.html:16
6616 #, no-wrap
6617 msgid ""
6618 "if ([!java|c]getIndication() == 'R'[/!][!scala]readMessage() == \"R\"[/!]) "
6619 "{\n"
6620 " right();\n"
6621 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
6622 "} else if ([!java|c]getIndication() == 'L'[/!][!scala]readMessage() == "
6623 "\"L\"[/!]) {\n"
6624 " left();\n"
6625 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
6626 "} else if ([!java|c]getIndication() == 'I'[/!][!scala]readMessage() == "
6627 "\"I\"[/!]) {\n"
6628 " back();\n"
6629 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
6630 "<span class=\"comment\">/* other else if */</span>\n"
6631 "} else {\n"
6632 " finished = [!c]1[/!][!java|scala]true[/!];\n"
6633 "}\n"
6634 msgstr ""
6635 "if ([!java|c]getIndicação() == 'R'[/!][!scala]lerMensagem() == \"R\"[/!]) {\n"
6636 " right();\n"
6637 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
6638 "} else if ([!java|c]getIndicação() == 'L'[/!][!scala]lerMensagem() == \"L\""
6639 "[/!]) {\n"
6640 " left();\n"
6641 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
6642 "} else if ([!java|c]getIndicação() == 'I'[/!][!scala]lerMensagem() == \"I\""
6643 "[/!]) {\n"
6644 " back();\n"
6645 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
6646 "<span class=\"comment\">/* other else if */</span>\n"
6647 "} else {\n"
6648 " terminou = [!c]1[/!][!java|scala]true[/!];\n"
6649 "}\n"
6650
6651 #. type: Content of: <p>
6652 #: src/lessons/welcome/bdr/BDR2.html:31
6653 msgid ""
6654 "When you review this code, it may not be clear at the first glance that it "
6655 "is simply a choice with 4 branches depending on the value of "
6656 "[!java|c]getIndication()[/!][!scala]readMessage()[/!]. To improve this, we "
6657 "will use a [!java|c]<code>switch</code> construct, which Java syntax is the "
6658 "following:[/!] [!scala] pattern matching, which is a very powerful construct "
6659 "that greatly generalizes the <code>if</code>. It is arguably one of the "
6660 "major advantages of Scala when compared to languages such as Java or "
6661 "python. It is not new either, as other languages such as OCaml or Haskell "
6662 "offer this feature since long, but still. It's really cool![/!]"
6663 msgstr ""
6664 "Quando revisa este código, não fica claro à primeira vista que é "
6665 "simplesmente a escolha entre quatro ramos a depender do valor de "
6666 "[!java|c]getIndicação()[/!][!scala]lerMensagem()[/!]. Para melhorar ele, "
6667 "vamos usar uma construção [!java|c]<code>switch</code>, que na sintaxe de "
6668 "Java é o seguinte:[/!] [!scala] de busca de padrões, que é bastante poderosa "
6669 "e generaliza muito o <code>if</code>. É com certeza uma das maiores "
6670 "vantagens de Scala quando comparada com linguagens como Java ou python. E "
6671 "nem é tão nova assim, já que outras linguagens como OCaml e Haskell já tem "
6672 "esta funcionalidade há muito tempo. É bem fixe![/!]"
6673
6674 #. type: Content of: outside any tag (error?)
6675 #: src/lessons/welcome/bdr/BDR2.html:40
6676 msgid "[/!] [!java|c]"
6677 msgstr "[/!] [!java|c]"
6678
6679 #. type: Content of: <pre>
6680 #: src/lessons/welcome/bdr/BDR2.html:44
6681 #, no-wrap
6682 msgid ""
6683 "switch (<b>expression</b>) {\n"
6684 " case <b>firstValue</b>: \n"
6685 " <b>whatToDoIfExpressionEqualsFirstValue();</b>\n"
6686 " break;\n"
6687 " case <b>secondValue</b>: \n"
6688 " <b>whatToDoIfExpressionEqualsSecondValue();</b>\n"
6689 " break;\n"
6690 " case <b>thirdValue</b>: \n"
6691 " <b>whatToDoIfExpressionEqualsThirdValue();</b>\n"
6692 " break;\n"
6693 " /* as much similar cases as you want */\n"
6694 " default: \n"
6695 " <b>whatToDoIfExpressionDoesNotEqualsAnySeenValues();</b>\n"
6696 "}"
6697 msgstr ""
6698 "switch (<b>expression</b>) {\n"
6699 " case <b>firstValue</b>: \n"
6700 " <b>whatToDoIfExpressionEqualsFirstValue();</b>\n"
6701 " break;\n"
6702 " case <b>secondValue</b>: \n"
6703 " <b>whatToDoIfExpressionEqualsSecondValue();</b>\n"
6704 " break;\n"
6705 " case <b>thirdValue</b>: \n"
6706 " <b>whatToDoIfExpressionEqualsThirdValue();</b>\n"
6707 " break;\n"
6708 " /* as much similar cases as you want */\n"
6709 " default: \n"
6710 " <b>whatToDoIfExpressionDoesNotEqualsAnySeenValues();</b>\n"
6711 "}"
6712
6713 #. type: Content of: <p>
6714 #: src/lessons/welcome/bdr/BDR2.html:59
6715 msgid ""
6716 "Observe that each branch of a <tt>switch</tt> must be ended by a "
6717 "<code>break</code>. If you forget this, the machine keeps going and execute "
6718 "the next branch in the list after the branch it jumped to. There is even "
6719 "some <b>rare</b> cases where this behavior reveals helpful."
6720 msgstr ""
6721 "Observe que cada ramo de um <tt>switch</tt> deve terminar com um "
6722 "<code>break</code>. se esquecer dele, a máquina continua e executa o próximo "
6723 "ramo na lista depois do ramo para o qual pulou. Existem na verdade uns "
6724 "<b>raros</b> casos onde este comportamento é útil."
6725
6726 #. type: Content of: <p>
6727 #: src/lessons/welcome/bdr/BDR2.html:64
6728 msgid ""
6729 "It is then possible to rewrite previous BDR code in a cleaner way using the "
6730 "<tt>switch</tt> construct:"
6731 msgstr ""
6732 "É então possível reescrever o código do BDR anterior numa forma mais clara a "
6733 "usar a construção <tt>switch</tt>:"
6734
6735 #. type: Content of: <pre>
6736 #: src/lessons/welcome/bdr/BDR2.html:67
6737 #, no-wrap
6738 msgid ""
6739 "switch (getIndication()) {\n"
6740 " case 'R':\n"
6741 " right(); \n"
6742 " [!c]stepForward()[/!][!java]forward()[/!]; \n"
6743 " break;\n"
6744 " case 'L':\n"
6745 " left();\n"
6746 " [!c]stepForward()[/!][!java]forward()[/!]; \n"
6747 " break;\n"
6748 " case 'I':\n"
6749 " back();\n"
6750 " [!c]stepForward()[/!][!java]forward()[/!];\n"
6751 " break;\n"
6752 " default: \n"
6753 " return;\n"
6754 "}"
6755 msgstr ""
6756 "switch (getIndicação()) {\n"
6757 " case 'R':\n"
6758 " right(); \n"
6759 " [!c]stepForward()[/!][!java]forward()[/!]; \n"
6760 " break;\n"
6761 " case 'L':\n"
6762 " left();\n"
6763 " [!c]stepForward()[/!][!java]forward()[/!]; \n"
6764 " break;\n"
6765 " case 'I':\n"
6766 " back();\n"
6767 " [!c]stepForward()[/!][!java]forward()[/!];\n"
6768 " break;\n"
6769 " default: \n"
6770 " return;\n"
6771 "}"
6772
6773 #. type: Content of: <pre>
6774 #: src/lessons/welcome/bdr/BDR2.html:85
6775 #, no-wrap
6776 msgid ""
6777 "<i>expression</i> <b>match</b> {\n"
6778 " <b>case</b> <i>possible value</i> <b>=></b> instructions\n"
6779 " <b>case</b> <i>other value</i> <b>=></b> other instructions\n"
6780 " <b>case</b> <i>another value</i> <b>=></b> yet another instructions\n"
6781 " <b>case _ =></b> default instructions\n"
6782 "}\n"
6783 msgstr ""
6784 "<i>expressão</i> <b>match</b> {\n"
6785 " <b>case</b> <i>um valor possível</i> <b>=></b> instruções\n"
6786 " <b>case</b> <i>um outro valor</i> <b>=></b> outras instruções\n"
6787 " <b>case</b> <i>mais outro valor</i> <b>=></b> e outras instruções\n"
6788 " <b>case _ =></b> instruções padrão\n"
6789 "}\n"
6790
6791 #. type: Content of: <p>
6792 #: src/lessons/welcome/bdr/BDR2.html:92
6793 msgid ""
6794 "The expression provided before the keyword <code>match</code>, and then the "
6795 "branches are evaluated one after the other until we find one which value "
6796 "provided between <code>case</code> and <code>=&gt</code> is equal to the "
6797 "expression's value. The <code>_</code> symbol acts as a wildcard, so the "
6798 "<code>_</code> branch <i>always</i> matches. Here is an example where a "
6799 "variable <code>name</code> is matched."
6800 msgstr ""
6801 "A espressão fornecida antes da palavra-chave <code>match</code> e os ramos "
6802 "seguintes são avaliados um após o outro até encontrarmos um cujo valor "
6803 "fornecido entre <code>case</code> e <code>=&gt</code> seja igual ao valor da "
6804 "expressão. O símbolo <code>_</code> age como um coringa, logo o ramo "
6805 "<code>_</code> <i>sempre</i> casa. Aqui está um exemplo de onde uma variável "
6806 "<code>name</code> casa."
6807
6808 #. type: Content of: <pre>
6809 #: src/lessons/welcome/bdr/BDR2.html:97
6810 #, no-wrap
6811 msgid ""
6812 "name match {\n"
6813 " case \"Martin\" => println(\"Hello Martin, how are you?\")\n"
6814 " case \"Gerald\" => println(\"Hey Gerald! How are you doing?\")\n"
6815 " case _ => println(\"Welcome stranger.\")\n"
6816 "}"
6817 msgstr ""
6818 "name match {\n"
6819 " case \"Martin\" => println(\"Oi Martin, como vai?\")\n"
6820 " case \"Gerald\" => println(\"Oi Gerald! como está?\")\n"
6821 " case _ => println(\"Olá estranho.\")\n"
6822 "}"
6823
6824 #. type: Content of: <p>
6825 #: src/lessons/welcome/bdr/BDR2.html:103
6826 msgid ""
6827 "It is possible to have more than one instruction per branch, and merge "
6828 "branches when the values are separated by a | symbol."
6829 msgstr ""
6830 "é possível ter mais que uma instrução por ramo e mesclar ramos quando os "
6831 "valores são separados por um símbolo | ."
6832
6833 #. type: Content of: <pre>
6834 #: src/lessons/welcome/bdr/BDR2.html:105
6835 #, no-wrap
6836 msgid ""
6837 "name match {\n"
6838 " case \"Martin\" | \"Gerald\" => println(\"Hello \"+name+\", how are "
6839 "you?\"); openTheDoor()\n"
6840 " case _ => println(\"Hello stranger. Please do "
6841 "not pass.\"); lockTheDoor()\n"
6842 "}"
6843 msgstr ""
6844 "name match {\n"
6845 " case \"Martin\" | \"Gerald\" => println(\"Oi \"+name+\", como está?\"); "
6846 "openTheDoor()\n"
6847 " case _ => println(\"Oi estranho. Favor não "
6848 "passar.\"); lockTheDoor()\n"
6849 "}"
6850
6851 #. type: Content of: <p>
6852 #: src/lessons/welcome/bdr/BDR2.html:110
6853 msgid ""
6854 "You can even add guards to your branches. These are extra conditions that "
6855 "must be respected for the branch to get applied. This is handy if you want "
6856 "match on value ranges, as follows."
6857 msgstr ""
6858 "Sempre pode adicionar guardas aos seus ramos. São condições adicionais que "
6859 "devem ser respeitadas para que o ramo seja aplicado. São úteis se quiser "
6860 "corresponder com intervalos de valores, como a seguir."
6861
6862 #. type: Content of: <pre>
6863 #: src/lessons/welcome/bdr/BDR2.html:112
6864 #, no-wrap
6865 msgid ""
6866 "age match {\n"
6867 " case i if i&lt;10 => println(\"Hey kid!\")\n"
6868 " case i if i&lt;20 => println(\"Hey dude!\")\n"
6869 " case i if i&lt;30 => println(\"Hello young man\")\n"
6870 " case _ => println(\"Hello Sir\")\n"
6871 "}"
6872 msgstr ""
6873 "age match {\n"
6874 " case i if i&lt;10 => println(\"Oi menino!\")\n"
6875 " case i if i&lt;20 => println(\"Oi cara!\")\n"
6876 " case i if i&lt;30 => println(\"Oi, meu caro\")\n"
6877 " case _ => println(\"Oi senhor\")\n"
6878 "}"
6879
6880 #. type: Content of: <p>
6881 #: src/lessons/welcome/bdr/BDR2.html:118
6882 msgid ""
6883 "Note that there is no need to check whether the value is higher than 10 on "
6884 "the second line because the first matching branch is used. So, if the second "
6885 "branch gets evaluated, then the first one did not match."
6886 msgstr ""
6887 "Observe que não há necessidade de verificar se o valor é maior que 10 na "
6888 "segunda linha por que o primeiro ramo \"foi verificado\". Então, se o "
6889 "segundo ramo está a ser verificado, o primeiro não aprovou."
6890
6891 #. type: Content of: <p>
6892 #: src/lessons/welcome/bdr/BDR2.html:121
6893 msgid "Finally, it is possible also to match several variables in one shoot!"
6894 msgstr "Finalmente, é possível também aprovar várias variáveis de uma vez!"
6895
6896 #. type: Content of: <pre>
6897 #: src/lessons/welcome/bdr/BDR2.html:122
6898 #, no-wrap
6899 msgid ""
6900 "(x,y) match {\n"
6901 " case (0,0) => println(\"that's the origin\")\n"
6902 " case (_,0) => println(\"On the ordinate\")\n"
6903 " case (0,_) => println(\"On the abscissa\")\n"
6904 " case (_,_) => println(\"Some random point\")\n"
6905 "}"
6906 msgstr ""
6907 "(x,y) match {\n"
6908 " case (0,0) => println(\"Esta é a origem\")\n"
6909 " case (_,0) => println(\"nas ordenadas\")\n"
6910 " case (0,_) => println(\"nas abscissas\")\n"
6911 " case (_,_) => println(\"algum ponto qualquer\")\n"
6912 "}"
6913
6914 #. type: Content of: <p>
6915 #: src/lessons/welcome/bdr/BDR2.html:129
6916 msgid ""
6917 "I told you that scala's pattern matching is very powerful! I actually love "
6918 "this feature!"
6919 msgstr ""
6920 "Disse que reconhecimentod e padrões em scala é muito poderoso! Adoro esta "
6921 "funcionalidade!"
6922
6923 #. type: Content of: <p>
6924 #: src/lessons/welcome/bdr/BDR2.html:133
6925 msgid ""
6926 "[!java|scala|c]Apply the improvement we just saw to rewrite your buggle code "
6927 "with the following dance steps. [/!] [!python]Let's teach a new dance step "
6928 "to the buggles. It is slightly more complex but actually better "
6929 "looking. Beside of that, that's the same old story.[/!] Note that we can now "
6930 "move up to 6 cells in one dance step."
6931 msgstr ""
6932 "[!java|scala|c]\"Aplique\" a melhoria que acabamos de ver para reescrever o "
6933 "seu código do buggle com os seguintes passos de dança. [/!] [!python]Vamos "
6934 "ensinar um novo passo de dança aos buggles. É um pouco mais complexo mas na "
6935 "verdade vai ficar mais legal. Apesar disto, é a mesma história de sempre.[/!]"
6936 " Observe que nósagora vamos subir seis células num passo de dança."
6937
6938 #. type: Content of: <table><tr><td>
6939 #: src/lessons/welcome/bdr/BDR2.html:144
6940 msgid "Turn back and move one step forward"
6941 msgstr "Vire e dê um passo para frente"
6942
6943 #. type: Content of: <table><tr><td>
6944 #: src/lessons/welcome/bdr/BDR2.html:149
6945 msgid "[!java|c]'D'[/!][!scala|python]\"D\"[/!]"
6946 msgstr "[!java|c]'D'[/!][!scala|python]\"D\"[/!]"
6947
6948 #. type: Content of: <table><tr><td>
6949 #: src/lessons/welcome/bdr/BDR2.html:149
6950 msgid "Move four cells forward"
6951 msgstr "Mova quantro passos para frente"
6952
6953 #. type: Content of: <table><tr><td>
6954 #: src/lessons/welcome/bdr/BDR2.html:150
6955 msgid "[!java|c]'E'[/!][!scala|python]\"E\"[/!]"
6956 msgstr "[!java|c]'E'[/!][!scala|python]\"E\"[/!]"
6957
6958 #. type: Content of: <table><tr><td>
6959 #: src/lessons/welcome/bdr/BDR2.html:150
6960 msgid "Move five cells forward"
6961 msgstr "Mova cinco passos para frente"
6962
6963 #. type: Content of: <table><tr><td>
6964 #: src/lessons/welcome/bdr/BDR2.html:151
6965 msgid "[!java|c]'F'[/!][!scala|python]\"F\"[/!]"
6966 msgstr "[!java|c]'F'[/!][!scala|python]\"F\"[/!]"
6967
6968 #. type: Content of: <table><tr><td>
6969 #: src/lessons/welcome/bdr/BDR2.html:151
6970 msgid "Move six cells forward"
6971 msgstr "Mova seis passos para frente"
6972
6973 #. type: Content of: <table><tr><td>
6974 #: src/lessons/welcome/bdr/BDR2.html:156
6975 msgid "[!java|c]'W'[/!][!scala|python]\"W\"[/!]"
6976 msgstr "[!java|c]'W'[/!][!scala|python]\"W\"[/!]"
6977
6978 #. type: Content of: <table><tr><td>
6979 #: src/lessons/welcome/bdr/BDR2.html:156
6980 msgid "Move four cells backward"
6981 msgstr "Mova quatro passos para trás"
6982
6983 #. type: Content of: <table><tr><td>
6984 #: src/lessons/welcome/bdr/BDR2.html:157
6985 msgid "[!java|c]'V'[/!][!scala|python]\"V\"[/!]"
6986 msgstr "[!java|c]'V'[/!][!scala|python]\"V\"[/!]"
6987
6988 #. type: Content of: <table><tr><td>
6989 #: src/lessons/welcome/bdr/BDR2.html:157
6990 msgid "Move five cells backward"
6991 msgstr "Mova cinco passos para trás"
6992
6993 #. type: Content of: <table><tr><td>
6994 #: src/lessons/welcome/bdr/BDR2.html:158
6995 msgid "[!java|c]'U'[/!][!scala|python]\"U\"[/!]"
6996 msgstr "[!java|c]'U'[/!][!scala|python]\"U\"[/!]"
6997
6998 #. type: Content of: <table><tr><td>
6999 #: src/lessons/welcome/bdr/BDR2.html:158
7000 msgid "Move six cells backward"
7001 msgstr "Mova seis passos para trás"
7002
7003 #. type: Content of: <p>
7004 #: src/lessons/welcome/bdr/BDR2.html:163
7005 msgid "When you program works again, proceed to next exercise."
7006 msgstr "Quando seu programa funcionar de novo, vá ao próximo exercício."
7007
7008 #. type: Content of: <p>
7009 #: src/lessons/welcome/traversal/Snake.html:4
7010 msgid ""
7011 "We will now teach the buggle to explore its world. Its initial position is "
7012 "the bottom left corner, and it should visit any cells up to the top "
7013 "(coloring the ground on its path. The main loop of your code is something "
7014 "like:"
7015 msgstr ""
7016 "Agora vamos ensinar o buggle a explorar o mundo dele. A posição inicial dele "
7017 "é o canto inferior esquerdo e deve visitar todas as células até o topo (a "
7018 "colorir o chão onde passa. O loop principal do seu código é algo assim:"
7019
7020 #. type: Content of: <pre>
7021 #: src/lessons/welcome/traversal/Snake.html:8
7022 #, no-wrap
7023 msgid ""
7024 " move brush down\n"
7025 " while we did not reach the final position\n"
7026 " move like a snake\n"
7027 msgstr ""
7028 " abaixe o pincel\n"
7029 " enquanto não chegar na posição final\n"
7030 " se mova como uma cobra\n"
7031
7032 #. type: Content of: <p>
7033 #: src/lessons/welcome/traversal/Snake.html:13
7034 msgid ""
7035 "We thus have to write two specific methods: The first one returns a boolean "
7036 "indicating whether we are on a final position while the second moves one "
7037 "snake step forward."
7038 msgstr ""
7039 "Então temos que escrever dois métodos específicos: o primeiro retorna um "
7040 "booleano a indicar se estamos numa posição final enquanto o segundo um "
7041 "\"snake step\" para frente."
7042
7043 #. type: Content of: <p>
7044 #: src/lessons/welcome/traversal/Snake.html:17
7045 msgid "We reached the final position if and only if both conditions are true:"
7046 msgstr ""
7047 "Chegamos na posição final se e apenas se ambas as condições são verdadeiras:"
7048
7049 #. type: Content of: <ul><li>
7050 #: src/lessons/welcome/traversal/Snake.html:19
7051 msgid "We are facing a wall"
7052 msgstr "Estamos de frente para uma parede"
7053
7054 #. type: Content of: <ul><li>
7055 #: src/lessons/welcome/traversal/Snake.html:20
7056 msgid ""
7057 "There is a wall on the north of the buggle. So, if the buggle is facing "
7058 "east, you should check whether there is a wall on the left, and if the "
7059 "buggle is facing west, you should check on the right side."
7060 msgstr ""
7061 "Existe uma parede no norte do buggle. Então, se o buggle está a olhar para o "
7062 "leste, deve verificar se existe uma parede à esquerda e se o buggle está a "
7063 "olhar para o oeste, deve verificar do lado direito."
7064
7065 #. type: Content of: <ul><li>
7066 #: src/lessons/welcome/traversal/Snake.html:23
7067 msgid ""
7068 "We can get the current heading of the buggle using the "
7069 "<code>getDirection()</code>, and we know whether it looks east using "
7070 "<code>getDirection() == [!scala|python|java]Direction.[/!]EAST</code> (WEST "
7071 "for west)."
7072 msgstr ""
7073 "Podemos obter a direção atual do buggle a usar o <code>getDirection()</code> "
7074 "e sabemos se ele está a apontar para o leste a usar <code>getDirection() == "
7075 "[!scala|python|java]Direção.[/!]LESTE</code> (OESTE para oeste)."
7076
7077 #. type: Content of: <ul><li>
7078 #: src/lessons/welcome/traversal/Snake.html:26
7079 msgid ""
7080 "To check, nothing magical: you have to turn the buggle and check whether it "
7081 "is facing a wall afterward."
7082 msgstr ""
7083 "Para verificar, não tem mágica: tem que virar o buggle e verificar em "
7084 "seguida se está a olhar para uma parede."
7085
7086 #. type: Content of: <p>
7087 #: src/lessons/welcome/traversal/Snake.html:29
7088 msgid ""
7089 "Then, a snake step can be achieved by moving one step forward if we are not "
7090 "facing a wall, and moving to the upper line else (i.e., if you look to the "
7091 "west facing a wall, you have to turn right, forward and turn right)."
7092 msgstr ""
7093 "Então, um passo de cobra pode ser conseguido a mover um passo para a frente "
7094 "se não estivermos de cara para a parede e a mover para a linha acima caso "
7095 "contrário (p.ex., se olha para o oeste e está de cara para uma parede, tem "
7096 "que virar a direita, andar e virar a direita)."
7097
7098 #. type: Content of: <p>
7099 #: src/lessons/welcome/traversal/Snake.html:33
7100 msgid ""
7101 "Hint: the main loop of your code must continue while the testing function "
7102 "returns false. There is two ways of writing it:"
7103 msgstr ""
7104 "Dica: o loop principal do seu código deve continuar enquanto a função de "
7105 "teste retorna false. Existem duas formas de fazer isto:"
7106
7107 #. type: Content of: <pre>
7108 #: src/lessons/welcome/traversal/Snake.html:35
7109 #, no-wrap
7110 msgid ""
7111 "while (testingFunction() == [!c]0) {[/!][!java|scala]false) "
7112 "{[/!][!python]False):[/!]"
7113 msgstr ""
7114 "while (testingFunction() == [!c]0) {[/!][!java|scala]false) "
7115 "{[/!][!python]False):[/!]"
7116
7117 #. type: Content of: <p>
7118 #: src/lessons/welcome/traversal/Snake.html:36
7119 msgid ""
7120 "[!python]You may prefer to write it as:[/!] [!java|scala|c]Since the "
7121 "exclamation mark (!) denotes the boolean negation in [!thelang], you may "
7122 "write it as:[/!]"
7123 msgstr ""
7124 "[!python]Pode preferir escrever como:[/!] [!java|scala|c]Já que a marca de "
7125 "exclamação (!) denota a negação booleana em [!thelang], pode escrever "
7126 "como:[/!]"
7127
7128 #. type: Content of: <pre>
7129 #: src/lessons/welcome/traversal/Snake.html:38
7130 #, no-wrap
7131 msgid ""
7132 "while ([!java|scala|c]![/!][!python]not "
7133 "[/!]testingFunction())[!java|scala|c] {[/!][!python]:[/!]"
7134 msgstr ""
7135 "while ([!java|scala|c]![/!][!python]not [/!]testingFunction())[!java|scala|c]"
7136 " {[/!][!python]:[/!]"
7137
7138 #. type: Content of: <p>
7139 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:4
7140 msgid ""
7141 "The goal of this serie of exercises is to let the buggle traverse its "
7142 "world. It must number the cells it walks on to show its traversal order."
7143 msgstr ""
7144 "O objetivo desta série de exercícios é fazer o buggle percorrer o mundo "
7145 "dele. Deve numerar as células por onde passa para mostrar a ordem do caminho."
7146
7147 #. type: Content of: <p>
7148 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:7
7149 msgid "The main loop of your code should be something like:"
7150 msgstr "O loop principal do seu código deve ser algo como:"
7151
7152 #. type: Content of: <pre>
7153 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:9
7154 #, no-wrap
7155 msgid ""
7156 " while we are not on the final position\n"
7157 " go to the next position\n"
7158 " label the cell with its number\n"
7159 msgstr ""
7160 " enquanto não estiver na posição final\n"
7161 " vá à próxima posição\n"
7162 " rotule a célula com um número\n"
7163
7164 #. type: Content of: <p>
7165 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:14
7166 msgid ""
7167 "In contrary to the exercises we saw so far, we won't use the "
7168 "<code>forward()</code>, <code>backward()</code> and similar "
7169 "methods. Instead, we will compute the coordinate of the next buggle position "
7170 "and use the <code>setPos(x, y)</code> method to <i>teleport</i> the buggle "
7171 "directly to this position. For example, <code>setPos(3, 5)</code> teleports "
7172 "the buggle to the cell where x=3 and y=5."
7173 msgstr ""
7174 "Ao contrário dos exercícios que vimos até agora, não vamos usar os métodos "
7175 "<code>forward()</code>, <code>backward()</code> e similares. Ao invés disto, "
7176 "vamos calcular as coordenadas da próxima posição de buggle e usar o método "
7177 "<code>setPos(x, y)</code> para <i>teletransportar</i> o buggle diretamente "
7178 "para esta posição. Por exemplo, <code>setPos(3, 5)</code> teletransporta o "
7179 "buggle à célula onde x=3 e y=5."
7180
7181 #. type: Content of: <p>
7182 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:21
7183 msgid ""
7184 "Your first task is thus to write a boolean function indicating whether the "
7185 "buggle reached the final position or not, ie if it reached the bottom right "
7186 "corner of the world. For this, you can use <code>getWorldWidth()</code> and "
7187 "<code>getWorldHeight()</code> which return respectively the world's width "
7188 "and height. Your test is about comparing the buggle's current position (that "
7189 "you can access with <code>getX()</code> and <code>getY()</code>) to the "
7190 "world dimensions."
7191 msgstr ""
7192 "A sua primeira tarefa é escrever uma função booleana a indicar se o buggle "
7193 "alcançou a posição final ou não, ou seja, se alcançou o canto inferior "
7194 "direito do mundo. Para isto, pode usar <code>getWorldWidth()</code> e "
7195 "<code>getWorldHeight()</code> que retornam respetivamente a largura e altura "
7196 "do mundo. O seu teste deve comparar a posição atual do buggle (que pode "
7197 "acessar com <code>getX()</code> e <code>getY()</code>) com as dimensões do "
7198 "mundo."
7199
7200 #. type: Content of: <p>
7201 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:28
7202 msgid ""
7203 "Beware, the first line and column are numbered 0 and not 1, and the point "
7204 "(0,0) is on the top left corner. This may seem surprising, but it is very "
7205 "often so in Computer Science."
7206 msgstr ""
7207 "Cuidado, a primeira linha e coluna são numeradas com 0 e não com 1 e o ponto "
7208 "(0,0) fica no canto superior esquerdo. Isto pode parecer estranho, mas é bem "
7209 "comum em ciência da computação."
7210
7211 #. type: Content of: <p>
7212 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:32
7213 msgid ""
7214 "Then, you have to write the code to reach the next position. In this "
7215 "exercise, you have to traverse the world row after row. So, if you are at "
7216 "the bottom of a row, you have to move to the top of next row. Else, you have "
7217 "to move to the cell below."
7218 msgstr ""
7219 "Então, tem que escrever o código para alcançar a próxima posição. Neste "
7220 "exercício, tem que percorrer o mundo linha após linha. Logo, se está no "
7221 "fundo de uma linha, tem que mover ao topo da próxima, caso contrário tem que "
7222 "mover à célula abaixo."
7223
7224 #. type: Content of: <p>
7225 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:37
7226 msgid ""
7227 "At this point, you can launch your program to check that the buggle "
7228 "correctly traverse the world in the expected order, and that it stops when "
7229 "it has to. Use the <b>stop</b> button if the buggle does not stop correctly."
7230 msgstr ""
7231 "Neste ponto, pode lançar o seu programa para verificar se o buggle percorre "
7232 "corretamente o mundo na ordem esperada e que pára quando tem que parar. Use "
7233 "oo botão <b>stop</b> se o buggle não parar corretamente."
7234
7235 #. type: Content of: <p>
7236 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:41
7237 msgid ""
7238 "It is now time to write down the cell numbers. For that, you will need a "
7239 "counter initialiser to zero at the beginning of your code, and incremented "
7240 "by one at each step (for example with <code>counter += 1;</code>). Then, "
7241 "you have to use <code>writeMessage()</code> to write the value on the "
7242 "ground."
7243 msgstr ""
7244 "Agora é hora de escrever os números das células. Para isto, vai precisar de "
7245 "um contador a iniciar em zero no começo do seu código e incrementar de um em "
7246 "cada passo (por exemplo com <code>counter += 1;</code>). Então, terá que "
7247 "usar <code>writeMessage()</code> para escrever o valor no chão."
7248
7249 #. type: Content of: <p>
7250 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:47
7251 msgid ""
7252 "You probably need to write the first [!java|scala|c]or last [/!]value out of "
7253 "the main loop [!java|scala|c], depending on whether you prefer to use a "
7254 "<code>while</code> or a <code>do/while</code> one[/!]."
7255 msgstr ""
7256 "Provavelmente vai precisar escrever o primeiro [!java|scala|c]ou último [/!]"
7257 "valor fora do loop principal [!java|scala|c], a depender se prefere usar um "
7258 "<code>while</code> ou um <code>do/while</code>[/!]."
7259
7260 #. type: Content of: outside any tag (error?)
7261 #: src/lessons/welcome/traversal/line/TraversalByLine.html:4
7262 msgid ""
7263 "You once again have to let the buggle traverse the world numbering the cells "
7264 "on its way, but the goal of this exercise is to write a line traversal. Most "
7265 "of the code you wrote for previous exercise remains usable here. Simply, the "
7266 "method computing the coordinates of the next buggle position has to be "
7267 "correctly updated: if you are at the right of a line, you have to go to the "
7268 "beginning of the next one. If not, you have to go to the right cell."
7269 msgstr ""
7270 "Mais uma vez terá que deixar o buggle percorrer o mundo a numerar as células "
7271 "no caminho, mas o objetivo do exercício é escrever uma linha transversal. A "
7272 "maioria do código que escreveu para exercícios anteriores continua útil "
7273 "aqui. Simplesmente, o método a calcular as coordenadas da próxima posição do "
7274 "buggle tem que ser atualizado corretamente: se estiver a direita de uma "
7275 "linha, terá que ir ao começo da próxima. Senão, terá que ir à célula da "
7276 "direita."
7277
7278 #. type: Content of: <p>
7279 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:4
7280 msgid ""
7281 "This time, you are asked to traverse the world one diagonal after the "
7282 "other. Have a look at the objective world for more details on the requested "
7283 "traversal order."
7284 msgstr ""
7285 "Agora é para atravessar o mundo uma diagonal depois da outra. Dê uma olhada "
7286 "no mundo objetivo para maiores detalhes quanto à ordem a percorrer pedida."
7287
7288 #. type: Content of: <p>
7289 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:8
7290 msgid ""
7291 "You may find useful to use an integer variable <code>diag</code> storing the "
7292 "number of the diagonal you are traversing."
7293 msgstr ""
7294 "Pode ser útil usar uma variável inteira <code>diag</code> a guardar o número "
7295 "da diagonal que está a atravessar."
7296
7297 #. type: Content of: outside any tag (error?)
7298 #: src/lessons/welcome/traversal/zigzag/TraversalZigZag.html:4
7299 msgid ""
7300 "This time, you have to zigzag on the way up. Have a look at the objective "
7301 "world for more details on the requested traversal order."
7302 msgstr ""
7303 "Desta vez, vai ter que fazer um zigzag no caminho para cima. Dê uma olhada "
7304 "no mundo objetivo para mais detalhes da ordem a percorrer pedida."
7305
7306 #. type: Content of: <h2>
7307 #: src/lessons/welcome/summative/Moria.html:2
7308 msgid "Lost in the Moria"
7309 msgstr "Perdido em Moria"
7310
7311 #. type: Content of: <p>
7312 #: src/lessons/welcome/summative/Moria.html:4
7313 msgid ""
7314 "You buggles got stuck in the mines of Moria! Some rocks are blocking the "
7315 "exit, and you will have to clear your way to the exit. Well of course these "
7316 "are only baggles and you could simply walk away, but it will be easier to "
7317 "program the buggles so that they move those \"rocks\" than convincing them "
7318 "to walk away without solving the problem. Dwarfs are sometimes really "
7319 "stubborns..."
7320 msgstr ""
7321 "Os seus buggles ficaram presos nas minas de Moria! Algumas pedras estão a "
7322 "bloquear a saída e terá que limpar o seu caminho para a saída. Bem, é claro "
7323 "que são apenas baggles e pode simplesmente sair a andar, mas será mais fácil "
7324 "programar os buggles de forma que mova estas \"pedras\" do que convencer-los "
7325 "que ele pode sair a andar facilmente sem resolver o problema. Anões podem "
7326 "ser bem teimosos..."
7327
7328 #. type: Content of: <p>
7329 #: src/lessons/welcome/summative/Moria.html:11
7330 msgid ""
7331 "So, you have to find the first baggle blocking the exit (simply walk to the "
7332 "east until you are over a baggle), take it and move it back to the other "
7333 "side of the tunnel (walk to the west while you are not over a baggle, and "
7334 "then move back one step to the east and drop your baggle), and iterate until "
7335 "you find the exit (that is, the wall to the east side). Afterward, move out "
7336 "as in the objective world. That's only a few more steps away."
7337 msgstr ""
7338 "Bem, tem que encontrar o primeiro baggle a bloquear a saída (simplemente "
7339 "ande para o leste até que esteja sobre um baggle), leve-o e mova para o "
7340 "outro lado do túnel (ande para o oeste enquanto ainda não estiver sobre um "
7341 "baggle e depois mova-se de volta um passo para o leste e solte o seu baggle) "
7342 "e repita até encontrar a saída (ou seja, a parede com o muro para o lado "
7343 "leste). Depois disto, mova-se para fora como no mundo objetivo. São só mais "
7344 "uns passos."
7345
7346 #. type: Content of: <p>
7347 #: src/lessons/welcome/summative/Moria.html:18
7348 msgid ""
7349 "To make things worse, you have to write a program that works for every "
7350 "buggle, even if writing a specific program for each of them would be "
7351 "easier. It seems that using <code>while</code> loops is the only solution to "
7352 "move the buggles correctly."
7353 msgstr ""
7354 "Para piorar ainda mais as coisas, tem que escrever um programa que funcione "
7355 "para qualquer buggle, mesmo se escrever um programa específico para cada um "
7356 "deles for mais fácil. Parece que usar loops <code>while</code> é a única "
7357 "solução para mover os buggles corretamente."
7358
7359 #. type: Content of: <p>
7360 #: src/lessons/welcome/summative/Moria.html:23
7361 msgid ""
7362 "Once you manage to escape this trap, you can move forward to the next "
7363 "exercise. This exercise is a bit more complex, so you can also leave it for "
7364 "now and come back later if you don't get it right now."
7365 msgstr ""
7366 "Quando conseguir escapar desta armadilha, poderá avançar para o próximo "
7367 "exercício. Este exercício é um pouco mais complexo, então também pode "
7368 "esperar e voltar mais tarde se não o conseguir agora mesmo."
7369
7370 #. type: Content of: <h3>
7371 #: src/lessons/turmites/Main.html:2 src/lessons/turmites/short_desc.html:2
7372 msgid "The turmites"
7373 msgstr "Os turmites"
7374
7375 #. type: Content of: <p>
7376 #: src/lessons/turmites/Main.html:4
7377 msgid ""
7378 "This set of activities lets you play with Langton's ants, that are 2D turing "
7379 "machines. They constitute very simple application problems, achievable by "
7380 "beginners, and open the door to an amazing world."
7381 msgstr ""
7382 "Este conjunto de atividades é para brincar com formigas de Langton, que são "
7383 "máquinas de Turing 2D. Elas constituem problemas bem simples, bons para "
7384 "iniciantes e abrem as portas para um mundo fantástico."
7385
7386 #. type: Content of: <p>
7387 #: src/lessons/turmites/Main.html:8
7388 msgid ""
7389 "This mechanism were invented in 1986 by Chris Langton, and later generalized "
7390 "in several ways (as we shall see in the next exercises). It was proven that "
7391 "Turmites and Turing machines are of equal power: An ant's trajectory can be "
7392 "used to compute any boolean circuit, and thus that an ant is capable of "
7393 "universal computation. Put simply, any possible computation can be achieved "
7394 "using a turmite as a computing device. Yet another subject of fascination..."
7395 msgstr ""
7396 "Este mecanismo foi inventado em 1986 por Chris Langton e depois generalizado "
7397 "em várias formas (como veremos nos próximos exercícios). Foi provado que "
7398 "Turmites e máquinas de Turing têm o mesmo poder: Uma trajetória de formiga "
7399 "pode ser usada para calcular qualquer circuito booleano e logo uma formiga é "
7400 "capaz de qualquer cálculo universal. a resumir, qualquer cálculo possível "
7401 "pode ser alcançado a usar uma turmite como aparelho computacional. Ainda "
7402 "outro assunto fascinante..."
7403
7404 #. type: Content of: <p>
7405 #: src/lessons/turmites/Main.html:14
7406 msgid ""
7407 "Multicolor Langton's ants were discovered in 1995 by Propp et Al. Another "
7408 "funny fact is that the ants which name is a list of consecutive pair of "
7409 "identical letters (LL and RR) produce symmetric patterns. This fact was even "
7410 "formally proved."
7411 msgstr ""
7412 "formigas de Langton multicoloridas foram descobertas em 1995 por Propp et "
7413 "Al. Outro fato divertido é que as formigas cujos nomes é uma lista de pares "
7414 "consecutivos de letras idênticas (LL e RR) produzem padrões simétricos. Este "
7415 "fato foi até mesmo provado formalmente."
7416
7417 #. type: Content of: <p>
7418 #: src/lessons/turmites/Main.html:19
7419 msgid ""
7420 "Check the corresponding wikipedia web page, of which this exercise is "
7421 "inspired, for further details."
7422 msgstr ""
7423 "Verifique a página da wikipédia correspondente, na qual este exercício é "
7424 "inspirado, para maiores detalhes."
7425
7426 #. type: Content of: <h3>
7427 #: src/lessons/turmites/Main.html:22 src/lessons/sort/basic/Main.html:15
7428 #: src/lessons/sort/dutchflag/Main.html:9 src/lessons/sort/pancake/Main.html:30
7429 #: src/lessons/sort/baseball/Main.html:28 src/lessons/turtleart/Main.html:12
7430 msgid "What can I do to improve this PLM universe?"
7431 msgstr "O que posso fazer para melhorar este universo do PLM?"
7432
7433 #. type: Content of: <p>
7434 #: src/lessons/turmites/Main.html:24 src/lessons/sort/basic/Main.html:17
7435 #: src/lessons/sort/dutchflag/Main.html:11
7436 #: src/lessons/sort/pancake/Main.html:32 src/lessons/sort/baseball/Main.html:30
7437 #: src/lessons/turtleart/Main.html:14 src/lessons/recursion/cons/Main.html:7
7438 msgid ""
7439 "As usual, there are several things that could be done in the code of this "
7440 "universe to improve it:"
7441 msgstr ""
7442 "Como sempre, existem várias coisas que podem ser feitas no código deste "
7443 "universo para melhorá-lo:"
7444
7445 #. type: Content of: <ul><li>
7446 #: src/lessons/turmites/Main.html:26
7447 msgid ""
7448 "We are probably missing some good exercises. The turmite creator exercise is "
7449 "a bit harsh: we could introduce the patterns in a more friendly manner."
7450 msgstr ""
7451 "Alguns bons exercícios estão provavelmente a faltar. O exercício de criador "
7452 "de turmite é um pouco pé-duro: podemos introduzir os padrões de uma forma "
7453 "mais amigável."
7454
7455 #. type: Content of: <ul><li>
7456 #: src/lessons/turmites/Main.html:28
7457 msgid "We may want to write an exercise on the busy beaver, maybe?"
7458 msgstr "Quem sabe não escrevemos um exercício sobre os \"busy beavers\"?"
7459
7460 #. type: Content of: <p>
7461 #: src/lessons/turmites/short_desc.html:3
7462 msgid "Discover the Langton's ants, that are 2D turing machines."
7463 msgstr "Descubra as formigas de Langton, que são máquinas de Turing 2D."
7464
7465 #. type: Content of: <p>
7466 #: src/lessons/turmites/short_desc.html:5
7467 msgid ""
7468 "These activities are very simple application problems, achievable by "
7469 "beginners, and open the door to an amazing world."
7470 msgstr ""
7471 "Estas atividades são problemas bem simples, bons para iniciantes e abrema a "
7472 "porta para um mundo fantástico."
7473
7474 #. type: Content of: <h2>
7475 #: src/lessons/turmites/langton/Langton.html:2
7476 msgid "Langton's ant"
7477 msgstr "formiga de Langton"
7478
7479 #. type: Content of: <p>
7480 #: src/lessons/turmites/langton/Langton.html:4
7481 msgid ""
7482 "In this exercise, you will turn your buggle into a <i>Langton's "
7483 "ant</i>. These artificial little animals are very interesting because they "
7484 "are given simple rules that depend only on their local environment, and "
7485 "after a period of apparent chaotic behavior, a general pattern "
7486 "<i>emerges</i>."
7487 msgstr ""
7488 "Neste exercício, vai transformar o seu buggle numa <i>formiga de Langton</"
7489 "i>. Estes pequenos animais artificiais são bastante interessantes por que "
7490 "eles recebem regras simples que dependem apenas do seu ambiente local e "
7491 "depois de um período de aparente comportamento caótico, um modelo geral "
7492 "<i>surge</i>."
7493
7494 #. type: Content of: <p>
7495 #: src/lessons/turmites/langton/Langton.html:9
7496 msgid ""
7497 "The rules are absolutely trivial: to compute what the next step should be, "
7498 "you should check the current color of the ground (using "
7499 "<code>getGroundColor()</code>). If it's white, change it to black, turn "
7500 "right and move forward by one cell. If the ground is currently black, change "
7501 "it to white, turn left and move forward by one cell."
7502 msgstr ""
7503 "As regras são absolutamente triviais: para calcular qual o próximo passo, "
7504 "verifique a cor atual do chão (a usar <code>getGroundColor()</code>). Se for "
7505 "branco, mude para preto, vire à direita e mova uma célula. Se for preto mude "
7506 "para branco, vire a esquerda e ande uma célula."
7507
7508 #. type: Content of: <p>
7509 #: src/lessons/turmites/langton/Langton.html:15
7510 msgid ""
7511 "It's hard to come up with simpler rules isn't it? Well, let's go and code it "
7512 "now. You have to complete the <code>step()</code> method, which encodes the "
7513 "behavior of the ant at each step. You will probably use the "
7514 "<code>getGroundColor()</code> method to retrieve the color of the cell on "
7515 "which the ant is currently. Colors of interest are simply named "
7516 "<code>Color.black</code> and <code>Color.white</code>."
7517 msgstr ""
7518 "Difícil encontrar regras mais simples, não é? Bem, vamos em frente codificar "
7519 "isto agora. Precisa completar o método <code>step()</code>, que codifica o "
7520 "comportamento da formiga em cada passo. Vai provavelmente usar o método "
7521 "<code>getGroundColor()</code> para recuperar a cor da célula na qual a "
7522 "formiga está no momento. Cores úteis são nomeadas simplesmente de <code>Cor."
7523 "preto</code> e <code>Cor.branco</code>."
7524
7525 #. type: Content of: <p>
7526 #: src/lessons/turmites/langton/Langton.html:22
7527 msgid ""
7528 "To compare colors, you cannot use the equal signs (==), because these things "
7529 "are not scalar values but objects. Instead, you need to write something like "
7530 "the following:"
7531 msgstr ""
7532 "Para comparar cores, não pode usar o símbolo de igualdade (==), pois estas "
7533 "coisas não são valores escalares, mas objetos. Ao invés disto, precisa "
7534 "escrever algo como o seguinte:"
7535
7536 #. type: Content of: <pre>
7537 #: src/lessons/turmites/langton/Langton.html:25
7538 #, no-wrap
7539 msgid ""
7540 "Color c /* = some initialization */;\n"
7541 "if (c.equals(Color.black)) {\n"
7542 " /* that's equal */\n"
7543 "} else {\n"
7544 " /* that was not equal */\n"
7545 "}\n"
7546 msgstr ""
7547 "Cor c /* = alguma inicialização */;\n"
7548 "if (c.equals(Cor.preto)) {\n"
7549 " /* é igual */\n"
7550 "} else {\n"
7551 " /* não é igual */\n"
7552 "}\n"
7553
7554 #. type: Content of: <p>
7555 #: src/lessons/turmites/langton/Langton.html:34
7556 msgid ""
7557 "Changing the ground color is not difficult, but a bit long: you have to "
7558 "change the brush color of your buggle, set the brush down (to mark the "
7559 "current cell -- with <code>brushDown()</code>), and set the brush back up "
7560 "(with <code>brushUp()</code>) to avoid further issues when the buggle will "
7561 "move. You are naturally free of organizing your code the way you want, but "
7562 "you may want to write a <code>setGroundColor(color)</code> method to "
7563 "factorize things a bit."
7564 msgstr ""
7565 "Mudar a cor do chão não é difícil, mas meio demorado: tem que mudar a cor do "
7566 "pincel do seu buggle, baixar o pincel (para marcar a célula atual -- com "
7567 "<code>brushDown()</code>) e levantar o pincel de novo (com "
7568 "<code>brushUp()</code>) para evitar problemas quando o buggle se mexer. É, "
7569 "naturalmente, livre para organizar o seu código da forma que quiser, mas "
7570 "deve querer escrever um método <code>setGroundColor(color)</code> para "
7571 "separar um pouco as coisas."
7572
7573 #. type: Content of: <p>
7574 #: src/lessons/turmites/langton/Langton.html:41
7575 msgid ""
7576 "As you can see from the execution of this exercise, the interest in this "
7577 "algorithm is that after about 10000 steps of relative chaotic behavior, the "
7578 "ant start building a regular pattern. This emergence of a regular pattern "
7579 "from the chaos is rather fascinating, isn't it? Move on to the next exercise "
7580 "to see more of them."
7581 msgstr ""
7582 "Como pode ver da execução deste exercício, o interessante neste algoritmo é "
7583 "que depois de uns 10000 passos de comportamento relativamente caótico, a "
7584 "formiga começa a construir um modelo regular. O surgimento deste modelo "
7585 "regular em meio ao caos é bastante fascinante, não acha? Mova para o próximo "
7586 "exercício para ver mais disto."
7587
7588 #. type: Content of: <h2>
7589 #: src/lessons/turmites/langtoncolors/LangtonColors.html:2
7590 msgid "Multicolor Langton's ant"
7591 msgstr "formiga de Langton multicolorida"
7592
7593 #. type: Content of: <p>
7594 #: src/lessons/turmites/langtoncolors/LangtonColors.html:4
7595 msgid ""
7596 "There is several ways to extend the concept of Langton's ant. In this "
7597 "exercise, we explore first one, using more than two colors. It remains very "
7598 "similar to the base case: the behavior at each step still depends on the "
7599 "ground color, but you have more than 2 possibilities. It allows to have more "
7600 "than one kind of ant, depending on what you decide to do for each color. For "
7601 "example, the ant LRL takes 3 colors. It turns left on the first color, right "
7602 "on the second one and left on the third color. According to this definition, "
7603 "the basic ant is a RL (since it turns right on white cells and left on black "
7604 "ones)."
7605 msgstr ""
7606 "Existem várias formas de extender o conceito de formiga de Langton. Neste "
7607 "exercício, vamos explorar a primeira, a usar mais que duas cores. Ela se "
7608 "mantem muito similar ao caso base: o comportamento em cada passo ainda "
7609 "depende da cor do chão, mas tem mais que duas possibilidades. Pode ter mais "
7610 "que um tipo de formiga, a depender do que decide fazer para cada cor. Por "
7611 "exemplo, a formiga LRL recebe 3 cores. Ela vira a esquerda na primiera cor, "
7612 "a direita na segunda e a esquerda na terceira. De acordo com esta definição, "
7613 "a formiga básica é uma RL (já que ela vira a direita em células brancas e a "
7614 "esquerda em pretas)."
7615
7616 #. type: Content of: <p>
7617 #: src/lessons/turmites/langtoncolors/LangtonColors.html:13
7618 msgid ""
7619 "Some of these ants draw fascinating patterns (switch the world to see them): "
7620 "LLRR build a symmetric figure resembling loosely to a ball, LRRRRRLLR draws "
7621 "a square, LLRRRLRLRLLR draws a convoluted regular pattern after a period of "
7622 "seemingly chaotic behavior, and RRLLLRLLLRRR seems to fill a hour glass..."
7623 msgstr ""
7624 "Algumas destas formigas desenham padrões fascinantes (alterne o mundo para "
7625 "vê-los): LLRR constrói uma figura simétrica semelhante a uma bola, LRRRRRLLR "
7626 "desenha um quadrado, LLRRRLRLRLLR desenha um padrão regular convolucionado "
7627 "depois de um período de aparente caos e RRLLLRLLLRRR parece preencher uma "
7628 "ampulheta..."
7629
7630 #. type: Content of: <p>
7631 #: src/lessons/turmites/langtoncolors/LangtonColors.html:18
7632 msgid ""
7633 "Changing your buggle into a generic Langton's ant is not very complicated, "
7634 "although it is not completely trivial. As previously, you have to write a "
7635 "<code>step</code> function. But this time, it receives two arrays as "
7636 "parameters. The first one defines the rules to follow depending on the "
7637 "ground color while the second one gives the sequence of colors to use. For "
7638 "example, the basic ant would have [!java]<code>{'R', 'L'}</code> and "
7639 "<code>{Color.white, Color.black}</code>[/!] [!python]<code>['R', 'L']</code> "
7640 "and <code>[Color.white, Color.black]</code>[/!] [!scala]<code>Array('R', "
7641 "'L')</code> and <code>Array(Color.white, Color.black)</code>[/!] as "
7642 "arguments."
7643 msgstr ""
7644 "Transformar o seu buggle numa formiga de Langton genérica não é muito "
7645 "complicado, embora não seja totalmente trivial. Como anteriormente, tem que "
7646 "escrever uma função <code>step</code>. Mas desta vez, ela recebe duas arrays "
7647 "como parâmetros. A primeira define as regras para seguir a depender da cor "
7648 "do chão enquanto a segunda dá a sequência de cores a usar. Por exemplo, a "
7649 "formiga básica deve ter [!java]<code>{'R', 'L'}</code> e <code>{Cor.branco, "
7650 "Cor.preto}</code>[/!] [!python]<code>['R', 'L']</code> e <code>[Cor.branco, "
7651 "Cor.preto]</code>[/!] [!scala]<code>Array('R', 'L')</code> e <code>Array("
7652 "Cor.branco, Cor.preto)</code>[/!] como argumentos."
7653
7654 #. type: Content of: <p>
7655 #: src/lessons/turmites/langtoncolors/LangtonColors.html:29
7656 msgid "At each step, you thus have to apply the following pseudo-code:"
7657 msgstr "Em cada passo, deve então ter que aplicar o seguinte pseudo-código:"
7658
7659 #. type: Content of: <ul><li>
7660 #: src/lessons/turmites/langtoncolors/LangtonColors.html:31
7661 msgid "Find the position of the ground color in the color sequence;"
7662 msgstr "Encontre a posição da cor do chão na sequência de cores;"
7663
7664 #. type: Content of: <ul><li>
7665 #: src/lessons/turmites/langtoncolors/LangtonColors.html:32
7666 msgid ""
7667 "Turn left or right depending on the content of the rule array at that "
7668 "position;"
7669 msgstr ""
7670 "Vire a esquerda ou direita a depender do conteúdo da array de regras nesta "
7671 "posição;"
7672
7673 #. type: Content of: <ul><li>
7674 #: src/lessons/turmites/langtoncolors/LangtonColors.html:33
7675 msgid ""
7676 "Mark the current ground with the next color in the sequence (the last color "
7677 "being followed by the first one);"
7678 msgstr ""
7679 "Marque o chão com a próxima cor na sequência (a cor seguinte à última é a "
7680 "primeira);"
7681
7682 #. type: Content of: <ul><li>
7683 #: src/lessons/turmites/langtoncolors/LangtonColors.html:34
7684 msgid "Move forward by one step."
7685 msgstr "ande um passo para frente."
7686
7687 #. type: Content of: <p>
7688 #: src/lessons/turmites/langtoncolors/LangtonColors.html:37
7689 #: src/lessons/turmites/helloturmite/HelloTurmite.html:67
7690 msgid "You now should have enough information to succeed."
7691 msgstr "Agora tem informação o suficiente para conseguir."
7692
7693 #. type: Content of: <h2>
7694 #: src/lessons/turmites/helloturmite/HelloTurmite.html:2
7695 msgid "Turmites"
7696 msgstr "Turmites"
7697
7698 #. type: Content of: <p>
7699 #: src/lessons/turmites/helloturmite/HelloTurmite.html:4
7700 msgid ""
7701 "This exercise explores a new way to extend the concept of Langton's "
7702 "ant. Now, the behavior of the ant not only depends on the color on the "
7703 "ground, but also on its internal state (represented by an integer "
7704 "value). The idea of changing the ant into such an automata naturally comes "
7705 "from the Turing machine concept. This explains the name of these new "
7706 "animals, which is a portemanteau of <i>Turing</i> and <i>Termite</i> (if you "
7707 "don't know what a Turing machine is, you should run to wikipedia, because it "
7708 "is simply impossible to be a real computer scientist before that)."
7709 msgstr ""
7710 "Este exercício explora uma nova forma de extender o conceito de formiga de "
7711 "Langton. Agora, o comportamento da formiga não depende apenas da cor no "
7712 "chão, mas também do estado interno dela (representado por um valor inteiro). "
7713 "A ideia de transformar a formiga num autômato vem naturalmente do conceito "
7714 "de máquina de Turing. Isto explica o nome destes novos animais, que é um "
7715 "amálgama de <i>Turing</i> e <i>Termite</i> (se não sabe o que uma máquina de "
7716 "Turing é, vá à wikipédia, por que é impossível ser um cientista da "
7717 "computação de verdade sem conhecê-la)."
7718
7719 #. type: Content of: <p>
7720 #: src/lessons/turmites/helloturmite/HelloTurmite.html:13
7721 msgid ""
7722 "Once again, you just have to write the <code>step()</code> method, in charge "
7723 "of doing one turmite's step. Once again, you should first find the rank of "
7724 "the current's cell ground color in the color sequence. But this time, the "
7725 "<code>rule</code> data depends both on the current color and the current "
7726 "state. <code>rule</code> actually contains 3 information in each situation: "
7727 "the color to write, the move to do, and the next state value. For example, "
7728 "[!java|python]rule[1][0][/!][!scala]rule(1)(0)[/!] contains the informations "
7729 "to use when <code>state==1</code> and <code>color==0</code>. In other "
7730 "worlds, you can retrieve the information relative to your current situation "
7731 "by using "
7732 "<code>[!java|python]rule[state][currentColor][/!][!scala]rule(state)(currentColor)[/!]</code>."
7733 msgstr ""
7734 "Novamente, tem que simplesmente escrever o método <code>step()</code>, "
7735 "encarregado de fazer o turmite dar um passo. Novamente, deve primeiro "
7736 "encontrar o rank da cor do chão da célula atual na sequência de cores. Mas "
7737 "agora, os dados de <code>rule</code> (regras) dependem tanto da cor atual "
7738 "quanto do estado atual. A <code>rule</code> na verdade contém 3 informações "
7739 "em cada situação: a cor que a escreve, o movimento a fazer e o valor do "
7740 "próximo estado. Por exemplo, "
7741 "[!java|python]rule[1][0][/!][!scala]rule(1)(0)[/!] contém as informações "
7742 "para usar quando <code>state==1</code> e <code>color==0</code>. Em outros "
7743 "mundos, pode recuperar a informação relativa à sua situação atual a usar <cod"
7744 "e>[!java|python]rule[state][currentColor][/!][!scala]rule(state)(currentColor"
7745 ")[/!]</code>."
7746
7747 #. type: Content of: <p>
7748 #: src/lessons/turmites/helloturmite/HelloTurmite.html:25
7749 msgid ""
7750 "Each such information set contains 3 values. The first one is the rank of "
7751 "the color to write on the ground. The second is the move to do, with the "
7752 "following notation: 0=stop, 1=noturn, 2=left, 4=u-turn, 8=right. Note that "
7753 "if the command is stop, you shouldn't even move forward on that step (but "
7754 "you shouldn't stop your program either: the next steps can do something else "
7755 "in a future state). Finally, the third integer is the next "
7756 "<code>state</code> value to go into after this iteration."
7757 msgstr ""
7758 "Cada um destes conjuntos de informações contém 3 valores. O primeiro é o "
7759 "rank da cor para escrever no chão. O segundo é o movimento para fazer, com a "
7760 "seguinte notação: 0=stop, 1=noturn, 2=left, 4=u-turn, 8=right. Observe que "
7761 "se o comando é stop, não se pode mover nem para a frente neste passo (mas "
7762 "também não pode parar o programa: os próximos passos podem fazer algo mais "
7763 "num estado futuro). Finalmente, o terceiro inteiro é o próximo valor do "
7764 "<code>state</code> a ir dentro da próxima iteração."
7765
7766 #. type: Content of: <p>
7767 #: src/lessons/turmites/helloturmite/HelloTurmite.html:32
7768 msgid ""
7769 "Since these arbitrary notations are somehow difficult to remember, you "
7770 "should define a set of constants that you should use instead of the direct "
7771 "numerical values. Their names could be NOTURN, LEFT, RIGHT and so on. "
7772 "[!scala]Just declare them using the keyword <code>val</code> instead of "
7773 "<code>var</code>. You should always use <code>val</code> instead of "
7774 "<code>var</code> when possible anyway.[/!] [!java]The modifiers <code>final "
7775 "static</code> before their type is the way to mark variables as constant in "
7776 "Java. You should write for example <code>static final int NOTURN=1;</code> "
7777 "Sorry for the complexity of this notation. [/!] [!python]By convention, such "
7778 "constant variables are written in upper case in python. Technically, you "
7779 "can still modify them, but that would be a very bad idea.[/!] You should "
7780 "write them out of any method so that they are globally visible."
7781 msgstr ""
7782 "Uma vez que estas notações arbitrárias são de certa forma difíceis de "
7783 "lembrar, deve definir um conjunto de constantes que deve usar no lugar dos "
7784 "valores numéricos diretos. Os nomes deles podem ser NOTURN, LEFT, RIGHT etc. "
7785 "[!scala]Simplesmente declare-as a usar keyword <code>val</code> no lugar de "
7786 "<code>var</code>. Deve sempre usar <code>val</code> no lugar de <code>var</"
7787 "code> quando possível de qualquer forma.[/!] [!java]Os modificadores "
7788 "<code>final static</code> antes do tipo dele é a forma de marcar variáveis "
7789 "como constantes em Java. Deve escrever, por exemplo, <code>static final int "
7790 "NOTURN=1;</code> Desculpe pela complesxidade desta notação. [/!] [!python]"
7791 "Por convenção, tais variáveis constantes são escritas em maiúsculas no "
7792 "python. Tecnicamente, ainda pode modificá-las, mas isto é uma má ideia.[/!] "
7793 "Deve escrevê-las fora de qualquer método para que elas se tornem visíveis "
7794 "globalmente."
7795
7796 #. type: Content of: <p>
7797 #: src/lessons/turmites/helloturmite/HelloTurmite.html:44
7798 msgid ""
7799 "Using such constants greatly help making the code easier to read. Compare "
7800 "the next two code chunks:"
7801 msgstr ""
7802 "Usar tais constantes ajuda em muito a fazer o código mais legível. Compare "
7803 "os dois blocos de código a seguir:"
7804
7805 #. type: Content of: <pre>
7806 #: src/lessons/turmites/helloturmite/HelloTurmite.html:46
7807 #, no-wrap
7808 msgid ""
7809 "[!java]if (rule[state][currentColor][NEXT_MOVE] == LEFT) {[/!][!python]if "
7810 "rule[state][currentColor][NEXT_MOVE] == LEFT:[/!][!scala]if "
7811 "(rule(state)(currentColor)(NEXT_MOVE) == LEFT) {[/!]\n"
7812 " left()[!java];[/!]\n"
7813 "[!java|scala]}[/!]"
7814 msgstr ""
7815 "[!java]if (rule[state][currentColor][NEXT_MOVE] == LEFT) {[/!][!python]if "
7816 "rule[state][currentColor][NEXT_MOVE] == LEFT:[/!][!scala]if "
7817 "(rule(state)(currentColor)(NEXT_MOVE) == LEFT) {[/!]\n"
7818 " left()[!java];[/!]\n"
7819 "[!java|scala]}[/!]"
7820
7821 #. type: Content of: <p>
7822 #: src/lessons/turmites/helloturmite/HelloTurmite.html:49
7823 msgid "This is much more easier to read (although longer) than the following:"
7824 msgstr ""
7825 "Isto é muito mais fácil de se ler (embora seja mais longo) do que o seguinte:"
7826
7827 #. type: Content of: <pre>
7828 #: src/lessons/turmites/helloturmite/HelloTurmite.html:50
7829 #, no-wrap
7830 msgid ""
7831 "[!java]if (rule[i][j][1] == 2) {[/!][!python]if rule[i][j][1] == "
7832 "2:[/!][!scala]if (rule(i)(j)(1) == 2) {[/!]\n"
7833 " left()[!java];[/!]\n"
7834 "[!java|scala]}[/!]"
7835 msgstr ""
7836 "[!java]if (rule[i][j][1] == 2) {[/!][!python]if rule[i][j][1] == "
7837 "2:[/!][!scala]if (rule(i)(j)(1) == 2) {[/!]\n"
7838 " left()[!java];[/!]\n"
7839 "[!java|scala]}[/!]"
7840
7841 #. type: Content of: <p>
7842 #: src/lessons/turmites/helloturmite/HelloTurmite.html:54
7843 msgid ""
7844 "Finally, you probably want to write a <code>elif</code> branch for the "
7845 "<code>STOP</code> condition too. Having a <code>else</code> branch "
7846 "displaying an error message such as \"unknown case\" is a good practice: it "
7847 "makes your assumptions about your code more explicit, and you will get an "
7848 "error message if they fall short. When doing so, the next problem is that "
7849 "you have nothing to do in the <code>STOP</code> case, but python do not "
7850 "allows you to write empty <code>elif</code> branches. You should use the "
7851 "<code>pass</code> instruction as a placeholder: it says python that you have "
7852 "a branch here, and that it does not contain anything."
7853 msgstr ""
7854 "Finalmente, provavelmente vai escrever um ramo <code>elif</code> para a "
7855 "condição <code>STOP</code> também. Ter um ramo <code>else</code> a mostrar "
7856 "uma mensagem de erro tal como \"unknown case\" é uma boa prática: faz as "
7857 "suas suposições sobre o seu código mais explícitas e tem uma mensagem de "
7858 "erro se elas falharem. Quando fizer isto, o próximo problema vai ser que não "
7859 "tem nada para fazer no caso do <code>STOP</code>, mas python não permite que "
7860 "escreva ramos <code>elif</code> vazios. Deve usar a instrução <code>pass</"
7861 "code> como substituto, que diz ao python que tem um ramo aqui e que não faz "
7862 "nada."
7863
7864 #. type: Content of: <p>
7865 #: src/lessons/turmites/helloturmite/HelloTurmite.html:63
7866 msgid ""
7867 "You should probably use a [!java]switch case[/!][!scala]pattern matching[/!] "
7868 "construct to keep your code readable. If you can't remember what it is, "
7869 "check <a href=\"plm://lessons.welcome/bdr.BDR2\">this exercise</a>."
7870 msgstr ""
7871 "Provavelmente deve usar uma construção [!java]switch case[/!][!scala]pattern "
7872 "matching[/!] para manter o seu código legível. Se não se lembra o que isto "
7873 "é, veja <a href=\"plm://lessons.welcome/bdr.BDR2\">este exercício</a>."
7874
7875 #. type: Content of: <h2>
7876 #: src/lessons/turmites/helloturmite/HelloTurmite.html:69
7877 msgid "Bibliographical notes"
7878 msgstr "Notas bibliográficas"
7879
7880 #. type: Content of: <p>
7881 #: src/lessons/turmites/helloturmite/HelloTurmite.html:70
7882 msgid ""
7883 "According to wikipedia, turmites were invented independently by the end of "
7884 "the eighties. It has been shown that turmites in general are exactly "
7885 "equivalent in power to one-dimensional Turing machines with an infinite "
7886 "tape, as either can simulate the other. This means that absolutely any "
7887 "program that you can think of could theoretically be computed on this "
7888 "device..."
7889 msgstr ""
7890 "De acordo com a wikipédia, os turmites foram inventados independentemente no "
7891 "final dos anos oitenta. Foi provado que turmites em geral são exatamente "
7892 "equivalentes em capacidade a máquinas de turing uni-dimensionais com uma "
7893 "fita infinita, pois um pode simular o outro. Isto significa que qualquer "
7894 "programa que possa conceber pode teoricamente ser executado neste aparelho..."
7895
7896 #. type: Content of: <h2>
7897 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:2
7898 msgid "Creating Turmites"
7899 msgstr "Criar Turmites"
7900
7901 #. type: Content of: <p>
7902 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:4
7903 msgid ""
7904 "This exercise allows you to build your own turmites. To pass the exercise, "
7905 "you should simply write a <code>init()</code> method which initializes the "
7906 "<code>rule</code> to use the following transitions table (from wikipedia), "
7907 "set the buggle initial position at (8;33), and ask for 8342 steps."
7908 msgstr ""
7909 "Este exercício permite que construa os seus próprios turmites. Para passar "
7910 "neste exercício, deve simplesmente escrever um método <code>init()</code> "
7911 "que inicializa a <code>rule</code> para usar a seguintes tabela de "
7912 "transições (da wikipédia), configure a posição inicial em (8;33) e peça por "
7913 "8342 passos."
7914
7915 #. type: Content of: <table><tr><th>
7916 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:11
7917 msgid "Current color"
7918 msgstr "Cor atual"
7919
7920 #. type: Content of: <table><tr><td>
7921 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:14
7922 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:29
7923 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:32
7924 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:40
7925 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:42
7926 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:43
7927 msgid "0"
7928 msgstr "0"
7929
7930 #. type: Content of: <table><tr><td>
7931 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:15
7932 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:30
7933 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:33
7934 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:35
7935 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:38
7936 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:45
7937 msgid "1"
7938 msgstr "1"
7939
7940 #. type: Content of: <table><tr><th>
7941 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:19
7942 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:22
7943 msgid "Write color"
7944 msgstr "Escrever cor"
7945
7946 #. type: Content of: <table><tr><th>
7947 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:20
7948 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:23
7949 msgid "Turn"
7950 msgstr "Turn"
7951
7952 #. type: Content of: <table><tr><th>
7953 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:21
7954 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:24
7955 msgid "Next state"
7956 msgstr "Próximo estado"
7957
7958 #. type: Content of: <table><tr><th>
7959 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:27
7960 msgid "Current state"
7961 msgstr "Estado atual"
7962
7963 #. type: Content of: <table><tr><td>
7964 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:31
7965 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:34
7966 msgid "R"
7967 msgstr "R"
7968
7969 #. type: Content of: <table><tr><td>
7970 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:41
7971 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:44
7972 msgid "N"
7973 msgstr "N"
7974
7975 #. type: Content of: <p>
7976 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:49
7977 msgid ""
7978 "where the direction to turn is one of <b>L</b> (90° left), <b>R</b> (90° "
7979 "right), <b>N</b> (no turn) and <b>U</b> (180° U-turn)."
7980 msgstr ""
7981 "Onde a direção para virar é <b>L</b> (90° à esquerda), <b>R</b> (90° à "
7982 "direita), <b>N</b> (não vira) e <b>U</b> (meia-volta)."
7983
7984 #. type: Content of: <h2>
7985 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:51
7986 msgid "Going further"
7987 msgstr "Ir mais longe"
7988
7989 #. type: Content of: <p>
7990 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:52
7991 msgid ""
7992 "This exercise is naturally an excuse to let you experiment with your own "
7993 "turmites. Feel free to change the transition table and the amount of steps "
7994 "to experiment by yourself. To that extend, you may find the Ed Pegg Jr's "
7995 "library useful. If you find new interesting patterns, send them per email so "
7996 "that we can integrate them to this list!"
7997 msgstr ""
7998 "Este exercício é naturalmente uma desculpa para deixá-lo experimentar com os "
7999 "seus próprios turmites. Sinta-se à vontade para mudar a tabela de transições "
8000 "e a quantidade de passos por conta própria. Nesta altura, pode se interessar "
8001 "pela biblioteca de Pegg Jr. Se encontrar novos padrões interessantes, envie-"
8002 "os por email para que eles possam integrar a lista!"
8003
8004 #. type: Content of: <p>
8005 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:58
8006 msgid ""
8007 "In addition, wikipedia is desperately missing some good looking colorful "
8008 "turmites: only black and white ones are depicted. You should consider "
8009 "submitting your creations directly to the free encyclopedia."
8010 msgstr ""
8011 "Adicionalmente, a wikipédia está a precisar desesperadamente de alguns "
8012 "turmites coloridos bem apresentáveis: apenas os preto e branco estão "
8013 "descritos. Deveria considerar a possibilidade de enviar as suas criações "
8014 "diretamente à enciclopédia livre."
8015
8016 #. type: Content of: <p>
8017 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:63
8018 msgid ""
8019 "Here are some 2-color turmites, extracted from "
8020 "http://demonstrations.wolfram.com/Turmites/ [!python|scala]They are not "
8021 "written using the [!thelang] syntax, but converting them should be easy.[/!]"
8022 msgstr ""
8023 "Aqui estão alguns turmites de 2 cores, extraídos de http://demonstrations."
8024 "wolfram.com/Turmites/ [!python|scala]Eles não foram escritos a usar o "
8025 "sintaxe de [!thelang], mas convertê-los não deve ser difícil.[/!]"
8026
8027 #. type: Content of: <pre>
8028 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:67
8029 #, no-wrap
8030 msgid ""
8031 "{{{1, RIGHT , 0}, {0, LEFT , 0}}} # 1: Langton's ant\n"
8032 "{{{1, RIGHT , 0}, {0, NOTURN, 0}}} # 2: binary counter\n"
8033 "{{{0, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 3: "
8034 "(filled triangle)\n"
8035 "{{{0, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {0, NOTURN, 1}}} # 4: "
8036 "spiral in a box\n"
8037 "{{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 5: "
8038 "stripe-filled spiral\n"
8039 "{{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {1, NOTURN, 0}}} # 6: "
8040 "stepped pyramid\n"
8041 "{{{0, RIGHT , 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {1, LEFT , 0}}} # 7: "
8042 "contoured island\n"
8043 "{{{0, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {0, RIGHT , 1}}} # 8: "
8044 "woven placemat\n"
8045 "{{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {1, LEFT , 0}}} # 9: "
8046 "snowflake-ish\n"
8047 "{{{1, LEFT , 0}, {0, NOTURN, 1}}, {{0, LEFT , 0}, {0, LEFT , 1}}} # 10: "
8048 "slow city builder\n"
8049 "{{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 0}, {0, LEFT , 1}}} # 11: "
8050 "framed computer art\n"
8051 "{{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 1}, {1, LEFT , 0}}} # 12: "
8052 "balloon bursting (makes a spreading highway)\n"
8053 "{{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 13: "
8054 "makes a horizontal highway\n"
8055 "{{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 1}, {1, RIGHT , 0}}} # 14: "
8056 "makes a 45 degree highway\n"
8057 "{{{1, LEFT , 1}, {0, LEFT , 1}}, {{1, RIGHT , 1}, {0, LEFT , 0}}} # 15: "
8058 "makes a 45 degree highway\n"
8059 "{{{1, LEFT , 1}, {0, NOTURN, 0}}, {{1, NOTURN, 0}, {1, RIGHT , 0}}} # 16: "
8060 "spiral in a filled box\n"
8061 "{{{1, LEFT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 17: "
8062 "glaciers\n"
8063 "{{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 18: "
8064 "golden rectangle!\n"
8065 "{{{1, LEFT , 1}, {1, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 19: "
8066 "fizzy spill\n"
8067 "{{{1, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 20: "
8068 "nested cabinets\n"
8069 "{{{1, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {1, NOTURN, 1}}} # 21: "
8070 "(cross)\n"
8071 "{{{1, NOTURN, 1}, {0, NOTURN, 0}}, {{0, RIGHT , 0}, {1, LEFT , 0}}} # 22: "
8072 "saw-tipped growth\n"
8073 "{{{1, NOTURN, 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 23: "
8074 "curves in blocks growth\n"
8075 "{{{1, NOTURN, 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 24: "
8076 "textured growth\n"
8077 "{{{1, NOTURN, 1}, {0, RIGHT , 1}}, {{1, LEFT , 0}, {1, RIGHT , 0}}} # 25: "
8078 "(diamond growth)\n"
8079 "{{{1, NOTURN, 1}, {1, LEFT , 0}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 26: "
8080 "coiled rope\n"
8081 "{{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, NOTURN, 1}}} # 27: "
8082 "(growth)\n"
8083 "{{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, RIGHT , 1}}} # 28: "
8084 "(square spiral)\n"
8085 "{{{1, RIGHT , 0}, {1, RIGHT , 1}}, {{0, NOTURN, 0}, {0, NOTURN, 1}}} # 29: "
8086 "loopy growth with holes\n"
8087 "{{{1, RIGHT , 1}, {0, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 30: "
8088 "Lanton's Ant drawn with squares\n"
8089 "{{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 1}, {1, LEFT , 0}}} # 31: "
8090 "growth with curves and blocks\n"
8091 "{{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, NOTURN, 0}, {1, RIGHT , 1}}} # 32: "
8092 "distracted spiral builder\n"
8093 "{{{1, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 33: "
8094 "cauliflower stalk (45 deg highway)\n"
8095 "{{{1, RIGHT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, RIGHT , 0}}} # 34: "
8096 "worm trails (eventually turns cyclic!)\n"
8097 "{{{1, RIGHT , 1}, {1, NOTURN, 0}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 35: "
8098 "eventually makes a two-way highway!\n"
8099 "{{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, NOTURN, 0}, {0, NOTURN, 0}}} # 36: "
8100 "almost symmetric mould bloom\n"
8101 "{{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, RIGHT , 0}, {1, NOTURN, 1}}} # 37: "
8102 "makes a 1 in 2 gradient highway\n"
8103 "{{{1, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 38: "
8104 "immediately makes a 1 in 3 highway\n"
8105 "{{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{0, LEFT , 2}, {0, LEFT , 0}}, {{1, "
8106 "RIGHT , 2}, {1, LEFT , 0}}} # 39: squares and diagonals growth\n"
8107 "{{{1, LEFT , 1}, {0, NOTURN, 0}}, {{0, RIGHT , 2}, {1, LEFT , 0}}, {{1, "
8108 "RIGHT , 1}, {1, NOTURN, 0}}} # 40: streak at approx. an 8.1 in 1 gradient\n"
8109 "{{{1, LEFT , 1}, {0, NOTURN, 2}}, {{0, RIGHT , 2}, {1, NOTURN, 1}}, {{1, "
8110 "RIGHT , 1}, {1, NOTURN, 0}}} # 41: streak at approx. a 1.14 in 1 gradient\n"
8111 "{{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 2}}, {{0, "
8112 "LEFT , 1}, {1, NOTURN, 1}}} # 42: maze-like growth\n"
8113 "{{{1, LEFT , 2}, {0, RIGHT , 0}}, {{1, LEFT , 0}, {0, RIGHT , 0}}, {{0, "
8114 "LEFT , 0}, {0, LEFT , 1}}} # 43: growth by cornices \n"
8115 "{{{1, RIGHT , 0}, {0, RIGHT , 2}}, {{0, LEFT , 0}, {0, RIGHT , 0}}, {{0, "
8116 "NOTURN, 1}, {1, LEFT , 0}}} # 44: makes a 1 in 7 highway\n"
8117 "{{{1, RIGHT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 2}, {0, NOTURN, 0}}, {{1, "
8118 "LEFT , 0}, {0, LEFT , 0}}} # 45: makes a 4 in 1 highway\n"
8119 msgstr ""
8120 "{{{1, RIGHT , 0}, {0, LEFT , 0}}} # 1: formiga de Langton\n"
8121 "{{{1, RIGHT , 0}, {0, NOTURN, 0}}} # 2: contador binário\n"
8122 "{{{0, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 3: ("
8123 "triâgulo preenchido)\n"
8124 "{{{0, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {0, NOTURN, 1}}} # 4: "
8125 "espiral numa caixa\n"
8126 "{{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 5: "
8127 "espiral stripe-filled\n"
8128 "{{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {1, NOTURN, 0}}} # 6: "
8129 "pirâmide inclinada\n"
8130 "{{{0, RIGHT , 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {1, LEFT , 0}}} # 7: "
8131 "ilha contoured\n"
8132 "{{{0, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {0, RIGHT , 1}}} # 8: "
8133 "woven placemat\n"
8134 "{{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {1, LEFT , 0}}} # 9: "
8135 "floco de neve\n"
8136 "{{{1, LEFT , 0}, {0, NOTURN, 1}}, {{0, LEFT , 0}, {0, LEFT , 1}}} # 10: "
8137 "construtor de cidades lento\n"
8138 "{{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 0}, {0, LEFT , 1}}} # 11: "
8139 "framed computer art\n"
8140 "{{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 1}, {1, LEFT , 0}}} # 12: "
8141 "balloon bursting (makes a spreading highway)\n"
8142 "{{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 13: "
8143 "makes a horizontal highway\n"
8144 "{{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 1}, {1, RIGHT , 0}}} # 14: "
8145 "makes a 45 degree highway\n"
8146 "{{{1, LEFT , 1}, {0, LEFT , 1}}, {{1, RIGHT , 1}, {0, LEFT , 0}}} # 15: "
8147 "makes a 45 degree highway\n"
8148 "{{{1, LEFT , 1}, {0, NOTURN, 0}}, {{1, NOTURN, 0}, {1, RIGHT , 0}}} # 16: "
8149 "spiral in a filled box\n"
8150 "{{{1, LEFT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 17: "
8151 "glaciers\n"
8152 "{{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 18: "
8153 "golden rectangle!\n"
8154 "{{{1, LEFT , 1}, {1, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 19: "
8155 "fizzy spill\n"
8156 "{{{1, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 20: "
8157 "nested cabinets\n"
8158 "{{{1, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {1, NOTURN, 1}}} # 21: "
8159 "(cross)\n"
8160 "{{{1, NOTURN, 1}, {0, NOTURN, 0}}, {{0, RIGHT , 0}, {1, LEFT , 0}}} # 22: "
8161 "saw-tipped growth\n"
8162 "{{{1, NOTURN, 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 23: "
8163 "curves in blocks growth\n"
8164 "{{{1, NOTURN, 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 24: "
8165 "textured growth\n"
8166 "{{{1, NOTURN, 1}, {0, RIGHT , 1}}, {{1, LEFT , 0}, {1, RIGHT , 0}}} # 25: ("
8167 "diamond growth)\n"
8168 "{{{1, NOTURN, 1}, {1, LEFT , 0}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 26: "
8169 "coiled rope\n"
8170 "{{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, NOTURN, 1}}} # 27: "
8171 "(growth)\n"
8172 "{{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, RIGHT , 1}}} # 28: ("
8173 "square spiral)\n"
8174 "{{{1, RIGHT , 0}, {1, RIGHT , 1}}, {{0, NOTURN, 0}, {0, NOTURN, 1}}} # 29: "
8175 "loopy growth with holes\n"
8176 "{{{1, RIGHT , 1}, {0, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 30: "
8177 "Lanton's Ant drawn with squares\n"
8178 "{{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 1}, {1, LEFT , 0}}} # 31: "
8179 "growth with curves and blocks\n"
8180 "{{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, NOTURN, 0}, {1, RIGHT , 1}}} # 32: "
8181 "distracted spiral builder\n"
8182 "{{{1, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 33: "
8183 "cauliflower stalk (45 deg highway)\n"
8184 "{{{1, RIGHT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, RIGHT , 0}}} # 34: "
8185 "worm trails (eventually turns cyclic!)\n"
8186 "{{{1, RIGHT , 1}, {1, NOTURN, 0}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 35: "
8187 "eventually makes a two-way highway!\n"
8188 "{{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, NOTURN, 0}, {0, NOTURN, 0}}} # 36: "
8189 "almost symmetric mould bloom\n"
8190 "{{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, RIGHT , 0}, {1, NOTURN, 1}}} # 37: "
8191 "makes a 1 in 2 gradient highway\n"
8192 "{{{1, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 38: "
8193 "immediately makes a 1 in 3 highway\n"
8194 "{{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{0, LEFT , 2}, {0, LEFT , 0}}, {{1, "
8195 "RIGHT , 2}, {1, LEFT , 0}}} # 39: squares and diagonals growth\n"
8196 "{{{1, LEFT , 1}, {0, NOTURN, 0}}, {{0, RIGHT , 2}, {1, LEFT , 0}}, {{1, "
8197 "RIGHT , 1}, {1, NOTURN, 0}}} # 40: streak at approx. an 8.1 in 1 gradient\n"
8198 "{{{1, LEFT , 1}, {0, NOTURN, 2}}, {{0, RIGHT , 2}, {1, NOTURN, 1}}, {{1, "
8199 "RIGHT , 1}, {1, NOTURN, 0}}} # 41: streak at approx. a 1.14 in 1 gradient\n"
8200 "{{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 2}}, {{0, "
8201 "LEFT , 1}, {1, NOTURN, 1}}} # 42: maze-like growth\n"
8202 "{{{1, LEFT , 2}, {0, RIGHT , 0}}, {{1, LEFT , 0}, {0, RIGHT , 0}}, {{0, "
8203 "LEFT , 0}, {0, LEFT , 1}}} # 43: growth by cornices \n"
8204 "{{{1, RIGHT , 0}, {0, RIGHT , 2}}, {{0, LEFT , 0}, {0, RIGHT , 0}}, {{0, "
8205 "NOTURN, 1}, {1, LEFT , 0}}} # 44: makes a 1 in 7 highway\n"
8206 "{{{1, RIGHT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 2}, {0, NOTURN, 0}}, {{1, "
8207 "LEFT , 0}, {0, LEFT , 0}}} # 45: makes a 4 in 1 highway\n"
8208
8209 #. type: Content of: <p>
8210 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:114
8211 msgid ""
8212 "Langton's ants may not share the expressiveness power of the turmites, but "
8213 "they remain fascinating too. You can experiment with them using the "
8214 "initLangton() method, provided in your template, that allows to build a "
8215 "Turmite transition table from a Langton's ant name. Tiny changes in the ant "
8216 "may result huge changes. For example, \"RRL\" does not seem to lead to any "
8217 "constructed pattern, even after a million steps, but \"RLL\" starts building "
8218 "a very simple highway pattern after less than 100 steps!"
8219 msgstr ""
8220 "Formigas de Langton podem não compartilhar do poder de expressão dos "
8221 "turmites, mas ainda assim são fascinantes. Pode experimentar elas a usar o "
8222 "método initLangton(), fornecido no seu template, que permite construir uma "
8223 "tabela de transição do nome da formiga de Langton. Pequenas mudanças na "
8224 "formiga podem resultar em grandes mudanças. Por exemplo, \"RRL\" parece não "
8225 "levar a nenhum padrão, mesmo após um milhão de passos, mas \"RLL\" começa a "
8226 "construir um padrão de estrada muito simples depois de menos de 100 passos!"
8227
8228 #. type: Content of: <p>
8229 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:121
8230 msgid ""
8231 "Quite a lot of Langton's ants build highways: RL, of course, but also "
8232 "RLRLRLLRLR (about 2500 steps). The chaotic behavior of ants before the "
8233 "highway can be very short (as with RLL that only need 100 steps to converge) "
8234 "or very long, as with LLLLLLRRLRRR which seems chaotic for more than 500,000 "
8235 "steps before build the highway or even RRLLLRRRLRRR which needs 1170000 to "
8236 "start converging. Some are narrow, and others are very large, such as "
8237 "RRLRLLRLRR (200,000 steps). This ant is also notable since it is somehow "
8238 "squarish even before the highway start where most others do not show "
8239 "anything notable before their highway."
8240 msgstr ""
8241 "Muitas das formigas de Langton constróem estradas: RL, claro, mas também "
8242 "RLRLRLLRLR (em cerca de 2500 passos). O comportamento caótico das formigas "
8243 "antes da estrada pode ser bastante curto (como no caso RLL que precisa de "
8244 "apenas 100 passos para convergir) ou muito longo, como LLLLLLRRLRRR que "
8245 "parece caótico até mais de 500.000 de passos antes de contruir a estrada, ou "
8246 "até mesmo RRLLLRRRLRRR que precisa de 1.170.000 para começar a convergir. "
8247 "Umas são estreitas e outras bem largas, como em RRLRLLRLRR (200,000 passos). "
8248 "Esta formiga é também notável pois é meio quadrada mesmo antes da estrada "
8249 "começar, enquanto que as outras não exibem nada de especial antes da estrada."
8250
8251 #. type: Content of: <p><p><p>
8252 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:129
8253 msgid ""
8254 "Some ants fill solid sectors, such as RRLLLRLLLRRR (16,000 steps), "
8255 "RRLLLRLLLRRR (30,000 steps), RRLLLRRRRRLR (125,000 steps) or RRLRLLRRRRRR "
8256 "(20,000 steps). Some even fill the whole space (RRLRR after 3000 "
8257 "steps). Some of my personal favorite ones are the ones where the ant seem to "
8258 "be bouncing within a box that gets bigger on each bump, such as LRRRRRLLR "
8259 "(30,000 steps). LRRRRLLLRRR is even more impressing since the bounces within "
8260 "the box are regular and since it converges more rapidly to its stable "
8261 "behavior (15,000 steps are enough)."
8262 msgstr ""
8263 "Algumas formiga preenchem setores sólidos, como RRLLLRLLLRRR(16,000 passos), "
8264 "RRLLLRLLLRRR (30,000 passos), RRLLLRRRRRLR (125,000 passos) ou RRLRLLRRRRRR ("
8265 "20,000 passos). Algumas preenchem até mesmo todo o plano (RRLRR depois de "
8266 "3000 passos). algumas das minhas favoritas são aquelas onde as formigas "
8267 "parecem ricochetear desntro de uma caixa que vai a ficar maior em cada "
8268 "batida, como LRRRRRLLR (30,000 passos). LRRRRLLLRRR é ainda mais "
8269 "impressionante pois as ricocheteadas dantro da caixa são regulares e também "
8270 "por que ela converge mais rapidamente o comportamento estável dele (15,000 "
8271 "passos são suficientes)."
8272
8273 #. type: Content of: <p><p><p>
8274 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:136
8275 msgid ""
8276 "Finally, some ants are just build artistic patterns. You should check this "
8277 "video for some beautiful ones: "
8278 "http://www.youtube.com/watch?v=1X-gtr4pEBU. If you want to convert them into "
8279 "your code, you have to shift them by one: For example, the one depicted at "
8280 "3:42 is not RRLRLRLLRL, but RLRLRLLRLR (the first visible move should be "
8281 "read as last one)."
8282 msgstr ""
8283 "Finalmente, algumas formigas fazem padrões simplesmente artísticos. Pode "
8284 "verificar este vídeo com alguns deles: http://www.youtube.com/watch?v=1X-"
8285 "gtr4pEBU. Se quiser convertê-los em código, tem que transladar um caractere: "
8286 "por exemplo, aquele descrito no minuto 3:42 não será RRLRLRLLRL, mas sim "
8287 "RLRLRLLRLR (o primeiro movimento visível deve ser lido como o último)."
8288
8289 #. type: Content of: <p><p><p>
8290 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:141
8291 msgid ""
8292 "As you can see by exploring the above set of turmites, they are usually not "
8293 "as colorful as the ants, but this may be because very few colors suffice to "
8294 "exhibit complex behaviors. For example, there is a specific class of "
8295 "turmites called <i>busy beavers</i> which are turmites that write a lot of "
8296 "things before stopping (busy beavers are usually classical turing machines, "
8297 "but the idea fits perfectly to turmites too). There is a sort of "
8298 "international competition where people strive to find the turmite that "
8299 "covers the biggest area before stopping. The web page is here: "
8300 "http://code.google.com/p/ruletablerepository/wiki/TwoDimensionalTuringMachines"
8301 msgstr ""
8302 "Como pode ver ao explorar o conjunto de turmites acima, elas não são tão "
8303 "coloridas quanto as formigas, mas isto pode ser por que poucas cores são o "
8304 "suficientes para exibir comportamentos complexos. Por exemplo, existe uma "
8305 "classe específica de turmites chamada <i>busy beavers</i> que são turmites "
8306 "que escrevem várias coisas antes de parar (busy beavers normalmente são "
8307 "máquinas de turing clássicas, mas a ideia encaixa perfeitamente em turmites "
8308 "também). Existe um tipode competição internacional onde as pessoas tentam "
8309 "encontrar o turmite que cobre a maior área antes de parar. A página é esta: "
8310 "http://code.google.com/p/ruletablerepository/wiki/"
8311 "TwoDimensionalTuringMachines"
8312
8313 #. type: Content of: <h1>
8314 #: src/lessons/turmites/universe/TurmiteWorld.html:2
8315 msgid "Turmite universe"
8316 msgstr "Universo dos Turmites"
8317
8318 #. type: Content of: <p>
8319 #: src/lessons/turmites/universe/TurmiteWorld.html:4
8320 msgid ""
8321 "This universe is very similar to the buggle one, but you will probably not "
8322 "use all buggles methods. So, this page only recap the buggle methods that "
8323 "you will use."
8324 msgstr ""
8325 "Este universo é bastante similar ao dos buggles, mas provavelmente não vai "
8326 "usar nenhum método dos buggles. Então, esta página apenas repacitula os "
8327 "métodos do buggle que vai usar."
8328
8329 #. type: Content of: <table><tr><td>
8330 #: src/lessons/turmites/universe/TurmiteWorld.html:12
8331 msgid ""
8332 "[!java|c]void [/!][!c]stepForward()[/!][!java|python|scala]forward()[/!] or "
8333 "[!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])"
8334 msgstr ""
8335 "[!java|c]void [/!][!c]stepForward()[/!][!java|python|scala]forward()[/!] ou "
8336 "[!java|c]void [/!]forward([!java|c]int [/!]passos[!scala]:Int[/!])"
8337
8338 #. type: Content of: <table><tr><td>
8339 #: src/lessons/turmites/universe/TurmiteWorld.html:13
8340 msgid ""
8341 "[!java|c]void [/!][!c]stepBackward()[/!][!java|python|scala]backward()[/!] "
8342 "or [!java|c]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])"
8343 msgstr ""
8344 "[!java|c]void [/!][!c]stepBackward()[/!][!java|python|scala]back()[/!] ou "
8345 "[!java|c]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])"
8346
8347 #. type: Content of: <h1>
8348 #: src/plm/universe/sort/SortingWorld.html:2
8349 msgid "Sorting World"
8350 msgstr "Mundo da ordenação"
8351
8352 #. type: Content of: outside any tag (error?)
8353 #: src/plm/universe/sort/SortingWorld.html:3
8354 msgid ""
8355 "This world provides tools to experiment with the sorting algorithms. It can "
8356 "be used in two different ways: the first one is naturally to write the "
8357 "required sorting algorithms. But it is also possible to simply use the demo "
8358 "mode of each exercise to observe the behavior of sorting algorithms. It "
8359 "helps understanding the differences between each of them."
8360 msgstr ""
8361 "Este mundo fornece ferramentas para experimentar com algoritmos de "
8362 "ordenação. Pode ser usado de duas formas diferentes: a primeira é "
8363 "naturalmente para escrever os algoritmos de ordenação necessários. Mas "
8364 "também é possível simplesmente usar o modo de demonstração de cada exercício "
8365 "para observar o comportamento de algoritmos de ordenação. Isto ajuda a "
8366 "entender as diferenças entre cada um deles."
8367
8368 #. type: Content of: <h2>
8369 #: src/plm/universe/sort/SortingWorld.html:9
8370 msgid "Methods available to sorting algorithms"
8371 msgstr "Métodos disponíveis para algoritmos de ordenação"
8372
8373 #. type: Content of: <table><tr><td>
8374 #: src/plm/universe/sort/SortingWorld.html:11
8375 msgid "<b>Method</b>"
8376 msgstr "<b>Método</b>"
8377
8378 #. type: Content of: <table><tr><td>
8379 #: src/plm/universe/sort/SortingWorld.html:11
8380 msgid "<b>Action</b>"
8381 msgstr "<b>Ação</b>"
8382
8383 #. type: Content of: <table><tr><td>
8384 #: src/plm/universe/sort/SortingWorld.html:11
8385 msgid "<b>Cost</b>"
8386 msgstr "<b>Custo</b>"
8387
8388 #. type: Content of: <table><tr><td>
8389 #: src/plm/universe/sort/SortingWorld.html:12
8390 msgid "[!java|c]int [/!]getValueCount() [!scala]:Int[/!]"
8391 msgstr "[!java|c]int [/!]getValueCount() [!scala]:Int[/!]"
8392
8393 #. type: Content of: <table><tr><td>
8394 #: src/plm/universe/sort/SortingWorld.html:13
8395 msgid "Returns the amount of values in the array"
8396 msgstr "Retorna a quantidade de valores na array"
8397
8398 #. type: Content of: <table><tr><td>
8399 #: src/plm/universe/sort/SortingWorld.html:13
8400 #: src/plm/universe/sort/SortingWorld.html:31
8401 msgid "none"
8402 msgstr "nenhum"
8403
8404 #. type: Content of: <table><tr><td>
8405 #: src/plm/universe/sort/SortingWorld.html:15
8406 msgid ""
8407 "[!java]boolean [/!][!c]int [/!]isSmaller([!java|c]int [/!]i[!scala]:Int[/!], "
8408 "[!java|c]int [/!]j[!scala]:Int[/!]) [!scala]:Boolean[/!]"
8409 msgstr ""
8410 "[!java]boolean [/!][!c]int [/!]éMenor([!java|c]int [/!]i[!scala]:Int[/!], "
8411 "[!java|c]int [/!]j[!scala]:Int[/!]) [!scala]:Boolean[/!]"
8412
8413 #. type: Content of: <table><tr><td>
8414 #: src/plm/universe/sort/SortingWorld.html:16
8415 msgid ""
8416 "Returns true if the content of cell i is strictly smaller than the one of "
8417 "cell j"
8418 msgstr ""
8419 "Retorna true se o conteúdo da célula i é estritamente menor que o da célula j"
8420
8421 #. type: Content of: <table><tr><td>
8422 #: src/plm/universe/sort/SortingWorld.html:16
8423 msgid "two reads"
8424 msgstr "duas leituras"
8425
8426 #. type: Content of: <table><tr><td>
8427 #: src/plm/universe/sort/SortingWorld.html:17
8428 msgid ""
8429 "[!java]boolean [/!][!c]int [/!]isSmallerThan([!java|c]int "
8430 "[/!]i[!scala]:Int[/!], [!java|c]int [/!]value[!scala]:Int[/!])[!scala] "
8431 ":Boolean[/!]"
8432 msgstr ""
8433 "[!java]boolean [/!][!c]int [/!]éMenorQue([!java|c]int [/!]i[!scala]:Int[/!], "
8434 "[!java|c]int [/!]value[!scala]:Int[/!])[!scala] :Boolean[/!]"
8435
8436 #. type: Content of: <table><tr><td>
8437 #: src/plm/universe/sort/SortingWorld.html:18
8438 msgid ""
8439 "Returns true if the content of cell i is strictly smaller than the "
8440 "<code>value</code>"
8441 msgstr ""
8442 "Retorna true se o conteúdo da célula i é estritamente menor que "
8443 "<code>valor</code>"
8444
8445 #. type: Content of: <table><tr><td>
8446 #: src/plm/universe/sort/SortingWorld.html:18
8447 #: src/plm/universe/sort/SortingWorld.html:26
8448 msgid "one read"
8449 msgstr "uma leitura"
8450
8451 #. type: Content of: <table><tr><td>
8452 #: src/plm/universe/sort/SortingWorld.html:20
8453 msgid ""
8454 "[!java|c]void [/!]swap([!java|c]int [/!]i[!scala]:Int[/!], [!java|c]int "
8455 "[/!]j[!scala]:Int[/!])"
8456 msgstr ""
8457 "[!java|c]void [/!]alternar([!java|c]int [/!]i[!scala]:Int[/!], [!java|c]int "
8458 "[/!]j[!scala]:Int[/!])"
8459
8460 #. type: Content of: <table><tr><td>
8461 #: src/plm/universe/sort/SortingWorld.html:21
8462 msgid "Swaps the content of cell i and the one of cell j"
8463 msgstr "Alterna (\"swap\") o conteúdo da célula i com o da célula j"
8464
8465 #. type: Content of: <table><tr><td>
8466 #: src/plm/universe/sort/SortingWorld.html:21
8467 msgid "two reads, two writes"
8468 msgstr "duas escritas, duas leituras"
8469
8470 #. type: Content of: <table><tr><td>
8471 #: src/plm/universe/sort/SortingWorld.html:22
8472 msgid ""
8473 "[!java|c]void [/!]copy([!java|c]int [/!]from[!scala]:Int[/!], [!java|c]int "
8474 "[/!]to[!scala]:Int[/!])"
8475 msgstr ""
8476 "[!java|c]void [/!]copia([!java|c]int [/!]de[!scala]:Int[/!], [!java|c]int "
8477 "[/!]para[!scala]:Int[/!])"
8478
8479 #. type: Content of: <table><tr><td>
8480 #: src/plm/universe/sort/SortingWorld.html:23
8481 msgid "Copy the content of cell 'from' into the cell 'to'"
8482 msgstr "Copia o conteúdo da célula 'de' para a célula 'para'"
8483
8484 #. type: Content of: <table><tr><td>
8485 #: src/plm/universe/sort/SortingWorld.html:23
8486 msgid "one read, one write"
8487 msgstr "uma leitura, uuma escrita"
8488
8489 #. type: Content of: <table><tr><td>
8490 #: src/plm/universe/sort/SortingWorld.html:25
8491 msgid "[!java|c]int [/!]getValue([!java|c]int [/!]idx[!scala]:Int[/!])"
8492 msgstr "[!java|c]int [/!]getValor([!java|c]int [/!]idx[!scala]:Int[/!])"
8493
8494 #. type: Content of: <table><tr><td>
8495 #: src/plm/universe/sort/SortingWorld.html:26
8496 msgid "Returns the value of cell idx"
8497 msgstr "Retorna o valor da célula idx"
8498
8499 #. type: Content of: <table><tr><td>
8500 #: src/plm/universe/sort/SortingWorld.html:27
8501 msgid ""
8502 "[!java|c]void [/!]setValue([!java|c]int [/!]idx[!scala]:Int[/!], "
8503 "[!java|c]int [/!]value[!scala]:Int[/!])"
8504 msgstr ""
8505 "[!java|c]void [/!]setValor([!java|c]int [/!]idx[!scala]:Int[/!], [!java|c]"
8506 "int [/!]valor[!scala]:Int[/!])"
8507
8508 #. type: Content of: <table><tr><td>
8509 #: src/plm/universe/sort/SortingWorld.html:28
8510 msgid "Sets cell 'idx' to the <code>value</code>"
8511 msgstr "Coloca na célula 'idx' o <code>valor</code>"
8512
8513 #. type: Content of: <table><tr><td>
8514 #: src/plm/universe/sort/SortingWorld.html:28
8515 msgid "one write"
8516 msgstr "uma escrita"
8517
8518 #. type: Content of: <table><tr><td>
8519 #: src/plm/universe/sort/SortingWorld.html:30
8520 msgid "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
8521 msgstr "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
8522
8523 #. type: Content of: outside any tag (error?)
8524 #: src/plm/universe/sort/SortingWorld.html:31
8525 #: src/lessons/sort/pancake/universe/PancakeWorld.html:22
8526 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:28
8527 msgid "Returns whether the current world is selected in the graphical interface."
8528 msgstr "Retorna true se o mundo atual está selecionado na interface gráfica."
8529
8530 #. type: Content of: <h2>
8531 #: src/plm/universe/sort/SortingWorld.html:35
8532 msgid "History view"
8533 msgstr "Visão do histórico"
8534
8535 #. type: Content of: <p>
8536 #: src/plm/universe/sort/SortingWorld.html:36
8537 msgid ""
8538 "It is not enough to sort the array to pass the exercises. Your solution must "
8539 "strictly follow the expected behavior of each exercise. This is enforced by "
8540 "checking that your algorithm needs the same amount of read and write "
8541 "operations to sort the array. When they don't match, understanding the "
8542 "difference between your code and the expected solution can reveal very "
8543 "difficult."
8544 msgstr ""
8545 "É suficiente ordenar a array para resolver os exercícios. A sua solução deve "
8546 "seguir estritamente o comportamento esperado em cada exercício. Isto é "
8547 "reforçado a verificar que o seu algoritmo precisa da mesma quantidade de "
8548 "operações de leitura e escrita para ordenar a array. Quando estas "
8549 "quantidades não coincidem, compreender a diferença entre o seu código e a "
8550 "solução esperada pode se mostrar bem difícil."
8551
8552 #. type: Content of: <p>
8553 #: src/plm/universe/sort/SortingWorld.html:43
8554 msgid ""
8555 "To help in this process, it is possible to graphically explore the history "
8556 "of your sorting algorithm. Switch to the Objective view and use the "
8557 "contextual menu (right click) to switch from the view of the current state "
8558 "to the view of its history."
8559 msgstr ""
8560 "Para ajudar neste processo, é possível explorar graficamente o histórico do "
8561 "algoritmo de ordenação. Alternar à visão Objetivo e usar o menu de contexto ("
8562 "clique com botão direito) para alternar da visão do estado atual à visão do "
8563 "histórico."
8564
8565 #. type: Content of: <p>
8566 #: src/plm/universe/sort/SortingWorld.html:48
8567 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:19
8568 msgid ""
8569 "The history view is a bit hairly at the first glance, but actually rather "
8570 "simple: The time flows from left to right on this graph, and each row is a "
8571 "cell of your array. The curved lines that go navigate between rows represent "
8572 "a given data value. When two lines cross, this means that two values were "
8573 "swapped at this time stamp; A line fork represent a value copy; When a value "
8574 "is magenta and followed by an interrogation mark (?), it was read using "
8575 "getValue(); If the value is red and followed with an exclamation point (!), "
8576 "it was written using setValue()."
8577 msgstr ""
8578 "A visão do histórico é um pouco bagunçada à primeira vista, mas na verdade é "
8579 "bem simples: o tempo anda da esquerda para a direita neste gráfico e cada "
8580 "linha é uma célula da sua array. As linhas curvas que navegam entre linhas "
8581 "representam um certo valor de um dado. Quando duas linhas se cruzam, "
8582 "significa que dois valores foram alternados agora; uma bifurcação numa linha "
8583 "representa uma cópia de valor; quando um valor é magenta e seguido de uma "
8584 "interrogação (?), foi lido a usar getValue(); Se o valor é vermelho e "
8585 "seguido de uma exclamação (!), foi escrito com setValor()."
8586
8587 #. type: Content of: <p>
8588 #: src/plm/universe/sort/SortingWorld.html:57
8589 msgid ""
8590 "This view, inspired from Aldo Cortesi, reveals very helpful understand the "
8591 "inner behavior of sorting algorithms."
8592 msgstr ""
8593 "Esta visão, inspirada por Aldo Cortesi, se mostra muito útil para entender o "
8594 "comportamento interno de algoritmos de ordenação."
8595
8596 #. type: Content of: <h3>
8597 #: src/lessons/sort/basic/Main.html:2 src/lessons/sort/basic/short_desc.html:2
8598 msgid "Sorting Algorithms"
8599 msgstr "Algoritmos de Ordenação"
8600
8601 #. type: Content of: outside any tag (error?)
8602 #: src/lessons/sort/basic/Main.html:4
8603 msgid ""
8604 "This lesson allows to experiment with some classical sorting algorithms (and "
8605 "some less common variant of them). The goal is two fold: you can first "
8606 "better understand the idea of these algorithms by writing them yourself. But "
8607 "even if you don't code the algorithms, you can use the demo mode to organize "
8608 "\"races\" between these algorithms to experiment in practice what the "
8609 "different asymptotical complexity mean."
8610 msgstr ""
8611 "Esta lição permite a experimentação com alguns algoritmos de ordenação "
8612 "clássicos (e algumas variações menos comuns deles). E temos um duplo "
8613 "objetivo: pode primeiro compreender melhor a ideia destes algoritmos a "
8614 "escrever eles por si só. Mas mesmo se não codificar os algoritmos, pode usar "
8615 "o modo de demonstração para organizar \"corridas\" entre os algoritmos para "
8616 "experimentar na prática o que significam diferentes complexidades "
8617 "assintóticas."
8618
8619 #. type: Content of: <p>
8620 #: src/lessons/sort/basic/Main.html:11
8621 msgid ""
8622 "More exercises are planned for the future, on recursive sorting algorithms "
8623 "(such as QuickSort and MergeSort) or using other microworlds to apply these "
8624 "algorithms to other contexts."
8625 msgstr ""
8626 "Mais exercícios estão previstos para o futuro, sobre os algoritmos de "
8627 "ordenação recursivos (como o QuickSort e o MergeSort) ou a usar outros "
8628 "micromundos para aplicar estes algoritmos a outros contextos."
8629
8630 #. type: Content of: <ul><li>
8631 #: src/lessons/sort/basic/Main.html:19
8632 msgid ""
8633 "Other graphical representations could be proposed, such as the ones "
8634 "presented at <a href=\"http://sorting.at/\">http://sorting.at/</a>."
8635 msgstr ""
8636 "Outras representações gráficas podem ser propostas, como aquelas "
8637 "apresentadas em <a href=\"http://sorting.at/\">http://sorting.at/</a>."
8638
8639 #. type: Content of: <p>
8640 #: src/lessons/sort/basic/short_desc.html:4
8641 msgid ""
8642 "This lesson allows to experiment with some classical sorting algorithms (and "
8643 "some less common variant of them :)"
8644 msgstr ""
8645 "Esta lição permite a experimentação com alguns algotimos de ordenação "
8646 "clássicos (e algumas variantes menos comuns deles :)"
8647
8648 #. type: Content of: <p>
8649 #: src/lessons/sort/basic/short_desc.html:7
8650 #: src/lessons/recursion/lego/short_desc.html:6
8651 #: src/lessons/maze/short_desc.html:6
8652 msgid "You are supposed to master the bases of programming to take this lesson."
8653 msgstr "Para fazer esta lição deve dominar as bases da programação."
8654
8655 #. type: Content of: <h1>
8656 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:2
8657 msgid "BubbleSort"
8658 msgstr "BubbleSort"
8659
8660 #. type: Content of: <p>
8661 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:4
8662 msgid ""
8663 "Welcome to the sorting universe. It allows you to experiment with the "
8664 "existing sorting algorithms. The list of buildins that you can use in your "
8665 "algorithms is available in the world reference documentation "
8666 "(\"Help\"-&gt;\"About this world\")."
8667 msgstr ""
8668 "Bem-vindo ao universo da ordenação. Ele permite que experimente os "
8669 "algoritmos de ordenação existentes. A lista de \"buildins\" que pode usar "
8670 "nos seus algoritmos está disponível na documentação de referência do mundo ("
8671 "\"Ajuda\"-&gt;\"Sobre este mundo\")."
8672
8673 #. type: Content of: <p>
8674 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:8
8675 msgid ""
8676 "It is not enough to sort the array to pass the exercises. Your solution must "
8677 "strictly follow the expected behavior of each exercise. This is enforced by "
8678 "checking that your algorithm needs the same amount of read and write "
8679 "operations to sort the array."
8680 msgstr ""
8681 "Não é suficiente ordenar a array para passar nos exercícios. A sua solução "
8682 "deve seguir estritamente o comportamento esperado em cada exercício. Isto é "
8683 "reforçado a verificar que o seu algoritmo precisa da mesma quantidade de "
8684 "operações de escrita e leitura para ordenar a array."
8685
8686 #. type: Content of: <p>
8687 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:13
8688 msgid ""
8689 "When your algorithm diverges from the expectation, understanding the "
8690 "difference between your code and the expected solution can reveal very "
8691 "difficult. To help in this process, it is posible to graphically explore the "
8692 "history of your sorting algorithm. Switch to the Objective view and use the "
8693 "contextual menu (right click) to switch from the the view of the current "
8694 "state to the view of its history."
8695 msgstr ""
8696 "Quando seu algoritmo divergge das expectativas, entender a diferença entre o "
8697 "seu código e a solução esperada pode ser muito difícil. Para ajudar neste "
8698 "processo, é possível explorar graficamente a história do seu algoritmo de "
8699 "ordenação. Alterne à visão Objetivo e use o menu contextual (clique com o "
8700 "botão direito) para alternar da visão do estado atual para a visão do "
8701 "histórico dele."
8702
8703 #. type: Content of: <h2>
8704 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:28
8705 msgid "First attempt at BubbleSort"
8706 msgstr "Primeira tentativa no BubbleSort"
8707
8708 #. type: Content of: <p>
8709 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:30
8710 msgid ""
8711 "This first sorting algorithm is the most simple one: Bubble sort consists in "
8712 "progressively moving up the smaller elements of the array, as if they were "
8713 "air bubbles moving up to the surface of a liquid. The algorithm traverse the "
8714 "array, and compare any pair of adjacent elements. If two adjacent elements "
8715 "are wrongly sorted, they are swapped. Once the array was completely "
8716 "traversed, the operation starts again from the beginning. When no elements "
8717 "were sorted after a full traversal, it means that the array is completely "
8718 "sorted: the algorithm can stop. Bubble sort is studied because of its "
8719 "simplicity, but it is almost never used in practice because of its bad "
8720 "performance (O(n^2) on average)."
8721 msgstr ""
8722 "O primeiro algoritmo de ordenação é o mais simples: Bubble sort consiste em "
8723 "progressivamente mover o menor elemento da array, como se fossem bolhas de "
8724 "ar a subir à superfície de um líquido. O algoritmo percorre a array e "
8725 "compara qualquer par de elementos adjacentes. Se dois elementos adjacentes "
8726 "estiverem fora de ordem, eles são alternados. Quando a array estiver "
8727 "completamente percorrida, a operação começa de novo do começo. Quando nenhum "
8728 "elemento for ordenado após uma passagem completa, significa que a array está "
8729 "completamente ordenada: e o algoritmo pode parar. Bubble sort é estudado "
8730 "por causa da simplicidade dele, mas quase nunca é usado na prática por causa "
8731 "do baixo desempenho dele (O(n^2) em média)."
8732
8733 #. type: Attribute 'alt' of: <div>
8734 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:40
8735 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:12
8736 msgid "Show Tip (Pseudo-code)"
8737 msgstr "Mostrar Dica (Pseudo-código)"
8738
8739 #. type: Content of: <div><p>
8740 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:41
8741 msgid "The pseudo-code of the BubbleSort algorithm is the following:"
8742 msgstr "O pseudo-código do algoritmo BubbleSort é o seguinte:"
8743
8744 #. type: Content of: <div><pre>
8745 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:42
8746 #, no-wrap
8747 msgid ""
8748 "do: \n"
8749 " For each i in [0,len-2]\n"
8750 " If cells i and i+1 must be swapped, do it\n"
8751 "while we swapped something during last traversal\n"
8752 msgstr ""
8753 "faça: \n"
8754 " Para cada i em [0,len-2]\n"
8755 " Se a célula i e i+1 devem ser alternadas, alterne\n"
8756 "enquanto algo foi alternado na última passagem\n"
8757
8758 #. type: Content of: <h1>
8759 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:2
8760 msgid "BubbleSort (take 2)"
8761 msgstr "BubbleSort (take 2)"
8762
8763 #. type: Content of: <p>
8764 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:4
8765 msgid ""
8766 "If you look carefully at the behavior of BubbleSort, a first easy "
8767 "optimization appears: after one traversal, the last element of the array "
8768 "must be the biggest of all since the traversal moved it up like a bubble to "
8769 "its position. More generally, after N traversal, we know that the N last "
8770 "elements of the array are already sorted. It is thus not necessary to "
8771 "compare them again during the subsequent traversals. For now, we will have "
8772 "as many traversal as there is in the array."
8773 msgstr ""
8774 "Se olhar atentamente ao comportamento do BubbleSort, uma primeira e fácil "
8775 "otimização aparece: depois de uma travesia, o último elemento da array é o "
8776 "maior de todos, pois a travessia moveu-o para cima como uma bolha à posição "
8777 "dele. Mais geralmente, depois de N travessias, sabemos que os últimos N "
8778 "elementos da array já estão ordenados. Portanto, não é necessário compará-"
8779 "los de novo durante travessias subsequentes. Por agora, vamos ter tantas "
8780 "travessias quantos elementos na array."
8781
8782 #. type: Content of: <div><p>
8783 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:13
8784 msgid "The pseudo-code of the BubbleSort2 algorithm is the following:"
8785 msgstr "O pseudo-código do algoritmo BubbleSort2 é o seguinte:"
8786
8787 #. type: Content of: <div><pre>
8788 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:14
8789 #, no-wrap
8790 msgid ""
8791 "For all i in [len-2,0] (traversing from biggest to smallest)\n"
8792 " For all j in [0, i]\n"
8793 " If cells j and j+1 must be swapped, do it\n"
8794 msgstr ""
8795 "Para todo i em [len-2,0] (a percorrer do maior ao menor)\n"
8796 " Para todo j em [0, i]\n"
8797 " Se células j e j+1 devem ser trocadas, troque\n"
8798
8799 #. type: Content of: <p>
8800 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:20
8801 msgid ""
8802 "When we run this algorithm, it is quite disappointing to see that it runs "
8803 "approximately at the same speed than the basic version of BubbleSort. This "
8804 "is a graphical effect only since only value changes are graphically "
8805 "represented. Since this variation avoids some useless comparisons, it does "
8806 "exactly the same amount of swaps that the basic version. It is thus quite "
8807 "logical that the graphical interface draws this version at the same pace "
8808 "than the base version. But the statistics on the amount of reads show that "
8809 "we saved about the fourth of the amount of reads, which is not bad."
8810 msgstr ""
8811 "Quando rodamos este algoritmo, desaponta bastante ver que executa cerca de "
8812 "na mesma velocidade que a versão básica do BubbleSort. Isto é um elemento "
8813 "gráfico apenas já que apenas mudanças de valores são representadas "
8814 "graficamente. Como esta variação evita algumas comparações inúteis, ela faz "
8815 "a mesma quantidade de trocas que a versão básica. É, portanto, bastante "
8816 "lógico que a interface gráfica desenhe esta versão no mesmo ritmo que a "
8817 "versão básica. Mas as estatísticas da quantidade de leituras mostram que "
8818 "economizamos cerca de um quarto das leituras, o que não é nada mal."
8819
8820 #. type: Content of: <p>
8821 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:29
8822 msgid ""
8823 "From the asymptotic complexity point of view, there is absolutely no "
8824 "difference: this variation is still in O(n^2) on average (our gain is only "
8825 "on the constant term, ignored when computing the asymptotic complexity)."
8826 msgstr ""
8827 "Do ponto de vista da complexidade asimtótica, não existe nenhuma diferença: "
8828 "Esta variação ainda é O(n^2) no caso médio (nosso ganho é apenas no termo "
8829 "constante, ignorado quando se está a calcular a complexidade asimtótica)."
8830
8831 #. type: Content of: <h1>
8832 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:2
8833 msgid "BubbleSort (take 3)"
8834 msgstr "BubbleSort (take 3)"
8835
8836 #. type: Content of: <p>
8837 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:4
8838 msgid ""
8839 "Let's now reintroduce the little optimization we removed at previous step: "
8840 "if a traversal does not swap any element, it means that the array is already "
8841 "sorted. In that case, we want to stop the whole sorting process."
8842 msgstr ""
8843 "Vamos agora reintroduzir a pequena otimização que fizemos no passo anterior: "
8844 "se uma passagem não troca nenhum elemento, significa que a array já está "
8845 "ordenada. Neste caso, vamos parar todo o processo de ordenação."
8846
8847 #. type: Content of: <p>
8848 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:9
8849 msgid ""
8850 "[!java|python|c]For that, simply use the <code>break</code> keyword, which "
8851 "breaks the current loop. Beware, if you have several nested loops, this "
8852 "will apply to the internal one.[/!] [!scala]For that, simply quit the "
8853 "current function by calling <code>return</code> with no associated "
8854 "value.[/!]"
8855 msgstr ""
8856 "[!java|python|c]Para isto, simplesmente use a palavra-chave <code>break</"
8857 "code>, que interrompe o loop atual. Cuidado, se tem vários loops aninhados, "
8858 "isto só vai ter efeito no mais interno.[/!] [!scala]Para isto, simplesmente "
8859 "saia da função atual a chamar <code>return</code> sem nenhum valor "
8860 "associado.[/!]"
8861
8862 #. type: Attribute 'alt' of: <div>
8863 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:14
8864 msgid "If you want, this tip shows the pseudo-code."
8865 msgstr "Se quiser, esta dica mostra o pseudo-código."
8866
8867 #. type: Content of: <div><pre>
8868 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:16
8869 #, no-wrap
8870 msgid ""
8871 "For all i in [len-2,0] (traversing from biggest to smallest)\n"
8872 " For all j in [0, i]\n"
8873 " If cells j and j+1 must be swapped, do it\n"
8874 " If traversal on j did not swap anything, break the for loop\n"
8875 msgstr ""
8876 "para todo i em [len-2,0] (a percorrer do maior ao menor)\n"
8877 " Para todo j em [0, i]\n"
8878 " Se células j e j+1 devem ser trocadas, troque\n"
8879 " Se ao percorrer j não fez nenhuma troca, pare o loop\n"
8880
8881 #. type: Content of: <p>
8882 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:23
8883 msgid ""
8884 "This optimization is even more disappointing: it only provide a gain of a "
8885 "few percents on the amount of reads over BubbleSort2."
8886 msgstr ""
8887 "Esta otimização é ainda mais desapontadora: ela só dá um ganho de alguns "
8888 "porcento sobre o BubbleSort2 no total de leituras."
8889
8890 #. type: Content of: <h1>
8891 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:2
8892 msgid "CocktailSort"
8893 msgstr "CocktailSort"
8894
8895 #. type: Content of: <p>
8896 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:4
8897 msgid ""
8898 "To improve further the BubbleSort algorithm, we need to look closer its "
8899 "behavior. One can notice that big elements are moved very quickly in "
8900 "position while small ones move very slowly to their destination. They are "
8901 "thus traditionally referred to as \"rabbits\" and \"turtles\" respectively "
8902 "for big fast values and small slow ones."
8903 msgstr ""
8904 "Para melhorar ainda mais o algoritmo BubbleSort, precisamos ver "
8905 "comportamente dele bem de perto. Pode perceber que os elementos grandes se "
8906 "movem bem rápido enquanto os pequenos se movem lentamente para os destinos "
8907 "dele. Eles são então tradicionalmente chamados de \"coelhos\" e \"tartarugas"
8908 "\" respectivamente para valores grandes e rápidos e valores pequenos e "
8909 "lentos."
8910
8911 #. type: Content of: <p>
8912 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:10
8913 msgid ""
8914 "To help the turtles moving faster, the cocktail sort traverse alternatively "
8915 "the array from right to left and from left to right. Here is the "
8916 "pseudo-code:"
8917 msgstr ""
8918 "Para ajudar as tartarugas a se mover rápido, o cocktail sort percorre "
8919 "alternativamente a array da direita para a esquerda e da esquerda para a "
8920 "direita. Aqui está o pseudo-código:"
8921
8922 #. type: Content of: <pre>
8923 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:15
8924 #, no-wrap
8925 msgid ""
8926 "Do\n"
8927 " For all i in [0,len-2], do:\n"
8928 " if i and i+1 must be swapped, do it\n"
8929 " For all i in [len-2,0] (downward), do:\n"
8930 " if i and i+1 must be swapped, do it\n"
8931 "while at least one of the traversal swapped an element\n"
8932 msgstr ""
8933 "Do\n"
8934 " For all i in [0,len-2], do:\n"
8935 " if i and i+1 must be swapped, do it\n"
8936 " For all i in [len-2,0] (downward), do:\n"
8937 " if i and i+1 must be swapped, do it\n"
8938 "while at least one of the traversal swapped an element\n"
8939
8940 #. type: Content of: <p>
8941 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:23
8942 msgid ""
8943 "One can see that cocktail sort achieves exactly the same amount of swaps "
8944 "than the bubble sort, but improves slightly on read amount. It is however "
8945 "still worse than BubbleSort2 to that extend."
8946 msgstr ""
8947 "Podemos perceber que cocktail sort alcança a mesma quantidade de trocas que "
8948 "o bubble sort, mas melhora levemente na quantidade de leituras. Entretanto, "
8949 "é ainda pior que o BubbleSort2 neste assunto."
8950
8951 #. type: Content of: <h1>
8952 #: src/lessons/sort/basic/cocktail/AlgCocktailSort2.html:2
8953 msgid "CocktailSort (take 2)"
8954 msgstr "CocktailSort (take 2)"
8955
8956 #. type: Content of: <p>
8957 #: src/lessons/sort/basic/cocktail/AlgCocktailSort2.html:4
8958 msgid ""
8959 "We will now apply to CocktailSort the same optimization than BubbleSort2 did "
8960 "to BubbleSort. We must remember the limits of the array part not being "
8961 "sorted yet, and traverse it alternatively from left to right and from right "
8962 "to left:"
8963 msgstr ""
8964 "Vamos agora aplicar ao CocktailSort a mesma otimização que o BubbleSort2 faz "
8965 "no BubbleSort. Devemos lembrar que os limites da parte do array que não está "
8966 "ordenada ainda e percorrer ela alternativamente da esquerda para a direita e "
8967 "da diretia para a esquerda:"
8968
8969 #. type: Content of: <pre>
8970 #: src/lessons/sort/basic/cocktail/AlgCocktailSort2.html:9
8971 #, no-wrap
8972 msgid ""
8973 "beg=0; end=len-2\n"
8974 "do\n"
8975 " For all Pour i in [beg,end], do:\n"
8976 " If cells i and i+1 must be swapped, do it \n"
8977 " end -= 1 (this means end = end - 1)\n"
8978 " For all Pour i in [beg,end] (downwards), do:\n"
8979 " If cells i and i+1 must be swapped, do it \n"
8980 " beg += 1 (this means beg = beg + 1)\n"
8981 "while at least one of the traversal swapped an element\n"
8982 msgstr ""
8983 "beg=0; end=len-2\n"
8984 "do\n"
8985 " For all Pour i in [beg,end], do:\n"
8986 " If cells i and i+1 must be swapped, do it \n"
8987 " end -= 1 (this means end = end - 1)\n"
8988 " For all Pour i in [beg,end] (downwards), do:\n"
8989 " If cells i and i+1 must be swapped, do it \n"
8990 " beg += 1 (this means beg = beg + 1)\n"
8991 "while at least one of the traversal swapped an element\n"
8992
8993 #. type: Content of: <h1>
8994 #: src/lessons/sort/basic/cocktail/AlgCocktailSort3.html:2
8995 msgid "CocktailSort (take 3)"
8996 msgstr "CocktailSort (3o tempo)"
8997
8998 #. type: Content of: <p>
8999 #: src/lessons/sort/basic/cocktail/AlgCocktailSort3.html:4
9000 msgid ""
9001 "Even if the asymptotic complexity of CocktailSort2 is the same than the one "
9002 "of BubbleSort, it seem to perform better in practice. It is even possible to "
9003 "improve a bit further by stopping it if the first traversal didn't found "
9004 "anything to swap, without achieving the downwards traversal. Likewise, we "
9005 "can stop if the upward traversal found something to swap, but not the "
9006 "downwards one."
9007 msgstr ""
9008 "Mesmo se a complexidade assintótica de CocktailSort2 for a mesma do "
9009 "BubbleSort, que parece melhor, na prática. É até mesmo possível melhorar um "
9010 "pouco mais a pará-lo na primeira rodada que não encontrar nada para "
9011 "alternar, se realizar a rodada para baixo. Da mesma forma, podemos parar se "
9012 "a rodada para cima encontrar algo para alternar, mas a rodada para baixo não."
9013
9014 #. type: Content of: <h1>
9015 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:2
9016 msgid "InsertionSort"
9017 msgstr "InsertionSort"
9018
9019 #. type: Content of: <p>
9020 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:5
9021 msgid ""
9022 "This sorting algorithm is quite simple to understand and write, even if it "
9023 "is not as efficient as possible. Its asymptotic complexity is in O(n2), but "
9024 "it is more efficient in practice (linear in best case, ie when the array is "
9025 "already sorted, and N2/4 on average)."
9026 msgstr ""
9027 "Este algoritmo de ordenação é muito simples de entender e escrever, mesmo se "
9028 "não for o mais eficiente possível. A complexidade assintótica dela é O(n2), "
9029 "mas é mais eficiente, na prática (linear no melhor caso, p.ex. quando a "
9030 "array já está ordenada e N2/4 no caso médio)."
9031
9032 #. type: Content of: <p>
9033 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:10
9034 msgid ""
9035 "The idea is to traverse all elements of the array, and to insert each of "
9036 "them into its proper position in the already sorted part of the array. When "
9037 "we look at an element x, the situation is the following: any elements to the "
9038 "left of the array are already sorted, and we have to insert x at its "
9039 "position in the array."
9040 msgstr ""
9041 "A ideia é percorrer todos os elementos da array e inserir cada um deles na "
9042 "posição correta dele numa parte já ordenada da array. Quando olhamos num "
9043 "elemento x, a situação é a seguinte: qualquer elemento da esquerda da array "
9044 "já está ordenado e temos que inserir x na posição dele na array."
9045
9046 #. type: Content of: <p>
9047 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:18
9048 msgid "Once this is done, the situation is the following:"
9049 msgstr "Uma vez isto feito, a situação é a seguinte:"
9050
9051 #. type: Content of: <p>
9052 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:22
9053 msgid "The pseudo-code of this algorithm is thus the following:"
9054 msgstr "O pseudo-código deste algoritmo é então o seguinte:"
9055
9056 #. type: Content of: <pre>
9057 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:23
9058 #, no-wrap
9059 msgid ""
9060 "For each i in [1,len-1]\n"
9061 " store the value of i in a variable v\n"
9062 " copy the cell i-1 into i if i-1 contains a value bigger than v\n"
9063 " copy the cell i-2 into i-1 if i-2 contains a value bigger than v\n"
9064 " copy the cell i-3 into i-2 if i-3 contains a value bigger than v\n"
9065 " copy the cell i-4 into i-3 if i-4 contains a value bigger than v\n"
9066 " ...\n"
9067 " copy v into the last cell copied above\n"
9068 msgstr ""
9069 "For each i in [1,len-1]\n"
9070 " store the value of i in a variable v\n"
9071 " copy the cell i-1 into i if i-1 contains a value bigger than v\n"
9072 " copy the cell i-2 into i-1 if i-2 contains a value bigger than v\n"
9073 " copy the cell i-3 into i-2 if i-3 contains a value bigger than v\n"
9074 " copy the cell i-4 into i-3 if i-4 contains a value bigger than v\n"
9075 " ...\n"
9076 " copy v into the last cell copied above\n"
9077
9078 #. type: Content of: <p>
9079 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:33
9080 msgid ""
9081 "Naturally, you should use a loop to write the big permutation within the "
9082 "given loop. Writing it this way would be really ... counter-productive."
9083 msgstr ""
9084 "Naturalmente, deve usar um loop para escrever a grande permutação dentro do "
9085 "loop. Escrever ela desta forma deve ser na verdade ... improdutivo."
9086
9087 #. type: Content of: <p>
9088 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:36
9089 msgid ""
9090 "If you've always wondered what computer science researchers do nowadays, "
9091 "here is part of the answer: They improve fundamental algorithms so that "
9092 "others can write efficient programs."
9093 msgstr ""
9094 "Se já se perguntou o que cientistas da computação fazem nos dias de hoje, "
9095 "aqui está uma parte da resposta: Eles melhoram algoritmos fundamentais para "
9096 "que outras pessoas possam escrever programas eficientes."
9097
9098 #. type: Content of: <h2>
9099 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:40
9100 msgid "Other variation of insertion sort"
9101 msgstr "Outra variação do insertion sort"
9102
9103 #. type: Content of: <p>
9104 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:42
9105 msgid ""
9106 "TreeSort builds a binary search tree to sort them. It leads to a O(n log(n)) "
9107 "on average, but O(n^2) in worst cases. We won't study this algorithm here "
9108 "since understanding its behavior requires to know what a binary tree is, "
9109 "what is beyond our present goals."
9110 msgstr ""
9111 "TreeSort constrói uma árvore de busca binária para ordená-la. Consegue O(n "
9112 "log(n)) no caso médio, mas O(n^2) nos piores casos. Não vamos estudar este "
9113 "algoritmo aqui, pois para entendê-lo temos que entender o que uma árvore "
9114 "binária é, o que está além dos nossos objetivos atuais."
9115
9116 #. type: Content of: <p>
9117 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:47
9118 msgid ""
9119 "There is other variations over the insertion sort, such as PatienceSort "
9120 "which builds piles of values and sort each pile afterward. This algorithm "
9121 "presents a 0(n log(n)) timing worst case and a 0(n) space "
9122 "complexity. LibrarySort (proposed in 2004) also trades a bit space in "
9123 "exchange for time since it provide a time complexity of O(n log(n)) but "
9124 "needs to store some more data."
9125 msgstr ""
9126 "Existem variações do insertion sort, tais como o PatienceSort que constrói "
9127 "pilhas de valores e ordena cada pilha depois. Este algoritmo apresenta um "
9128 "tempo 0(n log(n)) no pior caso e uma complexidade de espaço de 0(n). "
9129 "LibrarySort (proposto em 2004) também troca um pouco de espaço por tempo já "
9130 "que tem uma complexidade de tempo de O(n log(n)) mas precisa armazenar um "
9131 "pouco mais de dados."
9132
9133 #. type: Content of: <p>
9134 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:54
9135 msgid ""
9136 "Wikipedia provides a detailled description of all these algorithms we cannot "
9137 "present here because of time constraints."
9138 msgstr ""
9139 "A Wikipédia fornece uma descrição detalhada de cada um destes algoritmos que "
9140 "não apresentamos aqui devido a limitações de tempo."
9141
9142 #. type: Content of: <h2>
9143 #: src/lessons/sort/basic/shell/AlgShellSort.html:2
9144 msgid "ShellSort"
9145 msgstr "ShellSort"
9146
9147 #. type: Content of: outside any tag (error?)
9148 #: src/lessons/sort/basic/shell/AlgShellSort.html:4
9149 msgid ""
9150 "This algorithm is named after its author, Donald Shell, who published it in "
9151 "1959. It can be seen as an application of the CombSort idea (let elements "
9152 "having a long path to travel take shortcuts) to the insertion sort (CombSort "
9153 "is a variation of BubbleSort). Instead of comparing adjacent values during "
9154 "the insertion sort, it compares values separated by a bigger gap. The bigger "
9155 "the gap, the faster the elements are moved to their final destination, but "
9156 "also the less precise is this move. It is thus mandatory to apply the "
9157 "algorithm with a serie of decreasing gaps. At the last step, when the gap is "
9158 "one, InsertionSort is used, but onto an array which is almost already sorted "
9159 "by previous steps."
9160 msgstr ""
9161 "Este algoritmo é batizado em homenagem ao autor dele, Donald Shell, que o "
9162 "publicou em 1959. Seja uma aplicação da ideia do CombSort (faz com que "
9163 "elementos que tem um longo caminho tomarem atalhos) ao insertion sort ("
9164 "CombSort é uma variação do BubbleSort). Ao invés de comparar valores "
9165 "adjacentes durante o insertion sort, compara valores separados por um "
9166 "intervalo maior. Quanto maior o intervalo, mais rápido os elementos se movem "
9167 "ao destino deles, mas também menos preciso fica o movimento. É, portanto, "
9168 "essencial que o algoritmo vá a ser aplicado numa série de intervalos cada "
9169 "vez menor. No último passo, quando o intervalo for 1, o InsertionSort será "
9170 "usado, mas numa array que estará praticamente ordenada pelos passos "
9171 "anteriores."
9172
9173 #. type: Content of: <p>
9174 #: src/lessons/sort/basic/shell/AlgShellSort.html:15
9175 msgid ""
9176 "Donald Shell propose <code>len/2</code> as initial value of the gap, and "
9177 "then to divide it by 2 at each step. The pseudo-code is thus the following:"
9178 msgstr ""
9179 "Donald Shell propôs <code>len/2</code> como o valor inicial do intervalo e "
9180 "ir a dividir por 2 a cada passo. O pseudo-código é o seguinte:"
9181
9182 #. type: Content of: <p><pre>
9183 #: src/lessons/sort/basic/shell/AlgShellSort.html:18
9184 #, no-wrap
9185 msgid ""
9186 "gap=len/2\n"
9187 "while gap>0:\n"
9188 " apply InsertionSort, comparing i-gap and i, then i-2gap and i-gap, then "
9189 "i-3gap and i-2gap, etc.\n"
9190 msgstr ""
9191 "gap=len/2\n"
9192 "while gap>0:\n"
9193 " apply InsertionSort, comparing i-gap and i, then i-2gap and i-gap, then i-"
9194 "3gap and i-2gap, etc.\n"
9195
9196 #. type: Content of: <p><p>
9197 #: src/lessons/sort/basic/shell/AlgShellSort.html:23
9198 msgid ""
9199 "Just like in CombSort, the sequence of values taken by the gap is crucial "
9200 "for Shell sort performance. In some rare pathological cases, the sequence we "
9201 "used above can lead to a O(n^2) performance. Other sequences were proposed: "
9202 "the Hibbard's increments of 2k − 1 lead to a complexity of O(n^(3/2)) in "
9203 "worst cases. Pratt's increments 2^i3^j lead to a O(nlog(n)log(n) performance "
9204 "in worst cases. The existance of a sequence leading to a O(n log(n)) was "
9205 "precluded by Poonen, Plaxton, and Suel. Thanks to this performance, "
9206 "ShellSort is a valid candidate for array of several hundred thousands when "
9207 "correctly implemented."
9208 msgstr ""
9209 "Assim como no CombSort, a sequência de valores levados pelo intervalo é "
9210 "crucial para o desempenho do Shell sort. Em alguns casos patológicos raros, "
9211 "a sequência que usamos pode levar a um desempenho O(n^2). Outras sequências "
9212 "foram propostas: os incrementos de Hibbard de 2k − 1 levam a uma "
9213 "complexidade de O(n^(3/2)) em casos ruins. Incrementos de Pratt 2^i3^j levam "
9214 "a um desempenho de O(nlog(n)log(n) nos piores casos. A existência de uma "
9215 "sequência a levar a O(n log(n)) foi excluída por Poonen, Plaxton e Suel. "
9216 "Graças a este desempenho, ShellSort é um candidato válido para arrays de "
9217 "várias centenas de milhares quando corretamente implementado."
9218
9219 #. type: Content of: <p><p>
9220 #: src/lessons/sort/basic/shell/AlgShellSort.html:33
9221 msgid ""
9222 "In our case, the array are ways too small to benefit of these "
9223 "optimizations. If you ever need to do so, take as initial gap the biggest "
9224 "value of the targeted serie still smaller than the array size, and then use "
9225 "decreasing values of the serie."
9226 msgstr ""
9227 "No nosso caso, a array é pequena demais para se beneficiar destas "
9228 "otimizações. Se ainda assim quiser, tome o intervalo inicial como o maior "
9229 "valor da série alvo ainda menor que o tamanho do array e depois use valores "
9230 "decrescentes da série."
9231
9232 #. type: Content of: <p><p>
9233 #: src/lessons/sort/basic/shell/AlgShellSort.html:38
9234 msgid ""
9235 "Interestingly enough, determining the best gap sequence for shell sort turns "
9236 "into a research issue of our century in computer science. For example, an "
9237 "article of 2001 introduces the following sequence, which seems to be optimal "
9238 "in practice for arrays of size up to 10^5: {1, 4, 10, 23, 57, 132, 301, 701, "
9239 "1750} (Marcin Ciura, Best Increments for the Average Case of Shellsort, 13th "
9240 "International Symposium on Fundamentals of Computation Theory, LNCS 2001; "
9241 "Vol. 2138)."
9242 msgstr ""
9243 "Um fato interessante: Determinar a melhor sequência de intervalos para o "
9244 "shell sort se tornou um tema de pesquisa de nosso século em ciência da "
9245 "computação. Por exemplo, um artigo de 2001 introduz a seguinte sequência, "
9246 "que parece ser a melhor na prática para arrays de tamanho até 10^5: {1, 4, "
9247 "10, 23, 57, 132, 301, 701, 1750} (Marcin Ciura, Best Increments for the "
9248 "Average Case of Shellsort, 13th International Symposium on Fundamentals of "
9249 "Computation Theory, LNCS 2001; Vol. 2138)."
9250
9251 #. type: Content of: <h1>
9252 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:2
9253 msgid "Selection Sort"
9254 msgstr "Selection Sort"
9255
9256 #. type: Content of: outside any tag (error?)
9257 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:4
9258 msgid ""
9259 "In this exercise we will implement another classical algorithm: selection "
9260 "sort."
9261 msgstr ""
9262 "Neste exercício vamos implementar outro algoritmo clássico: selection sort."
9263
9264 #. type: Content of: <p>
9265 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:7
9266 msgid ""
9267 "The idea is simply to select for each cell of the array the smallest value "
9268 "from the part not already sorted. Thus for the first cell, it takes the "
9269 "smallest value over the whole array. For the second one, it takes the second "
9270 "smallest value, which is the smallest value from the cell not already "
9271 "sorted. You of course don't have to sort the last cell of the array, that is "
9272 "already sorted when you consider it."
9273 msgstr ""
9274 "A ideia é simplesmente selecionar para cada célula da array o menor valor da "
9275 "parte ainda não ordenada. Então para a primeira célula, levamos o menor "
9276 "valor da array toda. Para a segunda, precisamos do segundo menor valor, que "
9277 "é o menor valor das células ainda não ordenadas."
9278
9279 #. type: Content of: <p><p>
9280 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:14
9281 msgid ""
9282 "More generally, for the cell N, it looks the cell M in [N;len] containing "
9283 "the smallest possible value of the interval. Then, it swaps the content of "
9284 "cell N with the one of cell M."
9285 msgstr ""
9286 "De forma mais geral, para a célula N, procura a célula M em [N;len] a conter "
9287 "o menor valor possível do intervalo. Então, alterna o conteúdo da célula N "
9288 "com o da célula M."
9289
9290 #. type: Content of: <p><p><h2>
9291 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:18
9292 msgid "Existing variations"
9293 msgstr "Variações existentes"
9294
9295 #. type: Content of: <p><p>
9296 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:19
9297 msgid ""
9298 "Another classical algorithm which idea is based on the selection of good "
9299 "elements is HeapSort, but it uses a heap data structure which we did not see "
9300 "yet. Simply remember that HeapSort provides a O(n log n) performance in "
9301 "worst case, which is why it is a very interesting algorithm in practice."
9302 msgstr ""
9303 "Outro algoritmo clássico cuja ideia é baseada na seleção de bons elementos é "
9304 "o HeapSort, mas usa uma estrutura de dados heap que ainda não vimos. "
9305 "Simplesmente lembre-se que o HeapSort fornece um desempenho O(n log n) no "
9306 "pior caso, que é o motivo para ser bem interessante, na prática."
9307
9308 #. type: Content of: <h1>
9309 #: src/lessons/sort/basic/comb/AlgCombSort.html:2
9310 msgid "CombSort"
9311 msgstr "CombSort"
9312
9313 #. type: Content of: <p>
9314 #: src/lessons/sort/basic/comb/AlgCombSort.html:4
9315 msgid ""
9316 "We saw that CocktailSort improve a bit for turtles (i.e. small values near "
9317 "to the end of the array), but it is still possible to achieve "
9318 "better. ComboSort comes down to providing them a short cut: instead of "
9319 "comparing adjacent values, we compare values separated by a gap bigger than "
9320 "1. That way, turtles will traverse <i>gap</i> cells at each "
9321 "traversal. Naturally, we have to apply the algorithm with decreasing gaps, "
9322 "and finish with <i>gap=1</i> to ensure that the array is correctly sorted "
9323 "afterward. Choosing the right gap and how to decrease it is a difficult "
9324 "question, but in practice, dividing it by 1.3 after each traversal leads to "
9325 "good performance. Here is the corresponding pseudo-code:"
9326 msgstr ""
9327 "Vimos que CocktailSort melhora um pouco as coisas para as tartarugas (p.ex. "
9328 "pequenos valores próximos do fim da array), mas ainda é possível fazer "
9329 "melhor. ComboSort vem-les fornecer um atalho: ao invés de comparar valores "
9330 "adjacentes, comparamos valores separados por um intervalo (\"gap\") maior "
9331 "que 1. Desta forma, as tartarugas vão percorrer <i>gap</i> células em cada "
9332 "passagem. Naturalmente, temos que aplicar o algoritmo com distâncias "
9333 "decrescentes e terminar com <i>gap=1</i> para garantir que a array está "
9334 "corretamente ordenada ao final. Escolher a distância correta e como diminuí-"
9335 "la é uma questão difícil, mas na prática, dividir por 1.3 depois de cada "
9336 "passagem leva a uma boa performance. Aqui está o pseudo-código "
9337 "correspondente:"
9338
9339 #. type: Content of: <pre>
9340 #: src/lessons/sort/basic/comb/AlgCombSort.html:16
9341 #, no-wrap
9342 msgid ""
9343 "gap = len;\n"
9344 "do\n"
9345 " if gap>1 then\n"
9346 " gap = gap / 1.3\n"
9347 " i = O\n"
9348 " while i+gap &lt; len do:\n"
9349 " if i and i+gap must be swapped, do it\n"
9350 " increase i by one\n"
9351 "while the gap is bigger than 1 or the last traversal swapped at least one "
9352 "pair\n"
9353 msgstr ""
9354 "gap = len;\n"
9355 "do\n"
9356 " if gap>1 then\n"
9357 " gap = gap / 1.3\n"
9358 " i = O\n"
9359 " while i+gap &lt; len do:\n"
9360 " if i and i+gap must be swapped, do it\n"
9361 " increase i by one\n"
9362 "while the gap is bigger than 1 or the last traversal swapped at least one "
9363 "pair\n"
9364
9365 #. type: Content of: outside any tag (error?)
9366 #: src/lessons/sort/basic/comb/AlgCombSort.html:27
9367 #: src/lessons/maze/island/IslandMaze.html:67
9368 #: src/lessons/welcome/bat/bool1/Max1020.html:6
9369 msgid "[!scala]"
9370 msgstr "[!scala]"
9371
9372 #. type: Content of: <p>
9373 #: src/lessons/sort/basic/comb/AlgCombSort.html:27
9374 msgid ""
9375 "One tricky part is that we want to divide gap, that is an integer (of type "
9376 "Int), by 1.3, that is a Double. The type system of scala won't let us do "
9377 "this, because such discrepancy usually denotes a programmer error. As this "
9378 "is not an error this time, we have to convert gap to Double for the time of "
9379 "the operation, and then convert the result back to Int to store it into "
9380 "gap. This should be written this way:"
9381 msgstr ""
9382 "Um detalhe perigoso é que temos que dividir o intervalo, que é um inteiro ("
9383 "ou do tipo Int), por 1.3, que é um Double. O sistema de tipos do scala não "
9384 "nos deixa fazer isto, por que tal discrepância normalmente significa um erro "
9385 "de programação. Como isto não é um erro neste caso, vamos ter que converter "
9386 "o intervalo para Double para o momento da operação e depois converter o "
9387 "resultado de volta para Int para armazená-lo no intervalo. Isto deve ser "
9388 "escrito desta forma:"
9389
9390 #. type: Content of: <pre>
9391 #: src/lessons/sort/basic/comb/AlgCombSort.html:31
9392 #, no-wrap
9393 msgid "gap = (gap.asInstanceOf[Double] / 1.3).asInstanceOf[Int]"
9394 msgstr "gap = (gap.asInstanceOf[Double] / 1.3).asInstanceOf[Int]"
9395
9396 #. type: Content of: <p>
9397 #: src/lessons/sort/basic/comb/AlgCombSort.html:32
9398 msgid ""
9399 "This is rather verbose, but actually, this notation is not very complex. And "
9400 "remember that the type checker is your friend. It's picky and sometimes "
9401 "annoying (as on this one), but it often catches weird bugs that would have "
9402 "been a pain to debug if not catch by the type checker. And since the Scala's "
9403 "authors are pragmatic, the previous expression can be simplified:"
9404 msgstr ""
9405 "Isto é meio exagerado, mas, na verdade, esta notação não é muito complexa. E "
9406 "lembre-se que o verificador de sintaxe é o seu amigo. Ás vezes é chato e "
9407 "irritante (como neste caso), mas frequentemente apanha bugs esquisitos que "
9408 "seriam trabalhosos para depurar se não fosse o verificador de sintaxe. E "
9409 "como os autores do Scala são pragmáticos, a expressão anterior pode ser "
9410 "simplificada:"
9411
9412 #. type: Content of: <pre>
9413 #: src/lessons/sort/basic/comb/AlgCombSort.html:36
9414 #, no-wrap
9415 msgid "gap = (gap.toDouble / 1.3).toInt"
9416 msgstr "gap = (gap.toDouble / 1.3).toInt"
9417
9418 #. type: Content of: <p>
9419 #: src/lessons/sort/basic/comb/AlgCombSort.html:37
9420 msgid ""
9421 "<code>toDouble</code> and <code>toInt</code> are just shortcuts for the "
9422 "corresponding expressions <code>asInstanceOf[Double]</code> and "
9423 "<code>asInstanceOf[Int]</code>. It's not very generic, but it's very handy."
9424 msgstr ""
9425 "<code>toDouble</code> e <code>toInt</code> são apenas atalhos para as "
9426 "expressões correspondentes <code>asInstanceOf[Double]</code> e "
9427 "<code>asInstanceOf[Int]</code>. Não é muito genérico, mas é bem prático."
9428
9429 #. type: Content of: <p>
9430 #: src/lessons/sort/basic/comb/AlgCombSort.html:41
9431 msgid ""
9432 "This algorithm was invented by Wlodek Dobosiewicz in 1980, and later "
9433 "rediscovered and popularized by Stephen Lacey and Richard Box, who described "
9434 "it in Byte Magazine in April 1991."
9435 msgstr ""
9436 "Este algoritmo foi inventado por Wlodek Dobosiewicz em 1980 e depois "
9437 "redescoberto e popularizado por Stephen Lacey e Richard Box, que o "
9438 "descreveram na Byte Magazine em Abril de 1991."
9439
9440 #. type: Content of: <h1>
9441 #: src/lessons/sort/basic/comb/AlgCombSort11.html:2
9442 msgid "CombSort11"
9443 msgstr "CombSort11"
9444
9445 #. type: Content of: <p>
9446 #: src/lessons/sort/basic/comb/AlgCombSort11.html:4
9447 msgid ""
9448 "The authors of this algorithm observed that the performance is increased if "
9449 "we make sure that the last values of the gap are (11, 8, 6, 4, 3, 2, 1) "
9450 "rather than (9, 6, 4, 3, 2, 1) or (10, 7, 5, 3, 2, 1). Rework the code of "
9451 "CombSort to ensure just after the gap update that if it is 9 or 10, we "
9452 "should use 11 instead."
9453 msgstr ""
9454 "Os autores deste algoritmo observaram que o desempenho é aumentado se nos "
9455 "certificarmos que os últimos valores do intervalo são (11, 8, 6, 4, 3, 2, 1) "
9456 "ao invés de (9, 6, 4, 3, 2, 1) ou (10, 7, 5, 3, 2, 1). Retrabalhe o código "
9457 "do CombSort para garantir que apenas depois da atualização do intervalo que "
9458 "se for 9 ou 10, devemos usar 11."
9459
9460 #. type: Content of: <h1>
9461 #: src/lessons/sort/basic/gnome/AlgGnomeSort.html:2
9462 msgid "GnomeSort"
9463 msgstr "GnomeSort"
9464
9465 #. type: Content of: <p>
9466 #: src/lessons/sort/basic/gnome/AlgGnomeSort.html:4
9467 msgid ""
9468 "The Gnome sort is similar to insertion sort, but the elements are moved in "
9469 "position by a serie of swaps just like in bubble sort. It is named after the "
9470 "supposed behavior of garden gnomes when they sort flower pots. Here is a "
9471 "description of the algorithm by its author:"
9472 msgstr ""
9473 "O Gnome sort é similar ao insertion sort, mas os elementos são movidos de "
9474 "poisção por uma série de trocas que se parecem com o bubble sort. O nome "
9475 "veio do suposto comportamento que gnomos de jardim tem quando ordenam vasos "
9476 "de flores. Aqui está uma descrição do algoritmo pelo autor dele:"
9477
9478 #. type: Content of: <p>
9479 #: src/lessons/sort/basic/gnome/AlgGnomeSort.html:9
9480 msgid ""
9481 "Gnome Sort is based on the technique used by the standard Dutch Garden Gnome "
9482 "(Du.: tuinkabouter). Here is how a garden gnome sorts a line of flower "
9483 "pots. Basically, he looks at the flower pot next to him and the one "
9484 "immediately after ; if they are in the right order he steps one pot forward, "
9485 "otherwise he swaps them and steps one pot backwards. Boundary conditions: if "
9486 "there is no previous pot, he steps forwards; if there is no pot next to him, "
9487 "he is done. <i>—Dick Grune</i>"
9488 msgstr ""
9489 "Gnome Sort é baseado na técnica usada pelo gnomo de jardim holandês padrão ("
9490 "em holandês: tuinkabouter). Aqui está como um gnomo de jardim ordena uma "
9491 "fileira de potes de flores. Basicamente, procura pelo pote de flor próximo e "
9492 "o anterior; se estão na ordem correta vai para a frente em direção ao "
9493 "próximo pote, caso contrário troca os potes e vai para trás. Condições de "
9494 "contorno: se não existe um pote anterior, vai para a frente; se não existe "
9495 "um pote próximo, termina. <i>—Dick Grune</i>"
9496
9497 #. type: Content of: <h1>
9498 #: src/lessons/sort/dutchflag/Main.html:2
9499 #: src/lessons/sort/dutchflag/short_desc.html:2
9500 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:2
9501 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:2
9502 msgid "The Dutch Flag Problem"
9503 msgstr "O problema da bandeira holandesa"
9504
9505 #. type: Content of: <p>
9506 #: src/lessons/sort/dutchflag/Main.html:4
9507 msgid ""
9508 "This problem was first proposed by E.W Dijkstra in 1976 (in the chapter 14 "
9509 "of his book \"A Discipline of Programming\"). It is a very classical "
9510 "variation of the sorting algorithms since then. It is sometimes useful in "
9511 "real life, but it became famous for its pedagogical properties: its "
9512 "complexity is not trivial, but not complex either. It can easily be "
9513 "formally proven, but it's not absolutely trivial either."
9514 msgstr ""
9515 "Este problema foi proposto primeiro por E.W Dijkstra em 1976 (no capítulo 14 "
9516 "do livro dele \"A Discipline of Programming\"). É uma variação clássica de "
9517 "algoritmos de ordenação desde então. Às vezes é útil na realidade, mas se "
9518 "tornou famosos pelas propriedades pedagógicas dele: a complexidade não é "
9519 "trivial, mas não é muito complexo. Pode ser provados formalmente com "
9520 "facilidade, mas não é de forma alguma trivial."
9521
9522 #. type: Content of: <ul><li>
9523 #: src/lessons/sort/dutchflag/Main.html:13
9524 msgid "A temporal view could be welcomed."
9525 msgstr "Uma visão temporal pode ser bem-vinda."
9526
9527 #. type: Content of: <ul><li>
9528 #: src/lessons/sort/dutchflag/Main.html:14
9529 msgid ""
9530 "Other exercises, for example with 2 colors only or with more than 3 colors, "
9531 "could generalize the proposed approach."
9532 msgstr ""
9533 "Outros exercícios, por exemplo com 2 cores apenas ou com mais de 3 cores, "
9534 "podem generalizar a abordagem proposta."
9535
9536 #. type: Content of: <ul><li>
9537 #: src/lessons/sort/dutchflag/Main.html:15
9538 msgid "This problem could be solved recursively."
9539 msgstr "Este problema pode ser resolvido recursivamente."
9540
9541 #. type: Content of: <p>
9542 #: src/lessons/sort/dutchflag/short_desc.html:4
9543 msgid ""
9544 "This is a classical sorting problem, constituting a variation over the "
9545 "insertion sort."
9546 msgstr ""
9547 "Este é um problema de ordenação clássico, a constituir uma variação do "
9548 "insertion sort."
9549
9550 #. type: Content of: <p>
9551 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:4
9552 msgid ""
9553 "Your work is to sort all the colors of the Dutch flag, and the only provided "
9554 "primitive is to exchange two given lines. In addition, you should not "
9555 "create any additional variables (but a few indices)."
9556 msgstr ""
9557 "O seu trabalho é ordenar todas as cores da bandeira holandesa e a única "
9558 "primitiva fornecida é trocar duas linhas dadas. Adicionalmente, não deve "
9559 "criar quaisquer variáveis adicionais (exceto alguns índices)."
9560
9561 #. type: Content of: <p>
9562 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:7
9563 msgid ""
9564 "If you think carefully, this can be done in linear time, where you sort a "
9565 "line at each iteration of the loop. You may want to check again the <a "
9566 "href=\"plm://lessons.sort.basic/insertion.AlgInsertionSort\">insertion "
9567 "sort</a>, of which the Dutch Flag sort is a variation. The main difference "
9568 "is that you have 3 insertion points, not only one..."
9569 msgstr ""
9570 "Se pensar bem, pode ser feito em tempo linear, ondeordena uma linha a cada "
9571 "iteração do loop. Pode dar mais uma olhada no <a href=\"plm://lessons.sort."
9572 "basic/insertion.AlgInsertionSort\">insertion sort</a>, do qual o Dutch Flag "
9573 "sort é uma variação. A principal diferença é que tem 3 pontos de inserção e "
9574 "não apenas um..."
9575
9576 #. type: Attribute 'alt' of: <div>
9577 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:11
9578 msgid "I need an hint to start"
9579 msgstr "Preciso de uma dica para começar"
9580
9581 #. type: Content of: <div>
9582 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:12
9583 msgid "Do a traversal over your data, saving 3 indices:"
9584 msgstr "Atravesse os seus dados, a guardar 3 índices:"
9585
9586 #. type: Content of: <div><ul><li>
9587 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:14
9588 msgid ""
9589 "<code>afterBlue</code> is initialized to 0. Make sure that every cell below "
9590 "<code>afterBlue</code> is filled with blue elements."
9591 msgstr ""
9592 "<code>afterBlue</code> é iniciado como 0. Certifique-se de que cada célula "
9593 "abaixo de <code>afterBlue</code> é preenchida com elementos azuis."
9594
9595 #. type: Content of: <div><ul><li>
9596 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:15
9597 msgid ""
9598 "<code>whiteRed</code> is initialized to size-1. Make sure that every cell "
9599 "after <code>whiteRed</code> is filled with red elements."
9600 msgstr ""
9601 "<code>whiteRed</code> é iniciado como size-1. Certifique-se de que cada "
9602 "célula depois de <code>whiteRed</code> é preenchida com elementos vermelhos."
9603
9604 #. type: Content of: <div><ul><li>
9605 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:16
9606 msgid ""
9607 "<code>beforeWhite</code> is initialized to size-1. Make sure that every cell "
9608 "after <code>beforeWhite</code> and before <code>whiteRed</code> is filled "
9609 "with white elements."
9610 msgstr ""
9611 "<code>beforeWhite</code> é iniciado com size-1. Certifiqeu-se de que cada "
9612 "célula depois de <code>beforeWhite</code> e antes de <code>whiteRed</code> é "
9613 "preenchida com elementos brancos."
9614
9615 #. type: Content of: <div>
9616 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:18
9617 msgid ""
9618 "Note that the unsorted cells are always between <code>afterBlue</code> and "
9619 "<code>beforeWhite</code>."
9620 msgstr ""
9621 "Observe que as células não-ordenadas ficam sempre entre <code>afterBlue</"
9622 "code> e <code>beforeWhite</code>."
9623
9624 #. type: Content of: <div>
9625 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:20
9626 msgid ""
9627 "At each step of your traversal, check the color of the cell at "
9628 "<code>afterBlue</code> and do the required exchanges. The loop ending "
9629 "condition is when <code>afterBlue</code> becomes larger than "
9630 "<code>beforeWhite</code>."
9631 msgstr ""
9632 "Em cada passo da sua travessia, verifique a cor da célula em "
9633 "<code>afterBlue</code> e faça as mudanças necessárias. A condição de fim de "
9634 "loop é quando <code>afterBlue</code> se torna maior que "
9635 "<code>beforeWhite</code>."
9636
9637 #. type: Content of: <h2>
9638 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:4
9639 msgid "Provided values"
9640 msgstr "Valores fornecidos"
9641
9642 #. type: Content of: <p>
9643 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:6
9644 msgid ""
9645 "The colors are represented through the following constants: BLUE, WHITE and "
9646 "RED. You can use them directly in your code."
9647 msgstr ""
9648 "As cores são representadas através das seguintes constantes: BLUE, WHITE e "
9649 "RED. Pode usá-las diretamente no seu código."
9650
9651 #. type: Content of: <h2>
9652 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:9
9653 #: src/lessons/lander/universe/DelegatingLanderWorld.html:8
9654 msgid "Provided functions"
9655 msgstr "Funções fornecidas"
9656
9657 #. type: Content of: <p>
9658 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:11
9659 msgid "This world is very simple, with only 5 provided functions."
9660 msgstr "Este mundo é bem simples, com apenas 5 funções fornecidas."
9661
9662 #. type: Content of: <pre>
9663 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:13
9664 #, no-wrap
9665 msgid ""
9666 "[!java|c]void [/!]swap([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int "
9667 "[/!]y[!scala]:Int[/!])"
9668 msgstr ""
9669 "[!java|c]void [/!]alterna([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int "
9670 "[/!]y[!scala]:Int[/!])"
9671
9672 #. type: Content of: outside any tag (error?)
9673 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:14
9674 msgid "Swap the lines number <code>x</code> and <code>y</code>."
9675 msgstr ""
9676 "Troca as linhas de número <code>x</code> com a de número <code>y</code>."
9677
9678 #. type: Content of: <pre>
9679 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:16
9680 #, no-wrap
9681 msgid "[!java|c]int [/!]getSize() [!scala]:Int[/!]"
9682 msgstr "[!java|c]int [/!]getSize() [!scala]:Int[/!]"
9683
9684 #. type: Content of: outside any tag (error?)
9685 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:17
9686 msgid "Returns the amount of lines on this flag."
9687 msgstr "Retorna a quantidade de linhas desta bandeira."
9688
9689 #. type: Content of: <pre>
9690 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:19
9691 #, no-wrap
9692 msgid ""
9693 "[!java|c]int [/!]getColor([!java|c]int [/!]line[!scala]:Int[/!]) "
9694 "[!scala]:Int[/!]"
9695 msgstr ""
9696 "[!java|c]int [/!]getCor([!java|c]int [/!]linha[!scala]:Int[/!]) "
9697 "[!scala]:Int[/!]"
9698
9699 #. type: Content of: outside any tag (error?)
9700 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:20
9701 msgid "Returns the color of the given line."
9702 msgstr "Retorna a cor da linha dada."
9703
9704 #. type: Content of: <pre>
9705 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:22
9706 #: src/lessons/sort/baseball/universe/BaseballWorld.html:31
9707 #, no-wrap
9708 msgid "[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]"
9709 msgstr "[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]"
9710
9711 #. type: Content of: outside any tag (error?)
9712 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:23
9713 msgid "Returns whether the flag is sorted."
9714 msgstr "Retorna true se a bandeira estiver ordenada."
9715
9716 #. type: Content of: <pre>
9717 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:25
9718 #: src/lessons/sort/baseball/universe/BaseballWorld.html:37
9719 #, no-wrap
9720 msgid "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
9721 msgstr "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
9722
9723 #. type: Content of: outside any tag (error?)
9724 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:26
9725 #: src/lessons/sort/baseball/universe/BaseballWorld.html:38
9726 msgid "Returns whether the current world is selected in the interface."
9727 msgstr "Retorna true se o mundo atual estiver selecionado na interface."
9728
9729 #. type: Content of: <h1>
9730 #: src/lessons/sort/pancake/universe/PancakeWorld.html:2
9731 msgid "PancakeWorld"
9732 msgstr "PancakeWorld"
9733
9734 #. type: Content of: <p>
9735 #: src/lessons/sort/pancake/universe/PancakeWorld.html:4
9736 msgid "This universe is very simple, with only five functions provided."
9737 msgstr "Este universo é bastante simples, com apenas cinco funções fornecidas."
9738
9739 #. type: Content of: <pre>
9740 #: src/lessons/sort/pancake/universe/PancakeWorld.html:6
9741 #, no-wrap
9742 msgid "[!java|c]int [/!]getStackSize() [!scala]:Int[/!]"
9743 msgstr "[!java|c]int [/!]getStackSize() [!scala]:Int[/!]"
9744
9745 #. type: Content of: outside any tag (error?)
9746 #: src/lessons/sort/pancake/universe/PancakeWorld.html:7
9747 msgid "Returns the size of the stack, that is the amount of pancakes it contains."
9748 msgstr "Retorna o tamanho da pilha, ou seja, a quantidade de panquecas nela."
9749
9750 #. type: Content of: <pre>
9751 #: src/lessons/sort/pancake/universe/PancakeWorld.html:9
9752 #, no-wrap
9753 msgid ""
9754 "[!java|c]int [/!]getPancakeRadius([!java|c]int [/!]rank[!scala]:Int[/!]) "
9755 "[!scala]:Int[/!]"
9756 msgstr ""
9757 "[!java|c]int [/!]getRaioPanqueca([!java|c]int [/!]rank[!scala]:Int[/!]) "
9758 "[!scala]:Int[/!]"
9759
9760 #. type: Content of: outside any tag (error?)
9761 #: src/lessons/sort/pancake/universe/PancakeWorld.html:10
9762 msgid ""
9763 "Returns the radius of the pancake passed as argument, with the rank of the "
9764 "top-most pancake being 0."
9765 msgstr ""
9766 "Retorna o raio da panqueca passado como argumento, com o rank da panqueca "
9767 "mais acima a ser 0."
9768
9769 #. type: Content of: <pre>
9770 #: src/lessons/sort/pancake/universe/PancakeWorld.html:12
9771 #, no-wrap
9772 msgid ""
9773 "[!java]boolean [/!][!c]int [/!]isPancakeUpsideDown([!java|c]int "
9774 "[/!]rank[!scala]:Int[/!]) [!scala]:Boolean[/!]"
9775 msgstr ""
9776 "[!java]boolean [/!][!c]int [/!]panquecaDeCabeçaPraBaixo([!java|c]int "
9777 "[/!]rank[!scala]:Int[/!]) [!scala]:Boolean[/!]"
9778
9779 #. type: Content of: outside any tag (error?)
9780 #: src/lessons/sort/pancake/universe/PancakeWorld.html:13
9781 msgid ""
9782 "Returns whether the pancake passed as argument upside-down, that is, if its "
9783 "burned side is on top. As usual, the top-most pancake is of rank 0."
9784 msgstr ""
9785 "Retorna se a panqueca passada como argumento está de cabeça para baixo, ou "
9786 "seja, se o lado queimado está para cima. Como sempre, a panqueca mais acima "
9787 "é a de rank 0."
9788
9789 #. type: Content of: <pre>
9790 #: src/lessons/sort/pancake/universe/PancakeWorld.html:15
9791 #, no-wrap
9792 msgid "[!java|c]void [/!]flip([!java|c]int [/!]amount[!scala]:Int[/!])"
9793 msgstr "[!java|c]void [/!]flip([!java|c]int [/!]amount[!scala]:Int[/!])"
9794
9795 #. type: Content of: outside any tag (error?)
9796 #: src/lessons/sort/pancake/universe/PancakeWorld.html:16
9797 msgid ""
9798 "Flips the <code>amount</code> first pancakes composing the stack, from the "
9799 "top of it."
9800 msgstr ""
9801 "Vira as primeiras <code>amount</code> panquecas que compõe a pilha, do topo "
9802 "dela."
9803
9804 #. type: Content of: <pre>
9805 #: src/lessons/sort/pancake/universe/PancakeWorld.html:18
9806 #, no-wrap
9807 msgid "[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]"
9808 msgstr "[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]"
9809
9810 #. type: Content of: outside any tag (error?)
9811 #: src/lessons/sort/pancake/universe/PancakeWorld.html:19
9812 msgid "Returns whether the pancake stack is correctly sorted."
9813 msgstr "Retorna true se a pilha de panquecas estiver corretamente ordenada."
9814
9815 #. type: Content of: <pre>
9816 #: src/lessons/sort/pancake/universe/PancakeWorld.html:21
9817 #, no-wrap
9818 msgid "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
9819 msgstr "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
9820
9821 #. type: Content of: <h1>
9822 #: src/lessons/sort/pancake/Main.html:2
9823 #: src/lessons/sort/pancake/BasicPancake.html:2
9824 msgid "Pancake Sorting"
9825 msgstr "Ordenação da panqueca"
9826
9827 #. type: Content of: <p>
9828 #: src/lessons/sort/pancake/Main.html:4
9829 msgid ""
9830 "This activity is inspired by a problem first introduced in 1975 by Harry "
9831 "Dweighter in the American Mathematical Monthly. The question is not only to "
9832 "sort the pancakes, but to determine <code>f(n)</code> the <i>minimal</i> "
9833 "amount of flips mandated to sort any stack of size <code>n</code>."
9834 msgstr ""
9835 "Esta atividade é inspirada por um problema introduzido pela primeira vez em "
9836 "1975 por Harry Dweighter no American Mathematical Monthly. A pergunta não é "
9837 "apenas ordenar panquecas, mas determinar <code>f(n)</code> a quantidade "
9838 "<i>minima</i> de viradas necessárias para ordenar qualquer pilha de tamanho "
9839 "<code>n</code>."
9840
9841 #. type: Content of: <p>
9842 #: src/lessons/sort/pancake/Main.html:8
9843 msgid ""
9844 "This problem is now famous because Bill Gates authored (with "
9845 "C. Papadimitriou) his only scientific publication in 1979 on this topic, "
9846 "providing a faster algorithm and proving that <code>17n/16 ≤ f(n) ≤ "
9847 "(5n+5)/3</code>. This was the only publication of Bill Gates before he "
9848 "invented Windows and became rich."
9849 msgstr ""
9850 "Este problema é agora famoso por que Bill Gates escreveu (com C. "
9851 "Papadimitriou) a única publicação científica dele em 1979 neste tópico, a "
9852 "fornecer um algoritmo mais rápido e a provar que <code>17n/16 ≤ f(n) ≤ "
9853 "(5n+5)/3</code>. Este foi a única publicação de Bill Gates antes dele "
9854 "inventar o Windows e ficar rico."
9855
9856 #. type: Content of: <p>
9857 #: src/lessons/sort/pancake/Main.html:12
9858 msgid ""
9859 "Then, David X. Cohen, the inventor of the Futurama comics with many "
9860 "mathematical references, introduced the variant with burnt pancakes and "
9861 "studied its complexity with Manuel Blum in 1993."
9862 msgstr ""
9863 "Então, David X. Cohen, o inventor dos quadrinhos Futurama com muitas "
9864 "referências matemáticas, introduziu a variante com panquecas queimadas e "
9865 "estudou a complexidade dele com Manuel Blum em 1993."
9866
9867 #. type: Content of: <p>
9868 #: src/lessons/sort/pancake/Main.html:15
9869 msgid ""
9870 "An article of 2011 (by L. Bulteau, G. Fertin and I. Rusu) proved that "
9871 "determining the minimal amount of flips to sort the stack is a NP-complete "
9872 "problem. Naturally, the stack sorting problem is not NP-complete since it "
9873 "can be solved in 2n-3 steps with the naive algorithm and (5n+5)/3 steps with "
9874 "the Gates algorithm. That's determining the minimal amount of steps that is "
9875 "NP."
9876 msgstr ""
9877 "Um artigo de 2011 (por L. Bulteau, G. Fertin e I. Rusu) provou que "
9878 "determinar a quantidade mínima de voltas para ordenar a pilha é um problema "
9879 "NP-completo. Naturalmente, o problema de ordenação da pilha não é NP-"
9880 "completo já que pode ser resolvido em 2n-3 passos com o algoritmo ingénuo e "
9881 "(5n+5)/3 passos com o algoritmo Gates. Isso é determinar a quantidade "
9882 "mínima de passos que é NP."
9883
9884 #. type: Content of: <p>
9885 #: src/lessons/sort/pancake/Main.html:20
9886 msgid "Further information can be found on the wikipedia page, as usual."
9887 msgstr "Mais informações encontram-se na página da wikipédia, como sempre."
9888
9889 #. type: Content of: <p>
9890 #: src/lessons/sort/pancake/Main.html:23
9891 msgid ""
9892 "This activity is also integrated to CSIRL (my repository of <i>free</i> "
9893 "unplugged activities to introduce computer science, available at "
9894 "http://www.loria.fr/~quinson/Mediation/SMN/), and it may be interesting to "
9895 "run the unplugged activities before implementing these algorithms in PLM."
9896 msgstr ""
9897 "Esta atividade também é integrada ao CSIRL (o meu repositório de atividades "
9898 "offline <i>livres</i> para introdução de ciência da computação, disponível "
9899 "em http://www.loria.fr/~quinson/Mediation/SMN/) e pode ser interessante "
9900 "executar as atividades offline antes de implementar estes algoritmos no PLM."
9901
9902 #. type: Content of: <ul><li>
9903 #: src/lessons/sort/pancake/Main.html:34
9904 msgid "A temporal view similar to the sorting universe could be helpful"
9905 msgstr "Uma visão temporal similar ao universo da ordenação pode ser útil"
9906
9907 #. type: Content of: <ul><li>
9908 #: src/lessons/sort/pancake/Main.html:35
9909 msgid ""
9910 "Other exercises, for example on the Roti sorting, with a pile of Roti that "
9911 "have to touch the grill on each face (see "
9912 "http://en.wikipedia.org/wiki/Pancake_sorting#The_identical_pancake_stack)."
9913 msgstr ""
9914 "Outros exercícios, por exemplo sobre Roti sorting, com uma pilha de Roti que "
9915 "tem que tocar a grelha em ambos os lados (see http://en.wikipedia.org/wiki/"
9916 "Pancake_sorting#The_identical_pancake_stack)."
9917
9918 #. type: Content of: <h3>
9919 #: src/lessons/sort/pancake/short_desc.html:2
9920 msgid "The pancake problem"
9921 msgstr "O problema da panqueca"
9922
9923 #. type: Content of: <p>
9924 #: src/lessons/sort/pancake/short_desc.html:4
9925 msgid "Help the poor psychorigid pancakes' chef to sort its pancake stack!"
9926 msgstr ""
9927 "Ajude o pobre chef das panquecas psychorigid a ordenar a pilha de panquecas "
9928 "dele!"
9929
9930 #. type: Content of: <p>
9931 #: src/lessons/sort/pancake/short_desc.html:6
9932 msgid ""
9933 "This funny problem leads to algorithms that are somewhat more challenging to "
9934 "implement. You are supposed to master the bases of programming and some "
9935 "sorting algorithms to take this lesson."
9936 msgstr ""
9937 "Este problema divertido leva a algoritmos que são de certa forma mais "
9938 "desafiadores de implmentar. Espera-se que domine as bases da programação e "
9939 "de algoritmos de ordenação para fazer esta lição."
9940
9941 #. type: Content of: <p>
9942 #: src/lessons/sort/pancake/BasicPancake.html:4
9943 msgid ""
9944 "The pancake sorting problem is a simple puzzle where you have a set of "
9945 "pancakes, each of differing size. The chef cooking the pancake is a bit "
9946 "psychorigid: he hates when the pancakes are not correctly sorted on the "
9947 "plate. He loves when they are correctly ordered, with the small ones over "
9948 "the larger ones. As every pancake maker, he masters the pancake flipping "
9949 "with his spatula. He can flip the pancake on top of the stack, or even "
9950 "several pancakes at once. The thing is that he has only one plate and the "
9951 "table is too dirty to place pancakes on it, even temporary. The only allowed "
9952 "operation is to flip some pancakes that are on top of the stack."
9953 msgstr ""
9954 "O problema da ordenação da panqueca é um quebra-cabeças simples onde tem um "
9955 "conjunto de panquecas, cada uma de tamanhos diferentes. O cozinheiro que "
9956 "cozinha as panquecas é um pouco psicorígido: odeia quando as panquecas não "
9957 "estão corretamente ordenadas no prato. Adora quando elas estão corretamente "
9958 "ordenadas, com as pequenas sobre as grandes. Como todo fazedor de panquecas, "
9959 "é mestre em virar a panqueca com a espátula. Ele pode virar a panqueca do "
9960 "topo da pilha, ou até mesmo várias panquecas de uma vez. O problema é que "
9961 "tem apenas um prato e a mesa está muito suja para pôr as panquecas nela, "
9962 "mesmo temporariamente. A única operação permitida é virar algumas panquecas "
9963 "que estão no topo da pilha."
9964
9965 #. type: Content of: <p>
9966 #: src/lessons/sort/pancake/BasicPancake.html:13
9967 msgid ""
9968 "Your work is to help this poor guy sorting his stack by flipping the "
9969 "pancakes. Each pancake is defined by its radius and rank within the stack, "
9970 "with the top-most pancake is at rank 0, and the one below at rank 1."
9971 msgstr ""
9972 "O seu trabalho é ajudar este pobre coitado a ordenar a pilha dele a virar as "
9973 "panquecas. Cada panqueca é definida pelo raio e rank dentro da pilha, onde a "
9974 "panqueca de cima está com rank 0 e a próxima com rank 1."
9975
9976 #. type: Content of: <p>
9977 #: src/lessons/sort/pancake/BasicPancake.html:17
9978 msgid ""
9979 "Note that you can play physically with pieces of paper or wood at first to "
9980 "get the grasp on this problem. This is even one of the activities that I use "
9981 "in my CS-IRL (computer science in real life) project to introduce the "
9982 "concept of algorithm to absolute beginners that wonder about our "
9983 "science. More information at http://www.loria.fr/~quinson/Mediation/SMN/ (in "
9984 "French)."
9985 msgstr ""
9986 "Observe que pode brincar primeiro fisicamente com pedaços de papel ou "
9987 "madeira para ter a ideia do problema. Esta é inclusive uma das atividades "
9988 "que uso no meu projeto CS-IRL (computer science in real life - ciência da "
9989 "computação na vida real) para introduzir o conceito de algoritmo para "
9990 "completos iniciantes que querem saber da nossa ciência. Mais informações em "
9991 "http://www.loria.fr/~quinson/Mediation/SMN/ (em francês)."
9992
9993 #. type: Attribute 'alt' of: <p><div>
9994 #: src/lessons/sort/pancake/BasicPancake.html:23
9995 #: src/lessons/sort/pancake/BubblePancake.html:10
9996 msgid "I don't get it. I need some help."
9997 msgstr "Não compreendi. preciso de ajuda."
9998
9999 #. type: Content of: <p><div>
10000 #: src/lessons/sort/pancake/BasicPancake.html:24
10001 msgid ""
10002 "You should try to first move the largest pancake to the bottom, and then the "
10003 "largest but one pancake on top of it, and then the one just smaller on top, "
10004 "and so on."
10005 msgstr ""
10006 "Deve tentar primeiro mover a maior panqueca para o fundo e depois a segunda "
10007 "maior para cima dela e depois a menor para o topo e assim por diante."
10008
10009 #. type: Attribute 'alt' of: <p><p><div>
10010 #: src/lessons/sort/pancake/BasicPancake.html:28
10011 #: src/lessons/sort/pancake/BubblePancake.html:13
10012 msgid "The first tip was not enough. I need another one."
10013 msgstr "A primeira dica não foi suficiente. Preciso de outra."
10014
10015 #. type: Content of: <p><div>
10016 #: src/lessons/sort/pancake/BasicPancake.html:29
10017 msgid "So first, you need to move the largest pancake at the bottom of the stack."
10018 msgstr ""
10019 "Logo, em primeiro lugar precisa mover a maior panqueca para o fundo da pilha."
10020
10021 #. type: Content of: <p><div>
10022 #: src/lessons/sort/pancake/BasicPancake.html:30
10023 msgid ""
10024 "Can you imagine a situation in which you can easily bring this damn large "
10025 "pancake to the bottom?"
10026 msgstr ""
10027 "Pode imaginar uma situação onde possa facilmente trazer esta panqueca super-"
10028 "grande para o fundo?"
10029
10030 #. type: Content of: <p><div>
10031 #: src/lessons/sort/pancake/BasicPancake.html:31
10032 msgid "How could you reach this situation from the current one?"
10033 msgstr "Como pode atingir esta situação a partir da atual?"
10034
10035 #. type: Content of: <h1>
10036 #: src/lessons/sort/pancake/BubblePancake.html:2
10037 msgid "Bubble Pancakes"
10038 msgstr "Bubble Pancakes"
10039
10040 #. type: Content of: <p>
10041 #: src/lessons/sort/pancake/BubblePancake.html:4
10042 msgid ""
10043 "This problem is similar to the previous: you have to sort the pancakes, the "
10044 "smallest at the top and the biggest at the bottom, except you can only flip "
10045 "them to sort."
10046 msgstr ""
10047 "Este problema é similar ao anterior: tem que ordenar as panquecas, a menor "
10048 "no topo e a maior embaixo, mas só pode virar-las para ordená-las."
10049
10050 #. type: Content of: <p>
10051 #: src/lessons/sort/pancake/BubblePancake.html:6
10052 msgid ""
10053 "The purpose here is to sort them using the bubble algorithm, where one "
10054 "pancake is moved to the bottom until it encounters a bigger one. In "
10055 "graphical representations, it looks like a bubble takes the element and move "
10056 "them through the pile. This is where its name comes from."
10057 msgstr ""
10058 "O objetivo aqui é ordená-los a usar o algoritmo da bolha (bubble), onde uma "
10059 "panqueca é movida ao fundo até encontrar uma maior que ela. Em "
10060 "representações gráficas, parece que uma bolha ocupa o lugar do elemento e "
10061 "move-o através da pilha. É daí que saiu o nome do algoritmo."
10062
10063 #. type: Content of: <p>
10064 #: src/lessons/sort/pancake/BubblePancake.html:8
10065 msgid ""
10066 "Now, using pancakes makes it a little more difficult to write, because you "
10067 "have to find a way to swap only two pancakes at a time."
10068 msgstr ""
10069 "Agora, a usar panquecas torna as coisas um pouco mais difíceis de escrever, "
10070 "pois tem que encontrar uma forma de alternar apenas duas panquecas por vez."
10071
10072 #. type: Content of: <p><div>
10073 #: src/lessons/sort/pancake/BubblePancake.html:11
10074 msgid ""
10075 "The bubble algorithm consists in browsing the whole pile from top to bottom, "
10076 "and making a comparision between two pancakes. Each time the top pancake is "
10077 "bigger than the one below, you have to swap them, then compare the bigger "
10078 "pancake you just swapped with one below, and so on. You have to browse "
10079 "through the entire pile until no swap has occurred, in which case the pile "
10080 "is sorted."
10081 msgstr ""
10082 "O Algoritmo da bolha consiste em navegar a pilha completa de cima para baixo "
10083 "e a fazer uma comparação entre duas panquecas. Cada vez que a panqueca de "
10084 "cima é maior que a de baixo, tem que alterná-las, então comparar a panqueca "
10085 "maior que acabou de alternar com a de baixo dela e por aí vai. Tem que "
10086 "navegar através de toda a pilha até que nenhuma troca ocorra e neste caso, a "
10087 "pilha estará ordenada."
10088
10089 #. type: Content of: <p><p><div>
10090 #: src/lessons/sort/pancake/BubblePancake.html:14
10091 msgid ""
10092 "If you don't understand the basic bubble sorting algorithm, you should try "
10093 "the exercises within the “Sorting algorithms” lesson. If you do, but can't "
10094 "figure a way to swap only two pancakes at a time, think of a situation where "
10095 "only two pancakes are swapped at a time, and find a way to reach that "
10096 "situation."
10097 msgstr ""
10098 "Se não entende o algoritmo básico bubble sort, tente os exercícios da lição "
10099 "Algoritmos de Ordenação. Se consegue, mas não imagina uma forma de alternar "
10100 "apenas duas panquecas por vez, pense na situação onde apenas duas panquecas "
10101 "são alternadas por vez e encontre uma forma de chegar nesta situação."
10102
10103 #. type: Content of: <h1>
10104 #: src/lessons/sort/pancake/BurnedPancake.html:2
10105 msgid "Burned Pancakes"
10106 msgstr "Panquecas queimadas"
10107
10108 #. type: Content of: <p>
10109 #: src/lessons/sort/pancake/BurnedPancake.html:4
10110 msgid ""
10111 "Hard blow for the chef! The pancakes got burnt on one side! There is no way "
10112 "he can deliver a stack of pancakes with visibly burnt pancakes! You've got "
10113 "to help him ensuring that no pancake is upside-down while sorting his stack."
10114 msgstr ""
10115 "Hard blow for the chef! As panquecas queimaram de um lado! Não há forma de "
10116 "entregar uma pilha de panquecas com paquecas visivelmente queimadas! Tem que "
10117 "ajudá-lo a ter certeza de que nenhuma panqueca está de cabeça pra baixo "
10118 "enquanto ordena esta pilha."
10119
10120 #. type: Content of: <h1>
10121 #: src/lessons/sort/pancake/GatesPancake.html:2
10122 msgid "Faster Pancake Sorting"
10123 msgstr "Ondenação de Panqueca Rápida"
10124
10125 #. type: Content of: <p>
10126 #: src/lessons/sort/pancake/GatesPancake.html:4
10127 msgid ""
10128 "Unlike others sorting problem, the expensive operation is not the comparison "
10129 "of values, but the flipping of pancakes. In this exercise, we will explore "
10130 "another algorithm that attempt to reduce the amount of stack flipping. The "
10131 "funny side is that this algorithm was first introduced by Bill Gates, before "
10132 "invented Windows."
10133 msgstr ""
10134 "Ao contrário de outros problemas de ordenação, a operação cara não é a "
10135 "comparação de valores, mas virar as panquecas. Neste exercício, vamos "
10136 "explorar outro algoritmo que tenta reduzir a quantidade de viradas da pilha. "
10137 "O engraçado é que este algoritmo mostrado primeiro por Bill Gates, antes de "
10138 "inventar o Windows."
10139
10140 #. type: Content of: <p>
10141 #: src/lessons/sort/pancake/GatesPancake.html:9
10142 msgid ""
10143 "The basic idea is to grow sequences of sorted pancakes, not necessarily "
10144 "starting from the bottom. We say that a sequence of ordered pancakes "
10145 "constitute a <b>block</b> while a pancake that is not part of a block is "
10146 "said to be <b>free</b>. The algorithm then considers the topmost pancake (of "
10147 "radius <code>t</code>) and search for the <code>t+1</code> or "
10148 "<code>t-1</code> pancakes (the considered neighbor is noted "
10149 "<code>t+o</code>). Eight cases may happen:"
10150 msgstr ""
10151 "A ideia básica é aumentar as sequências de panquecas ordenadas, não "
10152 "necessariamente a começar do fundo. Dizemos que uma sequência de panquecas "
10153 "ordenadas constitui um <b>bloco</b> enquanto uma panqueca que não é parte de "
10154 "um bloco é dita <b>livre</b>. O algoritmo então considera o panqueca mais de "
10155 "cima (de raio <code>t</code>) e busca pelas panquecas <code>t+1</code> ou "
10156 "<code>t-1</code> (a vizinhança considerada é <code>t+o</code>). Oito casos "
10157 "podem acontecer:"
10158
10159 #. type: Content of: <ul><li>
10160 #: src/lessons/sort/pancake/GatesPancake.html:16
10161 msgid ""
10162 "<b>Case a</b>: Both <code>t</code> and <code>t+o</code> are free. They are "
10163 "then merged in one flip."
10164 msgstr ""
10165 "<b>Caso a</b>: tanto <code>t</code> quanto <code>t+o</code> são livres. elas "
10166 "são então juntadas numa virada."
10167
10168 #. type: Content of: <ul><li>
10169 #: src/lessons/sort/pancake/GatesPancake.html:20
10170 msgid ""
10171 "<b>Case b</b>: <code>t</code> is free, and <code>t+o</code> is the first of "
10172 "a block. They are merged in one flip."
10173 msgstr ""
10174 "<b>Caso b</b>: <code>t</code> é livre e <code>t+o</code> é o primeiro de um "
10175 "bloco. Eles são juntados numa virada."
10176
10177 #. type: Content of: <ul><li>
10178 #: src/lessons/sort/pancake/GatesPancake.html:25
10179 msgid ""
10180 "<b>Case c</b>: <code>t</code> is free but both <code>t-1</code> and "
10181 "<code>t+1</code> are the last elements of blocks. Both blocks and "
10182 "<code>t</code> are merged all together in 4 flips. Beware, if either "
10183 "<code>t-1</code> or <code>t+1</code> does not exist (because <code>t</code> "
10184 "is 0 or max), only two flips are mandated."
10185 msgstr ""
10186 "<b>Caso c</b>: <code>t</code> é livre mas tanto <code>t-1</code> quanto "
10187 "<code>t+1</code> são últimos elementos de blocos. Os blocos e <code>t</code> "
10188 "são mesclados juntos em 4 viradas. Cuidado, se <code>t-1</code> ou "
10189 "<code>t+1</code> não existir (pois <code>t</code> é 0 ou max), apenas duas "
10190 "viradas são obrigatórias."
10191
10192 #. type: Content of: <ul><li>
10193 #: src/lessons/sort/pancake/GatesPancake.html:33
10194 msgid ""
10195 "<b>Case d</b>: <code>t</code> is in a block but <code>t+o</code> is "
10196 "free. They are merged in one flip."
10197 msgstr ""
10198 "<b>Caso d</b>: <code>t</code> está num bloco mas <code>t+o</code> é livre. "
10199 "Eles são mesclados numa virada."
10200
10201 #. type: Content of: <ul><li>
10202 #: src/lessons/sort/pancake/GatesPancake.html:38
10203 msgid ""
10204 "<b>Case e</b>: <code>t</code> is in a block and <code>t+o</code> is the "
10205 "first element of a block. They are merged in one flip."
10206 msgstr ""
10207 "<b>Caso e</b>: <code>t</code> está num bloco e <code>t+o</code> é o primeiro "
10208 "elemento de um bloco. Eles são mesclados numa virada."
10209
10210 #. type: Content of: <ul><li>
10211 #: src/lessons/sort/pancake/GatesPancake.html:42
10212 msgid ""
10213 "<b>Case f</b>: <code>t</code> is in a block and <code>t+o</code> is the last "
10214 "element of another block. They are merged in 3 flips as follows."
10215 msgstr ""
10216 "<b>Caso f</b>: <code>t</code> está num bloco e <code>t+o</code> é o último "
10217 "elemento de outro bloco. Eles são mesclados em 3 viradas como segue."
10218
10219 #. type: Content of: <ul><li>
10220 #: src/lessons/sort/pancake/GatesPancake.html:46
10221 msgid ""
10222 "<b>Case g</b>: <code>t</code> is in a block of length k+1 (the last element "
10223 "is <code>t+ko</code>), <code>t+(k+1)o</code> is either free or the last "
10224 "element of another block. Both blocks are merged in 2 flips:"
10225 msgstr ""
10226 "<b>Caso g</b>: <code>t</code> está num bloco de comprimento k+1 (o último "
10227 "elemento é <code>t+ko</code>), <code>t+(k+1)o</code> é tanto livre ou o "
10228 "último elemento é outro bloco. Ambos os blocos são mesclados em 2 viradas:"
10229
10230 #. type: Content of: <ul><li>
10231 #: src/lessons/sort/pancake/GatesPancake.html:49
10232 msgid ""
10233 "<b>Case h</b>: <code>t</code> is in a block of length k+1 (the last element "
10234 "is <code>t+ko</code>), <code>t+(k+1)o</code> is the first element of another "
10235 "block (the difference with case g is that <code>t+(k+1)o</code> is now the "
10236 "<i>first</i> element of its block). Both blocks are merged in 2 flips:"
10237 msgstr ""
10238 "<b>Caso h</b>: <code>t</code> está num bloco de comprimento k+1 (o último "
10239 "elemento é <code>t+ko</code>), <code>t+(k+1)o</code> é o primeiro elemento "
10240 "de outro bloco (a diferença com o caso g é que <code>t+(k+1)o</code> é agora "
10241 "o <i>primeiro</i> elemento do bloco dele). Ambos os blocos são mesclados em "
10242 "2 viradas:"
10243
10244 #. type: Content of: <ul><li>
10245 #: src/lessons/sort/pancake/GatesPancake.html:55
10246 msgid ""
10247 "<b>Case i</b>: <code>t</code> is in a block of length <code>n</code> (this "
10248 "block contains all pancakes). If <code>t</code> is not 1, the whole stack "
10249 "is fliped. The algorithm then stops."
10250 msgstr ""
10251 "<b>Caso i</b>: <code>t</code> está num bloco de comprimento <code>n</code> ("
10252 "este bloco contém todas as panquecas). Se <code>t</code> não for 1, a pilha "
10253 "toda destá virada. O algoritmo então pára."
10254
10255 #. type: Content of: <p>
10256 #: src/lessons/sort/pancake/GatesPancake.html:58
10257 msgid ""
10258 "Each iteration increases the size of the blocks, so the algorithm eventually "
10259 "halts in all cases. A finer analysis would show that it takes at most "
10260 "<code>(5n+5)/3</code> steps to sort the stack. That's better than the naïve "
10261 "algorithm, that requires 2n-3 steps."
10262 msgstr ""
10263 "Cada iteração aumenta o tamanho dos blocos, então o algoritmo eventualmente "
10264 "pára em todos os casos. Uma análise mais aprofundada mostrará que leva no "
10265 "máximo <code>(5n+5)/3</code> passos para ordenar a pilha. O que é melhor que "
10266 "o algoritmo simplório, que precisa de 2n-3 passos."
10267
10268 #. type: Content of: <h2>
10269 #: src/lessons/sort/pancake/GatesPancake.html:61
10270 msgid "Your turn"
10271 msgstr "É a sua vez"
10272
10273 #. type: Content of: <p>
10274 #: src/lessons/sort/pancake/GatesPancake.html:62
10275 msgid ""
10276 "You now have almost enough information to implement this algorithm on your "
10277 "own. We just have to remove the last remaining ambiguities to ensure that "
10278 "you implement exactly the same algorithm that the correction. If several "
10279 "cases apply to your situation, then you should use the first given one. For "
10280 "example, if both cases a and b apply (e.g., with <code>t-1</code> on case "
10281 "<b>a</b> and <code>t+1</code> on case <b>b</b>), then you should apply the "
10282 "flips of case <b>a</b>. If a given case applies for both <code>t+1</code> "
10283 "and <code>t-1</code>, then you should apply it to <code>t+1</code>."
10284 msgstr ""
10285 "Agora tem quase toda a informação necessária para implementar este algoritmo "
10286 "por si só. Temos apenas que remover as últimas ambiguidades para garantir "
10287 "que implemente o mesmo algoritmo que a correção. Se vários casos se aplicam "
10288 "à sua situação, deve usar o primeiro que foi dado. Por exemplo, se tanto o "
10289 "caso a quanto o caso b se aplicam (e.g., com <code>t-1</code> no <b>a</b> e "
10290 "<code>t+1</code> no caso <b>b</b>), deve aplicar as viradas do caso <b>a</"
10291 "b>. Se um dado caso se aplica tanto para <code>t+1</code> quanto para "
10292 "<code>t-1</code>, então deve aplicá-lo a <code>t+1</code>."
10293
10294 #. type: Content of: <p>
10295 #: src/lessons/sort/pancake/GatesPancake.html:68
10296 msgid ""
10297 "Note that it is somehow harder than the other exercises we did so far, so "
10298 "don't be surprised if you need more time to achieve this. But do not give "
10299 "up hope, you can do it!"
10300 msgstr ""
10301 "Observe que este é de certa forma mais difícil que os outros exercícios que "
10302 "fizemos até agora, logo não se surpreenda se precisar de mais tempo para "
10303 "terminar. Mas não desista, pode conseguir!"
10304
10305 #. type: Attribute 'alt' of: <p><div>
10306 #: src/lessons/sort/pancake/GatesPancake.html:71
10307 msgid "Well, I need some help to start."
10308 msgstr "Bem, preciso de ajuda para começar."
10309
10310 #. type: Content of: <p><div>
10311 #: src/lessons/sort/pancake/GatesPancake.html:72
10312 msgid ""
10313 "First write some helper functions such as <code>isFirst()</code> or "
10314 "<code>isFree()</code>. This will simplify your main algorithm afterward, "
10315 "that can be written very similarly to the explication above with a bunch of "
10316 "if conditions. Factorizing code this way often helps making your code more "
10317 "readable."
10318 msgstr ""
10319 "Primeiro escreva algumas funções auxiliares tais como <code>isFirst()</code> "
10320 "ou <code>isFree()</code>. Isto vai simplificar o seu algoritmo principal, "
10321 "que vai poder ser escrito de forma muito similar à explicação acima com um "
10322 "conjunto de condições if. Fatorizar o código desta forma às vezes ajuda a "
10323 "tornar o seu código mais legível."
10324
10325 #. type: Attribute 'alt' of: <p><div>
10326 #: src/lessons/sort/pancake/GatesPancake.html:79
10327 msgid "My code keeps failing and I don't know how to debug it."
10328 msgstr "O meu código continua a falhar e não sei como depurar-lo."
10329
10330 #. type: Content of: <p><div>
10331 #: src/lessons/sort/pancake/GatesPancake.html:80
10332 msgid ""
10333 "To debug one world after the other and avoid that the messages of all worlds "
10334 "get intermixed, you can write your debug function only if the method "
10335 "<code>isSelected()</code> returns true. It will be so only for the entity "
10336 "that is currently selected in the graphical interface, that is probably the "
10337 "world you are currently debugging. This will help breaking the difficulty in "
10338 "parts by debugging the situation one after the other."
10339 msgstr ""
10340 "Para depurar um mundo depois do outro e evitar que as mensagens de todos os "
10341 "mundos fiquem misturadas, pode escrever a sua função de depuração apenas se "
10342 "o método <code>isSelected()</code> retorna true. Isto acontecerá apenas para "
10343 "a entidade que estiver selecionada na interface gráfica, que é provavelmente "
10344 "o mundo que está a depurar no momento. Isto vai ajudar a dividir a "
10345 "dificuldade em partes e a depurar a situção uma após a outra."
10346
10347 #. type: Content of: <p><div>
10348 #: src/lessons/sort/pancake/GatesPancake.html:86
10349 msgid ""
10350 "In particular, it may help to print textually the state of the world each "
10351 "time you enter the main loop."
10352 msgstr ""
10353 "Em particular, escrever textualmente o estado do mundo cada vez que entrar "
10354 "no loop principal pode ajudar."
10355
10356 #. type: Content of: <h1>
10357 #: src/lessons/sort/pancake/CohenPancake.html:2
10358 msgid "Faster Burned Pancake Sorting"
10359 msgstr "Faster Burned Pancake Sorting"
10360
10361 #. type: Content of: <p>
10362 #: src/lessons/sort/pancake/CohenPancake.html:4
10363 msgid ""
10364 "The Gates' algorithm that we saw in the previous exercise quickly sort a "
10365 "stack of unburned pancakes by increasing the size of the blocks of sorted "
10366 "pancakes. This is much faster that the naive algorithm which moves at each "
10367 "step the largest pancake to the bottom of still unsorted pancakes. Gates' "
10368 "algorithm manages to sort a stack of <i>n</i> pancakes in less than <i>(5n + "
10369 "5)/3</i> steps in the worst case, while the naive algorithm requires at most "
10370 "<i>2n</i> steps. Gates is thus about one third faster in the worst case."
10371 msgstr ""
10372 "O algoritmo de Gates que vimos no exercício anterior ordena rapidamente uma "
10373 "pilha de panquecas que não estão queimadas a aumentar o tamanho dos blocos "
10374 "de panquecas já ordenadas. Isto é muito mais rápido que o algoritmo que move "
10375 "em cada passo a panqueca maior para o fundo das panquecas ainda não "
10376 "ordenadas. O algoritmo de Gates ordena uma pilha de <i>n</i> panquecas em "
10377 "menos que <i>(5n + 5)/3</i> passos no pior caso, enquanto que o algoritmo "
10378 "simplório precisa de no máximo <i>2n</i> passos. Gates é então cerca de 3 "
10379 "vezes mais rápido no pior caso."
10380
10381 #. type: Content of: <p>
10382 #: src/lessons/sort/pancake/CohenPancake.html:11
10383 msgid ""
10384 "In this exercise, we will explore an adaptation of the same idea to burnt "
10385 "pancakes. This was first published by David X. Cohen and Manuel Blum. David "
10386 "Cohen co-founded a few years later the Futurama TV show full of mathematical "
10387 "jokes. Definitively, interesting people studied that little pancake "
10388 "problem..."
10389 msgstr ""
10390 "Neste exercício, vamos explorar uma adaptação da mesma ideia das panquecas "
10391 "queimadas. Isto foi publicado primeiramente por David X. Cohen e Manuel "
10392 "Blum. David Cohen co-fundou uns anos depois a série de TV Futurama, cheia de "
10393 "piadas matemáticas. Definitivamente, pessoas interessantes estudaram este "
10394 "singelo problema da panqueca..."
10395
10396 #. type: Content of: <p>
10397 #: src/lessons/sort/pancake/CohenPancake.html:16
10398 msgid ""
10399 "The Cohen's algorithm is slightly easier than the Gates' one since it "
10400 "distinguishes less cases:"
10401 msgstr ""
10402 "O algoritmo de Cohen é um pouco mais fácil que o algoritmo de Gates já que "
10403 "ele distingue menos casos:"
10404
10405 #. type: Content of: <p>
10406 #: src/lessons/sort/pancake/CohenPancake.html:18
10407 msgid ""
10408 "<b>Case 1:</b> At least one pancake is rightside up in the stack. Let "
10409 "<i>p</i> be the largest such pancake. Note that <i>p + 1</i> must therefore "
10410 "be upside down, unless <i>p = n</i> (in which case there is no <i>p + 1</i> "
10411 "pancake)."
10412 msgstr ""
10413 "<b>Caso 1:</b> pelo menos uma panqueca está de cabeça para cima na pilha. "
10414 "Seja <i>p</i> a maior destas panquecas. Observe que <i>p + 1</i> deve "
10415 "portanto estar de cabeça para baixo, a menos que <i>p = n</i> (e neste caso "
10416 "não existe a panqueca <i>p + 1</i>)."
10417
10418 #. type: Content of: <ul><li>
10419 #: src/lessons/sort/pancake/CohenPancake.html:22
10420 msgid "<b>Case 1.a:</b> <i>p+1</i> is lower in the stack than <i>p</i>."
10421 msgstr "<b>Caso 1.a:</b> <i>p+1</i> é menor que <i>p</i> na pilha."
10422
10423 #. type: Content of: <ul><li>
10424 #: src/lessons/sort/pancake/CohenPancake.html:23
10425 msgid "<b>Case 1.b:</b> <i>p+1</i> is higher in the stack than <i>p</i>."
10426 msgstr "<b>Caso 1.b:</b> <i>p+1</i> é maior que <i>p</i> na pilha."
10427
10428 #. type: Content of: <ul><li>
10429 #: src/lessons/sort/pancake/CohenPancake.html:24
10430 msgid ""
10431 "<b>Case 1.c:</b> There is no <i>p+1</i> because <i>p</i> is the largest "
10432 "pancake in stack, that is because <i>p = n</i>. If pancake <i>p</i> is "
10433 "already in position, there is nothing to do. If not, you can move it to the "
10434 "bottom of the stack in 2 flips:"
10435 msgstr ""
10436 "<b>Caso 1.c:</b> Não existe <i>p+1</i> pois <i>p</i> é a maior panqueca da "
10437 "pilha, isto por que <i>p = n</i>. Se a panqueca <i>p</i> já estiver na "
10438 "posição, não há nada a fazer. Se não, pode movê-la para o fundo da pilha em "
10439 "duas viradas:"
10440
10441 #. type: Content of: <ul><li>
10442 #: src/lessons/sort/pancake/CohenPancake.html:28
10443 msgid ""
10444 "<b>The trick is that the pancake <i>p</i> should never be considered "
10445 "again.</b> Otherwise, you will consider that pancake again and again since "
10446 "it's rightside up, and since that's the largest pancake. To leave that "
10447 "pancake alone, you should keep track of the stack size that is still to be "
10448 "sorted. Any traversal of the stack must then only consider these pancakes, "
10449 "leaving alone the ones that are already in position at the bottom of the "
10450 "stack."
10451 msgstr ""
10452 "<b>O truque é que a panqueca <i>p</i> nunca deve ser considerada de novo.</"
10453 "b> caso contrário, vai considerar ela de novo e de novo pois ela está de "
10454 "cabeça pra cima e já que é a maior panqueca. Para desconsiderar-la, deve se "
10455 "lembrar do tamanho da pilha que ainda está para ser ordenada. Qualquer "
10456 "travessia da pilha deve então considerar apenas estas panquecas, não a mexer "
10457 "nas que já estão posicionadas no fundo da pilha."
10458
10459 #. type: Content of: <p>
10460 #: src/lessons/sort/pancake/CohenPancake.html:36
10461 msgid ""
10462 "<b>Case 2:</b> All pancakes are downside. Again, we distinguish two "
10463 "sub-cases."
10464 msgstr ""
10465 "<b>Caso 2:</b> Todas as panquecas estão de cabeça para baixo. De novo, "
10466 "distinguimos dois sub-casos."
10467
10468 #. type: Content of: <ul><li>
10469 #: src/lessons/sort/pancake/CohenPancake.html:39
10470 msgid ""
10471 "<b>Case 2.a:</b> There is at least one <i>p</i> for which <i>p+1</i> is "
10472 "higher than <i>p</i> (if there is several such <i>p</i>, take the largest "
10473 "one)."
10474 msgstr ""
10475 "<b>Caso 2.a:</b> Existe pelo menos um <i>p</i> para o qual <i>p+1</i> é "
10476 "maior que <i>p</i> (se existem vários destes <i>p</i>, pegue o maior)."
10477
10478 #. type: Content of: <ul><li>
10479 #: src/lessons/sort/pancake/CohenPancake.html:43
10480 msgid ""
10481 "<b>Case 2.b:</b> Any pancake <i>p</i> is lower than pancake <i>p+1</i>. In "
10482 "that case, we must have that setting:"
10483 msgstr ""
10484 "<b>Caso 2.b:</b> Qualquer panqueca <i>p</i> é menor que a panqueca <i>p+1</"
10485 "i>. Neste caso, devemos ter a seguinte configuração:"
10486
10487 #. type: Content of: <p>
10488 #: src/lessons/sort/pancake/CohenPancake.html:48
10489 msgid ""
10490 "As you can see, we achieve one join in 2 flips in the cases 1 or 2.a. Since "
10491 "we need to achieve n joins to sort the stack, we can sort the stack in "
10492 "<i>2n</i> steps if case 2.b does not occurs."
10493 msgstr ""
10494 "Como pode ver, alcançamos um \"join\" em duas viradas nos casos 1 ou 2.a. Já "
10495 "que precisamos alcançar n junções para ordenar a pilha, podemos ordenar a "
10496 "pilha em <i>2n</i> passos se o caso 2.b não ocorrer."
10497
10498 #. type: Content of: <p>
10499 #: src/lessons/sort/pancake/CohenPancake.html:51
10500 msgid ""
10501 "That case 2.b requires a very different handling as it is obviously not "
10502 "possible to achieve a join in only 2 flips. But fortunately, we can "
10503 "leverage the very specific setting of the stack in that case to provide the "
10504 "following algorithm. It sorts a stack in that exact configuration after "
10505 "exactly <i>2n</i> steps."
10506 msgstr ""
10507 "Este caso 2.b necessita um tratamento particular já que é obviamente "
10508 "impossível juntar duas panquecas em apenas duas viradas. Mas por sorte, uma "
10509 "única configuração bem específica da pilha cai neste caso da figura. Podemos "
10510 "então utilizar o algoritmo seguinte, conhecido por tirar vantagem desta "
10511 "configuração. Este algoritmo ordena toda a pilha em exatamente <i>2n</i> "
10512 "passos."
10513
10514 #. type: Content of: <pre>
10515 #: src/lessons/sort/pancake/CohenPancake.html:56
10516 #, no-wrap
10517 msgid ""
10518 "Repeat n times\n"
10519 " Flip the whole stack of n pancakes\n"
10520 " Flip the top (n-1) pancakes\n"
10521 msgstr ""
10522 "Repita n vezes\n"
10523 " vire a pilha toda de n panquecas\n"
10524 " Vire as (n-1) panquecas mais de cima\n"
10525
10526 #. type: Content of: <p>
10527 #: src/lessons/sort/pancake/CohenPancake.html:61
10528 msgid ""
10529 "It may sound somehow magic, but it actually works, as depicted on an example "
10530 "below."
10531 msgstr ""
10532 "Pode parecer mágica, mas funciona de verdade, como é mostrado no exemplo "
10533 "abaixo."
10534
10535 #. type: Content of: <p>
10536 #: src/lessons/sort/pancake/CohenPancake.html:65
10537 msgid ""
10538 "So, all in all, the Cohen algorithm manages to sort the stack of burnt "
10539 "pancakes in <i>2n</i> steps in all cases. Quite a win over the naive "
10540 "algorithm for burnt pancakes that requires <i>3n</i> steps."
10541 msgstr ""
10542 "Portanto, em todo caso, o algoritmo de Cohen trata de ordenar a pilha de "
10543 "panquecas queimadas em <i>2n</i> passos em todos os casos. Uma vitória sobre "
10544 "o algoritmo simplório para panquecas queimadas que precisa de <i>3n</i> "
10545 "passos."
10546
10547 #. type: Attribute 'alt' of: <p><div>
10548 #: src/lessons/sort/pancake/CohenPancake.html:68
10549 msgid "I cannot get it right."
10550 msgstr "Não entendi direito."
10551
10552 #. type: Content of: <p><div>
10553 #: src/lessons/sort/pancake/CohenPancake.html:69
10554 msgid ""
10555 "Don't worry. This exercise is very difficult, so it's ok if it does not work "
10556 "right away for you. Add some relevant logging to your code to understand "
10557 "where it stop performing correctly. Make sure to use the method "
10558 "<code>isSelected()</code> so that your logs only appears in the currently "
10559 "displayed world. In particular, it may help to print textually the state of "
10560 "the world each time you enter the main loop."
10561 msgstr ""
10562 "Não se preocupe. Este exercício é muito difícil, então tudo bem se não "
10563 "conseguir de primeira. Adicione alguns logs relevantes ao seu código para "
10564 "entender onde parou de funcionar corretamente. Certifique-se de usar o "
10565 "método <code>isSelected()</code> de forma que os seus logs apenas apareçam "
10566 "no mundo que estiver a ser exibido no momento. Em particular, pode ajudar se "
10567 "imprimir textualmente o estado do mundo cada vez que adentrar no loop "
10568 "principal."
10569
10570 #. type: Content of: <h1>
10571 #: src/lessons/sort/baseball/Main.html:2
10572 msgid "The Rainbow Baseball Game"
10573 msgstr "O jogo do basebal multicores"
10574
10575 #. type: Content of: <p>
10576 #: src/lessons/sort/baseball/Main.html:4
10577 msgid ""
10578 "This activity is inspired from the orange game, from the \"Computer Science "
10579 "Unplugged\" activities repository. It was however heavily since then, first "
10580 "for the CSIRL (my repository of <i>free</i> unplugged activities to "
10581 "introduce computer science, available at "
10582 "http://www.loria.fr/~quinson/Mediation/SMN/) and now for PLM."
10583 msgstr ""
10584 "Esta atividade é inspirada do jogo orange, do repositório de atividades "
10585 "\"Computer Science Unplugged\". Foi entretanto profundamente alterada, "
10586 "primeiro para o CSIRL (o meu repositório de atividades unplugged <i>livres</"
10587 "i> para introduzir a ciência da computação, disponível em http://www.loria."
10588 "fr/~quinson/Mediation/SMN/) e agora para o PLM."
10589
10590 #. type: Content of: <p>
10591 #: src/lessons/sort/baseball/Main.html:8
10592 msgid ""
10593 "In the literature, the generalized form of this problem is known as the "
10594 "pebble motion problem (the bases can be connected by any kind of graph, and "
10595 "the affinity of pebbles with bases may be different). Another variant of "
10596 "this problem is the well known 15-puzzle, with one player per base, and a "
10597 "two dimensional square grid. Much more information about these problems can "
10598 "be found on wikipedia, as usual."
10599 msgstr ""
10600 "Na literatura, a forma geral deste problema é conhecida como o \"Pebble "
10601 "motion problem\" (as bases podem ser conectadas por qualquer tipo de grafo e "
10602 "a afinidade das \"pebbles\" com bases pode ser diferente). Outra variante "
10603 "deste problema é o famoso jogo do 15, com um jogador por base e um tabuleiro "
10604 "quadrado bidimensional. Mais informações sobre estes problemas encontram-se "
10605 "na wikipédia em inglês, como sempre."
10606
10607 #. type: Content of: <h3>
10608 #: src/lessons/sort/baseball/Main.html:13
10609 msgid ""
10610 "How do you know that the naive algorithm won't loop on that initial "
10611 "situation?"
10612 msgstr ""
10613 "Como sabe que o algoritmo simplório não vai entrar em loop nesta situação "
10614 "inicial?"
10615
10616 #. type: Content of: <p>
10617 #: src/lessons/sort/baseball/Main.html:15
10618 msgid ""
10619 "Well, we simply tested all possible situations to see when this algorithm "
10620 "loops and when it finds the correct solution. We found that it works for all "
10621 "situations where no player is at home (there is 84 such situations for 4 "
10622 "bases, once you take the symmetries into account). It obviously works for "
10623 "some situations that do not respect this criteria (such as all situations it "
10624 "encounters from one of those 84 boards to the final state), but that's "
10625 "another story. Having such a criteria allows us to generate pseudo-random "
10626 "initial situations for the first exercise for which the algorithm we propose "
10627 "is guarenteed to work."
10628 msgstr ""
10629 "Bem, simplesmente testamos todas as situações possíveis para ver quando este "
10630 "algoritmo entra em loop e quando acha a solução correta. Verificamos que "
10631 "funciona em todas as situações onde nenhum jogador está na casa dele ("
10632 "existem 84 situações destas para 4 bases, a considerar as simetrias). "
10633 "Obviamente funciona para algumas situações que não respeitam este critério ("
10634 "como todas as situações que encontra desde uma dessas 84 bases até ao estado "
10635 "final), mas isto é outra história. Dado tal critério podemos gerar situações "
10636 "iniciais pseudo-aleatórias para o primeiro exercício para o qual o algoritmo "
10637 "que propomos com certeza funciona."
10638
10639 #. type: Content of: <p>
10640 #: src/lessons/sort/baseball/Main.html:22
10641 msgid ""
10642 "We also explored bigger instances of the problem, and unfortunately, we have "
10643 "no such criteria for them. With 5 bases, the algorithm wrongly loops for 24 "
10644 "of the 1824 possible boards where no player is home (that's 1.31%). With 6 "
10645 "bases, it fails on 1251 of the 58860 such boards (2.12%). With 7 bases, it "
10646 "fails for 84444 out of 2633940 (that's 3.2%). I am still looking for a "
10647 "criteria ensuring that the algorithm won't loop. If you discover one, please "
10648 "report it. Ideally, it would be simple to enforce manually so that we can "
10649 "use it during our unplugged activities."
10650 msgstr ""
10651 "Também exploramos instâncias maiores do problema e infelizmente, não temos "
10652 "tal critério para elas. Com 5 bases, o algoritmo entra em loop de forma "
10653 "errada para 24 dos 1824 possíveis tabuleiros onde nenhum jogador está na "
10654 "casa dele (que dá 1.31%). Com 6 bases, falha em 1251 dos 58860 tabuleiros (2"
10655 ".12%). Com 7 bases, falha em 84444 dos 2633940 (3.2%). Ainda estou à procura "
10656 "dum critério que garanta que o algoritmo não vai entrar em loop. Se "
10657 "descobrir um, por favor avise. Idealmente, deve ser simples garantir "
10658 "manualmente de forma que possamos usá-lo durante as nossas atividades "
10659 "\"unplugged\"."
10660
10661 #. type: Content of: <ul><li>
10662 #: src/lessons/sort/baseball/Main.html:32
10663 msgid ""
10664 "Other graphical representations could be proposed, such as a linear one (for "
10665 "the existing exercises) or other ones (such as a grid or a tree, if an "
10666 "exercise on this kind of graph proves interesting)."
10667 msgstr ""
10668 "Outras representações gráficas podem ser propostas, tais como uma linear ("
10669 "para os exercícios existentes) ou outros (como um grid ou uma árvore, se um "
10670 "exercício neste tipo de grafo se mostrar interessante)."
10671
10672 #. type: Content of: <ul><li>
10673 #: src/lessons/sort/baseball/Main.html:34
10674 msgid ""
10675 "Other exercises on other algorithms on this variant, or on other variants "
10676 "such as the 15-puzzle."
10677 msgstr ""
10678 "Outros exercícios em outros algoritmos desta variante, ou em outras "
10679 "variantes como o jogo do 15."
10680
10681 #. type: Content of: <h3>
10682 #: src/lessons/sort/baseball/short_desc.html:2
10683 msgid "Rainbow baseball"
10684 msgstr "basebal multicores"
10685
10686 #. type: Content of: <p>
10687 #: src/lessons/sort/baseball/short_desc.html:4
10688 msgid ""
10689 "This is another funny variation on the sorting problem, adapting the main "
10690 "sorting algorithms on an unusual context."
10691 msgstr ""
10692 "Este é outra variação divertida do problema da ordenação, a adaptar os "
10693 "pricipais algoritmos de ordenação num contexto inusitado."
10694
10695 #. type: Content of: <h1>
10696 #: src/lessons/sort/baseball/universe/BaseballWorld.html:2
10697 msgid "Rainbow Baseball"
10698 msgstr "Rainbow Baseball"
10699
10700 #. type: Content of: <p>
10701 #: src/lessons/sort/baseball/universe/BaseballWorld.html:3
10702 msgid ""
10703 "The colors are represented by integers, between <code>0</code> and "
10704 "<code>amount of bases -1</code>. The hole is represented by the special "
10705 "value <code>-1</code>. The color of each base is its rank. So base "
10706 "<code>1</code> is of color <code>1</code>. In the graphical interface, the "
10707 "base <code>0</code> is the dark blue one while the base <code>1</code> is "
10708 "the fuscia one."
10709 msgstr ""
10710 "As cores são representadas por inteiros, entre <code>0</code> e "
10711 "<code>quantidade de bases -1</code>. O espaço vazio é representado por um "
10712 "valor especial <code>-1</code>. A cor de cada base é o rank dela. Logo, a "
10713 "base <code>1</code> é de cor <code>1</code>. Na interface gráfica, a base "
10714 "<code>0</code> é a azul escura enquanto que a base <code>1</code> é a fuscia."
10715
10716 #. type: Content of: <p>
10717 #: src/lessons/sort/baseball/universe/BaseballWorld.html:9
10718 msgid ""
10719 "Once every players on the field are in their home base, the hole should be "
10720 "in the last base, that is of rank <code>getBasesAmount()-1</code>."
10721 msgstr ""
10722 "Uma vez que todos os jogadores no campo estejam nas bases deles, o espaço "
10723 "vazio deve estar na última base, ou seja, a de rank "
10724 "<code>getBasesAmount()-1</code>."
10725
10726 #. type: Content of: <h2>
10727 #: src/lessons/sort/baseball/universe/BaseballWorld.html:12
10728 msgid "Functions to retrieve the world's dimensions"
10729 msgstr "FFunções para recuperar as dimensões do mundo"
10730
10731 #. type: Content of: <pre>
10732 #: src/lessons/sort/baseball/universe/BaseballWorld.html:14
10733 #, no-wrap
10734 msgid "[!java|c]int [/!]getBasesAmount() [!scala]:Int[/!]"
10735 msgstr "[!java|c]int [/!]getBasesAmount() [!scala]:Int[/!]"
10736
10737 #. type: Content of: outside any tag (error?)
10738 #: src/lessons/sort/baseball/universe/BaseballWorld.html:15
10739 msgid "Returns the amount of bases on this field."
10740 msgstr "Retorna a quantidade de bases neste campo."
10741
10742 #. type: Content of: <pre>
10743 #: src/lessons/sort/baseball/universe/BaseballWorld.html:17
10744 #, no-wrap
10745 msgid "[!java|c]int [/!]getPositionsAmount() [!scala]:Int[/!]"
10746 msgstr "[!java|c]int [/!]getPositionsAmount() [!scala]:Int[/!]"
10747
10748 #. type: Content of: outside any tag (error?)
10749 #: src/lessons/sort/baseball/universe/BaseballWorld.html:18
10750 msgid "Returns the amount of player's positions per base on this field."
10751 msgstr "Retorna a quantidade de posições de jogadores por base neste campo."
10752
10753 #. type: Content of: <h2>
10754 #: src/lessons/sort/baseball/universe/BaseballWorld.html:20
10755 msgid "Functions to retrieve the world's state"
10756 msgstr "Funções para recuperar o estado do mundo"
10757
10758 #. type: Content of: <pre>
10759 #: src/lessons/sort/baseball/universe/BaseballWorld.html:22
10760 #, no-wrap
10761 msgid "[!java|c]int [/!]getHoleBase() [!scala]:Int[/!]"
10762 msgstr "[!java|c]int [/!]getHoleBase() [!scala]:Int[/!]"
10763
10764 #. type: Content of: outside any tag (error?)
10765 #: src/lessons/sort/baseball/universe/BaseballWorld.html:23
10766 msgid "Returns the base in which the hole is located."
10767 msgstr "Retorna a base na qual o espaço vazio está localizado."
10768
10769 #. type: Content of: <pre>
10770 #: src/lessons/sort/baseball/universe/BaseballWorld.html:25
10771 #, no-wrap
10772 msgid "[!java|c]int [/!]getHolePosition() [!scala]:Int[/!]"
10773 msgstr "[!java|c]int [/!]getHolePosition() [!scala]:Int[/!]"
10774
10775 #. type: Content of: outside any tag (error?)
10776 #: src/lessons/sort/baseball/universe/BaseballWorld.html:26
10777 msgid "Returns the hole position within its base"
10778 msgstr "Retorna a posição do espaço vazio na base dela"
10779
10780 #. type: Content of: <pre>
10781 #: src/lessons/sort/baseball/universe/BaseballWorld.html:28
10782 #, no-wrap
10783 msgid ""
10784 "[!java|c]int [/!]getPlayerColor([!java|c]int [/!]base[!scala]:Int[/!], "
10785 "[!java|c]int [/!]position[!scala]:Int[/!]) [!scala]:Int[/!]"
10786 msgstr ""
10787 "[!java|c]int [/!]getCorDoJogador([!java|c]int [/!]base[!scala]:Int[/!], "
10788 "[!java|c]int [/!]posição[!scala]:Int[/!]) [!scala]:Int[/!]"
10789
10790 #. type: Content of: outside any tag (error?)
10791 #: src/lessons/sort/baseball/universe/BaseballWorld.html:29
10792 msgid "Returns the color of the player at a given location."
10793 msgstr "Retorna a cor do jogador numa dada posição."
10794
10795 #. type: Content of: outside any tag (error?)
10796 #: src/lessons/sort/baseball/universe/BaseballWorld.html:32
10797 msgid "Returns whether all players of the field are at home."
10798 msgstr "Retorna se todos os jogadores em campo estão nos \"home\" deles."
10799
10800 #. type: Content of: <pre>
10801 #: src/lessons/sort/baseball/universe/BaseballWorld.html:34
10802 #, no-wrap
10803 msgid ""
10804 "[!java]boolean [/!][!c]int [/!]isBaseSorted([!java|c]int [/!]base) "
10805 "[!scala]:Boolean[/!]"
10806 msgstr ""
10807 "[!java]boolean [/!][!c]int [/!]baseEstáOrdenada([!java|c]int [/!]base) "
10808 "[!scala]:Boolean[/!]"
10809
10810 #. type: Content of: outside any tag (error?)
10811 #: src/lessons/sort/baseball/universe/BaseballWorld.html:35
10812 msgid "Returns whether all players of a given base are at home."
10813 msgstr "Retorna se todos os jogadores de uma dada base estão em \"home\"."
10814
10815 #. type: Content of: <h2>
10816 #: src/lessons/sort/baseball/universe/BaseballWorld.html:39
10817 msgid "Functions to change the world"
10818 msgstr "Funções para mudar o mundo"
10819
10820 #. type: Content of: <pre>
10821 #: src/lessons/sort/baseball/universe/BaseballWorld.html:41
10822 #, no-wrap
10823 msgid ""
10824 "[!java|c]void [/!]move([!java|c]int [/!]base[!scala]:Int[/!], [!java|c]int "
10825 "[/!]position[!scala]:Int[/!])"
10826 msgstr ""
10827 "[!java|c]void [/!]mover([!java|c]int [/!]base[!scala]:Int[/!], [!java|c]int "
10828 "[/!]posição[!scala]:Int[/!])"
10829
10830 #. type: Content of: outside any tag (error?)
10831 #: src/lessons/sort/baseball/universe/BaseballWorld.html:42
10832 msgid ""
10833 "Moves a given player into the hole. This throws an IllegalArgumentException "
10834 "if the specified player is not near the hole (at most one base away)."
10835 msgstr ""
10836 "Move um dado jogador para um espaço vazio. Vai levantar uma "
10837 "IllegalArgumentException se o jogador especificado não estiver próximo do "
10838 "espaço vazio (no máximo a uma base de distância)."
10839
10840 #. type: Content of: <h1>
10841 #: src/lessons/sort/baseball/NaiveBaseball.html:2
10842 msgid "Naive Rainbow Baseball"
10843 msgstr "Basebal do arco-íris simples"
10844
10845 #. type: Content of: <p>
10846 #: src/lessons/sort/baseball/NaiveBaseball.html:4
10847 msgid ""
10848 "Today, the buggles decided to play a baseball game, but they are rather out "
10849 "of luck, actually. First, kinda forgot the rules, and ... well ... they "
10850 "cannot find the ball and bats again. So they decided to \"adapt a bit\" the "
10851 "rules. As the are no ball, the buggles can only running around the field, "
10852 "what they do happily: for a while, all attending buggle run at full speed in "
10853 "all directions around the field."
10854 msgstr ""
10855 "Hoje os buggles decidiram jogar um jogo de basebal, mas eles estão sem muita "
10856 "sorte, na verdade. Primeiro, eles esqueceram-se das regras e... bem... eles "
10857 "não acharam as bolas e tacos de novo. Então eles decidiram adaptar um pouco "
10858 "as regras. Como eles não são bolas, tudo que podem fazer é correr ao redor "
10859 "do campo, o que fazem felizes da vida: Por um período, todos os buggles "
10860 "correram na máxima velocidade em todas as direções pelo campo."
10861
10862 #. type: Content of: <p>
10863 #: src/lessons/sort/baseball/NaiveBaseball.html:10
10864 msgid ""
10865 "But after a few collisions, they decide to invent new rules to organize a "
10866 "bit the game: They make one team per base and two players per team. One of "
10867 "the teams has only one player so that its base has an empty location. Then, "
10868 "the players are dispatched randomly around the bases, and the game for them "
10869 "is to reach their home base. The whole game stops when all players are "
10870 "home. There is no winning team: either all players win, or they all "
10871 "lose. Actually, this game is very different from the original baseball. The "
10872 "only rule that remains is that you can only run around the field, from one "
10873 "base to the next one, without crossing middle of the field."
10874 msgstr ""
10875 "Mas depois de algumas colisões eles decidiram inventar novas regras para "
10876 "organizar o jogo um pouco: eles fizeram um time por base e dois jogadores "
10877 "por time. Um dos times tem apenas um jogador de forma que a base deles tem "
10878 "uma vaga. Então, os jogadores são despachados aleatoriamente entre as bases "
10879 "e o jogo deles é encontrar a base de origem deles. O jogo como um todo para "
10880 "quando todos os jogadores estão nas bases de origem delws. Não existe um "
10881 "time vencedor: ou todo mundo ganha ou todo mundo perde. Na verdade, este "
10882 "jogo é muito diferente do baseball original. A única regra que sobrou é que "
10883 "só pode correr ao redor do campo, de uma base à próxima, sem cruzar o meio "
10884 "do campo."
10885
10886 #. type: Content of: <p>
10887 #: src/lessons/sort/baseball/NaiveBaseball.html:18
10888 msgid ""
10889 "Now, they are asking you to help them deciding who and when should move so "
10890 "that each player returns to its base. Only one buggle can move at each "
10891 "round, from its position to the empty spot. The maximal distance that a "
10892 "buggle can cover in one round is of one base."
10893 msgstr ""
10894 "Agora, eles estão a pedir-lhe que lhes ajude a decidir quem se deve mover de "
10895 "forma que cada jogador retorne à sua base de origem. Apenas um buggle pode "
10896 "se mover por rodada, da posição dele para um espaço vazio. A distância "
10897 "máxima que um buggle pode percorrer numa rodada é de uma base."
10898
10899 #. type: Content of: <p>
10900 #: src/lessons/sort/baseball/NaiveBaseball.html:22
10901 msgid ""
10902 "So, at each round, the empty spot is on one base (say <code>B</code>), and "
10903 "you should decide which buggle enters that empty spot. There is four "
10904 "candidates (two from base <code>B-1</code> and two from base "
10905 "<code>B+1</code>). Actually, there is a fifth candidate since the buggle "
10906 "that is on the same base than the empty spot can change its position, but "
10907 "that's not really helping."
10908 msgstr ""
10909 "Logo, em cada turno, o espaço vazio fica numa base (digamos <code>B</code>) "
10910 "e deve decidir que buggle vai entrar neste espaço vazio. Existem quatro "
10911 "candidatos (dois de base <code>B-1</code> e dois da base <code>B+1</code>). "
10912 "Na verdade, existe um quinto candidato pois o buggle que está na mesma base "
10913 "que o espaço vazio pode mudar de posição, mas isto não ajuda muito."
10914
10915 #. type: Content of: <h3>
10916 #: src/lessons/sort/baseball/NaiveBaseball.html:27
10917 msgid "The Naïve algorithm"
10918 msgstr "O algoritmo simplório"
10919
10920 #. type: Content of: <p>
10921 #: src/lessons/sort/baseball/NaiveBaseball.html:29
10922 msgid ""
10923 "In this exercise, we will first explore a very simple algorithm. To decide "
10924 "which of the four candidate buggles should enter the empty spot, we first "
10925 "restrict ourselves and decide that buggles can only turn clockwise. Then, "
10926 "from the two remaining candidates, we pick the one that has the largest "
10927 "distance to cover to reach its base (turning clockwise). Click on the demo "
10928 "button: this works rather well in practice."
10929 msgstr ""
10930 "Neste exercício, vamos primeiramente explorar um algoritmo muito simples. "
10931 "Para decidir qual dos quatro buggles candidatos deve entrar no espaço vazio, "
10932 "vamos primeiro nos restringir e decidir que os buggles só podem andar no "
10933 "sentido horário. Então, dos dois candidatos restantes, escolhemos o que tem "
10934 "a maior distância a percorrer para alcançar a base deles (no sentido horário)"
10935 ". Clique no botão demo: isto funciona melhor, na prática."
10936
10937 #. type: Content of: <p>
10938 #: src/lessons/sort/baseball/NaiveBaseball.html:35
10939 msgid ""
10940 "It's hard to find a simpler algorithm for this problem: While it's not "
10941 "sorted, search for the base containing the candidate buggles: if the hole is "
10942 "in base <code>B</code>, it's the base <code>B+1</code>, modulo the amount of "
10943 "bases. Then, compute the distance that each buggle of that base still has to "
10944 "run to reach its base (0 if it's already home). Once you found the buggle "
10945 "that should enter the empty spot, just use the <code>move</code> method on "
10946 "it, and iterate."
10947 msgstr ""
10948 "É difícil encontrar um algoritmo simples para este problema: Como não está "
10949 "ordenado, busque pela base a conter os buggles candidatos: se o vazio "
10950 "estiver na base <code>B</code>, será a base <code>B+1</code>, módulo a "
10951 "quantidade de bases. Então, calcule a distância que cada buggle daquela base "
10952 "ainda tem que andar para atingir a própria base (0 se já estiver na própria "
10953 "base). Uma vez que encontra o buggle que deve entrar no vazio, simplesmente "
10954 "use o método <code>move</code> nele e itere."
10955
10956 #. type: Content of: <p>
10957 #: src/lessons/sort/baseball/NaiveBaseball.html:41
10958 msgid ""
10959 "The main difficulty should be to get the few equations right: determining "
10960 "the base next to the hole should be easy, but determining the distance that "
10961 "a player has to cover may reveal a bit more challenging. Don't hesitate to "
10962 "draw pictures on a paper to cover all possible cases. It should not be that "
10963 "difficult either: there is not that many cases after all."
10964 msgstr ""
10965 "A principal dificuldade deve ser obter corretamente as poucas equações: "
10966 "determinar a base próxima do espaço vazio deve ser fácil, mas determinar a "
10967 "distância que um jogador tem que cobrir pode se revelar um pouco "
10968 "desafiadora. Não hesite em desenhar esboços num papel para cobrir todas as "
10969 "possibilidades. Não vai ser tão difícil no final das contas: não existem "
10970 "tantos casos assim."
10971
10972 #. type: Content of: <h1>
10973 #: src/lessons/sort/baseball/SelectBaseball.html:2
10974 msgid "Selection Baseball"
10975 msgstr "Selection Baseball"
10976
10977 #. type: Content of: <p>
10978 #: src/lessons/sort/baseball/SelectBaseball.html:4
10979 msgid ""
10980 "The previous algorithm is very pleasant: it's rather simple and rather fast "
10981 "to implement, but unfortunately, it is also rather wrong! In some cases, it "
10982 "never stops, which is obviously bad. If you don't believe it, just copy "
10983 "paste your previous code, and hit the run button. The first world of this "
10984 "exercise is one of these unfortunate situations that drives our previous "
10985 "algorithm crazy."
10986 msgstr ""
10987 "O algoritmo anterior é muito agradável: é muito simples e muito rápido de "
10988 "implementar, mas infelizmente, é também bastante errado! Em alguns casos, "
10989 "nunca para, o que é obviamente ruim. Se não acredita, simplesmente copie e "
10990 "cole o seu código anterior e aperte no botão executar. O primeiro mundo "
10991 "deste exercício é uma destas situações infelizes que deixam endoidar o "
10992 "algoritmo anterior."
10993
10994 #. type: Content of: <p>
10995 #: src/lessons/sort/baseball/SelectBaseball.html:10
10996 msgid ""
10997 "So we have to find another algorithm, preferably one that works in all "
10998 "cases."
10999 msgstr ""
11000 "Portanto temos que encontrar outro algoritmo, preferencialmente um que "
11001 "funcione em todos os casos."
11002
11003 #. type: Content of: <p>
11004 #: src/lessons/sort/baseball/SelectBaseball.html:12
11005 msgid ""
11006 "For that, the best solution is to start from a well known algorithm instead "
11007 "of trying to invent a new one from scratch as we just did. When you think a "
11008 "bit about this problem, this can is very similar to a sorting problem: Just "
11009 "make sure that the players are sorted by their colors and you're set. And "
11010 "while we are at it, let's generalize the game to allow more that 4 bases."
11011 msgstr ""
11012 "Para isto, a melhor solução é começar de um algoritmo bem conhecido ao invés "
11013 "de tentar inventar um novo do zero como fizemos. Quando pensa um pouco sobre "
11014 "este problema, ele pode ser muito similar a um problema de ordenação: apenas "
11015 "se certifique de que todos os jogadores estão ordenados pelas cores deles. E "
11016 "enquanto fazemos isto, vamos generalizar o jogo para poder ter mais de 4 "
11017 "bases."
11018
11019 #. type: Content of: <p>
11020 #: src/lessons/sort/baseball/SelectBaseball.html:18
11021 msgid ""
11022 "Let's adapt the selection sort to our situation. The big lines of the "
11023 "algorithm is then \"for each base, select the players that should occupy "
11024 "this base and make sure that they come to their position\". This way, we "
11025 "will grow an sorted area where all players are already sorted (and never "
11026 "changed) while the unsorted area shrinks."
11027 msgstr ""
11028 "Vamos adaptar o selection sort para nossa situação. As linhas grandes do "
11029 "algoritmo se tornam \"para cada base, selecione os jogadores que devem "
11030 "ocupar esta base e garanta que eles venham às posições deles\". Desta forma, "
11031 "vamos aumentar uma área ordenada onde todos os jogadores já estão ordenados ("
11032 "e nunca deixam de estar) enquanto a área não-ordenada se reduz."
11033
11034 #. type: Content of: <p>
11035 #: src/lessons/sort/baseball/SelectBaseball.html:24
11036 msgid ""
11037 "Selecting the player should be no problem; Do not hesitate to define some "
11038 "methods such as <code>findPlayer()</code> or "
11039 "<code>findPlayerBase()</code>. This will ensure that your code remains "
11040 "understandable."
11041 msgstr ""
11042 "Selecionar o jogador não deve ser um problema; Não hesite para definir "
11043 "alguns métodos como <code>findPlayer()</code> ou <code>findPlayerBase()</"
11044 "code>. Isto vai garantir que o seu código permaneça entendível."
11045
11046 #. type: Content of: <p>
11047 #: src/lessons/sort/baseball/SelectBaseball.html:28
11048 msgid ""
11049 "The most problematic aspect is to move the selected players into "
11050 "position. For that, you have to move the hole to the position where the "
11051 "player is, and then move both the player and the hole to the base that is "
11052 "next to the player's goal (probably in a loop), and finally put the player "
11053 "in the right position of its target base."
11054 msgstr ""
11055 "O aspeto mais problemático é mover os jogadores selecionados para as "
11056 "posições deles. Para isto, tem que mover o espaço vazio à posição onde o "
11057 "jogador está e depois mover ambos os jogadores e o espaço vazio à base que "
11058 "estiver próxima do objetivo do jogador (provavelmente com um loop) e "
11059 "finalmente pôr o jogador na posição correta da base favorita dele."
11060
11061 #. type: Content of: <p>
11062 #: src/lessons/sort/baseball/SelectBaseball.html:33
11063 msgid ""
11064 "As often in programming, the devil is in the details: there is a bunch of "
11065 "corner cases that you should detect and deal with correctly, such as the "
11066 "cases where the player is already in the base (but not in the position that "
11067 "you would like), or when the hole is on the right of the player (probably "
11068 "when you sort the first base). But you will find and hunt these while "
11069 "debugging your code."
11070 msgstr ""
11071 "Como é comum em programação, o diabo esconde-se nos detalhes: existe um "
11072 "conjunto de casos particulares que deve detetar e lidar corretamente, como "
11073 "os casos onde o jogador já está na base (mas não na posição que gostaria), "
11074 "ou quando o buraco está à direita do jogador (provavelmente quando ordena a "
11075 "primeira base). Mas vai caçar tais coisas enquanto depurar o seu código."
11076
11077 #. type: Content of: <h1>
11078 #: src/lessons/sort/baseball/InsertBaseball.html:2
11079 msgid "Insertion Baseball"
11080 msgstr "Insertion Baseball"
11081
11082 #. type: Content of: <p>
11083 #: src/lessons/sort/baseball/InsertBaseball.html:4
11084 msgid ""
11085 "The good point of adapting the selection sort to the baseball problem is "
11086 "that we know that it works (provided that our adaptation is correct). That's "
11087 "much better than the first naive algorithm, that was unable to converge to "
11088 "the solution in some situations. But actually, the selection sort is not "
11089 "perfect either as it requires a lot of swaps: we have to bring the hole to "
11090 "the selected player and then both the player and hole in position, and "
11091 "more. We can do better."
11092 msgstr ""
11093 "O aspeto bom de adaptar o selection sort para o problema do basebol é que "
11094 "sabemos que isto funciona (desde que a nossa adaptação esteja correta). O "
11095 "que é muito melhor que o nosso primeiro e simplório algoritmo, que é incapaz "
11096 "de convergir à solução em algumas situações. Mas, na verdade, o selection "
11097 "sort também não é perfeito, pois requer muitas trocas: temos que trazer o "
11098 "espaço vazio para e jogador selecionado e então levar o jogador e o espaço "
11099 "vazio à posição e mais. Podemos fazer melhor."
11100
11101 #. type: Content of: <p>
11102 #: src/lessons/sort/baseball/InsertBaseball.html:10
11103 msgid ""
11104 "For example, each player can run quite a long way from its initial position "
11105 "to its target solution. Instead, it may be more interesting to split the "
11106 "field in two parts: one on the left where all players are sorted relatively "
11107 "to each others, and one on the right where the players are still at their "
11108 "initial positions. Then, at each iteration, we take the player at the border "
11109 "between the sorted and unsorted areas (that is, the left-most player of the "
11110 "unsorted area) and move it to the left (within the sorted area) until it "
11111 "reaches its position (that is, until the position where it's bigger that its "
11112 "left neighbor). This would at least reduce the travel of players to the "
11113 "sorted area as we use the first one on the border."
11114 msgstr ""
11115 "Por exemplo, cada jogador pode correr por uma longa distância da posição "
11116 "inicial dele para o objetivo. Portanto, pode ser mais interessante dividir o "
11117 "campo em duas partes: uma à esquerda onde todos os jogadores estejam "
11118 "ordenados relativamente uns aos outros e outra à direita onde os jogadores "
11119 "ainda estejam nas posições iniciais deles. Então, em cada iteração, "
11120 "escolhemos o jogador na fronteira entre as áreas ordenada e não ordenada (ou "
11121 "sejam o jogador mais à esquerda da parte não ordenada) e moveremo-lo para a "
11122 "esquerda (dentro da parte ordenada) até que alcance a posição dele (ou seja, "
11123 "até a posição onde seja maior que o vizinho dele da esquerda). Isto pode, "
11124 "pelo menos, reduzir o trajeto dos jogadores à área ordenada já que usamos o "
11125 "mais perto da fronteira."
11126
11127 #. type: Content of: <p>
11128 #: src/lessons/sort/baseball/InsertBaseball.html:19
11129 msgid ""
11130 "Actually, that's exactly what an insertion sort would do: maintain a sorted "
11131 "area on the left, and put iteratively the player on the border to its "
11132 "position within the sorted area. This is good, as we know that our algorithm "
11133 "is not inherently flawed since we adapt a well known one."
11134 msgstr ""
11135 "Na verdade, é exatamente isto que o insertion sort deve fazer: manter uma "
11136 "área ordenada na esquerda e pôr iterativamente o jogador na fronteira com "
11137 "esta posição dentro da área ordenada. Isto é bom, já que sabemos que nosso "
11138 "algoritmo não é inerentemente \"flawed\" pois adaptamos um algoritmo bem "
11139 "conhecido."
11140
11141 #. type: Content of: <p>
11142 #: src/lessons/sort/baseball/InsertBaseball.html:23
11143 msgid ""
11144 "The easiest to adapt the insertion sort to the baseball problem is to "
11145 "consider all positions as adjacent and forget about bases. For that, we "
11146 "define the methods <code>getColor[!c]Insert[/!](pos)</code>, "
11147 "<code>move[!c]Insert[/!](pos)</code> and "
11148 "<code>getHole[!c]Insert[/!]()</code> that all use a unique integer to "
11149 "designate a given position. These functions simply convert between the way "
11150 "to specify a position and then call the usual functions to interact with the "
11151 "world. If you have an <code>index</code> and want to convert it into a "
11152 "<code>base,pos</code>, then <code>base=index/2</code> and "
11153 "<code>pos=index%2</code>. To compute the reverse, "
11154 "<code>index=base*2+pos</code> (this works because "
11155 "<code>getPositionsAmount()</code> always returns 2)."
11156 msgstr ""
11157 "O mais fácil de adaptar o insertion sort ao problema do basebol é considerar "
11158 "todas as posições como adjacentes e esquecer-se das bases. Para isto, "
11159 "definimos os métodos <code>getColor[!c]Insert[/!](pos)</code>, "
11160 "<code>move[!c]Insert[/!](pos)</code> e <code>getHole[!c]Insert[/!]()</code> "
11161 "que usam, todos, um único inteiro para designar uma dada posição. Estas "
11162 "funções simplesmente convertem a forma de especificar uma posição para em "
11163 "seguida chamar as funções usuais para interagir com o mundo. Se tem um "
11164 "<code>index</code> e quer convertê-lo a <code>base,pos</code>, para então a "
11165 "<code>base=index/2</code> e <code>pos=index%2</code>. Para calcular o "
11166 "reverso, <code>index=base*2+pos</code> (isto funciona, pois "
11167 "<code>getPositionsAmount()</code> sempre retorna 2)."
11168
11169 #. type: Content of: <p>
11170 #: src/lessons/sort/baseball/InsertBaseball.html:32
11171 msgid ""
11172 "For the algorithm itself, you should first move the hole to the position "
11173 "1. The position 0 is considered to be the sorted area (of size 1 for now) "
11174 "while the area above 2 is the unsorted area. Then comes an iteration to "
11175 "sort each element of the unsorted area. Since this iteration is a bit "
11176 "complex, you should think of its loop invariant, that is, the condition that "
11177 "is true before and after the loop and which explains that the loop fulfills "
11178 "its goal. Here, the loop invariant is twofold: First, the hole is between "
11179 "the sorted area and the unsorted area, and then, the every elements of the "
11180 "sorted area are ... well sorted relatively to their neighbors."
11181 msgstr ""
11182 "Para o algoritmo em si, deve primeiro mover o espaço vazio à posição 1. A "
11183 "posição 0 é considerada como a área ordenada (de tamanho 1 por enquanto) "
11184 "enquanto que a área acima de 2 é a área não-ordenada. Então fazemos uma "
11185 "iteração para ordenar cada elemento da área não-ordenada. Já que esta "
11186 "iteração é um pouco complexa, deve pensar no invariante dela do loop, ou "
11187 "seja, a condição que é verdadeira antes e depois do loop e que explica que o "
11188 "loop satisfaz o objetivo dele. Aqui, o invariante do loop é duplo: Primeiro, "
11189 "o espaço vazio está entre a área ordenada e a não-ordenada is between the "
11190 "sorted area and the unsorted area, and then, the every elements of the "
11191 "sorted area are ... well sorted relatively to their neighbors."
11192
11193 #. type: Content of: <p>
11194 #: src/lessons/sort/baseball/InsertBaseball.html:40
11195 msgid ""
11196 "Then, the loop body to sort an element should first descend the hole and the "
11197 "elements within the sorted area until the element is larger than the element "
11198 "before in the sorted area (2 moves per position to travel), and then move "
11199 "the hole back to its position between the sorted and unsorted areas (1 move "
11200 "per position)."
11201 msgstr ""
11202 "Então, o corpo do loop para ordenar um elemento deve primeiro empurrar para "
11203 "baixo o espaço vazio e os elementos dentro da área ordenada até que o "
11204 "elemento seja maior que o elemento que está depois na área ordenada (2 "
11205 "movimentos por posição para se mover) e então mover o espaço vazio de volta "
11206 "para sua posição entre as áreas ordenadas e não-ordenadas (1 movimento por "
11207 "posição)."
11208
11209 #. type: Content of: <p>
11210 #: src/lessons/sort/baseball/InsertBaseball.html:44
11211 msgid ""
11212 "Once you insert the last element within the sorted area, your whole set is "
11213 "sorted and you're done. I preserve the surprise of the border cases that "
11214 "will require some little adjustments to your algorithm to make it work "
11215 "properly :)"
11216 msgstr ""
11217 "Uma vez que insira o último elemento dentro da área ordenada, o seu conjunto "
11218 "como um todo estará ordenado e terá terminado. Vou deixar como surpresa os "
11219 "casos da fronteira que vão precisar de alguns pequenos ajustes no seu "
11220 "algoritmo para funcionar corretamente :)"
11221
11222 #. type: Content of: <h1>
11223 #: src/lessons/sort/baseball/BubbleBaseball.html:2
11224 msgid "Bubble Baseball"
11225 msgstr "Bubble Baseball"
11226
11227 #. type: Content of: <p>
11228 #: src/lessons/sort/baseball/BubbleBaseball.html:4
11229 msgid ""
11230 "Crap, we adapted the insertion sort because our selection sort required too "
11231 "much moves to get the selected players to their position, but the insertion "
11232 "sort requires an inordinate amount of changes to get the border elements to "
11233 "their position within the sorted area without mixing the already sorted "
11234 "elements. At the end of the day, our selection variant was more efficient "
11235 "with at most <code>3*amountOfBase</code> moves to sort one element (1 to get "
11236 "the hole alongside with the player, and 2 to get the hole+player in "
11237 "position) while our insertion variant requires at most "
11238 "<code>3*amountOfPlayers</code> to sort one element (2 to descend the hole "
11239 "and player in position, 1 to get the hole back to its position). That's "
11240 "twice as bad as there is two players per base. It may be possible to improve "
11241 "the insertion sort by moving by more than one element when descending, but "
11242 "it seems uneasy (at least, while not mixing the already sorted elements) and "
11243 "it would probably only ensure that our insertion variant becomes as "
11244 "efficient as our selection variant, not dramatically better."
11245 msgstr ""
11246 "Puxa, adaptamos o insertion sort por que o selection sort precisava de "
11247 "muitos movimentos para pôr os jogadores selecionados nas posições deles, mas "
11248 "o insertion sort necessita de uma quantidade estúpida de mudanças para "
11249 "alcançar os elementos de fronteira para as posições deles dentro da área "
11250 "ordenada sem bagunçar os elementos já ordenados. No final, a nossa variante "
11251 "\"selection\" era mais eficiente com pelo menos <code>3*amountOfBase</code> "
11252 "movimentos para ordenar um elemento (1 para alcançar o espaço vazio ao lado "
11253 "do jogador e 2 para pôr o espaço vazio e o jogador em posição) enquanto a "
11254 "nossa variante \"insertion\" precisa de no máximo <code>3*amountOfPlayers</"
11255 "code> para ordenar um elemento (2 para descer o espaço vazio e o jogador na "
11256 "posição, 1 para trazer o espaço vazio de volta para a posição dele). Isto é "
11257 "duas vezes pior que ter dois jogadores por base. Pode ser possível melhorar "
11258 "o insertion sort a mover mais que um elemento enquanto desce, mas parece "
11259 "difícil (pelo menos, enquanto não misturar os elementos já ordenados) e "
11260 "provavelmente isto apenas vai garantir que a nossa variante \"insertion\" se "
11261 "torne tão eficiente como a nossa variante \"selection\", não dramaticamente "
11262 "melhor."
11263
11264 #. type: Content of: <p>
11265 #: src/lessons/sort/baseball/BubbleBaseball.html:16
11266 msgid ""
11267 "If we cannot make the sort faster, we can make it easier. If you think about "
11268 "it, it seems rather natural to adapt the bubble sort to this problem: the "
11269 "hole becomes the bubble that moves up and down, sorting a bit the array "
11270 "during each traversal. The big lines are simply: \"while it's not sorted, "
11271 "move the hole down to base 0 (moving the biggest player of each base at each "
11272 "step) and then back to the maximal base (moving the smallest player of each "
11273 "base)\". After a while, <code>isSorted()</code> will return true and your "
11274 "algorithm will stop."
11275 msgstr ""
11276 "Se não pudermos tornar o ordenamento mais rápido, podemos torná-lo mais "
11277 "fácil. Se pensar a respeito, parece natural adaptar a ordenação bolha para "
11278 "este problema: o buraco se torna a bolha que se move para cima e para baixo, "
11279 "a ordenar um pouco o array a cada passagem. As linhas grandes são simples: "
11280 "\"enquanto (while) não estiver ordenado, mova o buraco para baixo até a base "
11281 "0 (a mover o maior jogador de cada base em cada passo) e então de volta à "
11282 "base maximal (a mover o menor jogador de cada base)\". Depois de algum "
11283 "tempo, <code>isSorted()</code> vai retornar true e o seu algoritmo vai parar."
11284
11285 #. type: Content of: <p>
11286 #: src/lessons/sort/baseball/BubbleBaseball.html:22
11287 msgid ""
11288 "This is so easy that we introduce another variant of the problem, with more "
11289 "than two players per base. But actually, that shouldn't block you very "
11290 "long, should it?"
11291 msgstr ""
11292 "Isto é tão fácil que vamos introduzir outra variante do problema, com mais "
11293 "de dois jogadores por base. Mas isto não vai te segurar por muito tempo, né?"
11294
11295 #. type: Content of: <p>
11296 #: src/lessons/sort/baseball/BubbleBaseball.html:25
11297 msgid ""
11298 "Surprisingly, the bubble sort variant requires ways less moves than the "
11299 "other variants. This is astonishing because usually, the bubble sort "
11300 "performs much worse than the others sorts, but it comes from the very good "
11301 "match between its big lines and the baseball universe. It actually happens "
11302 "rather often that a pleasantly written algorithm performs very decently. But "
11303 "this is not an universal rule either, as demonstrated by the naive algorithm "
11304 "of the first exercise, that was nice, simple and wrong ;)"
11305 msgstr ""
11306 "Surpreendentemente, a variante bubble sort precisa de menos movimentos que "
11307 "as outras variantes. Isto é fantástico, por que normalmente, o bubble sort é "
11308 "muito pior que os outros algoritmos, mas isto é graças à boa combinação "
11309 "entre as linhas grandes deles e o universo do basebol. E, na verdade, "
11310 "acontece bastante de um algoritmo escrito de forma agradável executa de "
11311 "forma bem decente. Mas isto não é uma regra universal, como foi demonstrado "
11312 "pelo algoritmo simplório do primeiro exercício, que era legal, simples e "
11313 "errado ;)"
11314
11315 #. type: Content of: <h1>
11316 #: src/plm/universe/turtles/TurtleWorld.html:2
11317 msgid "The universe of turtles"
11318 msgstr "O universo das tartarugas"
11319
11320 #. type: Content of: <p>
11321 #: src/plm/universe/turtles/TurtleWorld.html:4
11322 msgid "This is an adaptation of LOGO for the Programmer's Learning Machine."
11323 msgstr "Esta é uma adaptação do LOGO para o Programmer's Learning Machine."
11324
11325 #. type: Content of: <p>
11326 #: src/plm/universe/turtles/TurtleWorld.html:6
11327 msgid ""
11328 "It is directly inspired from the work of the mathematician Seymour Papert in "
11329 "the 60's. Inspired from the swiss psycholog Jean Piaget, he came up with a "
11330 "learning method called LOGO to teach programming to young childs. The world "
11331 "is full of turtles which leave a painting where they go and which respond to "
11332 "simple orders."
11333 msgstr ""
11334 "É diretamente inspirado no trabalho do matemático Seymour Papert nos anos "
11335 "60. Inspirado no psicólogo suíço Jean Piaget, apresentou um método de ensino "
11336 "chamado LOGO para ensinar programação para crianças pequenas. O mundo é "
11337 "cheio de tartarugas que deixam um rastro de tinta por onde passam e que "
11338 "obedecem a comandos simples."
11339
11340 #. type: Content of: <h2>
11341 #: src/plm/universe/turtles/TurtleWorld.html:12
11342 msgid "Functions to move the turtle"
11343 msgstr "Funções para mover a tartaruga"
11344
11345 #. type: Content of: <pre>
11346 #: src/plm/universe/turtles/TurtleWorld.html:14
11347 #, no-wrap
11348 msgid ""
11349 "[!java|c]void [/!]forward([!java|c]double [/!]steps[!scala]:Double[/!])\n"
11350 "[!java|c]void [/!]backward([!java|c]double [/!]steps[!scala]:Double[/!])"
11351 msgstr ""
11352 "[!java|c]void [/!]avançar([!java|c]double [/!]passos[!scala]:Double[/!])\n"
11353 "[!java|c]void [/!]recuar([!java|c]double [/!]passos[!scala]:Double[/!])"
11354
11355 #. type: Content of: outside any tag (error?)
11356 #: src/plm/universe/turtles/TurtleWorld.html:16
11357 msgid "Moves forward or backward of the requested amount of steps."
11358 msgstr "Move para frente e para trás na quantidade de passos pedidos."
11359
11360 #. type: Content of: <pre>
11361 #: src/plm/universe/turtles/TurtleWorld.html:18
11362 #, no-wrap
11363 msgid ""
11364 "[!java|c]void [/!]right([!java|c]double [/!]angle[!scala]:Double[/!])\n"
11365 "[!java|c]void [/!]left([!java|c]double [/!]angle[!scala]:Double[/!])"
11366 msgstr ""
11367 "[!java|c]void [/!]direita([!java|c]double [/!]ângulo[!scala]:Double[/!])\n"
11368 "[!java|c]void [/!]esquerda([!java|c]double [/!]ângulo[!scala]:Double[/!])"
11369
11370 #. type: Content of: outside any tag (error?)
11371 #: src/plm/universe/turtles/TurtleWorld.html:20
11372 msgid "Turns left or right of the given angle (in degrees)."
11373 msgstr "Vira à esquerda ou à direita um dado ângulo (em graus)."
11374
11375 #. type: Content of: <pre>
11376 #: src/plm/universe/turtles/TurtleWorld.html:22
11377 #: src/lessons/lander/universe/DelegatingLanderWorld.html:10
11378 #, no-wrap
11379 msgid ""
11380 "[!java|c]double [/!]getX()[!scala]:Double[/!]\n"
11381 "[!java|c]double [/!]getY()[!scala]:Double[/!]"
11382 msgstr ""
11383 "[!java|c]double [/!]getX()[!scala]:Double[/!]\n"
11384 "[!java|c]double [/!]getY()[!scala]:Double[/!]"
11385
11386 #. type: Content of: outside any tag (error?)
11387 #: src/plm/universe/turtles/TurtleWorld.html:24
11388 msgid ""
11389 "Returns the current position of the turtle. Note that the point (0,0) is on "
11390 "the top left corner, as it is often the case in Computer Science."
11391 msgstr ""
11392 "Retorna a posição atual da tartaruga. Observe que o ponto (0,0) está no "
11393 "canto superior esquerdo, como é comum na ciência da computação."
11394
11395 #. type: Content of: <pre>
11396 #: src/plm/universe/turtles/TurtleWorld.html:27
11397 #, no-wrap
11398 msgid ""
11399 "[!java|c]void [/!]setX([!java|c]double [/!]x[!scala]:Double[/!])\n"
11400 "[!java|c]void [/!]setY([!java|c]double [/!]y[!scala]:Double[/!])\n"
11401 "[!java|c]void [/!]setPos([!java|c]double [/!]x[!scala]:Double[/!], "
11402 "[!java|c]double [/!]y[!scala]:Double[/!])"
11403 msgstr ""
11404 "[!java|c]void [/!]setX([!java|c]double [/!]x[!scala]:Double[/!])\n"
11405 "[!java|c]void [/!]setY([!java|c]double [/!]y[!scala]:Double[/!])\n"
11406 "[!java|c]void [/!]setPos([!java|c]double [/!]x[!scala]:Double[/!], [!java|c]"
11407 "double [/!]y[!scala]:Double[/!])"
11408
11409 #. type: Content of: outside any tag (error?)
11410 #: src/plm/universe/turtles/TurtleWorld.html:30
11411 msgid "Teleports the turtle to a new position (without leaving any trace)."
11412 msgstr "Teletransporta a tartaruga para uma nova posição (sem deixar rastros)."
11413
11414 #. type: Content of: <pre>
11415 #: src/plm/universe/turtles/TurtleWorld.html:32
11416 #, no-wrap
11417 msgid ""
11418 "[!java|c]void [/!]moveTo([!java|c]double [/!]x[!scala]:Double[/!], "
11419 "[!java|c]double [/!]y[!scala]:Double[/!])"
11420 msgstr ""
11421 "[!java|c]void [/!]moverPara([!java|c]double [/!]x[!scala]:Double[/!], "
11422 "[!java|c]double [/!]y[!scala]:Double[/!])"
11423
11424 #. type: Content of: outside any tag (error?)
11425 #: src/plm/universe/turtles/TurtleWorld.html:33
11426 msgid "Moves the turtle to a new position."
11427 msgstr "Move a tartaruga para uma nova posição."
11428
11429 #. type: Content of: <pre>
11430 #: src/plm/universe/turtles/TurtleWorld.html:35
11431 #, no-wrap
11432 msgid "[!java|c]void [/!]circle([!java|c]double [/!]radius[!scala]:Double[/!])"
11433 msgstr "[!java|c]void [/!]círculo([!java|c]double [/!]raio[!scala]:Double[/!])"
11434
11435 #. type: Content of: outside any tag (error?)
11436 #: src/plm/universe/turtles/TurtleWorld.html:36
11437 msgid "Draw a circle of the specified radius centered on the turtle."
11438 msgstr "Desenha um círculo de raio especificado com o centro na tartaruga."
11439
11440 #. type: Content of: <pre>
11441 #: src/plm/universe/turtles/TurtleWorld.html:38
11442 #, no-wrap
11443 msgid "[!java|c]void [/!]hide()"
11444 msgstr "[!java|c]void [/!]hide()"
11445
11446 #. type: Content of: outside any tag (error?)
11447 #: src/plm/universe/turtles/TurtleWorld.html:39
11448 msgid "Hides the turtle."
11449 msgstr "Esconde a tartaruga."
11450
11451 #. type: Content of: <pre>
11452 #: src/plm/universe/turtles/TurtleWorld.html:41
11453 #, no-wrap
11454 msgid "[!java|c]void [/!]show()"
11455 msgstr "[!java|c]void [/!]show()"
11456
11457 #. type: Content of: outside any tag (error?)
11458 #: src/plm/universe/turtles/TurtleWorld.html:42
11459 msgid "Shows the turtle back."
11460 msgstr "Mostra novamente a tartaruga."
11461
11462 #. type: Content of: <pre>
11463 #: src/plm/universe/turtles/TurtleWorld.html:44
11464 #, no-wrap
11465 msgid "[!java]boolean [/!][!c]int [/!]isVisible()[!scala]:Boolean[/!]"
11466 msgstr "[!java]boolean [/!][!c]int [/!]isVisible()[!scala]:Boolean[/!]"
11467
11468 #. type: Content of: outside any tag (error?)
11469 #: src/plm/universe/turtles/TurtleWorld.html:45
11470 msgid "Returns whether the turtle is currently visible."
11471 msgstr "Retorna se a tartaruga é visível ou não."
11472
11473 #. type: Content of: <pre>
11474 #: src/plm/universe/turtles/TurtleWorld.html:47
11475 #, no-wrap
11476 msgid "[!java|c]void [/!]clear()"
11477 msgstr "[!java|c]void [/!]clear()"
11478
11479 #. type: Content of: outside any tag (error?)
11480 #: src/plm/universe/turtles/TurtleWorld.html:48
11481 msgid "Removes any trail on the sheet."
11482 msgstr "Remove todos os rastros do papel."
11483
11484 #. type: Content of: <pre>
11485 #: src/plm/universe/turtles/TurtleWorld.html:50
11486 #, no-wrap
11487 msgid "[!java|c]double [/!]getHeading()[!scala]:Double[/!]"
11488 msgstr "[!java|c]double [/!]getHeading()[!scala]:Double[/!]"
11489
11490 #. type: Content of: outside any tag (error?)
11491 #: src/plm/universe/turtles/TurtleWorld.html:51
11492 msgid "Returns the current heading of the turtle (in degrees)."
11493 msgstr "Retorna a direção atual da tartaruga (em graus)."
11494
11495 #. type: Content of: <pre>
11496 #: src/plm/universe/turtles/TurtleWorld.html:53
11497 #, no-wrap
11498 msgid "[!java|c]void [/!]setHeading([!java|c]double [/!]angle[!scala]:Double[/!])"
11499 msgstr ""
11500 "[!java|c]void [/!]setDireção([!java|c]double [/!]ângulo[!scala]:Double[/!])"
11501
11502 #. type: Content of: outside any tag (error?)
11503 #: src/plm/universe/turtles/TurtleWorld.html:54
11504 msgid "Sets a new heading to the turtle (in degrees)."
11505 msgstr "Ajusta uma nova direção para a tartaruga (em graus)."
11506
11507 #. type: Content of: <h2>
11508 #: src/plm/universe/turtles/TurtleWorld.html:56
11509 msgid "Functions about the pen"
11510 msgstr "Funções da caneta"
11511
11512 #. type: Content of: <pre>
11513 #: src/plm/universe/turtles/TurtleWorld.html:58
11514 #, no-wrap
11515 msgid "[!java|c]void [/!]penUp()"
11516 msgstr "[!java|c]void [/!]penUp()"
11517
11518 #. type: Content of: outside any tag (error?)
11519 #: src/plm/universe/turtles/TurtleWorld.html:59
11520 msgid ""
11521 "Moves the pen up (turtles have pens, not brushes as buggles). The turtle "
11522 "will not leave any trace during its subsequent moves."
11523 msgstr ""
11524 "Levanta a caneta (tartarugas têm canetas, não pinceis, como os buggles). A "
11525 "tartaruga não vai deixar nenhum rastro durante os seus passos seguintes."
11526
11527 #. type: Content of: <pre>
11528 #: src/plm/universe/turtles/TurtleWorld.html:62
11529 #, no-wrap
11530 msgid "[!java|c]void [/!]penDown()"
11531 msgstr "[!java|c]void [/!]penDown()"
11532
11533 #. type: Content of: outside any tag (error?)
11534 #: src/plm/universe/turtles/TurtleWorld.html:63
11535 msgid ""
11536 "Moves the pen down. The turtle will leave a trace during its subsequent "
11537 "moves."
11538 msgstr ""
11539 "Abaixa a caneta. A tartaruga vai deixar um rastro nos próximos movimentos."
11540
11541 #. type: Content of: <pre>
11542 #: src/plm/universe/turtles/TurtleWorld.html:65
11543 #, no-wrap
11544 msgid "[!java]boolean [/!][!c]int [/!]isPenDown()[!scala]:Boolean[/!]"
11545 msgstr "[!java]boolean [/!][!c]int [/!]isPenDown()[!scala]:Boolean[/!]"
11546
11547 #. type: Content of: outside any tag (error?)
11548 #: src/plm/universe/turtles/TurtleWorld.html:66
11549 msgid "Returns the current pen position as a boolean."
11550 msgstr "Retorna a posição atual da caneta como um booleano."
11551
11552 #. type: Content of: <pre>
11553 #: src/plm/universe/turtles/TurtleWorld.html:68
11554 #, no-wrap
11555 msgid "[!java|c]Color [/!]getColor()[!scala]:Color[/!]"
11556 msgstr "[!java|c]Color [/!]getColor()[!scala]:Color[/!]"
11557
11558 #. type: Content of: outside any tag (error?)
11559 #: src/plm/universe/turtles/TurtleWorld.html:69
11560 msgid "Returns the current pen color."
11561 msgstr "Retorna a cor atual da caneta."
11562
11563 #. type: Content of: <pre>
11564 #: src/plm/universe/turtles/TurtleWorld.html:71
11565 #, no-wrap
11566 msgid "[!java|c]void [/!]setColor([!java|c]Color [/!]color[!scala]:Color[/!])"
11567 msgstr "[!java|c]void [/!]setCor([!java|c]Cor [/!]cor[!scala]:Cor[/!])"
11568
11569 #. type: Content of: outside any tag (error?)
11570 #: src/plm/universe/turtles/TurtleWorld.html:72
11571 msgid "Changes the pen color."
11572 msgstr "Muda a cor da caneta."
11573
11574 #. type: Content of: <h2>
11575 #: src/plm/universe/turtles/TurtleWorld.html:74
11576 msgid "Other functions"
11577 msgstr "Outras funções"
11578
11579 #. type: Content of: outside any tag (error?)
11580 #: src/plm/universe/turtles/TurtleWorld.html:77
11581 msgid "Returns whether the current turtle is selected in the graphical interface."
11582 msgstr "Retorna se a tartaruga atual está selecionada na interface gráfica."
11583
11584 #. type: Content of: <h3>
11585 #: src/lessons/turtleart/Main.html:2 src/lessons/turtleart/short_desc.html:2
11586 msgid "Turtle Art"
11587 msgstr "Turtle Art"
11588
11589 #. type: Content of: <p>
11590 #: src/lessons/turtleart/Main.html:4
11591 msgid ""
11592 "Since its inception in the 60's, the LOGO turtle fascinates by its ability "
11593 "to draw nice figures on computer. This lesson allows you to explore some of "
11594 "the classical figures, and draw your own."
11595 msgstr ""
11596 "Desde a concepção dela nos anos 60, a tartaruga do LOGO fascinou pela "
11597 "habilidade dela de desenhar belas figuras no computador. Este lição permite "
11598 "que explore algumas das figuras clássicas e desenhe as suas próprias."
11599
11600 #. type: Content of: <p>
11601 #: src/lessons/turtleart/Main.html:7
11602 msgid ""
11603 "The language's syntax is absolutely not presented, but if you know a bit of "
11604 "it or if someone tells you, you can take these exercises even if you are an "
11605 "absolute beginner in programming."
11606 msgstr ""
11607 "A sintaxe da linguagem é não vai ser apresentada, mas se conhece um pouco ou "
11608 "se alguém lhe mostrar, pode tentar estes exercícios mesmo a ser um completo "
11609 "iniciante em programação."
11610
11611 #. type: Content of: <p>
11612 #: src/lessons/turtleart/Main.html:10
11613 msgid ""
11614 "Please send us your best contributions so that they get added to this "
11615 "gallery to inspire the next ones."
11616 msgstr ""
11617 "Por favor mande-nos as suas melhores contribuições para que sejam "
11618 "adicionadas a esta galeria para inspirar os próximos utilizadores."
11619
11620 #. type: Content of: <ul><li>
11621 #: src/lessons/turtleart/Main.html:16
11622 msgid ""
11623 "Other exercises should be added. A whole lot of exercises are available from "
11624 "<a "
11625 "href=\"http://neoparaiso.com/logo/#sect4\">http://neoparaiso.com/logo/#sect4</a> "
11626 "or from <a "
11627 "href=\"http://billkerr2.blogspot.fr/2009/08/40-maths-shapes-challenges.html.\">http://billkerr2.blogspot.fr/2009/08/40-maths-shapes-challenges.html</a>."
11628 msgstr ""
11629 "Outros exercícios devem ser adicionados. Um conjunto completo de exercícios "
11630 "está disponível em <a href=\"http://neoparaiso.com/logo/#sect4\""
11631 ">http://neoparaiso.com/logo/#sect4</a> ou em <a href=\"http://billkerr2."
11632 "blogspot.fr/2009/08/40-maths-shapes-challenges.html.\">http://billkerr2."
11633 "blogspot.fr/2009/08/40-maths-shapes-challenges.html</a>."
11634
11635 #. type: Content of: <ul><li>
11636 #: src/lessons/turtleart/Main.html:19
11637 msgid ""
11638 "Missing: the built-ins arc() and arcTo(), that draw an arc, either w/o "
11639 "moving or by moving to the end of the arc."
11640 msgstr ""
11641 "A faltar: os built-ins arc() e arcTo(), que desenham um arco, tanto a mover "
11642 "ou sem mover para o final do arco."
11643
11644 #. type: Content of: <p>
11645 #: src/lessons/turtleart/short_desc.html:3
11646 msgid ""
11647 "Draw beautiful figures with the Logo turtle, and learn programming while "
11648 "playing."
11649 msgstr ""
11650 "Desenhe belas figuras com a tartaruga do Logo e aprenda a programar enquanto "
11651 "brinca."
11652
11653 #. type: Content of: <p>
11654 #: src/lessons/turtleart/short_desc.html:6
11655 msgid ""
11656 "You should know the basic syntax of the programming language you will "
11657 "choose, but no exhaustive programming practice is required to take this "
11658 "lesson."
11659 msgstr ""
11660 "Deve saber a sintaxe básica da linguagem de programação que escolher, mas "
11661 "técnicas avançadas de programação não são necessárias para fazer esta lição."
11662
11663 #. type: Content of: <h1>
11664 #: src/lessons/recursion/cons/universe/ConsWorld.html:2
11665 msgid "ConsWorld"
11666 msgstr "ConsWorld"
11667
11668 #. type: Content of: <p>
11669 #: src/lessons/recursion/cons/universe/ConsWorld.html:4
11670 msgid ""
11671 "This world allows you to experiment with the recursive lists, as they were "
11672 "first introduced in Lisp. It is very similar to the BatWorld, but you are "
11673 "supposed to write recursive functions working on [!python|java]recursive "
11674 "strings. Since [!thelang] does not provide such a construct natively, the "
11675 "ConsWorld defines recursive lists of type <code>RecList</code>.[/!] "
11676 "[!scala]lists of integers (<code>List[Int]</code>).[/!]"
11677 msgstr ""
11678 "Este mundo permite que experimente com listas recursivas, pois foi "
11679 "introduzido primeiro em Lisp. É muito similar ao BatWorld, mas deve escrever "
11680 "funções recursivas que funcionem em [!python|java]cadeias recursivas. Desde "
11681 "que [!thelang] não fornece tal contrução nativamente, o ConsWorld define "
11682 "listas recursivas do tipo <code>RecList</code>.[/!] [!scala]listas de "
11683 "inteiros (<code>List[Int]</code>).[/!]"
11684
11685 #. type: Content of: <p>
11686 #: src/lessons/recursion/cons/universe/ConsWorld.html:12
11687 msgid ""
11688 "Any given such list is either the empty list (noted "
11689 "<code>[!scala]Nil[/!][!java]null[/!][!python]None[/!]</code>), or an integer "
11690 "followed by a list. If a list is not empty, you can retrieve its first "
11691 "integer with <code>list.head</code> and the list containing its other "
11692 "parameters with <code>list.tail</code>. Of course, the empty list has no "
11693 "head nor the tail, so trying to access these elements will result in an "
11694 "(unpleasant) error message."
11695 msgstr ""
11696 "Qualquer lista dada é ou a lista vazia (noted "
11697 "<code>[!scala]Nil[/!][!java]null[/!][!python]None[/!]</code>), ou um inteiro "
11698 "seguido de uma lista. Se uma lista não é vazia, pode recuperar o primeiro "
11699 "inteiro dela com <code>list.head</code> e a lista a conter os demais "
11700 "parâmetros com <code>list.tail</code>. Obviamente, a lista vazia não tem "
11701 "head nem tail, portanto, tentar acessar estes elementos vai resultar numa "
11702 "mensagem de erro (desagradável)."
11703
11704 #. type: Content of: <p>
11705 #: src/lessons/recursion/cons/universe/ConsWorld.html:20
11706 msgid ""
11707 "To build your own list, you need to concatenate a head and a tail as "
11708 "follows: [!java|python]<code>cons(head, tail)</code>[/!] "
11709 "[!scala]<code>head::tail</code> Note that <code>::</code> is a generic "
11710 "operator in Scala to build lists.[/!]"
11711 msgstr ""
11712 "Para construir a sua própria lista, precisa concatenar um head e um tail "
11713 "como segue: [!java|python]<code>cons(head, tail)</code>[/!] "
11714 "[!scala]<code>head::tail</code> Observe que <code>::</code> é um operador "
11715 "genérico em Scala para construir listas.[/!]"
11716
11717 #. type: Content of: <p>
11718 #: src/lessons/recursion/cons/universe/ConsWorld.html:26
11719 msgid ""
11720 "So, in summary, you can solve every exercises of this lesson with the "
11721 "following constructs."
11722 msgstr ""
11723 "Logo, a resumir, pode resolver cada exercício desta lição com as seguintes "
11724 "construções."
11725
11726 #. type: Content of: <ul><li>
11727 #: src/lessons/recursion/cons/universe/ConsWorld.html:30
11728 msgid "<b>The empty list:</b>"
11729 msgstr "<b>A lista vazia:</b>"
11730
11731 #. type: Content of: <ul><li><pre>
11732 #: src/lessons/recursion/cons/universe/ConsWorld.html:30
11733 #, no-wrap
11734 msgid "[!java]null[/!][!scala]Nil[/!][!python]None[/!]"
11735 msgstr "[!java]null[/!][!scala]Nil[/!][!python]None[/!]"
11736
11737 #. type: Content of: <ul><li>
11738 #: src/lessons/recursion/cons/universe/ConsWorld.html:31
11739 msgid "<b>Get the first element of <code>l</code></b>"
11740 msgstr "<b>Obtém o primeiro elemento de <code>l</code></b>"
11741
11742 #. type: Content of: <ul><li><pre>
11743 #: src/lessons/recursion/cons/universe/ConsWorld.html:31
11744 #, no-wrap
11745 msgid "l.head"
11746 msgstr "l.head"
11747
11748 #. type: Content of: <ul><li>
11749 #: src/lessons/recursion/cons/universe/ConsWorld.html:32
11750 msgid "<b>Get the rest of the list</b>, when the first element is removed:"
11751 msgstr "<b>Obtém o resto da lista</b>, quando o primeiro elemento é removido:"
11752
11753 #. type: Content of: <ul><li><pre>
11754 #: src/lessons/recursion/cons/universe/ConsWorld.html:32
11755 #, no-wrap
11756 msgid "l.tail"
11757 msgstr "l.tail"
11758
11759 #. type: Content of: <ul><li>
11760 #: src/lessons/recursion/cons/universe/ConsWorld.html:33
11761 msgid ""
11762 "<b>Build a list</b> from a <code>value</code> and a <code>list</code>: "
11763 "[!java|python]"
11764 msgstr ""
11765 "<b>Constrói uma lista</b> a partir de um <code>valor</code> e uma "
11766 "<code>lista</code>: [!java|python]"
11767
11768 #. type: Content of: <ul><li><pre>
11769 #: src/lessons/recursion/cons/universe/ConsWorld.html:34
11770 #, no-wrap
11771 msgid "cons(value, list)"
11772 msgstr "cons(value, list)"
11773
11774 #. type: Content of: <ul><li><pre>
11775 #: src/lessons/recursion/cons/universe/ConsWorld.html:35
11776 #, no-wrap
11777 msgid "value::list"
11778 msgstr "value::list"
11779
11780 #. type: Content of: <h1>
11781 #: src/lessons/recursion/cons/Main.html:2
11782 msgid "Recursive Lists"
11783 msgstr "Listas Recursivas"
11784
11785 #. type: Content of: <p>
11786 #: src/lessons/recursion/cons/Main.html:3
11787 msgid ""
11788 "This lesson contains a bunch of classical exercises on recursive lists. It "
11789 "is certainly not the most pleasant lesson to do, but I think that it is the "
11790 "easiest of the PLM lessons dealing with recursion."
11791 msgstr ""
11792 "Esta lição contém um monte de exercícios clássicos com listas recursivas. "
11793 "Com certeza não é a lição mais agradável para fazer, mas das lições do PLM "
11794 "que lidam com recursão, acho esta a mais fácil."
11795
11796 #. type: Content of: <ul><li>
11797 #: src/lessons/recursion/cons/Main.html:10
11798 msgid ""
11799 "New exercises could be proposed, such as "
11800 "http://webloria.loria.fr/~quinson/Teaching/TOP/02-td-recursivite-enonce.pdf "
11801 "If you know some others, please report them as an issue."
11802 msgstr ""
11803 "Novos exercícios podem ser propostos, como http://webloria.loria.fr/~quinson/"
11804 "Teaching/TOP/02-td-recursivite-enonce.pdf. Se conhecer outros, por favor "
11805 "abra uma \"issue\" para relatar."
11806
11807 #. type: Content of: <ul><li>
11808 #: src/lessons/recursion/cons/Main.html:13
11809 msgid ""
11810 "It would be interesting to check the asymptotic complexity of the student's "
11811 "code, but that does not sound easy to do. In Python and Java (where we "
11812 "provide a hand-made RecList class), we could count the amount of cons per "
11813 "exercise, but it won't be easy to relate this to the right BatTest. For "
11814 "Scala, it sounds even more difficult as we use the classical :: operators of "
11815 "the language. That will be difficult to override to add a counting "
11816 "mechanism. Another solution would be to ensure that the call stack does not "
11817 "pass a given threshold, but that sounds very difficult too. Any idea is "
11818 "welcome."
11819 msgstr ""
11820 "Pode ser interessante verificar a complexidade assintótica do código do "
11821 "estudante, mas isto não parece fácil de fazer. Em Python e Java (onde "
11822 "fornecemos uma classe RecList feita à mão), podemos contar a quantidade de "
11823 "cons por exercício, mas não é fácil relacionar isto ao BatTest correto. Para "
11824 "Scala, parece ainda mais difícil, pois usamos os operadores :: clássicos da "
11825 "linguagem. Vai ser difícil fazer uma sobreposição (\"override\") para "
11826 "adicionar um mecanismo de contagem. Outra solução seria garantir que a pilha "
11827 "de chamadas não passe de um dado limiar, mas parece muito difícil de fazer "
11828 "também. Quaisquer ideias são bem-vindas."
11829
11830 #. type: Content of: <h1>
11831 #: src/lessons/recursion/cons/Length.html:2
11832 msgid "Length"
11833 msgstr "Comprimento"
11834
11835 #. type: Content of: outside any tag (error?)
11836 #: src/lessons/recursion/cons/Length.html:3
11837 msgid ""
11838 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return its "
11839 "length[!scala] (without using its <code>size</code> method, of course)[/!]. "
11840 "[!java|python]"
11841 msgstr ""
11842 "Dada uma [!scala]Lista[Int][/!][!java|python]lista recursiva[/!], retorna o "
11843 "comprimento dele[!scala] (sem usar o método <code>size</code> dele, "
11844 "claro)[/!]. [!java|python]"
11845
11846 #. type: Content of: <p>
11847 #: src/lessons/recursion/cons/Length.html:5
11848 msgid ""
11849 "[!python]Be careful, you are not supposed to use the Python lists, but the "
11850 "specific type defined in this exercise. [/!] Please refer to the world's "
11851 "documentation for more information about recursive lists."
11852 msgstr ""
11853 "[!python]Cuidado, não pode usar listas de Python, mas sim o tipo específico "
11854 "definido neste exercício. [/!] favor ver a documentação do mundo para mais "
11855 "informações a respeito de listas recursivas."
11856
11857 #. type: Content of: <p>
11858 #: src/lessons/recursion/cons/Length.html:10
11859 #: src/lessons/recursion/cons/IsMember.html:7
11860 #: src/lessons/recursion/cons/Occurrence.html:7
11861 #: src/lessons/recursion/cons/Last.html:6 src/lessons/recursion/cons/Min.html:6
11862 #: src/lessons/recursion/cons/Increasing.html:6
11863 #: src/lessons/recursion/cons/ButLast.html:6
11864 #: src/lessons/recursion/cons/PlusOne.html:5
11865 #: src/lessons/recursion/cons/Remove.html:9
11866 #: src/lessons/recursion/cons/ButNfirst.html:6
11867 msgid "Your solution should be linear in time."
11868 msgstr "A sua solução deve ser linear no tempo."
11869
11870 #. type: Content of: <h1>
11871 #: src/lessons/recursion/cons/IsMember.html:2
11872 msgid "IsMember"
11873 msgstr "IsMember"
11874
11875 #. type: Content of: outside any tag (error?)
11876 #: src/lessons/recursion/cons/IsMember.html:3
11877 msgid ""
11878 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an "
11879 "integer, return true if the given integer is one of the elements of the "
11880 "list, or false if it cannot be found."
11881 msgstr ""
11882 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro, "
11883 "retorna true se o dado inteiro é um dos elementos desta lista, ou false se "
11884 "não for encontrado."
11885
11886 #. type: Content of: <h1>
11887 #: src/lessons/recursion/cons/Occurrence.html:2
11888 msgid "Occurrences"
11889 msgstr "Occurrences"
11890
11891 #. type: Content of: outside any tag (error?)
11892 #: src/lessons/recursion/cons/Occurrence.html:3
11893 msgid ""
11894 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an "
11895 "integer, return the amount of occurrences of the given integer in the "
11896 "list. If the integer is not a member of the list, the function should thus "
11897 "return 0."
11898 msgstr ""
11899 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro, "
11900 "retorna a quantidade de ocorrências de um dado inteiro na lista. Se o "
11901 "inteiro não for um membro da lista, a função deve retornar 0."
11902
11903 #. type: Content of: <h1>
11904 #: src/lessons/recursion/cons/Last.html:2
11905 msgid "Last"
11906 msgstr "Last"
11907
11908 #. type: Content of: outside any tag (error?)
11909 #: src/lessons/recursion/cons/Last.html:3
11910 msgid ""
11911 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return its "
11912 "last element. You can assume that the list is not empty."
11913 msgstr ""
11914 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna o "
11915 "último elemento dela. Pode assumir que a lista não é vazia."
11916
11917 #. type: Content of: <h1>
11918 #: src/lessons/recursion/cons/Min.html:2
11919 msgid "Min"
11920 msgstr "Min"
11921
11922 #. type: Content of: outside any tag (error?)
11923 #: src/lessons/recursion/cons/Min.html:3
11924 msgid ""
11925 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return the "
11926 "smallest of its values. You will probably need an extra function, even if "
11927 "you can assume that the list is not empty."
11928 msgstr ""
11929 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna o "
11930 "menor dos seus valores. Vai precisar provavelmente de uma função adicional, "
11931 "mesmo se puder assumir que a lista é não vazia."
11932
11933 #. type: Content of: <h1>
11934 #: src/lessons/recursion/cons/Increasing.html:2
11935 msgid "Increasing"
11936 msgstr "Increasing"
11937
11938 #. type: Content of: outside any tag (error?)
11939 #: src/lessons/recursion/cons/Increasing.html:3
11940 msgid ""
11941 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return "
11942 "whether its elements form an increasing sequence (i.e., if the elements are "
11943 "sorted from the smallest to the largest one)."
11944 msgstr ""
11945 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna se "
11946 "os elementos dela estão em ordem crescente (p.ex., se os elementos são "
11947 "ordenados do menor ao maior)."
11948
11949 #. type: Content of: <h1>
11950 #: src/lessons/recursion/cons/ButLast.html:2
11951 msgid "But Last"
11952 msgstr "But Last"
11953
11954 #. type: Content of: outside any tag (error?)
11955 #: src/lessons/recursion/cons/ButLast.html:3
11956 msgid ""
11957 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return the "
11958 "list containing every elements but the last one. You can assume that the "
11959 "list is not empty."
11960 msgstr ""
11961 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna a "
11962 "lista a conter todos os elementos exceto o último. Pode assumir que a lista "
11963 "é não vazia."
11964
11965 #. type: Content of: <h1>
11966 #: src/lessons/recursion/cons/PlusOne.html:2
11967 msgid "PlusOne"
11968 msgstr "PlusOne"
11969
11970 #. type: Content of: outside any tag (error?)
11971 #: src/lessons/recursion/cons/PlusOne.html:3
11972 msgid ""
11973 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return a new "
11974 "list containing all elements of your parameter incremented by one."
11975 msgstr ""
11976 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorne uma "
11977 "nova lista a conter todos os elementos do seu parâmetro incrementados de um."
11978
11979 #. type: Content of: <h1>
11980 #: src/lessons/recursion/cons/Remove.html:2
11981 msgid "Remove"
11982 msgstr "Remove"
11983
11984 #. type: Content of: outside any tag (error?)
11985 #: src/lessons/recursion/cons/Remove.html:4
11986 msgid ""
11987 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] "
11988 "<code>L</code>and an integer, return a new list containing all elements of "
11989 "<code>L</code> that are not equal to the value received as parameter."
11990 msgstr ""
11991 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] <code>L</"
11992 "code> e um inteiro, retorna uma nova lista a conter todos os elementos de "
11993 "<code>L</code> que não são iguais ao valor recebido como parâmetro."
11994
11995 #. type: Content of: <h1>
11996 #: src/lessons/recursion/cons/Nth.html:2
11997 msgid "Nth"
11998 msgstr "Nth"
11999
12000 #. type: Content of: outside any tag (error?)
12001 #: src/lessons/recursion/cons/Nth.html:3
12002 msgid ""
12003 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
12004 "<code>N</code>, return the <code>N</code>th element of the list."
12005 msgstr ""
12006 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro "
12007 "<code>N</code>, retorna o <code>N</code>-ésimo elemento da lista."
12008
12009 #. type: Content of: <p>
12010 #: src/lessons/recursion/cons/Nth.html:6
12011 #: src/lessons/recursion/cons/Nfirst.html:7
12012 msgid ""
12013 "You can assume that the list is long enough, i.e. that there is at least "
12014 "<code>N</code> elements. Your solution should be linear in time."
12015 msgstr ""
12016 "Pode assumir que a lista é longa o suficiente, p.ex. que existe pelo menos "
12017 "<code>N</code> elementos. A sua solução deve ser linear no tempo."
12018
12019 #. type: Content of: <h1>
12020 #: src/lessons/recursion/cons/Nfirst.html:2
12021 msgid "Nfirst"
12022 msgstr "Nfirst"
12023
12024 #. type: Content of: outside any tag (error?)
12025 #: src/lessons/recursion/cons/Nfirst.html:3
12026 msgid ""
12027 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
12028 "<code>N</code>, return the list constituted of the first <code>N</code> "
12029 "elements. You can assume that the list is long enough, i.e. that there is at "
12030 "least <code>N</code> elements."
12031 msgstr ""
12032 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro "
12033 "<code>N</code>, retorna a lista constituída dos primeiros <code>N</code> "
12034 "elementos. Pode assumir que a lista é longa o suficiente, p.ex. que existem "
12035 "pelo menos <code>N</code> elementos."
12036
12037 #. type: Content of: <h1>
12038 #: src/lessons/recursion/cons/Nlast.html:2
12039 msgid "Nlast"
12040 msgstr "Nlast"
12041
12042 #. type: Content of: outside any tag (error?)
12043 #: src/lessons/recursion/cons/Nlast.html:3
12044 msgid ""
12045 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
12046 "<code>N</code>, return the list with only the <code>N</code> last elements."
12047 msgstr ""
12048 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro "
12049 "<code>N</code>, retorna a lista com apenas os últimos <code>N</code> "
12050 "elementos."
12051
12052 #. type: Content of: <p>
12053 #: src/lessons/recursion/cons/Nlast.html:6
12054 #: src/lessons/recursion/cons/ButNlast.html:6
12055 #: src/lessons/recursion/cons/Concat.html:6
12056 msgid ""
12057 "Your solution should be linear in time, but you will probably need to define "
12058 "several functions to achieve that complexity."
12059 msgstr ""
12060 "A sua solução deve ser linear no tempo, mas provavelmente precisa definir "
12061 "várias funções para alcançar esta complexidade."
12062
12063 #. type: Attribute 'alt' of: <div>
12064 #: src/lessons/recursion/cons/Nlast.html:8
12065 #: src/lessons/recursion/cons/ButNlast.html:8
12066 #: src/lessons/recursion/cons/Reverse.html:8
12067 #: src/lessons/recursion/cons/Concat.html:8
12068 msgid "I cannot do it in linear time"
12069 msgstr "Não posso fazer isto em tempo linear"
12070
12071 #. type: Content of: <div>
12072 #: src/lessons/recursion/cons/Nlast.html:9
12073 #: src/lessons/recursion/cons/ButNlast.html:9
12074 msgid ""
12075 "The trick is to compute only once (and beforehand) how many elements you "
12076 "should keep."
12077 msgstr ""
12078 "O segredo é calcular apenas uma vez (e previamente) quantos elementos deve "
12079 "guardar."
12080
12081 #. type: Content of: <h1>
12082 #: src/lessons/recursion/cons/ButNfirst.html:2
12083 msgid "But Nfirst"
12084 msgstr "But Nfirst"
12085
12086 #. type: Content of: outside any tag (error?)
12087 #: src/lessons/recursion/cons/ButNfirst.html:3
12088 msgid ""
12089 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
12090 "<code>N</code>, return the list without the <code>N</code> first elements."
12091 msgstr ""
12092 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro "
12093 "<code>N</code>, retorne a lista sem os primeiros <code>N</code> elementos."
12094
12095 #. type: Content of: <h1>
12096 #: src/lessons/recursion/cons/ButNlast.html:2
12097 msgid "But Nlast"
12098 msgstr "But Nlast"
12099
12100 #. type: Content of: outside any tag (error?)
12101 #: src/lessons/recursion/cons/ButNlast.html:3
12102 msgid ""
12103 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
12104 "<code>N</code>, return the list without the <code>N</code> last elements."
12105 msgstr ""
12106 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro "
12107 "<code>N</code>, retorna a lista sem os últimos <code>N</code> elementos."
12108
12109 #. type: Content of: <h1>
12110 #: src/lessons/recursion/cons/Reverse.html:2
12111 msgid "Reverse"
12112 msgstr "Reverse"
12113
12114 #. type: Content of: outside any tag (error?)
12115 #: src/lessons/recursion/cons/Reverse.html:3
12116 msgid ""
12117 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return a new "
12118 "list with all elements in reverse order."
12119 msgstr ""
12120 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna uma "
12121 "nova lista com todos os elementos em ordem inversa."
12122
12123 #. type: Content of: <p>
12124 #: src/lessons/recursion/cons/Reverse.html:5
12125 msgid ""
12126 "This function is very important and you should not pass that challenge. "
12127 "Your solution should be linear in time, with the help of helper functions."
12128 msgstr ""
12129 "Esta função é muito importante e não deve pular este desafio. Sua solução "
12130 "deve ser linear no tempo, com a ajuda de funções auxiliares."
12131
12132 #. type: Content of: <div>
12133 #: src/lessons/recursion/cons/Reverse.html:9
12134 msgid ""
12135 "You need an helper function in which the result is accumulated (built) at "
12136 "each step."
12137 msgstr ""
12138 "Precisa de uma função auxiliar na qual o resultado é acumulado (construído) "
12139 "em cada passo."
12140
12141 #. type: Content of: <h1>
12142 #: src/lessons/recursion/cons/Concat.html:2
12143 msgid "Concat"
12144 msgstr "Concat"
12145
12146 #. type: Content of: outside any tag (error?)
12147 #: src/lessons/recursion/cons/Concat.html:3
12148 msgid ""
12149 "Given two [!scala]List[Int][/!][!java|python]recursive list[/!] "
12150 "<code>l1</code> and <code>l2</code>, return a new list with all elements of "
12151 "<code>l1</code> followed by the elements of <code>l2</code>."
12152 msgstr ""
12153 "Dadas duas [!scala]List[Int][/!][!java|python]recursive list[/!] <code>l1</"
12154 "code> e <code>l2</code>, retorna uma nova lista com todos os elementos de "
12155 "<code>l1</code> seguidos de todos os elementos de <code>l2</code>."
12156
12157 #. type: Content of: <div>
12158 #: src/lessons/recursion/cons/Concat.html:9
12159 msgid ""
12160 "You need to modify <code>l1</code> beforehand so that the computations at "
12161 "each step of the recursion are in constant time."
12162 msgstr ""
12163 "Precisa modificar <code>l1</code> antes de forma que os cálculos em cada "
12164 "passo da recursão sejam em tempo constante."
12165
12166 #. type: Content of: <h1>
12167 #: src/lessons/recursion/cons/AllDifferent.html:2
12168 msgid "All Different"
12169 msgstr "All Different"
12170
12171 #. type: Content of: outside any tag (error?)
12172 #: src/lessons/recursion/cons/AllDifferent.html:3
12173 msgid ""
12174 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return true "
12175 "if any two elements of the list are different (ie, if no element appears "
12176 "more than once in the list)."
12177 msgstr ""
12178 "Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorne true "
12179 "se quaisquer dois elementos da lista são diferentes (ie, se nenhum elemento "
12180 "aparece mais de uma vez na lista)."
12181
12182 #. type: Content of: <p>
12183 #: src/lessons/recursion/cons/AllDifferent.html:6
12184 msgid ""
12185 "The simplest solution is in O(n²), meaning that it runs in quadratic time. "
12186 "You will probably have to define one extra function for that. Another much "
12187 "more complex solution runs in O(n log(n))."
12188 msgstr ""
12189 "A solução mais simples é em O(n²), o que significa que executa em tempo "
12190 "quadrático. Provavelmente terá que definir uma função adicional para isto. "
12191 "Outra solução muito mais complexa executa em O(n log(n))."
12192
12193 #. type: Content of: <h1>
12194 #: src/lessons/recursion/lego/Main.html:2
12195 msgid "Recursive algorithms"
12196 msgstr "Algoritmos recursivos"
12197
12198 #. type: Content of: outside any tag (error?)
12199 #: src/lessons/recursion/lego/Main.html:3
12200 msgid "This lesson allows to experiment with recursive algorithms."
12201 msgstr "Esta lição permite que se experimente com algoritmos recursivos."
12202
12203 #. type: Content of: <p>
12204 #: src/lessons/recursion/lego/Main.html:5
12205 msgid ""
12206 "If you need more recursive algorithms, an exercise on recursive sorting "
12207 "algorithms (in particular QuickSort and MergeSort) is planned in the future "
12208 "within the sorting lesson."
12209 msgstr ""
12210 "Se precisa de mais algoritmos recursivos, um exercício em algoritmos de "
12211 "ordenação recursivos (em particular QuickSort e MergeSort) está planejado no "
12212 "futuro dentro da lição de ordenação."
12213
12214 #. type: Content of: <h3>
12215 #: src/lessons/recursion/lego/Main.html:9
12216 msgid "What can I do to improve this lesson?"
12217 msgstr "O que ru posso fazer para melhorar esta lição?"
12218
12219 #. type: Content of: <p>
12220 #: src/lessons/recursion/lego/Main.html:11
12221 msgid ""
12222 "As usual, there are several things that could be done in this lesson to "
12223 "improve it further:"
12224 msgstr ""
12225 "Como sempre, existem várias coisas que podem ser feitas nesta lição para "
12226 "melhorar ela ainda mais:"
12227
12228 #. type: Content of: <ul><li>
12229 #: src/lessons/recursion/lego/Main.html:13
12230 msgid ""
12231 "The Sierpinski triangle can be drawn using a simpler L-system. See "
12232 "http://jpvallon.free.fr/recursivite.html"
12233 msgstr ""
12234 "O triângulo de Sierpinski pode ser desenhado a usar um L-system mais "
12235 "simples. Veja em http://jpvallon.free.fr/recursivite.html"
12236
12237 #. type: Content of: <ul><li>
12238 #: src/lessons/recursion/lego/Main.html:14
12239 msgid ""
12240 "The arrowhead curve is also interesting: "
12241 "http://www.mathcurve.com/fractals/sierpinski/sierpinskitriangle.shtml"
12242 msgstr ""
12243 "A curva \"arrowhead\" também é interessante: http://www.mathcurve.com/"
12244 "fractals/sierpinski/sierpinskitriangle.shtml"
12245
12246 #. type: Content of: <ul><li>
12247 #: src/lessons/recursion/lego/Main.html:15
12248 msgid ""
12249 "The dragon curve could be explained as a L-system: "
12250 "http://ecademy.agnesscott.edu/~lriddle/ifs/heighway/heighway.htm"
12251 msgstr ""
12252 "A curva do dragão pode ser explicada como um L-system: http://ecademy."
12253 "agnesscott.edu/~lriddle/ifs/heighway/heighway.htm"
12254
12255 #. type: Content of: <ul><li>
12256 #: src/lessons/recursion/lego/Main.html:16
12257 msgid ""
12258 "The dragon2 curve is called the twin dragon: "
12259 "http://ecademy.agnesscott.edu/~lriddle/ifs/heighway/twindragon.htm"
12260 msgstr ""
12261 "A curva do dragão2 é chamada de \"twin dragon\": http://ecademy.agnesscott."
12262 "edu/~lriddle/ifs/heighway/twindragon.htm"
12263
12264 #. type: Content of: <ul><li>
12265 #: src/lessons/recursion/lego/Main.html:17
12266 msgid ""
12267 "The space filling curves could be added (Peano, Hildebert, etc). See: "
12268 "http://teachout1.net/village/fill.html"
12269 msgstr ""
12270 "As curvas de preenchimento de spaço podem ser adicionadas (Peano, Hildebert, "
12271 "etc). Veja: http://teachout1.net/village/fill.html"
12272
12273 #. type: Content of: <ul><li>
12274 #: src/lessons/recursion/lego/Main.html:19
12275 msgid ""
12276 "We could do another exercise on embeeded polygons: "
12277 "http://www.inrialpes.fr/helix/people/genoud/ENSJAVA/tds/sujets/dessinsReccursifs/actionsrecursives.html"
12278 msgstr ""
12279 "Podemos fazer outro exercício em polígonos \"embeeded\": http://www.inrialpes"
12280 ".fr/helix/people/genoud/ENSJAVA/tds/sujets/dessinsReccursifs/"
12281 "actionsrecursives.html"
12282
12283 #. type: Content of: <h3>
12284 #: src/lessons/recursion/lego/short_desc.html:2
12285 msgid "Bases of recursion"
12286 msgstr "As bases da recursão"
12287
12288 #. type: Content of: <p>
12289 #: src/lessons/recursion/lego/short_desc.html:3
12290 msgid ""
12291 "Discover the recursive way of thinking by drawing trees and other figures "
12292 "with the Logo turtle."
12293 msgstr ""
12294 "Descobrir a forma recursiva de pensar a desenhar árvores e outras figuras "
12295 "com a tartaruga do Logo."
12296
12297 #. type: Content of: <h2>
12298 #: src/lessons/recursion/lego/square/FourSquare.html:2
12299 msgid "The small cousines of Buggles"
12300 msgstr "Os primos menores dos buggles"
12301
12302 #. type: Content of: <p>
12303 #: src/lessons/recursion/lego/square/FourSquare.html:4
12304 msgid ""
12305 "Today, we will meet the small cousines of the buggles: the turtles. In fact, "
12306 "turtles are much olders than the buggles. They were invented in the 70's by "
12307 "a scientific from MIT called Seymour Papert to help teaching programming, "
12308 "and the buggles are a variation on the idea invented by Lyn Turbak from "
12309 "Wellesley College later."
12310 msgstr ""
12311 "Hoje vamos conhecer os primos menores dos buggles: as tartarugas. Na "
12312 "verdade, as tartarugas são muito mais velhas que os buggles. Elas foram "
12313 "inventadas nos anos 70 por um cientista do MIT chamado Seymour Papert para "
12314 "ajudar no ensino de programação e os buggles são uma variação da idéia "
12315 "seguinte de Lyn Turbak do Wellesley College."
12316
12317 #. type: Content of: <p>
12318 #: src/lessons/recursion/lego/square/FourSquare.html:10
12319 msgid ""
12320 "Turtles are thus a bit like buggles, but smaller. Just like buggles, you can "
12321 "order them to move forward, to turn, to move backward, etc. Just like "
12322 "buggles, they leave a line on their path when they move (but the line is "
12323 "much smaller)."
12324 msgstr ""
12325 "Tartarugas então, são meio parecidas com buggles, mas menores. Como os "
12326 "buggles, pode mandar que elas se movam para a frente, virem, se movam para "
12327 "trás, etc. Como os buggles, elas deixam uma linha no caminho por onde passam "
12328 "(mas a linha é muito menor)."
12329
12330 #. type: Content of: <p>
12331 #: src/lessons/recursion/lego/square/FourSquare.html:15
12332 msgid ""
12333 "The main difference is that where buggles can only move of right angles, "
12334 "turtles can move of any arbitrary angles specified by a real number (a "
12335 "double). This gives them much more liberty in their movings. The buggles can "
12336 "do several other tricks, like reading and writting messages, picking or "
12337 "dropping objects, and there is sometimes walls in their worlds (but all this "
12338 "is completely above the capacities of turtles)."
12339 msgstr ""
12340 "A principal diferença é que enquanto os buggles podem se mover apenas em "
12341 "ângulos retos, as tartarugas podem se mover em qualquer ângulo especificado "
12342 "por um número real (um double). Isto dá-lhes muito mais liberdade nos "
12343 "movimentos deles. Já os buggles podem fazer vários outros truques, como ler "
12344 "e escrever mensagens, apanhar e soltar objetos e às vezes lidar com paredes "
12345 "existentes nos mundos (mas isto está totalmente além da capacidade das "
12346 "tartarugas)."
12347
12348 #. type: Content of: <p>
12349 #: src/lessons/recursion/lego/square/FourSquare.html:22
12350 msgid ""
12351 "From a practical point of view, most of the methods you knew about buggles "
12352 "still work with turtles, with some minor adaptations. In particular, the "
12353 "<code>forward()</code> method takes the amount of steps to do not as an "
12354 "integer, but as a [!python]point number[/!][!java|scala|c]double[/!] (see "
12355 "\"About this world\" for more details)."
12356 msgstr ""
12357 "De um ponto de vista prático, a maioria dos métodos que conhece sobre "
12358 "buggles ainda funciona com tartarugas, com pequenas adaptações. Em "
12359 "particular, o método <code>forward()</code> leva a quantidade de passos a "
12360 "dar não como inteiro, mas como [!python]point "
12361 "number[/!][!java|scala|c]double[/!] (veja \"Sobre este mundo\" para maiores "
12362 "detalhes)."
12363
12364 #. type: Content of: <h3>
12365 #: src/lessons/recursion/lego/square/FourSquare.html:29
12366 msgid "Doubles? But what is it?"
12367 msgstr "Doubles? Mas o que é isto?"
12368
12369 #. type: Content of: outside any tag (error?)
12370 #: src/lessons/recursion/lego/square/FourSquare.html:30
12371 msgid "It's simply a point number. Example:"
12372 msgstr "é simplesmente um número com vírgula. Por exemplo:"
12373
12374 #. type: Content of: <pre>
12375 #: src/lessons/recursion/lego/square/FourSquare.html:32
12376 #, no-wrap
12377 msgid ""
12378 "double x = 3.72;\n"
12379 "x + 1.234 // Value = 4.954\n"
12380 "x + 2. // Value = 5.72 (2. means 2.0)\n"
12381 "x + 2 // [!java|c]Value = 5.72 (2 automatically converted to "
12382 "2.0)[/!][!scala]Type error (+ operator don't mix Double and Int); manual "
12383 "conversion mandatory[/!]\n"
12384 "x * 2. // Value = 7.44 \n"
12385 "x / 2. // Value = 1.86 \n"
12386 "[!java|c](int) x[/!][!scala]x.asInstanceOf[Int][/!] // Value = 1 (“casting "
12387 "to int”, converted to integer by truncating)\n"
12388 "Math.round(x) // Value = 2 (1.86 rounded to nearest integer)\n"
12389 "Math.floor(x) // Value = 1 (1.86 rounded toward minus infinity)\n"
12390 "Math.floor(-5.12) // Value = -6 (rounded toward minus infinity)\n"
12391 "Math.ceiling(x) // Value = 2 (1.86 rounded toward plus infinity)\n"
12392 "Math.ceiling(-5.12) // Value = -5 (rounded toward plus infinity)\n"
12393 "[!java|c](double) 17[/!][!scala]17.asInstanceOf[Double][/!] // Value = 17.0 "
12394 "(“casted to double”, converted to double)\n"
12395 msgstr ""
12396 "double x = 3.72;\n"
12397 "x + 1.234 // Valor = 4.954\n"
12398 "x + 2. // Valor = 5.72 (2. significa 2.0)\n"
12399 "x + 2 // [!java|c]Value = 5.72 (2 convertido automaticamente em 2."
12400 "0)[/!][!scala]Erro de tipo (o operador + não mistura Double e Int); é "
12401 "obrigatória a conversão manual[/!]\n"
12402 "x * 2. // Valor = 7.44 \n"
12403 "x / 2. // Valor = 1.86 \n"
12404 "[!java|c](int) x[/!][!scala]x.asInstanceOf[Int][/!] // Valor = 1 (“a fazer "
12405 "cast para int”, convertido para integer a truncar)\n"
12406 "Math.round(x) // Valor = 2 (1.86 arredondado ao inteiro mais próximo)\n"
12407 "Math.floor(x) // Valor = 1 (1.86 rounded toward minus infinity)\n"
12408 "Math.floor(-5.12) // Valor = -6 (rounded toward minus infinity)\n"
12409 "Math.ceiling(x) // Valor = 2 (1.86 rounded toward plus infinity)\n"
12410 "Math.ceiling(-5.12) // Valor = -5 (rounded toward plus infinity)\n"
12411 "[!java|c](double) 17[/!][!scala]17.asInstanceOf[Double][/!] // Valor = 17.0 "
12412 "(“feito cast para double”, convertido para double)\n"
12413
12414 #. type: Content of: <p>
12415 #: src/lessons/recursion/lego/square/FourSquare.html:49
12416 msgid ""
12417 "Even if this is the first exercise on the recursivity lesson, the code you "
12418 "have to write is not recursive. The goal is to get familiar with the turtle "
12419 "world before getting on serious matter."
12420 msgstr ""
12421 "Mesmo este a ser o primeiro exercício da lição de recursividade, o código "
12422 "que tem que escrever não é recursivo. O objetivo é se familiarizar com o "
12423 "mundo da tartaruga antes da coisa começar a ficar séria."
12424
12425 #. type: Content of: <p>
12426 #: src/lessons/recursion/lego/square/FourSquare.html:53
12427 msgid ""
12428 "You must reproduce a simple geometrical painting constituted of four 100 "
12429 "steps long squares (see the objective world for more details). It is "
12430 "obviously a good idea to write a method to draw a square, and then use it in "
12431 "your code."
12432 msgstr ""
12433 "Deve reproduzir uma pintura geometricamente simples de quatro quadrados de "
12434 "comprimento de 100 passos (veja o mundo objetivo para mais detalhes). É "
12435 "obviamente uma boa ideia escrever um método para desenhar um quadrado e "
12436 "então usá-lo no nosso código."
12437
12438 #. type: Content of: <h2>
12439 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:2
12440 msgid "Fractal of polygons"
12441 msgstr "Fractal de polígonos"
12442
12443 #. type: Content of: outside any tag (error?)
12444 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:4
12445 msgid ""
12446 "The fractal we will now draw is formed of a polygon, with little polygons on "
12447 "each corner. The prototype of the method drawing it is the following:"
12448 msgstr ""
12449 "O fractal que vamos desenhar agora é formado de um polígono, com pequenos "
12450 "polígonos em cada canto. O protótipo do método que vai desenhá-lo é o "
12451 "seguinte:"
12452
12453 #. type: Content of: <pre>
12454 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:6
12455 #, no-wrap
12456 msgid ""
12457 "[!java|c]void [/!]polygonFractal ([!java|c]int [/!]levels[!scala]:Int[/!], "
12458 "[!java|c]int [/!]sides[!scala]:Int[/!], [!java|c]double "
12459 "[/!]length[!scala]:Double[/!], [!java|c]double "
12460 "[/!]shrink[!scala]:Double[/!])"
12461 msgstr ""
12462 "[!java|c]void [/!]fractalDoPolígono ([!java|c]int [/!]níveis[!scala]:Int[/!]"
12463 ", [!java|c]int [/!]lados[!scala]:Int[/!], [!java|c]double "
12464 "[/!]comprimento[!scala]:Double[/!], [!java|c]double "
12465 "[/!]shrink[!scala]:Double[/!])"
12466
12467 #. type: Content of: <p>
12468 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:8
12469 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:26
12470 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:45
12471 msgid ""
12472 "Have a look at each world's objective view to understand how to write the "
12473 "function."
12474 msgstr ""
12475 "Dê uma olhada em cada visão de mundo objetivo para entender como escrever a "
12476 "função."
12477
12478 #. type: Content of: <h2>
12479 #: src/lessons/recursion/lego/koch/Koch.html:2
12480 msgid "Snow flake"
12481 msgstr "Floco de neve"
12482
12483 #. type: Content of: outside any tag (error?)
12484 #: src/lessons/recursion/lego/koch/Koch.html:4
12485 msgid ""
12486 "We will now draw snow flakes using the Koch fractal. A fractal is a "
12487 "geometric pattern repeated at every scale."
12488 msgstr ""
12489 "Vamos agora desenhar flocos de neve a usar o Koch fractal. Um fractal é um "
12490 "padrão geométrico repetido em cada escala."
12491
12492 #. type: Content of: <p>
12493 #: src/lessons/recursion/lego/koch/Koch.html:7
12494 msgid ""
12495 "The general form is a triangle, with each side given by several recursive "
12496 "calls. Your work is only to write the code of the <code>snowSide</code> "
12497 "method so that it draws one side of the triangle. To make it easier, each "
12498 "sides are represented in a specific color. Just draw the red things (without "
12499 "changing your pen color), and the other colors will be drawn automatically."
12500 msgstr ""
12501 "A forma geral é um triângulo, com cada lado dado por várias chamadas "
12502 "recursivas. O seu trabalho é apenas escrever o código do método "
12503 "<code>snowSide</code> de forma que desenhe um lado do triângulo. Para "
12504 "facilitar, cada um dos lados é representado numa cor específica. "
12505 "Simplesmente desenhe as coisas vermelhas (sem mudar a cor da sua caneta) e "
12506 "as outras cores serão desenhadas automaticamente."
12507
12508 #. type: Content of: <p>
12509 #: src/lessons/recursion/lego/koch/Koch.html:13
12510 msgid ""
12511 "Observe the drawing in each world's objective to understand the pattern's "
12512 "logic, and then reproduce it. At level 0, the Koch curve is just a straight "
12513 "line. At level 1, the curve is divided in three thirds, and the middle part "
12514 "is replaced by the two sides of an equilateral triangle of the same length "
12515 "as the segment being removed. At level 2, the process is repeated, whith "
12516 "each segments split in three parts and the middle part being replaced by the "
12517 "two sides of an equilateral triangle."
12518 msgstr ""
12519 "Observe o desenho em cada um dos mundos objetivo para entender a lógica do "
12520 "padrão e então reproduza ele. No nível 0, a curva de Koch é apenas uma linha "
12521 "reta. No nível 1, a curva é dividida em três terços e a parte média é "
12522 "substituída pelos dois lados de um triângulo equilátero do mesmo comprimento "
12523 "do segmento a ser removido. No nível 2, o processo é repetido, com cada um "
12524 "dos segmentos dividido em três partes e a parte do meio a ser substituída "
12525 "pelos dois lados de um triângulo equilátero."
12526
12527 #. type: Content of: <p>
12528 #: src/lessons/recursion/lego/koch/Koch.html:20
12529 msgid "The pseudo-code of the general case is the following:"
12530 msgstr "O pseudo-código do caso geral é o seguinte:"
12531
12532 #. type: Content of: <pre>
12533 #: src/lessons/recursion/lego/koch/Koch.html:22
12534 #, no-wrap
12535 msgid ""
12536 " Draw recursively a smaller segment\n"
12537 " Turn 60 degrees to the left\n"
12538 " Draw recursively a smaller segment \n"
12539 " Turn 120 degrees to the right\n"
12540 " Draw recursively a smaller segment\n"
12541 " Turn 60 degrees to the left\n"
12542 " Draw recursively a smaller segment\n"
12543 msgstr ""
12544 " Desenhe recursivamente um segmento menor\n"
12545 " Gire 60 graus para a esquerda\n"
12546 " Desenhe recursivamente um segmento menor\n"
12547 " Gire 120 graus para a direita\n"
12548 " Desenhe recursivamente um segmento menor\n"
12549 " Gire 60 graus para a esquerda\n"
12550 " Desenhe recursivamente um segmento menor\n"
12551
12552 #. type: Content of: <p>
12553 #: src/lessons/recursion/lego/koch/Koch.html:30
12554 msgid ""
12555 "As you can see, the function forward() is not called from the recursive "
12556 "case, only in the base case when there is no recursive call."
12557 msgstr ""
12558 "Como pode ver, a função forward() não é chamada no caso recursivo, apenas no "
12559 "caso base quando não existe chamada recursiva."
12560
12561 #. type: Attribute 'alt' of: <p><div>
12562 #: src/lessons/recursion/lego/koch/Koch.html:34
12563 msgid "Too much letters. Please picture it."
12564 msgstr "Muitas letras. Favor \"picture it\"."
12565
12566 #. type: Content of: <p><div><p>
12567 #: src/lessons/recursion/lego/koch/Koch.html:35
12568 #: src/lessons/recursion/lego/koch/SquareKoch.html:9
12569 msgid "Here are the results of the first levels of recursion."
12570 msgstr "Aqui estão os resultados dos primeiro níveis da recursão."
12571
12572 #. type: Content of: <p>
12573 #: src/lessons/recursion/lego/koch/Koch.html:39
12574 msgid ""
12575 "You must write the <code>snowSide()</code> method, which is recursive but "
12576 "<b>do not call snowFlake from snowSide</b>, or you will get very strange and "
12577 "unexpected behaviors."
12578 msgstr ""
12579 "Deve escrever o método <code>snowSide()</code>, que é recursivo mas <b>não "
12580 "chame snowFlake de dentro de snowSide</b>, ou vão acontecer resultados "
12581 "estranhos e inesperados."
12582
12583 #. type: Content of: <h2>
12584 #: src/lessons/recursion/lego/koch/SquareKoch.html:2
12585 msgid "Snow square"
12586 msgstr "Snow square"
12587
12588 #. type: Content of: <p>
12589 #: src/lessons/recursion/lego/koch/SquareKoch.html:4
12590 msgid ""
12591 "This exercise is a variation over the snow flake that we saw previously. "
12592 "The main difference is that we are growing little squares instead of "
12593 "triangles on the sides of the figure."
12594 msgstr ""
12595 "Este exercício é uma variação sobre o snow flake que vimos previamente. A "
12596 "principal diferença é que vamos fazer crescer pequenos quadrados ao invés de "
12597 "triângulos nos lados da figura."
12598
12599 #. type: Attribute 'alt' of: <p><div>
12600 #: src/lessons/recursion/lego/koch/SquareKoch.html:8
12601 msgid "I don't see it, sorry. Please picture it."
12602 msgstr "Desculpe, não vi isto. Favor \"picture it\"."
12603
12604 #. type: Content of: <p>
12605 #: src/lessons/recursion/lego/koch/SquareKoch.html:14
12606 msgid ""
12607 "As previously, your <code>squareSide</code> function should only draw one "
12608 "side of the figure, and the template will call it for all sides "
12609 "automatically (with one color per side)."
12610 msgstr ""
12611 "Como anteriormente, a sua função <code>squareSide</code> deve apenas "
12612 "desenhar um lado da figura e o modelo vai chamar ela para todos os lados "
12613 "automaticamente (com uma cor por lado)."
12614
12615 #. type: Content of: <h2>
12616 #: src/lessons/recursion/lego/koch/PentaKoch.html:2
12617 msgid "Snow pentagon"
12618 msgstr "Snow pentagon"
12619
12620 #. type: Content of: <p>
12621 #: src/lessons/recursion/lego/koch/PentaKoch.html:4
12622 msgid ""
12623 "Here comes yet another variation of the Koch curve. This time, we grow "
12624 "little pentagons (ie, polygons with five sides each). I'm sure you get it "
12625 "now."
12626 msgstr ""
12627 "Aqui vai outra variação da curva de Koch. desta vez, vamos crescer pequenos "
12628 "pentágonos (ie, polígonos com cinco lados cada). Tenho certeza que agora "
12629 "compreendeu."
12630
12631 #. type: Content of: <p>
12632 #: src/lessons/recursion/lego/koch/PentaKoch.html:7
12633 msgid ""
12634 "Another difference with earlier is that the length is not divided by three "
12635 "at each step anymore, but multiplied by 0.4. The curve looks better this way "
12636 ":)"
12637 msgstr ""
12638 "Outra diferença com o anterior é que o comprimento não é mais dividido por "
12639 "três em cada passo, mas multiplicado por 0.4. A curva parece melhor desta "
12640 "forma :)"
12641
12642 #. type: Content of: <p>
12643 #: src/lessons/recursion/lego/koch/PentaKoch.html:10
12644 msgid ""
12645 "We draw only one side in this exercise so your code will be called only once "
12646 "this time."
12647 msgstr ""
12648 "Desenhamos apenas um lado neste exercício de forma que o seu código vai ser "
12649 "chamado apenas uma vez agora."
12650
12651 #. type: Content of: <h2>
12652 #: src/lessons/recursion/lego/koch/HexaKoch.html:2
12653 msgid "Snow hexagon"
12654 msgstr "Snow hexagon"
12655
12656 #. type: Content of: <p>
12657 #: src/lessons/recursion/lego/koch/HexaKoch.html:4
12658 msgid ""
12659 "This time, we will draw the curve that is known as the (6, 0.14)-Koch "
12660 "curve. This means that you have to grow 6-sided polygons on the segments, "
12661 "and that the length should be multiplied by 0.14 at each recursion level."
12662 msgstr ""
12663 "Agora vamos desenhar a curva conhecida por curva (6, 0.14)-Koch. Isto "
12664 "significa que tem que crescer polígonos de 6 lados nos segmentos e que o "
12665 "comprimento deve ser multiplicado por 0.14 em cada nível de recursão."
12666
12667 #. type: Content of: <p>
12668 #: src/lessons/recursion/lego/koch/HexaKoch.html:8
12669 msgid ""
12670 "For the record, the original Koch curve is the (3, 1/3)-Koch curve, the Snow "
12671 "square would be (4,1/3)-Koch curve while the Snow pentagon is also called "
12672 "the (5, 0.4)-Koch curve. If you want, you can switch to the creative mode in "
12673 "the menu and explore freely other Koch curves. Just change the initial call "
12674 "to hexaKoch to what you want."
12675 msgstr ""
12676 "Para que conste, a curva de Koch original é a curva (3, 1/3)-Koch, a Snow "
12677 "square será a curva (4,1/3)-Koch enquanto a Snow pentagon é também chamada "
12678 "de curva (5, 0.4)-Koch. Se quiser, pode mudar ao modo criativo no menu e "
12679 "explorar livremente outras curvas de Koch. Simplesmente mude a chamada "
12680 "inicial de hexaKoch para o que quiser."
12681
12682 #. type: Content of: <p>
12683 #: src/lessons/recursion/lego/koch/HexaKoch.html:13
12684 msgid ""
12685 "For further reference, please see <a "
12686 "href=\"http://ecademy.agnesscott.edu/~lriddle/ifs/kcurve/kcurve.htm\">http://ecademy.agnesscott.edu/~lriddle/ifs/kcurve/kcurve.htm</a>."
12687 msgstr ""
12688 "Para mais referências, favor ler <a href=\"http://ecademy.agnesscott.edu/~"
12689 "lriddle/ifs/kcurve/kcurve.htm\">http://ecademy.agnesscott.edu/~lriddle/ifs/"
12690 "kcurve/kcurve.htm</a>."
12691
12692 #. type: Content of: <h2>
12693 #: src/lessons/recursion/lego/koch/Crab.html:2
12694 msgid "Fractal Crab"
12695 msgstr "Carangueijo Fractal"
12696
12697 #. type: Content of: <p>
12698 #: src/lessons/recursion/lego/koch/Crab.html:4
12699 msgid ""
12700 "The Crab curve is not exactly a Koch curve, but that's still a fractal and "
12701 "it's built rather similarly. This time, we grow square triangle on the side "
12702 "of the figure: the angle is 45 degrees, and the length is divided by "
12703 "[!java|scala]Math.sqrt(2)[/!][!python]math.sqrt(2)[/!][!c]sqrt(2);[/!] at "
12704 "each step."
12705 msgstr ""
12706 "A curva do carangueijo não é exatamente uma curva de Koch, mas ainda é um "
12707 "fractal e e construída de forma similar. Desta vez, vamos crescer um "
12708 "triângulo retângulo na lateral da figura: o ângulo é de 45 graus e o "
12709 "comprimento é dividido por [!java|scala]Math.sqrt(2)[/!][!python]math."
12710 "sqrt(2)[/!][!c]sqrt(2);[/!] em cada passo."
12711
12712 #. type: Content of: <p>
12713 #: src/lessons/recursion/lego/koch/Crab.html:8
12714 msgid ""
12715 "Check the figures produced by the first steps of recursion to understand the "
12716 "pattern."
12717 msgstr ""
12718 "Verifique as figuras produzidas pelos primeiros passos da recursão para "
12719 "entender o padrão."
12720
12721 #. type: Content of: <h3>
12722 #: src/lessons/recursion/lego/koch/Crab.html:10
12723 msgid "Bibliographical note"
12724 msgstr "nota bibliográfica"
12725
12726 #. type: Content of: <p>
12727 #: src/lessons/recursion/lego/koch/Crab.html:11
12728 msgid ""
12729 "This curve, also called the Lévy C curve was invented in 1938 by the French "
12730 "mathematician Paul Lévy. As usual, the wikipedia page is very instructive, "
12731 "and the page provide very good additions: <a "
12732 "href=\"http://www.mathcurve.com/fractals/c/c.shtml\">http://www.mathcurve.com/fractals/c/c.shtml</a>."
12733 msgstr ""
12734 "Esta curva, também chamada de curva C de Lévy foi inventada em 1938 pelo "
12735 "matemático francês Paul Lévy in 1938. Como sempre, a página da wikipédia é "
12736 "bem instrutiva, além de fornecer ótimos extras: <a href=\"http://www."
12737 "mathcurve.com/fractals/c/c.shtml\">http://www.mathcurve.com/fractals/c/c."
12738 "shtml</a>."
12739
12740 #. type: Content of: <h2>
12741 #: src/lessons/recursion/lego/tree/Tree.html:2
12742 msgid "Trees"
12743 msgstr "Árvores"
12744
12745 #. type: Content of: <p>
12746 #: src/lessons/recursion/lego/tree/Tree.html:4
12747 msgid ""
12748 "We will now draw trees. For that, we will write a method using double "
12749 "recursion following this prototype"
12750 msgstr ""
12751 "Vamos agora construir árvores. Para isto, vamos escrever um método a usar "
12752 "recursão dupla a seguir este protótipo"
12753
12754 #. type: Content of: <pre>
12755 #: src/lessons/recursion/lego/tree/Tree.html:6
12756 #, no-wrap
12757 msgid ""
12758 "[!java|c]void [/!]tree([!java|c]int [/!]steps[!scala]:Int[/!], "
12759 "[!java|c]double [/!]length[!scala]:Double[/!], [!java|c]double "
12760 "[/!]angle[!scala]:Double[/!], [!java|c]double [/!]shrink[!scala]:Double[/!])"
12761 msgstr ""
12762 "[!java|c]void [/!]árvore([!java|c]int [/!]passos[!scala]:Int[/!], [!java|c]"
12763 "double [/!]comprimento[!scala]:Double[/!], [!java|c]double "
12764 "[/!]ângulo[!scala]:Double[/!], [!java|c]double [/!]shrink[!scala]:Double[/!])"
12765
12766 #. type: Content of: <p>
12767 #: src/lessons/recursion/lego/tree/Tree.html:8
12768 msgid ""
12769 "To draw a tree of four levels, you have to draw a trunk of the given length, "
12770 "turn right of the given angle, draw a tree of level 3, turn left twice of "
12771 "the given angle, draw another tree of level 3, and come back to your initial "
12772 "location. Don't forget to come back to the initial location!"
12773 msgstr ""
12774 "Para desenhar uma árvore de quatro níveis, deve desenhar um tronco do "
12775 "comprimento dado, virar à direita num ângulo dado, desenhar uma árvore de "
12776 "nível 3, virar a esquerda duas vezes no ângulo dado, desenhar outra árvore "
12777 "de nível 3 e voltar à posição inicial. Não se esqueça de voltar à posição "
12778 "inicial!"
12779
12780 #. type: Content of: <p><p><p>
12781 #: src/lessons/recursion/lego/tree/Tree.html:13
12782 msgid ""
12783 "If a tree's trunk is of length 'len', the trunk of the next level tree will "
12784 "be of length 'len*shrink'."
12785 msgstr ""
12786 "Se um tronco da árvore é de comprimento 'len', o tronco da árvore no próximo "
12787 "nível será de comprimento 'len*shrink'."
12788
12789 #. type: Content of: <p><p><p><p><p>
12790 #: src/lessons/recursion/lego/tree/Tree.html:16
12791 msgid ""
12792 "At the end, here is the pseudo-code of the general case (you should add the "
12793 "base case yourself):"
12794 msgstr ""
12795 "Finalmente, aqui está o pseudo-código do caso geral (deve adicionar o caso "
12796 "base por si só):"
12797
12798 #. type: Content of: <p><p><p><p><pre>
12799 #: src/lessons/recursion/lego/tree/Tree.html:18
12800 #, no-wrap
12801 msgid ""
12802 " Move forward of the desired length\n"
12803 " Draw (recursively) the right subtree\n"
12804 " Draw (recursively) the left subtree\n"
12805 " Move back to your initial position\n"
12806 msgstr ""
12807 " Mova para a frente no comprimento desejado\n"
12808 " Desenhe (recursivamente) a sub-árvore da direita\n"
12809 " Desenhe (recursivamente) a sub-árvore da esquerda\n"
12810 " Mova para trás para a posição inicial\n"
12811
12812 #. type: Content of: <p><p><p><p><p>
12813 #: src/lessons/recursion/lego/tree/Tree.html:23
12814 msgid ""
12815 "Don't forget to add the base case to your code, or your buggle will enter an "
12816 "infinite loop. Then, drawing the right subtree comes down to turn right and "
12817 "then draw the subtree."
12818 msgstr ""
12819 "Não se esqueça de adicionar o caso base ao seu código, ou o seu buggle vai "
12820 "entrar num loop infinito. Então, desenhar a sub-árvore da direita é virar a "
12821 "direita e desenhar a sub-árvore."
12822
12823 #. type: Content of: <p><p><p><p><p>
12824 #: src/lessons/recursion/lego/tree/Tree.html:26
12825 msgid ""
12826 "As you can see, each recursion level is represented by a distinctive "
12827 "color. For that, you have to call the <code>current(step)</code>, passing "
12828 "the current recursion level as a parameter. This will pick the right color "
12829 "for you. Don't erase your great colors when you move back to your initial "
12830 "location."
12831 msgstr ""
12832 "Como pode ver, cada nível de recursão é representado por uma cor diferente. "
12833 "Para isto, tem que chamar o <code>current(step)</code>, passar o nível de "
12834 "recursão atual como parâmetro. Isto vai escolher a cor certa para si. Não "
12835 "apague as suas belas cores quando se mover de volta para sua posição inicial."
12836
12837 #. type: Content of: <p><p><p><p><p>
12838 #: src/lessons/recursion/lego/tree/Tree.html:30
12839 msgid ""
12840 "If you get your function wrong, this can easily become hairly to debug as "
12841 "your errors will appear at each level of the recursion, completely changing "
12842 "the drawing. For debugging purpose, you can use the <code>subtree()</code> "
12843 "that will draw a correct subtree. This function is then very similar to the "
12844 "one you are trying to write. The only difference is that "
12845 "<code>subtree()</code> only draws in black. So, you can use it instead of a "
12846 "recursive call to debug your code, but you have to change for a proper "
12847 "recursive call to your own code (once it works) to get the colors right, "
12848 "and pass the exercise."
12849 msgstr ""
12850 "Se a função foi feita errada, pode rapidamente ficar muito difícil de "
12851 "depurar, pois, os erros vão aparecer em cada nível da recursão, a mudar "
12852 "completamente o desenho. Por questões de depuração, pode usar o "
12853 "<code>subtree()</code> que vai desenhar uma sub-árvore corretamente. Esta "
12854 "função é, portanto muito similar àquela que está a tentar escrever. A única "
12855 "diferença é que <code>subtree()</code> apenas desenha em preto. Logo, pode "
12856 "usar ela no lugar da chamada recursiva para depurar o seu código, mas vai "
12857 "ter que mudar para uma chamada recursiva adequada no seu próprio código (uma "
12858 "vez que funcione) para obter as cores certas e passar no exercício."
12859
12860 #. type: Content of: <h2>
12861 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:2
12862 msgid "Sierpinski's Triangle"
12863 msgstr "Triângulo de Sierpinski"
12864
12865 #. type: Content of: <p>
12866 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:4
12867 msgid ""
12868 "The fractal we will now draw is formed of a big triangle inside which "
12869 "several smaller triangles are embedded. The prototype of the function to "
12870 "draw it is the following:"
12871 msgstr ""
12872 "O fractal que vamos desenhar é formado de um grande triângulo dentro do qual "
12873 "há vários pequenos triângulos. O protótipo da função que desenha isto é o "
12874 "seguinte:"
12875
12876 #. type: Content of: <pre>
12877 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:7
12878 #, no-wrap
12879 msgid ""
12880 "[!java|c]void [/!]sierpinski([!java|c]int [/!]level[!scala]:Int[/!], "
12881 "[!java|c]double [/!]length[!scala]:Double[/!])"
12882 msgstr ""
12883 "[!java|c]void [/!]sierpinski([!java|c]int [/!]nível[!scala]:Int[/!], "
12884 "[!java|c]double [/!]comprimento[!scala]:Double[/!])"
12885
12886 #. type: Content of: <p>
12887 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:9
12888 msgid ""
12889 "Have a look at each world's objective view to understand how to write the "
12890 "function. To draw one side of the triangle, draw a smaller recursive "
12891 "triangle (halve the length) and move forward by the requested length. "
12892 "Globally, you have to draw 3 such sides and turn by 120 between each side."
12893 msgstr ""
12894 "Dê uma olhada em cada uma das visões do mundo objetivo para entender como "
12895 "escrever a função. Para desenhar um lado do triângulo, desenhe um triângulo "
12896 "recursivo menor (metade do comprimento) e mova para a frente a distancia "
12897 "desejada. Globalmente, tem que desenhar 3 destes lados e girar 120 graus a "
12898 "cada lado."
12899
12900 #. type: Content of: <h2>
12901 #: src/lessons/recursion/lego/spiral/Spiral.html:2
12902 msgid "Spirals"
12903 msgstr "Espirais"
12904
12905 #. type: Content of: outside any tag (error?)
12906 #: src/lessons/recursion/lego/spiral/Spiral.html:4
12907 msgid ""
12908 "We will now draw our first recursive function with the turtle. The goal is "
12909 "to draw different kind of spirals with the same function, which prototype is "
12910 "the following:"
12911 msgstr ""
12912 "Vamos agora desenhar nossa primeira função recursiva com a tartaruga. O "
12913 "objetivo é desenhar diferentes tipos de espirais com a mesma função, cujo "
12914 "protótipo é o seguinte:"
12915
12916 #. type: Content of: <pre>
12917 #: src/lessons/recursion/lego/spiral/Spiral.html:7
12918 #, no-wrap
12919 msgid ""
12920 "[!java|c]void [/!]spiral([!java|c]int [/!]steps[!scala]:Int[/!], "
12921 "[!java|c]int [/!]angle[!scala]:Int[/!], [!java|c]int "
12922 "[/!]length[!scala]:Int[/!], [!java|c]int [/!]increment[!scala]:Int[/!])"
12923 msgstr ""
12924 "[!java|c]void [/!]espiral([!java|c]int [/!]passos[!scala]:Int[/!], [!java|c]"
12925 "int [/!]ângulo[!scala]:Int[/!], [!java|c]int [/!]comprimento[!scala]:Int[/!]"
12926 ", [!java|c]int [/!]incremento[!scala]:Int[/!])"
12927
12928 #. type: Content of: outside any tag (error?)
12929 #: src/lessons/recursion/lego/spiral/Spiral.html:9
12930 msgid ""
12931 "To help you understanding how to write it, here is an example of how the "
12932 "parameters change during one specific call:"
12933 msgstr ""
12934 "Para ajudar a entender como escrever isto, aqui está um exemplo de como os "
12935 "parâmetros mudam durante uma chamada específica:"
12936
12937 #. type: Content of: <pre>
12938 #: src/lessons/recursion/lego/spiral/Spiral.html:12
12939 #, no-wrap
12940 msgid ""
12941 "spiral(5, 90, 0, 3);\n"
12942 " forward(0);\n"
12943 " left(90);\n"
12944 " spiral(4,90,3,3);\n"
12945 " forward(3);\n"
12946 " left(90);\n"
12947 " spiral(3,90,6,3);\n"
12948 " forward(6);\n"
12949 " left(90);\n"
12950 " spiral(2,90,9,3);\n"
12951 " forward(9);\n"
12952 " left(90);\n"
12953 " spiral(1,90,12,3);\n"
12954 " forward(12);\n"
12955 " left(90);\n"
12956 " spiral(0,90,12,3);\n"
12957 msgstr ""
12958 "espiral(5, 90, 0, 3);\n"
12959 " avançar(0);\n"
12960 " esquerda(90);\n"
12961 " espiral(4,90,3,3);\n"
12962 " avançar(3);\n"
12963 " esquerda(90);\n"
12964 " espiral(3,90,6,3);\n"
12965 " avançar(6);\n"
12966 " esquerda(90);\n"
12967 " espiral(2,90,9,3);\n"
12968 " avançar(9);\n"
12969 " esquerda(90);\n"
12970 " espiral(1,90,12,3);\n"
12971 " avançar(12);\n"
12972 " esquerda(90);\n"
12973 " espiral(0,90,12,3);\n"
12974
12975 #. type: Content of: outside any tag (error?)
12976 #: src/lessons/recursion/lego/spiral/Spiral.html:30
12977 msgid ""
12978 "Note that you only have to write the function, not the initial call. Each "
12979 "world will provide a specific set of initial parameters (use the combobox to "
12980 "switch to other worlds). For example, the \"Square Pyramid\" world will call "
12981 "your function as follows:"
12982 msgstr ""
12983 "Note que só tem de escrever a função, não a chamada inicial. Cada mundo irá "
12984 "fornecer um conjunto específico de parâmetros iniciais (use a combobox para "
12985 "mudar para outros mundos). Por exemplo, o mundo \"Pirâmide Quadrada\" irá "
12986 "chamar a sua função da seguinte forma:"
12987
12988 #. type: Content of: <pre>
12989 #: src/lessons/recursion/lego/spiral/Spiral.html:36
12990 #, no-wrap
12991 msgid "spiral(100, 90, 0, 3);\n"
12992 msgstr "spiral(100, 90, 0, 3);\n"
12993
12994 #. type: Content of: <h2>
12995 #: src/lessons/recursion/lego/spiral/SpiralUse.html:2
12996 msgid "Drawing spirals"
12997 msgstr "Desenhar espirais"
12998
12999 #. type: Content of: <p>
13000 #: src/lessons/recursion/lego/spiral/SpiralUse.html:4
13001 msgid ""
13002 "This exercise is not really an exercise in that sense that you just have to "
13003 "click on the Execute button to get the reward: All the needed code is "
13004 "already provided. Instead, you can here explore the possibilities of the "
13005 "code you just wrote by changing the parameters of the call to the "
13006 "<code>spiral</code> function. You can move on to the next exercise if you "
13007 "are short on time, and come back later to play around."
13008 msgstr ""
13009 "Este exercício não é realmente um exercício pois tem que simplesmente clicar "
13010 "no botão Executar para ter uma recompensa: todo o código necessário já está "
13011 "pronto. Na verdade, pode explorar as possibilidades do código que acabou de "
13012 "escrever a mudar os parâmetros da chamada da função <code>spiral</code>. "
13013 "Pode mover ao próximo exercício se estiver com pressa e voltar depois para "
13014 "experimentar este."
13015
13016 #. type: Content of: <p>
13017 #: src/lessons/recursion/lego/spiral/SpiralUse.html:10
13018 msgid ""
13019 "Here are some of the figures that you can produce with your "
13020 "<code>Spiral</code> function, provided that you come with the right "
13021 "parameters. You can switch to the creative mode (from the Exercise menu) to "
13022 "disable the world comparison when you explore with these spirals."
13023 msgstr ""
13024 "Aqui estão algumas figuras que pode produzir com a sua função <code>Spiral</"
13025 "code>, dado que passe os parâmetros certos. Pode mudar ao modo criativo (do "
13026 "menu Exercício) para desativar a comparação de mundos quando estiver a "
13027 "explorar com estas espirais."
13028
13029 #. type: Content of: <p>
13030 #: src/lessons/recursion/lego/spiral/SpiralUse.html:21
13031 msgid ""
13032 "If you discover a cool figure, don't forget to send your parameters (menu "
13033 "Help/feedback) so that we can add it to the list!"
13034 msgstr ""
13035 "Se descobrir uma figura legal, não se esqueça de enviar os seus parâmetros ("
13036 "menu Ajuda/\"Dizer o que achou\") para que possamos adicionar a esta lista!"
13037
13038 #. type: Content of: <h2>
13039 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:2
13040 msgid "Dragon curve (1)"
13041 msgstr "Curva do Dragão (1)"
13042
13043 #. type: Content of: <p>
13044 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:4
13045 msgid "The dragon curve is a classical example of recursive method."
13046 msgstr "A curva do dragão é um exemplo clássico de método recursivo."
13047
13048 #. type: Content of: <p>
13049 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:6
13050 msgid "The definition of this curve is the following:"
13051 msgstr "A definição desta curva é a seguinte:"
13052
13053 #. type: Content of: <p>
13054 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:7
13055 msgid "the dragon curve of order 1 is a vector between to arbitrary points P and Q,"
13056 msgstr ""
13057 "A curva do dragão de ordem 1 é um vetor entre dois pontos P e Q arbitrários,"
13058
13059 #. type: Content of: <p>
13060 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:8
13061 msgid ""
13062 "the dragon curve of order n is the dragon curve of order n-1 between P and "
13063 "R, followed by the same curve of order n-1 between Q and R, where PRQ is an "
13064 "isosceles triangle with angle R being a right angle, and R being at the "
13065 "right of the PQ vector. Thus, if P and Q coordinates are (x, y) and (z, t), "
13066 "the coordinate (u, v) of R are given by:"
13067 msgstr ""
13068 "A curva do dragão de ordem n é a curva do dragão de ordem n-1 entre P e R, "
13069 "seguida da mesma curva de ordem n-1 entre Q e R, onde PRQ é um triângulo "
13070 "isósceles com o ângulo em R a ser um ângulo reto e R situado a direita do "
13071 "vetor PQ. Logo, se as coordenadas P e Q são (x, y) e (z, t), as coordenadas ("
13072 "u, v) de R são dadas por:"
13073
13074 #. type: Content of: <pre>
13075 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:14
13076 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:27
13077 #, no-wrap
13078 msgid ""
13079 "u = (x + z)/2 + (t - y)/2\n"
13080 "v = (y + t)/2 - (z - x)/2\n"
13081 msgstr ""
13082 "u = (x + z)/2 + (t - y)/2\n"
13083 "v = (y + t)/2 - (z - x)/2\n"
13084
13085 #. type: Content of: <p>
13086 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:18
13087 msgid "The prototype of the method drawing the curve is the following:"
13088 msgstr "O protótipo do método a desenhar a curva é o seguinte:"
13089
13090 #. type: Content of: <pre>
13091 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:19
13092 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:23
13093 #, no-wrap
13094 msgid ""
13095 "[!java|c]void [/!]dragon([!java|c]int [/!]order[!scala]:Int[/!], "
13096 "[!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double "
13097 "[/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], "
13098 "[!java|c]double [/!]t[!scala]:Double[/!])"
13099 msgstr ""
13100 "[!java|c]void [/!]dragão([!java|c]int [/!]ordem[!scala]:Int[/!], [!java|c]"
13101 "double [/!]x[!scala]:Double[/!], [!java|c]double [/!]y[!scala]:Double[/!], "
13102 "[!java|c]double [/!]z[!scala]:Double[/!], [!java|c]double "
13103 "[/!]t[!scala]:Double[/!])"
13104
13105 #. type: Content of: <p>
13106 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:22
13107 msgid ""
13108 "You should use the method <code>setPos(x,y)</code> to put your turtle at "
13109 "coordinates (x,y) and the method <code>moveTo(z,t)</code> to draw a line "
13110 "between the turtle position and the point(z,t)."
13111 msgstr ""
13112 "Deve usar o método <code>setPos(x,y)</code> para pôr a sua tartaruga nas "
13113 "coordenadas (x,y) e o método <code>moveTo(z,t)</code> para desenhar uma "
13114 "linha entre a posição da tartaruga e o ponto (z,t)."
13115
13116 #. type: Content of: <h2>
13117 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:2
13118 msgid "The dragon curve (2)"
13119 msgstr "A curva do dragão (2)"
13120
13121 #. type: Content of: <p>
13122 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:4
13123 msgid ""
13124 "Previous solution induce that the turtle teleports to other location, or at "
13125 "the very least, that it moves its pen up during the drawing. Indeed, the end "
13126 "of the drawing of the first recursive call does not match the beginning of "
13127 "the second recursive call. That is why we had to use the method "
13128 "<code>setPos()</code>"
13129 msgstr ""
13130 "A solução anterior \"induz\" que a tartaruga se teleporta para outro local, "
13131 "ou pelo menos, que ela levanta a caneta durante o desenho. Na verdade, o "
13132 "final do desenho da primeira chamada recursiva não coincide com o começo da "
13133 "segunda chamada recursiva. É por isto que temos que usar o método "
13134 "<code>setPos()</code>"
13135
13136 #. type: Content of: <p>
13137 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:10
13138 msgid ""
13139 "In this lesson, you will write a recursive method allowing to draw the "
13140 "dragon curve without taking the pen up. For that, we need another recursive "
13141 "method drawing the mirror side of the curve."
13142 msgstr ""
13143 "Nesta lição, vai escrever um método recursivo que permita desenhar a curva "
13144 "do dragão sem levantar a caneta. Para isto, precisamos de outro método "
13145 "recursivo que desenhe o lado espelhado da curva."
13146
13147 #. type: Content of: <p>
13148 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:14
13149 msgid ""
13150 "The method <code>dragon()</code> is then recursively defined using itself "
13151 "and <code>dragonReverse()</code>. Likewise, the method "
13152 "<code>dragonReverse()</code> is defined recursively using itself and "
13153 "<code>dragon()</code>. This is thus an example of <i>mutual recursion</i>."
13154 msgstr ""
13155 "O método <code>dragon()</code> é então definido recursivamente a usá-lo "
13156 "próprio e <code>dragonReverse()</code>. Da mesma forma, o método "
13157 "<code>dragonReverse()</code> é definido recursivamente a usá-lo próprio e "
13158 "<code>dragon()</code>. Este é, portanto, um exemplo de <i>recursão mútua</i>."
13159
13160 #. type: Content of: <p>
13161 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:21
13162 msgid ""
13163 "The prototype of the <code>dragon()</code> method remains unchanged from "
13164 "previous exercise:"
13165 msgstr ""
13166 "O protótipo do método <code>dragon()</code> é o mesmo do exercício anterior:"
13167
13168 #. type: Content of: <p>
13169 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:25
13170 msgid ""
13171 "The new point's coordinate (u, v) introduced by the <code>dragon()</code> "
13172 "are:"
13173 msgstr ""
13174 "A coordenada do novo ponto (u, v) introduzida pelo <code>dragon()</code> é:"
13175
13176 #. type: Content of: <p>
13177 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:31
13178 msgid "The prototype of the method <code>dragonReverse</code> is similar:"
13179 msgstr "O protótipo do método <code>dragonReverse</code> é similar:"
13180
13181 #. type: Content of: <pre>
13182 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:32
13183 #, no-wrap
13184 msgid ""
13185 "[!java|c]void [/!]dragonReverse([!java|c]int [/!]order[!scala]:Int[/!], "
13186 "[!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double "
13187 "[/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], "
13188 "[!java|c]double [/!]t[!scala]:Double[/!])"
13189 msgstr ""
13190 "[!java|c]void [/!]inverterDragão([!java|c]int [/!]order[!scala]:Int[/!], "
13191 "[!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double "
13192 "[/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], [!java|c]"
13193 "double [/!]t[!scala]:Double[/!])"
13194
13195 #. type: Content of: <p>
13196 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:34
13197 msgid ""
13198 "The new point's coordinate (u, v) introduced by the "
13199 "<code>dragonReverse()</code> are:"
13200 msgstr ""
13201 "A coordenada do novo ponto (u, v) introduzida pelo <code>dragonReverse()</"
13202 "code> é:"
13203
13204 #. type: Content of: <pre>
13205 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:36
13206 #, no-wrap
13207 msgid ""
13208 "u = (x + z)/2 - (t - y)/2\n"
13209 "v = (y + t)/2 + (z - x)/2\n"
13210 msgstr ""
13211 "u = (x + z)/2 - (t - y)/2\n"
13212 "v = (y + t)/2 + (z - x)/2\n"
13213
13214 #. type: Content of: <p>
13215 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:40
13216 msgid ""
13217 "To make the work of each method recursiv more visible, the line painted by "
13218 "the <code>dragon()</code> must be red (<code>Color.red</code>) while the "
13219 "line painted by the <code>dragonReverse()</code> must be blue "
13220 "(<code>Color.blue</code>)."
13221 msgstr ""
13222 "Para deixar o trabalho de cada um dos dois métodos recursivos mais visíveis, "
13223 "a linha pintada pelo <code>dragon()</code> deve ser vermelha (<code>Color."
13224 "red</code>) enquanto a linha pintada pelo <code>dragonReverse()</code> deve "
13225 "ser azul(<code>Color.blue</code>)."
13226
13227 #. type: Content of: <h3>
13228 #: src/lessons/recursion/hanoi/Main.html:2
13229 #: src/lessons/recursion/hanoi/short_desc.html:2
13230 msgid "Hanoi towers"
13231 msgstr "Torres de Hanoi"
13232
13233 #. type: Content of: <p>
13234 #: src/lessons/recursion/hanoi/Main.html:3
13235 msgid ""
13236 "Here comes the super classical exercise on recursion along with some "
13237 "variations. If you have any other nice variations, please submit them. At "
13238 "some point, someone should also probably contribute these variations to "
13239 "wikipedia, as only the base problem is nicely described there."
13240 msgstr ""
13241 "Aqui está o exercício super-clássico sobre recursão junto com algumas "
13242 "variações. Se tiver quaisquer outras variações legais, favor envie elas. Em "
13243 "algum momento, alguém deve enviar estas variações também à wikipédia, pois "
13244 "por enquanto apenas o problema básico é descrito lá."
13245
13246 #. type: Content of: <p>
13247 #: src/lessons/recursion/hanoi/Main.html:8
13248 msgid ""
13249 "The Interleaved and Split variations come from the following article: "
13250 "\"Exploring Recursion with Variations on the Towers of Hanoi\", Daniel "
13251 "W. Palmer. Available at "
13252 "http://www.ccscjournal.willmitchell.info/Vol12-96/No2a/Daniel%20W%20Palmer.pdf"
13253 msgstr ""
13254 "As variações intercalada e separada vêm do seguinte artigo: \"Exploring "
13255 "Recursion with Variations on the Towers of Hanoi\", Daniel W. Palmer. "
13256 "Available at http://www.ccscjournal.willmitchell.info/Vol12-96/No2a/"
13257 "Daniel%20W%20Palmer.pdf"
13258
13259 #. type: Content of: <p>
13260 #: src/lessons/recursion/hanoi/Main.html:13
13261 msgid ""
13262 "The Linear Hanoi is briefly discussed in the article presenting the Linear "
13263 "Twin Towers of Hanoi: \"The Linear Twin Towers of Hanoi Problem\", Steven "
13264 "Minsker (ACM SIGCSE Bulletin Volume 39 Issue 4, December 2007). This article "
13265 "can only be accessed through the paywall of the editor, sorry."
13266 msgstr ""
13267 "Hanoi linear é discutida rapidamente na artigo a apresentar as Torres Gêmeas "
13268 "Lineares de Hanoi: \"The Linear Twin Towers of Hanoi Problem\", Steven "
13269 "Minsker (ACM SIGCSE Bulletin Volume 39 Issue 4, December 2007). Este artigo "
13270 "só pode ser acessado através da via paga do editor, desculpe."
13271
13272 #. type: Content of: <p>
13273 #: src/lessons/recursion/hanoi/Main.html:18
13274 msgid ""
13275 "The 3-colors Towers of Hanoi problem was presented on this web page: "
13276 "http://www.cut-the-knot.org/recurrence/TricolorHanoiAuto.shtml"
13277 msgstr ""
13278 "O problema das Torres de Hanoi de 3 cores foi apresentado nesta página: "
13279 "http://www.cut-the-knot.org/recurrence/TricolorHanoiAuto.shtml"
13280
13281 #. type: Content of: <p>
13282 #: src/lessons/recursion/hanoi/Main.html:21
13283 msgid ""
13284 "The Cyclic Towers of Hanoi was proposed by M.D. Atkinson in an article of "
13285 "1981 titled \"The cyclic towers of Hanoi\" (Information Processing Letters, "
13286 "Volume 13:3). The article is available at "
13287 "http://www.cs.otago.ac.nz/staffpriv/mike/Papers/Hanoi/CyclicHanoi.pdf."
13288 msgstr ""
13289 "As Torres de hanoi cíclicas foram propostas por M.D. Atkinson num artigo de "
13290 "1981 intitulado \"The cyclic towers of Hanoi\" (Information Processing "
13291 "Letters, Volume 13:3). O artigo está disponível em http://www.cs.otago.ac.nz/"
13292 "staffpriv/mike/Papers/Hanoi/CyclicHanoi.pdf."
13293
13294 #. type: Content of: <p>
13295 #: src/lessons/recursion/hanoi/short_desc.html:3
13296 msgid "Here comes the super classical exercise on recursion."
13297 msgstr "Aqui está o exercício super-clássico de recursão."
13298
13299 #. type: Content of: <p>
13300 #: src/lessons/recursion/hanoi/short_desc.html:5
13301 msgid ""
13302 "This is an application exercise of recursion, that you should master to take "
13303 "this lesson."
13304 msgstr ""
13305 "Este é um exercício de aplicação em recursão, que deve dominar para fazer "
13306 "esta lição."
13307
13308 #. type: Content of: <h2>
13309 #: src/lessons/recursion/hanoi/HanoiBoard.html:2
13310 msgid "Tower of Hanoi"
13311 msgstr "Torre de Hanoi"
13312
13313 #. type: Content of: <p>
13314 #: src/lessons/recursion/hanoi/HanoiBoard.html:4
13315 msgid ""
13316 "The Tower of Hanoi or Towers of Hanoi, also called the Tower of Brahma or "
13317 "Towers of Brahma, is a mathematical game or puzzle. It consists of three "
13318 "pegs, and a number of disks of different sizes which can slide onto any "
13319 "peg. The puzzle starts with the disks in a neat stack in ascending order of "
13320 "size on one peg, the smallest at the top, thus forming a pyramid."
13321 msgstr ""
13322 "A Torre de Hanoi (ou Torres de Hanoi), também conhecida como Torre de Brahma "
13323 "(ou Torres de Brahma), é um quebra-cabeça ou jogo matemático. Consiste de "
13324 "três varas e uma quantidade de discos de tamanhos diferentes que podem "
13325 "encaixar em qualquer das varas. O jogo começa com os discos todos numa vara "
13326 "ordenados em ordem crescente, o menor em cima, a formar uma pirâmide."
13327
13328 #. type: Content of: outside any tag (error?)
13329 #: src/lessons/recursion/hanoi/HanoiBoard.html:10
13330 msgid ""
13331 "The objective of the puzzle is to move the entire stack to another peg, "
13332 "obeying the following rules:"
13333 msgstr ""
13334 "O objetivo do jogo é mover a pilha completa para outra vara, a obedecer as "
13335 "seguintes regras:"
13336
13337 #. type: Content of: <ul><li>
13338 #: src/lessons/recursion/hanoi/HanoiBoard.html:12
13339 msgid "Only one disk may be moved at a time."
13340 msgstr "Apenas um disco pode ser movido por vez."
13341
13342 #. type: Content of: <ul><li>
13343 #: src/lessons/recursion/hanoi/HanoiBoard.html:14
13344 msgid ""
13345 "Each move consists of taking the upper disk from one of the pegs and sliding "
13346 "it onto another peg, on top of the other disks that may already be present "
13347 "on that peg."
13348 msgstr ""
13349 "Cada movimento consiste em tirar o disco de cima de uma vara e colocá-lo em "
13350 "outra vara, no topo dos discos que já estiverem presentes."
13351
13352 #. type: Content of: <ul><li>
13353 #: src/lessons/recursion/hanoi/HanoiBoard.html:18
13354 msgid "No disk may be placed on top of a smaller disk."
13355 msgstr "Nenhum disco pode ser posto sobre um disco menor."
13356
13357 #. type: Content of: outside any tag (error?)
13358 #: src/lessons/recursion/hanoi/HanoiBoard.html:23
13359 msgid ""
13360 "Write the core of the method: <code>[!java|c]void "
13361 "[/!]hanoi[!c]Rec[/!]([!java|c]int [/!]height[!scala]:Int[/!], [!java|c]int "
13362 "[/!]src[!scala]:Int[/!], [!java|c]int [/!]other[!scala]:Int[/!],[!java|c]int "
13363 "[/!]dst[!scala]:Int[/!])</code>"
13364 msgstr ""
13365 "Escreva o núcleo do método: <code>[!java|c]void "
13366 "[/!]hanoi[!c]Rec[/!]([!java|c]int [/!]height[!scala]:Int[/!], [!java|c]int "
13367 "[/!]src[!scala]:Int[/!], [!java|c]int [/!]other[!scala]:Int[/!],[!java|c]int "
13368 "[/!]dst[!scala]:Int[/!])</code>"
13369
13370 #. type: Content of: <p>
13371 #: src/lessons/recursion/hanoi/HanoiBoard.html:26
13372 msgid ""
13373 "This method will recursively solve the presented problem. The first "
13374 "parameter named <code>height</code> is the height of the tower to move; The "
13375 "second parameter <code>src</code> is the index of the initial tower, the "
13376 "third parameter <code>other</code> is the index of the unused peg while the "
13377 "fourth parameter <code>dst</code> is the index of the expected final tower."
13378 msgstr ""
13379 "Este método vai, recursivamente, resolve o problema apresentado. O primeiro "
13380 "parâmetro chamado <code>height</code> é a altura da torre a mover; o segundo "
13381 "parâmetro <code>src</code> é o índice da torre inicial, o terceiro parâmetro "
13382 "<code>other</code> é o índica da vara não utilizada enquanto que o quarto "
13383 "parâmetro <code>dst</code> é o índice da torre final experada."
13384
13385 #. type: Content of: <p>
13386 #: src/lessons/recursion/hanoi/HanoiBoard.html:32
13387 msgid ""
13388 "A key to solving this puzzle is to recognize that it can be solved by "
13389 "breaking the problem down into a collection of smaller problems and further "
13390 "breaking those problems down into even smaller problems until a solution is "
13391 "reached."
13392 msgstr ""
13393 "O segredo para resolver este enigma é reconhecer que pode ser dividido em "
13394 "problemas menores e este em problemas menores até que uma solução é "
13395 "encontrada."
13396
13397 #. type: Attribute 'alt' of: <div>
13398 #: src/lessons/recursion/hanoi/HanoiBoard.html:36
13399 msgid "I don't get it, please give me some extra indications"
13400 msgstr "Ainda não captei, por favor me dê mais orientações"
13401
13402 #. type: Content of: <div>
13403 #: src/lessons/recursion/hanoi/HanoiBoard.html:37
13404 msgid "Here is the pseudo-code of the solution:"
13405 msgstr "Aqui está um pseudo-código da solução:"
13406
13407 #. type: Content of: <div><ul><li>
13408 #: src/lessons/recursion/hanoi/HanoiBoard.html:39
13409 msgid "label the pegs A, B, C (these labels may move at different steps)"
13410 msgstr ""
13411 "Rotule as varas como A, B, C (estes rótulos pode se mover com diferentes "
13412 "passos)"
13413
13414 #. type: Content of: <div><ul><li>
13415 #: src/lessons/recursion/hanoi/HanoiBoard.html:40
13416 msgid "let n be the total number of discs (the height of the initial tower)"
13417 msgstr "Seja n a quantidade total de discos (A altura da torre inicial)"
13418
13419 #. type: Content of: <div><ul><li>
13420 #: src/lessons/recursion/hanoi/HanoiBoard.html:41
13421 msgid "number the discs from 1 (smallest, topmost) to n (largest, bottommost)"
13422 msgstr ""
13423 "quantidade de discos a partir de 1 (menor, mais alto) até n (maior, mais "
13424 "baixo)"
13425
13426 #. type: Content of: <div>
13427 #: src/lessons/recursion/hanoi/HanoiBoard.html:44
13428 msgid "To move n discs from peg A to peg C:"
13429 msgstr "Para mover n discos da vara A para a vara C:"
13430
13431 #. type: Content of: <div><ul><li>
13432 #: src/lessons/recursion/hanoi/HanoiBoard.html:46
13433 msgid "move n−1 discs from A to B. This leaves disc number n alone on peg A"
13434 msgstr "mova n−1 discos de A para B. Isto deixa o disco n sozinho na vara A"
13435
13436 #. type: Content of: <div><ul><li>
13437 #: src/lessons/recursion/hanoi/HanoiBoard.html:47
13438 msgid "move disc number n from A to C"
13439 msgstr "Mova o disco de número n de A para C"
13440
13441 #. type: Content of: <div><ul><li>
13442 #: src/lessons/recursion/hanoi/HanoiBoard.html:48
13443 msgid "move n−1 discs from B to C so they sit on disc number n"
13444 msgstr ""
13445 "Mova n−1 discos de B para C de forma que eles fiquem sobre o disco de número "
13446 "n"
13447
13448 #. type: Content of: <h2>
13449 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:2
13450 msgid "Interleaved Towers of Hanoi"
13451 msgstr "Torres de Hanoi Intercaladas"
13452
13453 #. type: Content of: <p>
13454 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:4
13455 msgid ""
13456 "In this classical variation of the Towers of Hanoi, you are given 4 pegs "
13457 "with 2 stacks, one white and one black. You should mix the two stacks as "
13458 "depicted in the Objective world. As previously, you cannot move a disk on a "
13459 "smaller disk."
13460 msgstr ""
13461 "Nesta variação clássica das Torres de Hanoi tem 4 varas com duas pilhas, uma "
13462 "branca e outra preta. Deve misturar as duas pilhas como descrito no mundo "
13463 "objetivo. Como antes, não pode mover um disco para cima de um disco menor."
13464
13465 #. type: Content of: <p>
13466 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:8
13467 msgid ""
13468 "You will probably need to reuse the <code>hanoi()</code> method that you "
13469 "wrote in the previous exercise."
13470 msgstr ""
13471 "Provavelmente vai precisar reutilizar o método <code>hanoi()</code> que "
13472 "escreveu no exercício anterior."
13473
13474 #. type: Attribute 'alt' of: <div>
13475 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:10
13476 #: src/lessons/recursion/hanoi/SplitHanoi1.html:10
13477 msgid "Please show me an intermediate step"
13478 msgstr "Favor me mostra um passo intermediário"
13479
13480 #. type: Content of: <div>
13481 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:12
13482 #: src/lessons/recursion/hanoi/SplitHanoi1.html:12
13483 msgid "If your initial situation is as follows:"
13484 msgstr "Se a sua situação é a seguinte:"
13485
13486 #. type: Content of: <div>
13487 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:15
13488 #: src/lessons/recursion/hanoi/SplitHanoi1.html:15
13489 msgid "then you have the following situation right before the main recursive call:"
13490 msgstr ""
13491 "Então tem a seguinte situação exatamente antes da chamada recursiva "
13492 "principal:"
13493
13494 #. type: Content of: <h2>
13495 #: src/lessons/recursion/hanoi/SplitHanoi1.html:2
13496 msgid "Split Towers of Hanoi"
13497 msgstr "Torres de hanoi Separadas"
13498
13499 #. type: Content of: <p>
13500 #: src/lessons/recursion/hanoi/SplitHanoi1.html:4
13501 msgid ""
13502 "Given one interleaved stack (e.g. resulting from the previous exercise), you "
13503 "should build two separate stacks. In other words, your code should revert "
13504 "the operations done to solve the previous exercise."
13505 msgstr ""
13506 "Dada uma pilha intercalada (e.g. o resultado do exercício anterior), deve "
13507 "construir duas pilhas separadas. Em outras palavras, o seu código deve "
13508 "reverter as operações feitas para resolver o exercício anterior."
13509
13510 #. type: Content of: <p>
13511 #: src/lessons/recursion/hanoi/SplitHanoi1.html:7
13512 msgid ""
13513 "You will need an extra function that can move an interleaved stack of n "
13514 "pairs of disks, without changing the relative positions of disks of the same "
13515 "size."
13516 msgstr ""
13517 "Vai precisar de uma função adicional que mova uma pilha intercalada de n "
13518 "pares de discos, sem mudar as posições relativas dos discos de mesmo tamanho."
13519
13520 #. type: Content of: <h2>
13521 #: src/lessons/recursion/hanoi/SplitHanoi2.html:2
13522 msgid "Better Split Towers of Hanoi"
13523 msgstr "Better Split Towers of Hanoi"
13524
13525 #. type: Content of: <p>
13526 #: src/lessons/recursion/hanoi/SplitHanoi2.html:4
13527 msgid ""
13528 "Surprisingly, our solution to split the towers generates much more moves "
13529 "than our solution to interleave them. As both problems are symmetric, this "
13530 "should not be."
13531 msgstr ""
13532 "Surpreendentemente, a nossa solução de dividir (split) as torres gera muito "
13533 "mais movimentos que a solução de intercalá-las. Como os problemas são "
13534 "simétricos, isto não deveria acontecer."
13535
13536 #. type: Content of: <br><table><tr><td>
13537 #: src/lessons/recursion/hanoi/SplitHanoi2.html:7
13538 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
13539 msgid "Disks amount"
13540 msgstr "Quantidade de discos"
13541
13542 #. type: Content of: <br><table><tr><td>
13543 #: src/lessons/recursion/hanoi/SplitHanoi2.html:7
13544 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
13545 msgid "Interleaved"
13546 msgstr "Intercalada"
13547
13548 #. type: Content of: <table><tr><td>
13549 #: src/lessons/recursion/hanoi/SplitHanoi2.html:7
13550 msgid "Split"
13551 msgstr "Split"
13552
13553 #. type: Content of: <br><table><tr><td>
13554 #: src/lessons/recursion/hanoi/SplitHanoi2.html:8
13555 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
13556 msgid "5 pairs"
13557 msgstr "5 pares"
13558
13559 #. type: Content of: <br><table><tr><td>
13560 #: src/lessons/recursion/hanoi/SplitHanoi2.html:8
13561 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
13562 msgid "62 moves"
13563 msgstr "62 movimentos"
13564
13565 #. type: Content of: <br><table><tr><td>
13566 #: src/lessons/recursion/hanoi/SplitHanoi2.html:8
13567 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
13568 msgid "88 moves"
13569 msgstr "88 movimentos"
13570
13571 #. type: Content of: <br><table><tr><td>
13572 #: src/lessons/recursion/hanoi/SplitHanoi2.html:9
13573 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
13574 msgid "6 pairs"
13575 msgstr "6 pares"
13576
13577 #. type: Content of: <br><table><tr><td>
13578 #: src/lessons/recursion/hanoi/SplitHanoi2.html:9
13579 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
13580 msgid "126 moves"
13581 msgstr "126 movimentos"
13582
13583 #. type: Content of: <br><table><tr><td>
13584 #: src/lessons/recursion/hanoi/SplitHanoi2.html:9
13585 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
13586 msgid "183 moves"
13587 msgstr "183 movimentos"
13588
13589 #. type: Content of: <br><table><tr><td>
13590 #: src/lessons/recursion/hanoi/SplitHanoi2.html:10
13591 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
13592 msgid "7 pairs"
13593 msgstr "7 pares"
13594
13595 #. type: Content of: <br><table><tr><td>
13596 #: src/lessons/recursion/hanoi/SplitHanoi2.html:10
13597 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
13598 msgid "254 moves"
13599 msgstr "254 movimentos"
13600
13601 #. type: Content of: <br><table><tr><td>
13602 #: src/lessons/recursion/hanoi/SplitHanoi2.html:10
13603 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
13604 msgid "374 moves"
13605 msgstr "374 movimentos"
13606
13607 #. type: Content of: <p>
13608 #: src/lessons/recursion/hanoi/SplitHanoi2.html:13
13609 msgid "Can you make the split tower as efficient as the interleaved one?"
13610 msgstr "Consegue deixar o \"split\" tão eficiente quanto o intercalada?"
13611
13612 #. type: Attribute 'alt' of: <div>
13613 #: src/lessons/recursion/hanoi/SplitHanoi2.html:15
13614 msgid "I need a starter hint"
13615 msgstr "Preciso de uma dica de principiante"
13616
13617 #. type: Content of: <div>
13618 #: src/lessons/recursion/hanoi/SplitHanoi2.html:16
13619 msgid ""
13620 "The source of discrepancy is an inefficient problem decomposition. "
13621 "Satisfied that it merely worked, we looked no futher for a better solution. "
13622 "Keeping the disks of the interleaved tower in the correct order during every "
13623 "move is unnecessary. In fact, we can avoid moving the interleaved tower at "
13624 "all. A better problem decomposition splits the pair of disks into two "
13625 "colored towers as they are removed from the interleaved tower."
13626 msgstr ""
13627 "A fonte de discrepância é uma decomposição ineficiente do problema. "
13628 "Satisfeitos com o fato dele simplesmente funcionar, não procuramos mais por "
13629 "uma solução melhor. Manter os discos da torre intercalada na ordem correta "
13630 "durante cada movimento é desnecessário. De fato, podemos evitar "
13631 "completamente mover a torre intercalada. Uma decomposição melhor do problema "
13632 "divide o par de discos em duas torres coloridas à medida em que eles são "
13633 "removidos da torre intercalada."
13634
13635 #. type: Attribute 'alt' of: <br><br><div>
13636 #: src/lessons/recursion/hanoi/SplitHanoi2.html:24
13637 msgid "The starter hint was not enough"
13638 msgstr "A dica de principiante não foi suficiente"
13639
13640 #. type: Content of: <br><br><div>
13641 #: src/lessons/recursion/hanoi/SplitHanoi2.html:25
13642 msgid ""
13643 "If someone could split the (n-1) pairs of disks beforehand, could you split "
13644 "the remaining pair?"
13645 msgstr ""
13646 "Se alguém puder dividir os (n-1) pares de discos previamente, poderia "
13647 "dividir o par restante?"
13648
13649 #. type: Attribute 'alt' of: <br><br><br><br><div>
13650 #: src/lessons/recursion/hanoi/SplitHanoi2.html:30
13651 msgid "You need to be more explicit"
13652 msgstr "Precisa ser mais explícito"
13653
13654 #. type: Content of: <br><br><br><br><div><ul><li>
13655 #: src/lessons/recursion/hanoi/SplitHanoi2.html:32
13656 msgid ""
13657 "First split the first (n-1) pairs of disks from the interleaved stack into a "
13658 "white tower and a black tower (calling recursively your main function)."
13659 msgstr ""
13660 "Primeiro divida os primeiros (n-1) pares de discos da pilha intercalada em "
13661 "uma torre branca e uma torre preta (a chamar recursivamente a sua função "
13662 "principal)."
13663
13664 #. type: Content of: <br><br><br><br><div><ul><li>
13665 #: src/lessons/recursion/hanoi/SplitHanoi2.html:33
13666 msgid "Then move the large white disk on its target pole."
13667 msgstr "Então mova o disco branco grande para sua vara objetivo."
13668
13669 #. type: Content of: <br><br><br><br><div><ul><li>
13670 #: src/lessons/recursion/hanoi/SplitHanoi2.html:34
13671 msgid "Then move the (n-1) smaller white disks on top of the large one."
13672 msgstr "Então mova os (n-1) discos brancos menores ao topo do maior."
13673
13674 #. type: Content of: <br><br><br><br><div><ul><li>
13675 #: src/lessons/recursion/hanoi/SplitHanoi2.html:35
13676 msgid "Then move the large black disk on its target pole."
13677 msgstr "Então mova o disco preto grande para sua vara objetivo."
13678
13679 #. type: Content of: <br><br><br><br><div><ul><li>
13680 #: src/lessons/recursion/hanoi/SplitHanoi2.html:36
13681 msgid "Then move the smaller black disks in position."
13682 msgstr "Então mova os discos pretos pequenos para a posição."
13683
13684 #. type: Content of: <h2>
13685 #: src/lessons/recursion/hanoi/SplitHanoi3.html:2
13686 msgid "Fast Split Towers of Hanoi"
13687 msgstr "Fast Split Towers of Hanoi"
13688
13689 #. type: Content of: <p>
13690 #: src/lessons/recursion/hanoi/SplitHanoi3.html:4
13691 msgid ""
13692 "Again, our previous solution is working, but it is far from being optimal. "
13693 "When moving the towers, we use the algorithm for 3 pegs even if we have 4 "
13694 "pegs. Of course, movements to the last peg are restricted since it contains "
13695 "the other stack, but we can always store the smallest disk on top of the "
13696 "other stack before moving our stack."
13697 msgstr ""
13698 "Novamente, nossas soluções anteriores funcionam, mas estão longe de serem "
13699 "ótimas. Quando movemos as torres, usamos o algoritmo de 3 varas mesmo quando "
13700 "temos 4 varas. Obviamente, movimentos para a última vara são restritos pois "
13701 "ela contém a outra pilha, mas podemos sempre armazenar o menor disco no topo "
13702 "da outra pilha antes de mover nossa pilha."
13703
13704 #. type: Content of: <p>
13705 #: src/lessons/recursion/hanoi/SplitHanoi3.html:9
13706 msgid ""
13707 "For that, we need to devise a new function <code>hanoi_fast(height, src, "
13708 "free, full, dst)</code> that moves the stack from <code>src</code> to "
13709 "<code>dst</code> using <code>free</code>, but storing the smallest disk onto "
13710 "<code>full</code> beforehand."
13711 msgstr ""
13712 "Para isto, precisamos criar uma função <code>hanoi_fast(height, src, free, "
13713 "full, dst)</code> que move a pilha de <code>src</code> para <code>dst</code> "
13714 "a usar <code>free</code>, mas a armazenar o menor disco em <code>full</code> "
13715 "antes."
13716
13717 #. type: Attribute 'alt' of: <div>
13718 #: src/lessons/recursion/hanoi/SplitHanoi3.html:13
13719 msgid "I'm lost"
13720 msgstr "Estou perdido"
13721
13722 #. type: Content of: <div>
13723 #: src/lessons/recursion/hanoi/SplitHanoi3.html:14
13724 msgid ""
13725 "The <code>hanoi_fast(height, src, free, full, dst)</code> function is not "
13726 "recursive. It moves the first disk and then call the regular "
13727 "<code>hanoi()</code> function."
13728 msgstr ""
13729 "A função <code>hanoi_fast(height, src, free, full, dst)</code> não é "
13730 "recursiva. Ela move o primeiro disco e então chama a função regular "
13731 "<code>hanoi()</code>."
13732
13733 #. type: Content of: <br><p>
13734 #: src/lessons/recursion/hanoi/SplitHanoi3.html:18
13735 msgid ""
13736 "This change greatly improve the performance, as you can see below. Of "
13737 "course, this trick could also be used for the interleaved algorithm, leading "
13738 "as expected to the exact same performance."
13739 msgstr ""
13740 "Esta mudança melhora enormemente a eficiência, como pode ver abaixo. "
13741 "Obviamente, este truque também pode ser usado para o algoritmo intercalado, "
13742 "a levar, como esperado, a exatamente a mesma eficiência."
13743
13744 #. type: Content of: <br><table><tr><td>
13745 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
13746 msgid "Slow Split"
13747 msgstr "Slow Split"
13748
13749 #. type: Content of: <br><table><tr><td>
13750 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
13751 msgid "Fast Split"
13752 msgstr "Fast Split"
13753
13754 #. type: Content of: <br><table><tr><td>
13755 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
13756 msgid "46 moves"
13757 msgstr "46 movimentos"
13758
13759 #. type: Content of: <br><table><tr><td>
13760 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
13761 msgid "82 moves"
13762 msgstr "82 movimentos"
13763
13764 #. type: Content of: <br><table><tr><td>
13765 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
13766 msgid "150 moves"
13767 msgstr "150 movimentos"
13768
13769 #. type: Content of: <br><p>
13770 #: src/lessons/recursion/hanoi/SplitHanoi3.html:27
13771 msgid ""
13772 "As a conclusion, most of us are satisfied with a working solution and we "
13773 "easily overlook possibilities to improve the problem "
13774 "decomposition. <b>You</b> should not do that ;)"
13775 msgstr ""
13776 "Como uma conclusão, a maioria das pessoas se satisfaz com uma solução que "
13777 "funcione e rapidamente ignora possibilidades para melhorar a decomposição do "
13778 "problema. <b>Você</b> não deve fazer isto ;)"
13779
13780 #. type: Content of: <h2>
13781 #: src/lessons/recursion/hanoi/LinearHanoi.html:2
13782 msgid "Linear Towers of Hanoi"
13783 msgstr "Linear Towers of Hanoi"
13784
13785 #. type: Content of: <p>
13786 #: src/lessons/recursion/hanoi/LinearHanoi.html:4
13787 msgid ""
13788 "This is a classical variation over the Towers of Hanoi where some moves are "
13789 "forbidden. Specifically, disks cannot move directly between the left-most "
13790 "and the right-most pegs. The middle peg must be involved in every moves."
13791 msgstr ""
13792 "Esta é uma variação clássica das Torres de Hanoi onde alguns movimentos são "
13793 "proibidos. Especificamente, os disco não podem ser movidos diretamente da "
13794 "vara mais à esquerda para a vara mais a direita. A vara do meio deve ser "
13795 "envolvida em cada movimento."
13796
13797 #. type: Content of: <p>
13798 #: src/lessons/recursion/hanoi/LinearHanoi.html:8
13799 msgid ""
13800 "Beside of that extra complexity, the problem remains unchanged: you are "
13801 "requested to move the whole stack of disks from one extremity peg to the "
13802 "other one. You can only move one disk at a time, and a bigger disk cannot be "
13803 "placed over a smaller one."
13804 msgstr ""
13805 "Apesar desta complexidade, o problema permanece o mesmo: tem que mover toda "
13806 "a pilha de discos da vara numa extremidade para a vara na outra extremidade. "
13807 "Só pode mover um disco por vez e um disco não pode ficar sobre outro menor."
13808
13809 #. type: Content of: <p>
13810 #: src/lessons/recursion/hanoi/LinearHanoi.html:12
13811 msgid ""
13812 "As with the classical version, it is much easier to produce a recursive "
13813 "solution, and you are absolutely able to devise this solution if you think "
13814 "hard enough about it."
13815 msgstr ""
13816 "Como na versão clássica, é muito fácil produzir uma solução recursiva e é "
13817 "totalmente capaz de \"devise\" esta solução se pensar com atenção nela."
13818
13819 #. type: Attribute 'alt' of: <div>
13820 #: src/lessons/recursion/hanoi/LinearHanoi.html:15
13821 msgid "I tried, but I don't get it"
13822 msgstr "Tentei, mas não consegui"
13823
13824 #. type: Content of: <div>
13825 #: src/lessons/recursion/hanoi/LinearHanoi.html:16
13826 msgid ""
13827 "The standard recursive algorithm for classical Hanoi is of complexity "
13828 "<i>2^n-1</i> where the standard recursive algorithm for this variation is of "
13829 "complexity <i>3^n-1</i>."
13830 msgstr ""
13831 "O algortimo recursivo padrão para as torres de Hanoi clássicas é de "
13832 "complexidade <i>2^n-1</i> enquanto que o algoritmo recursivo padrão para "
13833 "esta variação é de complexidade <i>3^n-1</i>."
13834
13835 #. type: Attribute 'alt' of: <div>
13836 #: src/lessons/recursion/hanoi/LinearHanoi.html:20
13837 msgid "That first tip was not enough"
13838 msgstr "A primeira dica não foi suficiente"
13839
13840 #. type: Content of: <div>
13841 #: src/lessons/recursion/hanoi/LinearHanoi.html:21
13842 msgid ""
13843 "The standard recursive algorithm for classical Hanoi involves two recursive "
13844 "calls sandwiching one movement of the largest disk, the standard recursive "
13845 "algorithm for Linear Hanoi involves three recursive calls sandwiched around "
13846 "two movements of the same disk."
13847 msgstr ""
13848 "A algoritmo recursivo padrão para as torres de Hanoi clássicas envolve duas "
13849 "chamadas recursivas a sanduichar um movimento do disco maior, O algoritmo "
13850 "recursivo padrão para Hanoi Linear envolve três chamadas recursivas a "
13851 "sanduichar dois movimentos do mesmo disco."
13852
13853 #. type: Content of: <h2>
13854 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:2
13855 msgid "Linear Twin Towers of Hanoi"
13856 msgstr "Torres gêmeas de Hanoi Lineares"
13857
13858 #. type: Content of: <p>
13859 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:4
13860 msgid ""
13861 "This is a mix between both the Split and Interleaved problems, and the "
13862 "linear problem. We are given two stacks of disks, on three pegs. We are "
13863 "expected to swap the stacks' position while respecting the classical Hanoi "
13864 "movement restrictions (one disk at a time, and no large disk over smaller "
13865 "disks) and the linear movement restriction (no direct exchange between the "
13866 "left-most and right-most pegs)."
13867 msgstr ""
13868 "Esta é uma mistura entre os problemas \"Split\", Intercalado e linear. Temos "
13869 "duas pilhas de discos, em três varas. Devemos trocar a posição das pilhas a "
13870 "respeitar as restrições clássicas de movimento (um disco por vez, disco "
13871 "grande não pode ficar sobre disco pequeno) e a restrição do movimento linear "
13872 "(proibido mudança diretamente da vara mais à esquerda para a vara mais à "
13873 "direita)."
13874
13875 #. type: Content of: <p>
13876 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:10
13877 msgid "You will use three recursive functions:"
13878 msgstr "Vai usar três funções recursivas:"
13879
13880 #. type: Content of: <ul><li>
13881 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:12
13882 msgid ""
13883 "<b>moveDouble(k,from, to)</b>: moves an interleaved stack of k pairs of "
13884 "disks, without changing the relative positions of disks of the same size. As "
13885 "in the Split Hanoi problem, an interleaved stack alternates white and black "
13886 "disks of each sizes. This function is not completely new: you wrote a "
13887 "version with 4 pegs (but using only 3 of them) for the first version of the "
13888 "Split Hanoi problem."
13889 msgstr ""
13890 "<b>moveDouble(k,from, to)</b>: move uma pilha intercalada de k pares de "
13891 "discos, sem mudar as posições relativas dos discos de mesmo tamanho. Como no "
13892 "problema de hanoi \"Split\", uma pilha intercalada alterna discos brancos e "
13893 "pretos de cada tamanho. Esta função não é completamente nova: escreveu uma "
13894 "versão com 4 varas (mas a usar apenas 3 delas) para a primeira versão do "
13895 "problema de hanoi \"split\"."
13896
13897 #. type: Content of: <ul><li>
13898 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:17
13899 msgid ""
13900 "<b>gather(k)</b>: from the initial split situation, build on peg #2 an "
13901 "interleaved stack of k pairs of disks. You may parametrize your function so "
13902 "that it can be used to gather the disk on any peg passed as parameter, but "
13903 "in practice, your function will only be used to gather on the last peg."
13904 msgstr ""
13905 "<b>gather(k)</b>: da situação inicial do caso \"separado\", constrói na vara "
13906 "#2 uma pilha intercalada de k pares de discos. Pode parametrizar a sua "
13907 "função de forma que ela possa ser usada para obter o disco de qualquer vara "
13908 "passado como parâmetro, mas, na prática, a sua função vai apenas ser usada "
13909 "para obter na última vara."
13910
13911 #. type: Content of: <ul><li>
13912 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:21
13913 msgid ""
13914 "<b>scatter(k)</b>: from a situation where k pairs of disks are interleaved "
13915 "on peg #0, split it down by moving the white disks to peg #1 and black ones "
13916 "to peg #2."
13917 msgstr ""
13918 "<b>scatter(k)</b>: de uma situação onde k pares de discos são intercalados "
13919 "na vara #0, separe eles a mover os discos brancos para a vara #1 e os pretos "
13920 "para a vara #2."
13921
13922 #. type: Content of: <p>
13923 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:25
13924 msgid ""
13925 "In <code>gather()</code>, the recursive call comes before two calls to "
13926 "<code>moveDouble()</code> while in <code>scatter()</code>, the calls to "
13927 "<code>moveDouble()</code> come before the recursive call. The main function "
13928 "that you should write is not recursive, but simply gather almost all disks, "
13929 "moves directly the remaining disks, and then scatters back the small disks."
13930 msgstr ""
13931 "Em <code>gather()</code>, a chamada recursiva vem antes das duas chamadas a "
13932 "<code>moveDouble()</code> enquanto em <code>scatter()</code>, as chamadas "
13933 "para <code>moveDouble()</code> vem depois da chamada recursiva. A função "
13934 "principal que deve escrever não é recursiva, mas simplesmente obtém quase "
13935 "todos os discos, move os discos restantes diretamente e então espalha ("
13936 "\"scatters\") de volta os discos menores."
13937
13938 #. type: Content of: <p>
13939 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:31
13940 msgid ""
13941 "The linearity naturally induces some extra complexity as you have to "
13942 "decompose every move between pegs 0 and 2. I am still confident in your "
13943 "ability to overcome the challenge :)"
13944 msgstr ""
13945 "A linearidade naturalmente induz alguma complexidade adicional, pois tem que "
13946 "decompor cada movimento entre as varas 0 e 2. Ainda estou confiante na sua "
13947 "capacidade de vencer este desafio :)"
13948
13949 #. type: Content of: <p>
13950 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:35
13951 msgid ""
13952 "Note that the requested algorithm was proved optimal for that problem, so "
13953 "you don't need to fiddle the performance this time."
13954 msgstr ""
13955 "Observe que foi provado que o algoritmo requerido é ótimo para este "
13956 "problema, então não precisa mexer no desempenho desta vez."
13957
13958 #. type: Content of: <h2>
13959 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:2
13960 msgid "Tricolor Hanoi: stack move"
13961 msgstr "Hanoi de tricolor: movimentação de pilhas"
13962
13963 #. type: Content of: <p>
13964 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:4
13965 msgid ""
13966 "In this set of exercises, we will devise an algorithm for the Tricolor Hanoi "
13967 "problem. There will be 3 stacks on 3 pegs, each stack of a differing color, "
13968 "and the problem is to exchange the stacks' positions under the classical "
13969 "move rules (one disk at a time, and no bigger disk over smaller disk)."
13970 msgstr ""
13971 "Neste conjunto de exercícios, vamos \"devise\" um algoritmo para o problema "
13972 "de Hanoi Tricolor. Vão existir 3 pilhas em 3 varas, cada pilha de uma cor "
13973 "diferente e o problema é alternar a posição das pilhas seguindo as regras "
13974 "clássicas do movimento (um disco por vez, disco grande não pode ficar sobre "
13975 "disco pequeno)."
13976
13977 #. type: Content of: <p>
13978 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:9
13979 msgid "As in previous exercises, our solution will use three functions:"
13980 msgstr "Como nos exercícios anteriores, nossa solução vai usar três funções:"
13981
13982 #. type: Content of: <ul><li>
13983 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:11
13984 msgid ""
13985 "<code>move3(n, src, mid, dst)</code>: moves a stack of interleaved disks, ie "
13986 "a stack of (n*3) disks of alternating colors from peg <code>src</code> to "
13987 "peg <code>dst</code>."
13988 msgstr ""
13989 "<code>move3(n, src, mid, dst)</code>: move uma pilha de discos intercalados, "
13990 "p.ex. uma pilha de (n*3) discos de cores alternadas de uma vara <code>src</"
13991 "code> para uma vara <code>dst</code>."
13992
13993 #. type: Content of: <ul><li>
13994 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:13
13995 msgid ""
13996 "<code>gather()</code>: builds an interleaved stack from the regular split "
13997 "ones."
13998 msgstr ""
13999 "<code>gather()</code>: constrói uma pilha intercalada a partir de três "
14000 "pilhas \"split\"."
14001
14002 #. type: Content of: <ul><li>
14003 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:14
14004 msgid ""
14005 "<code>scatter()</code>: splits an interleaved stack into several regular "
14006 "ones."
14007 msgstr ""
14008 "<code>scatter()</code>: separa uma pilha intercalada em três pilhas normais."
14009
14010 #. type: Content of: <p>
14011 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:17
14012 msgid ""
14013 "The goal of this first exercise in the series is to devise the "
14014 "<code>move3()</code> function. This starter task should not block you for "
14015 "too long, actually. It is ok if your function changes the order of the "
14016 "bottom triplet of disks, but it must preserve the order of the other "
14017 "triplets."
14018 msgstr ""
14019 "O objetivo deste primeiro exercício na série é \"devise\" a função "
14020 "<code>move3()</code>. Esta tarefa inicial não o deve segurar muito, na "
14021 "verdade. Tudo bem se a sua função muda a ordem do trio de discos mais no "
14022 "fundo, mas ela deve preservar a ordem dos outros trios."
14023
14024 #. type: Content of: <h2>
14025 #: src/lessons/recursion/hanoi/TricolorHanoi2.html:2
14026 msgid "Tricolor Hanoi: the Gathering"
14027 msgstr "Tricolor Hanoi: the Gathering"
14028
14029 #. type: Content of: <p>
14030 #: src/lessons/recursion/hanoi/TricolorHanoi2.html:4
14031 msgid ""
14032 "It is now time to write the second function required by the Tricolor Hanoi "
14033 "problem. <code>gather()</code> builds an interleaved stack from the regular "
14034 "split ones. This function takes four arguments, the last one being the "
14035 "target peg where the interleaved stack must be assembled. As you can see in "
14036 "the examples, the colors of must be in the same order for each triplet of "
14037 "disks."
14038 msgstr ""
14039 "Agora é a hora de escrever a segunda função necessária para o problema de "
14040 "Hanoi Tricolor. <code>gather()</code> constrói uma pilha intercalada a "
14041 "partir de pilhas \"split\". Esta função recebe quatro argumentos, o último a "
14042 "ser a vara de destino onde a pilha intercalada deve ser montada. Como pode "
14043 "ver nos exemplos, as cores devem estar na mesma ordem para cada trio de "
14044 "discos."
14045
14046 #. type: Content of: <p>
14047 #: src/lessons/recursion/hanoi/TricolorHanoi2.html:9
14048 msgid ""
14049 "That function actually uses the <code>move3()</code> that you wrote just "
14050 "before. Simply copy/paste your code over to reuse it. If you're lost, please "
14051 "refer to the Interleaved Hanoi exercise. Gathering 3 stacks on 3 pegs is "
14052 "rather similar to gathering 2 stacks on 4 pegs. You can find that exercise "
14053 "<a href=\"plm://lessons.recursion.hanoi/InterleavedHanoi\">here</a>."
14054 msgstr ""
14055 "Esta função, na verdade, usa o <code>move3()</code> que escreveu agora a "
14056 "pouco. Simplesmente copie-e-cole o seu código e reuse-o. Se estiver perdido, "
14057 "favor olhe o exercício Hanoi Intercalada. Obter 3 pilhas em 3 varas é muito "
14058 "similar a obter 2 pilhas em 4 varas. Pode encontrar este exercício <a href="
14059 "\"plm://lessons.recursion.hanoi/InterleavedHanoi\">aqui</a>."
14060
14061 #. type: Content of: <h2>
14062 #: src/lessons/recursion/hanoi/TricolorHanoi3.html:2
14063 msgid "Tricolor Hanoi: the Final"
14064 msgstr "Hanoi Tricolor: o Final"
14065
14066 #. type: Content of: <p>
14067 #: src/lessons/recursion/hanoi/TricolorHanoi3.html:4
14068 msgid ""
14069 "We are almost ready to write the whole tricolor algorithm. We just need the "
14070 "<code>scatter()</code> function, very inspired from the first one that we "
14071 "wrote for the <a href=\"plm://lessons.recursion.hanoi/SplitHanoi1\">Split "
14072 "Hanoi problem</a>. Assuming that your interleaved stack is placed on the "
14073 "<code>mid</code> peg, spread the disks over all pegs. Make sure to use "
14074 "<code>move3()</code> an even amount of time at each recursive level to "
14075 "ensure that the bottom disks are in the correct order."
14076 msgstr ""
14077 "Estamos quase prontos para escrever o algoritmo tricolor. Precisamos apenas "
14078 "da função <code>scatter()</code>, bastante inspirada na primeira que "
14079 "escrevemos para o <a href=\"plm://lessons.recursion.hanoi/SplitHanoi1\""
14080 ">problema de Hanoi Separado</a>. A assumir que a sua pilha intercalada "
14081 "esteja na vara do <code>meio</code>, espalhe os discos por todas as varas. "
14082 "Certifique-se de usar <code>move3()</code> uma quantidade par de vezes em "
14083 "cada nível recursivo para garantir que os discos de baixo estejam na ordem "
14084 "correta."
14085
14086 #. type: Content of: <p>
14087 #: src/lessons/recursion/hanoi/TricolorHanoi3.html:10
14088 msgid ""
14089 "As you can see, the initial situation is not the one expected by "
14090 "<code>scatter()</code>. You first have to apply <code>gather()</code> and "
14091 "<code>move3()</code> (twice to get the bottom triplet in the right "
14092 "order). These few steps plus the new <code>scatter()</code> function are "
14093 "enough to entirely solve the Tricolor Hanoi problem."
14094 msgstr ""
14095 "Como pode ver, a situação inicial não é a esperada por <code>scatter()</"
14096 "code>. Primeiro tem que aplicar <code>gather()</code> e <code>move3()</code> "
14097 "(duas vezes para pôr o trio do fundo na ordem correta). Estes poucos passos "
14098 "mais a nova função <code>scatter()</code> são o suficiente para resolver "
14099 "inteiramente o problema de Hanoi Tricolor."
14100
14101 #. type: Content of: <h2>
14102 #: src/lessons/recursion/hanoi/CyclicHanoi.html:2
14103 msgid "Cyclic Towers of Hanoi"
14104 msgstr "Torres de Hanoi cíclicas"
14105
14106 #. type: Content of: <p>
14107 #: src/lessons/recursion/hanoi/CyclicHanoi.html:4
14108 msgid ""
14109 "This variation of the Towers of Hanoi is very similar to the regular "
14110 "problem: you are given one stack of disks and three pegs, and you cannot "
14111 "move a larger disk over a smaller one. The change is that you can only move "
14112 "disks clockwise: 0->1 or 1->2 or 2->0, but never in the other direction."
14113 msgstr ""
14114 "Esta variação das torres de Hanoi é muito similar ao problema normal: recebe "
14115 "uma pilha de discos e três varas e não pode mover um disco maior sobre um "
14116 "menor. A diferença é que só pode mover discos no sentido horário: 0->1 ou 1-"
14117 ">2 ou 2->0, mas nunca na outra direção."
14118
14119 #. type: Content of: <p>
14120 #: src/lessons/recursion/hanoi/CyclicHanoi.html:8
14121 msgid ""
14122 "Obviously, the movements are not symmetric anymore. Moves from A to B are "
14123 "now very different from moves to B to A. As a result, you need two "
14124 "recursive functions depending on whether you are moving the stack clockwise "
14125 "or counterclockwise."
14126 msgstr ""
14127 "Obviamente, os movimentos não são simétricos de forma alguma. Movimentos de "
14128 "A para B são agora muito diferentes de movimentos de B para A. Como "
14129 "resultado, precisa de duas funções recursivas a depender de estar a mover a "
14130 "pilha no sentido horário ou anti-horário."
14131
14132 #. type: Content of: <p>
14133 #: src/lessons/recursion/hanoi/CyclicHanoi.html:11
14134 msgid ""
14135 "That being said, the problem decomposition is very similar to the classical "
14136 "Hanoi. The twist is that each function call the other one, constituting a "
14137 "nice example of mutual recursion."
14138 msgstr ""
14139 "Dito isto, a decomposição do problema é muito similar ao Hanoi clássico. A "
14140 "diferença é que cada função chama a outra, a constituir um bom exemplo de "
14141 "recursão mútua."
14142
14143 #. type: Content of: <h2>
14144 #: src/lessons/recursion/hanoi/IterativeHanoi.html:2
14145 msgid "Iterative Towers of Hanoi"
14146 msgstr "Torres de Hanoi Iterativas"
14147
14148 #. type: Content of: <p>
14149 #: src/lessons/recursion/hanoi/IterativeHanoi.html:4
14150 msgid ""
14151 "In this last exercise of the series, we will implement an iterative "
14152 "algorithm for the base problem of the Towers of Hanoi (one stack, 3 pegs, no "
14153 "extra movement restriction)."
14154 msgstr ""
14155 "Neste último exercício da série, vamos implementar um algoritmo iterativo "
14156 "para o problema básico das Torres de hanoi (uma pilha, 3 varas, sem "
14157 "restrição de movimento adicional)."
14158
14159 #. type: Content of: <p>
14160 #: src/lessons/recursion/hanoi/IterativeHanoi.html:8
14161 msgid ""
14162 "This algorithm is actually very simple: On odd moves, the smallest disk is "
14163 "moved in a given direction (either increasing 0-&gt;1-&gt;2-&gt;0 or "
14164 "decreasing 2-&lt;1-&lt;0-&lt;2) while on even moves, the only possible move "
14165 "that does not imply the smallest disk is made. You stop as soon as the stack "
14166 "is rebuilt on another location."
14167 msgstr ""
14168 "Na verdade, este algoritmo é bastante simples: em movimentos ímpares, o "
14169 "disco menor é movido numa dada direção (tanto a aumentar 0-&gt;1-&gt;2-&gt;0 "
14170 "ou a diminuir 2-&lt;1-&lt;0-&lt;2) enquanto em movimentos pares, o único "
14171 "movimento possível que não usa o disco menor é feito. Pare assim que a pilha "
14172 "é reconstruída na outra localização."
14173
14174 #. type: Content of: <p>
14175 #: src/lessons/recursion/hanoi/IterativeHanoi.html:13
14176 msgid ""
14177 "The function that you now need to write takes two parameters: the initial "
14178 "position of the smallest disk (i.e., the peg initially containing the stack) "
14179 "and a boolean indicating whether the smallest disk should move in the "
14180 "increasing order or not."
14181 msgstr ""
14182 "A função que precisa escrever agora tem dois parâmetros: a posição inicial "
14183 "do disco menor (p.ex., a vara inicialmente a conter a pilha) e um booleano a "
14184 "indicar se o disco menor deve mover na ordem de aumento ou não."
14185
14186 #. type: Content of: <p>
14187 #: src/lessons/recursion/hanoi/IterativeHanoi.html:17
14188 msgid ""
14189 "The simplicity of this algorithm is actually almost deceiving. One could "
14190 "wonder on the interest of the recursive algorithms when such a simple "
14191 "iterative algorithm exists. My personal feeling is that this solution is "
14192 "nice to execute, but almost impossible to devise in the first place (I even "
14193 "suspect that the authors built this iterative solution from observations of "
14194 "the recursive execution)..."
14195 msgstr ""
14196 "A simplicidade deste algoritmo é, na verdade, enganosa. Podemos pensar sobre "
14197 "o interesse em algoritmos recursivos quando algoritmos iterativos tão "
14198 "simples existem. A minha impressão é que esta solução é boa de executar, mas "
14199 "quase impossível de ser concebida desde o princípio (suspeito que os autores "
14200 "construíram esta solução iterativa da observação da execução da solução "
14201 "recursiva)..."
14202
14203 #. type: Content of: <p>
14204 #: src/lessons/recursion/hanoi/IterativeHanoi.html:23
14205 msgid ""
14206 "Predicting the effect of this function is also difficult: When the small "
14207 "disk moves in the increasing order, the stack is reconstructed on the right "
14208 "peg with 5 disks but on the left with 6 disks."
14209 msgstr ""
14210 "Prever o efeito desta função também é difícil: quando o pequeno disco move "
14211 "na ordem crescente, a pilha é reconstruída na cavilha direita com 5 discos, "
14212 "mas na esquerda com 6 discos."
14213
14214 #. type: Content of: <p>
14215 #: src/lessons/recursion/hanoi/IterativeHanoi.html:27
14216 msgid ""
14217 "An interesting question is whether such simple iterative algorithms exist "
14218 "for the other variation of the problem. Some were given in the literature "
14219 "(e.g. for the cyclic variation). I would happily integrate your solutions to "
14220 "the PLM, especially if you can hint (without spoiling) the solution to guide "
14221 "the next ones."
14222 msgstr ""
14223 "Uma questão interessante é se tais algoritmos simples existem para a outra "
14224 "variante do problema. Alguns estão na literatura (p.ex. para a variante "
14225 "cíclica). Integraria as suas soluções no PLM com alegria, especialmente se "
14226 "puder dar uma dica (sem estragar a surpresa) da solução para guiar as outras "
14227 "pessoas."
14228
14229 #. type: Content of: <h1>
14230 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:2
14231 msgid "HanoiWorld"
14232 msgstr "HanoiWorld"
14233
14234 #. type: Content of: <p>
14235 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:5
14236 msgid ""
14237 "This world implements the ultra-classical Hanoi problem. You are asked to "
14238 "move the disk pile from the stick where they are to the target stick (given "
14239 "as second parameter in the world's name -- number 1 for the default "
14240 "world). There is some extra constraint: you can only move one disk at a "
14241 "time, and you cannot move a big disk over a smaller one."
14242 msgstr ""
14243 "Este mundo implementa o problema ultra clássico das torres de Hanói. Deve "
14244 "mover a pilha de discos da pilha onde eles estão para outra pilha (dado um "
14245 "segundo parâmetro no nome do mundo -- número 1 para o mundo predefinido). "
14246 "Existem algumas restrições adicionais: pode mover apenas um disco por vez e "
14247 "não pode pôr um disco sobre um menor."
14248
14249 #. type: Content of: <p>
14250 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:12
14251 msgid "Only 4 functions are provided:"
14252 msgstr "Apenas 4 funções são fornecidas:"
14253
14254 #. type: Content of: <pre>
14255 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:14
14256 #, no-wrap
14257 msgid "[!java|c]void [/!]move([!java|c]int [/!]src, [!java|c]int [/!]dst)"
14258 msgstr "[!java|c]void [/!]mover([!java|c]int [/!]src, [!java|c]int [/!]dst)"
14259
14260 #. type: Content of: outside any tag (error?)
14261 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:16
14262 msgid ""
14263 "Moves one disk from the stick <code>src</code> onto the stick "
14264 "<code>dst</code>. If you try to do an invalid move (like laying a disk over "
14265 "a smaller one), an IllegalArgumentException is thrown."
14266 msgstr ""
14267 "Move um disco da vara <code>src</code> para a vara <code>dst</code>. Se "
14268 "tentar fazer um movimento inválido (como pôr um disco sobre outro menor), "
14269 "uma IllegalArgumentException é lançada."
14270
14271 #. type: Content of: <pre>
14272 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:20
14273 #, no-wrap
14274 msgid "[!java|c]int [/!]getSlotSize([!java|c]int [/!]slot)[!scala]:Int[/!]"
14275 msgstr "[!java|c]int [/!]getTamanhoSlot([!java|c]int [/!]slot)[!scala]:Int[/!]"
14276
14277 #. type: Content of: outside any tag (error?)
14278 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:21
14279 msgid ""
14280 "Returns the amount of disks placed on the specified slot. This is mainly "
14281 "used to initialize the recursion and set the amount of recursive call to "
14282 "execute."
14283 msgstr ""
14284 "Retorna a quantidade de discos postos num ponto específico. É usado "
14285 "principalmente para inicializar a recursão e ajustar a quantidade de "
14286 "chamadas recursivas para executar."
14287
14288 #. type: Content of: <pre>
14289 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:24
14290 #, no-wrap
14291 msgid "[!java|c]int [/!]getSlotRadius([!java|c]int [/!]slot)[!scala]:Int[/!]"
14292 msgstr "[!java|c]int [/!]getSlotRadius([!java|c]int [/!]slot)[!scala]:Int[/!]"
14293
14294 #. type: Content of: outside any tag (error?)
14295 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:25
14296 msgid "Returns the radius of the top-most disk of the specified slot."
14297 msgstr "Retorna o raio do disco no topo da vara especificada."
14298
14299 #. type: Content of: <h3>
14300 #: src/lessons/maze/Main.html:2 src/lessons/maze/short_desc.html:2
14301 msgid "Labyrinths"
14302 msgstr "Labirintos"
14303
14304 #. type: Content of: <p>
14305 #: src/lessons/maze/Main.html:4 src/lessons/maze/short_desc.html:4
14306 msgid "This lesson proposes several exercises about labyrinths in the buggle world."
14307 msgstr ""
14308 "Esta lição propõe vários exercícios sobre labirintos no mundo dos buggles."
14309
14310 #. type: Content of: <h2>
14311 #: src/lessons/maze/randommouse/RandomMouseMaze.html:2
14312 msgid "The crazy mouse"
14313 msgstr "O rato doido"
14314
14315 #. type: Content of: <p>
14316 #: src/lessons/maze/randommouse/RandomMouseMaze.html:4
14317 msgid ""
14318 "The day of your buggle starts badly. Out of luck, it got trapped into a "
14319 "maze. Help it finding its path out of there."
14320 msgstr ""
14321 "O dia do seu buggle começou ruim. Com falta de sorte, ficou preso num "
14322 "labirinto. Ajude-o a encontrar o caminho para a saída."
14323
14324 #. type: Content of: <p>
14325 #: src/lessons/maze/randommouse/RandomMouseMaze.html:9
14326 msgid ""
14327 "The exit is represented by a baggle and you need to pick this baggle in "
14328 "order to exit the maze."
14329 msgstr ""
14330 "A saída é representada por um baggle e precisa apanhar este baggle para sair "
14331 "do labirinto."
14332
14333 #. type: Content of: <p>
14334 #: src/lessons/maze/randommouse/RandomMouseMaze.html:14
14335 msgid ""
14336 "Since the maze is so small, we can write the dumbest possible algorithm to "
14337 "do so. It relies on randomness and proves quite inefficient."
14338 msgstr ""
14339 "Como o labirinto é muito pequeno, vamos escrever o algoritmo mais bobo "
14340 "possível. É aleatório e vai mostrar-se bem ineficiente."
14341
14342 #. type: Content of: <p>
14343 #: src/lessons/maze/randommouse/RandomMouseMaze.html:19
14344 msgid ""
14345 "While the buggle didn't find the path to the escape, it must proceed the "
14346 "following way: pick a random integer between 0 and 2 by using the provided "
14347 "<code>random3()</code> method and make one of the following actions: moving "
14348 "forward if possible, turn left or turn right."
14349 msgstr ""
14350 "Enquanto o buggle não encontra o caminho para a saída, deve fazer o seguinte:"
14351 " escolher um número inteiro entre 0 e 2 a usar o método <code>random3()</"
14352 "code> fornecido e fazer uma das seguintes ações: andar em frente se for "
14353 "possível, virar à esquerda ou virar à direita."
14354
14355 #. type: Content of: <p>
14356 #: src/lessons/maze/randommouse/RandomMouseMaze.html:25
14357 msgid ""
14358 "You don't believe that it could work? Well, give it a try, you will see... "
14359 "Don't forget to pick up the baggle once you've reached it."
14360 msgstr ""
14361 "Julga que isto não vai funcionar? Bem, experimente e verá... Não se esqueça "
14362 "de apanhar o baggle quando lhe chegar."
14363
14364 #. type: Content of: <h2>
14365 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:2
14366 msgid "Following the walls"
14367 msgstr "Seguir as paredes"
14368
14369 #. type: Content of: <p>
14370 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:4
14371 msgid ""
14372 "This time, the maze is a bit more complicated. Random won't be enough, we "
14373 "ough to be smart!"
14374 msgstr ""
14375 "Agora, o labirinto é um pouco mais complicado. Aleatoriedade pode não ser "
14376 "suficiente, devemos ser espertos!"
14377
14378 #. type: Content of: <p>
14379 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:7
14380 msgid ""
14381 "The good news is that this maze is simpler that it seems at the first "
14382 "glance: every wall are connected to each other. To get out of this kind of "
14383 "maze, the buggle only have to follow a wall (the one on its left or the one "
14384 "on its right, it doesn't matter). While keeping a paw on the wall, the "
14385 "buggle must move forward until it finds the maze exit and this biscuit it "
14386 "loves so much."
14387 msgstr ""
14388 "A boa notícia é que este labirinto é mais simples do que pode parecer à "
14389 "primeira vista: todas as paredes são conectadas às outras. Para sair deste "
14390 "tipo de labirinto, o buggle tem que simplesmente seguir uma parede (a que "
14391 "fica à esquerda ou à direita dele, não importa). Enquanto manter uma pata na "
14392 "parede, o buggle deve mover para a frente até encontrar a saída do labirinto "
14393 "e o biscoito que tanto gosta."
14394
14395 #. type: Content of: <p>
14396 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:14
14397 msgid ""
14398 "This works here because there is no island of isolated walls, so our buggle "
14399 "cannot loop around for ever without encountering its baggle."
14400 msgstr ""
14401 "Isto funciona aqui porque não existem ilhas ou paredes isoladas, pois o "
14402 "nosso buggle não vai entrar num loop para sempre sem encontrar o baggle dele."
14403
14404 #. type: Content of: outside any tag (error?)
14405 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:18
14406 msgid ""
14407 "The goal of this exercise is to write an algorithm allowing the buggle to "
14408 "get out of this maze."
14409 msgstr ""
14410 "O objetivo deste exercício é escrever um algoritmo que permita que o buggle "
14411 "saia do labirinto."
14412
14413 #. type: Content of: <p>
14414 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:21
14415 msgid ""
14416 "As said earlier, it does not matter whether you decide to follow the left "
14417 "wall or the right one. Simply, the demo follows the left one, so you should "
14418 "do the same in your solution to ease the comparison of your solution and the "
14419 "demo."
14420 msgstr ""
14421 "Como dito anteriormente, não importa se decide seguir a parede à esquerda ou "
14422 "à direita. Simplesmente, a demonstração segue a da esquerda, logo deve fazer "
14423 "o mesmo na sua solução para facilitar a comparação da sua solução e da "
14424 "demonstração."
14425
14426 #. type: Content of: <p>
14427 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:26
14428 msgid ""
14429 "Write a method <code>keepHandOnSideWall()</code> which lets the buggle move "
14430 "one step forward while keeping the paw on the wall of the selected side. You "
14431 "must ensure that the buggle always keep the paw on the wall, but also that "
14432 "it won't crash into a wall. You can check the tip for more info on this, but "
14433 "only do so if you're stuck. Try to do it without the tip first."
14434 msgstr ""
14435 "Escreva um método <code>keepHandOnSideWall()</code> que faz o buggle andar "
14436 "uma casa para a frente enquanto mantém a pata na parede do lado selecionado. "
14437 "Deve garantir que o buggle sempre mantenha a pata na parede, mas também que "
14438 "não bata numa parede. Pode controlar a dica para mais informações, mas faça-"
14439 "o apenas se estiver perdido. Tente primeiro fazer sem a dica."
14440
14441 #. type: Content of: <p>
14442 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:33
14443 msgid ""
14444 "Then, write the whole algorithm to traverse the maze step by step (using "
14445 "<code>keepHandOnSideWall()</code>) until it finds the biscuit and the "
14446 "exit. Don't forget to pick the baggle up once you've found it."
14447 msgstr ""
14448 "Depois escreva o algoritmo inteiro para percorrer o labirinto passo a passo ("
14449 "a usar <code>keepHandOnSideWall()</code>) até encontrar o biscoito e a "
14450 "saída. Não se esqueça de apanhar o baggle quando o encontrar."
14451
14452 #. type: Attribute 'alt' of: <div>
14453 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:38
14454 msgid "I'm lost, please give me some extra indications"
14455 msgstr "Estou perdido, dê-me orientações adicionais"
14456
14457 #. type: Content of: <div><p>
14458 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:39
14459 msgid ""
14460 "When your buggle has a wall on the left, there is three situations to "
14461 "consider, depending on the surrounding walls. The following table depicts "
14462 "each initial situation, and where you should let your buggle end after one "
14463 "step."
14464 msgstr ""
14465 "Quando o seu buggle tem uma parede à esquerda, existem três situações a "
14466 "considerar, dependente das paredes à volta. A tabela a seguir explica cada "
14467 "situação inicial e onde deve deixar o seu buggle parar depois de cada passo."
14468
14469 #. type: Content of: <div><table><tr><td>
14470 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:46
14471 msgid "Case 1"
14472 msgstr "Caso 1"
14473
14474 #. type: Content of: <div><table><tr><td>
14475 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:47
14476 msgid "Case 2"
14477 msgstr "Caso 2"
14478
14479 #. type: Content of: <div><table><tr><td>
14480 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:48
14481 msgid "Case 3"
14482 msgstr "Caso 3"
14483
14484 #. type: Content of: <div><table><tr><td>
14485 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:50
14486 msgid "Initial situation"
14487 msgstr "Situação inicial"
14488
14489 #. type: Content of: <div><table><tr><td>
14490 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:55
14491 msgid "Where is the next step"
14492 msgstr "Onde é o próximo passo"
14493
14494 #. type: Content of: <div><p>
14495 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:61
14496 msgid ""
14497 "If you do a <code>right()</code> in any case at the end of your function, "
14498 "it's possible to write it in 3 lines with a <code>while</code> loop."
14499 msgstr ""
14500 "Se faz um <code>right()</code> em qualquer caso no final da sua função, é "
14501 "possível escreve-la com 3 linhas com um loop <code>while</code>."
14502
14503 #. type: Content of: <h2>
14504 #: src/lessons/maze/pledge/PledgeMaze.html:2
14505 msgid "Pledge algorithm"
14506 msgstr "Algoritmo de Pledge"
14507
14508 #. type: Content of: <p>
14509 #: src/lessons/maze/pledge/PledgeMaze.html:4
14510 msgid ""
14511 "Once again, you thought that your algorithm were good enough to escape the "
14512 "maze, and once again, you buggle is now in a maze where your previous "
14513 "algorithm fails. Just give it a try: copy/paste your code and hit the "
14514 "\"Run\" button and see your creation fail. The trap is shaped like an upper "
14515 "case \"G\". The buggle enters the trap and follows the inner border. At some "
14516 "point, it finds the north direction free, run into that direction, and falls "
14517 "again in the trap."
14518 msgstr ""
14519 "Novamente, pensou que o seu algoritmo era bom o suficiente para escapar do "
14520 "labirinto e novamente, o seu buggle está agora num labirinto onde o seu "
14521 "algoritmo anterior falhou. Dê-lhe uma hipótese: copie-e-cole o seu código e "
14522 "aperte o botão \"Executar\" e veja a sua criação falhar. A armadilha é no "
14523 "formato de um \"G\" maiúsculo. O buggle entra na armadilha e segue a borda "
14524 "interior. Num determinado momento, encontra a direção norte livre, vai nesta "
14525 "direção e cai de novo na armadilha."
14526
14527 #. type: Content of: <p>
14528 #: src/lessons/maze/pledge/PledgeMaze.html:14
14529 msgid ""
14530 "The Pledge's algorithm (named after Jon Pledge of Exeter) can solve this "
14531 "maze."
14532 msgstr ""
14533 "O algoritmo de Pledge (em homenagem a Jon Pledge of Exeter) pode resolver "
14534 "este labirinto."
14535
14536 #. type: Content of: <p>
14537 #: src/lessons/maze/pledge/PledgeMaze.html:17
14538 msgid ""
14539 "This algorithm is a modification of the previous one thought to avoid "
14540 "obstacles. It randomly picks a heading and let the buggle move in that "
14541 "direction. When it encounters an obstacle, a paw (for example the left one) "
14542 "is kept on the wall following the obstacle while counting the turns. When "
14543 "the buggle is back to its original heading and when the sum of the turns is "
14544 "0, the buggle leaves the obstacle and continues keeping its original "
14545 "heading."
14546 msgstr ""
14547 "Este algoritmo é uma modificação do anterior para evitar obstáculos. Escolhe "
14548 "aleatoriamente uma direção e deixe o buggle ir nesta direção. Quando "
14549 "encontra um obstáculo, uma pata (por exemplo, a da esquerda) é mantida na "
14550 "parede a seguir o obstáculo enquanto conta as curvas. Quando o buggle está "
14551 "de volta à direção original dele e a soma das curvas deu 0, o buggle deixa o "
14552 "obstáculo e continua a manter a direção original dele."
14553
14554 #. type: Content of: <p>
14555 #: src/lessons/maze/pledge/PledgeMaze.html:25
14556 msgid ""
14557 "Note that the use of \"total turning\" rather than just the \"current "
14558 "direction\" allows the algorithm to avoid G-shapped traps. If one proceeds "
14559 "left into the trap, one gets turned around a full 360 degrees by the "
14560 "walls. As we said before, the naive \"current direction\" algorithm gets "
14561 "into a limit cycle as it leaves the lower rightmost wall heading left and "
14562 "runs into the curved section on the left again."
14563 msgstr ""
14564 "Observe que o uso de \"total turning\" ao invés de simplesmente o \"current "
14565 "direction\" permite que o algoritmo evite armadilhas no formato G. Se alguém "
14566 "escolhe a esquerda para dentro da armadilha acaba a girar 260 graus pelas "
14567 "paredes. Como dissemos antes, o algoritmo simplório \"current direction\" "
14568 "entra num ciclo limitado à medida que deixa a parede mais à direita a "
14569 "apontar para a esquerda e anda para a secção curvada na esquerda de novo."
14570
14571 #. type: Content of: <p>
14572 #: src/lessons/maze/pledge/PledgeMaze.html:32
14573 msgid ""
14574 "The Pledge's algorithm does not leave the rightmost wall due to the total "
14575 "turning not being zero at that point. It follows the wall all the way "
14576 "around, finally leaving it heading left on the bottom outside"
14577 msgstr ""
14578 "O algoritmo de Pledge não deixa a parede mais à direita devido ao total de "
14579 "curvas não ser zero neste ponto. Segue a parede na volta toda, a deixa-o "
14580 "finalmente a apontar para a esquerda no \"fundo exterior\""
14581
14582 #. type: Content of: <p>
14583 #: src/lessons/maze/pledge/PledgeMaze.html:39
14584 msgid ""
14585 "<a name=\"Objective\"/>You now have to modify your solution to implement the "
14586 "Pledge algorithm to escape this maze."
14587 msgstr ""
14588 "<a name=\"Objective\"/>Agora tem que modificar a sua solução para "
14589 "implementar o algoritmo de Pledge para escapar deste labirinto."
14590
14591 #. type: Content of: <p>
14592 #: src/lessons/maze/pledge/PledgeMaze.html:42
14593 msgid ""
14594 "Change your <code>keepHandOnSideWall()</code> method to count the amount of "
14595 "turns done by the buggle (+1 when it turns left, and -1 when it turns "
14596 "right). This counting may require the addition of an <code>angleSum</code> "
14597 "integer value in your program."
14598 msgstr ""
14599 "Mude o seu método <code>keepHandOnSideWall()</code> para contar a quantidade "
14600 "de curvas feitas pelo buggle (+1 quando gira para a esquerda e -1 quando "
14601 "gira para a direita). Esta contagem pode necessitar a adição de um valor "
14602 "inteiro <code>angleSum</code> no seu programa."
14603
14604 #. type: Content of: <p>
14605 #: src/lessons/maze/pledge/PledgeMaze.html:47
14606 msgid ""
14607 "Write a boolean method <code>isDirectionFree(dir)</code> indicating if the "
14608 "provided direction is free, ie, if you can move in that direction (Note that "
14609 "the demo uses the NORTH direction for that). You can retrieve the current "
14610 "direction of the buggle using the method <code>getDirection()</code>. You "
14611 "can change your direction (without moving) using "
14612 "<code>setDirection(dir)</code>. Don't forget to store the previous direction "
14613 "of your buggle (in a dedicated variable) before checking if your favorite "
14614 "direction is free in order to restore your state afterward."
14615 msgstr ""
14616 "Escreva um método booleano <code>isDirectionFree(dir)</code> a indicar se a "
14617 "direção dada está livre, ou seja, se pode mover naquela direção (Observe que "
14618 "a demonstração usa a direção NORTH para isto). Pode recuperar a direção "
14619 "atual do buggle a usar o método <code>getDirection()</code>. Pode mudar a "
14620 "sua direção (sem se mover) a usar <code>setDirection(dir)</code>. Não se "
14621 "esqueça de guardar a direção anterior do seu buggle (numa variável exclusiva)"
14622 " antes de verificar se a sua direção favorita está livre para depois "
14623 "recuperar o seu estado."
14624
14625 #. type: Content of: <p>
14626 #: src/lessons/maze/pledge/PledgeMaze.html:56
14627 msgid ""
14628 "You may have to change the rest of your code also, but these changes should "
14629 "remain limited."
14630 msgstr ""
14631 "Também pode ter que mudar o resto do seu código, mas estas mudanças podiam "
14632 "ser poucas."
14633
14634 #. type: Content of: <p>
14635 #: src/lessons/maze/pledge/PledgeMaze.html:59
14636 msgid ""
14637 "Don't forget that if you have a method modifying a global variable (such as "
14638 "angleSum), you should ensure that it declares this variable as "
14639 "global. Without it, the method creates a new variable of the same name, and "
14640 "the global never gets modified."
14641 msgstr ""
14642 "Não se esqueça que se tem um método que modifica uma variável global (como "
14643 "angleSum), deve garantir que declara esta variável como global. Sem ele, o "
14644 "método cria uma variável de mesmo nome e a global nunca é modificada."
14645
14646 #. type: Content of: <pre>
14647 #: src/lessons/maze/pledge/PledgeMaze.html:63
14648 #, no-wrap
14649 msgid ""
14650 "def myMethod():\n"
14651 " global angleSum\n"
14652 " ...\n"
14653 " angleSum = angleSum + 1\n"
14654 msgstr ""
14655 "def myMethod():\n"
14656 " global angleSum\n"
14657 " ...\n"
14658 " angleSum = angleSum + 1\n"
14659
14660 #. type: Attribute 'alt' of: <div>
14661 #: src/lessons/maze/pledge/PledgeMaze.html:70
14662 msgid "Show an additional tip"
14663 msgstr "Mostre uma dica adicional"
14664
14665 #. type: Content of: <div>
14666 #: src/lessons/maze/pledge/PledgeMaze.html:71
14667 msgid ""
14668 "You should set your direction to your favorite one (NORTH is advised). Then, "
14669 "you should write the algorithm main loop. In other words, while your buggle "
14670 "did not find its biscuit, you have to move forward until next obstacle in "
14671 "the favorite direction. Then, put a paw on a wall (using "
14672 "<code>keepHandOnSideWall()</code>) while the sum of turns is not null and "
14673 "the favorite direction is not free. Do that until you find your baggle."
14674 msgstr ""
14675 "Deve ajustar a sua direção para a sua favorita (NORTH é a recomendada). "
14676 "Então, deve escrever o loop principal algoritmo. Em outras palavras, "
14677 "enquanto o seu buggle não encontra o biscoito dele, tem que mover para a "
14678 "frente até ao próximo obstáculo na sua direção favorita. Então, ponha uma "
14679 "pata na parede (a usar <code>keepHandOnSideWall()</code>) enquanto a soma de "
14680 "curvas não for null (nula) e a direção favorita não estiver livre. Faça-o "
14681 "até que encontre o seu baggle."
14682
14683 #. type: Content of: <h2>
14684 #: src/lessons/maze/island/IslandMaze.html:2
14685 msgid "Lost between islands"
14686 msgstr "Perdido entre ilhas"
14687
14688 #. type: Content of: <p>
14689 #: src/lessons/maze/island/IslandMaze.html:4
14690 msgid ""
14691 "You thought that your algorithm was enough to escape mazes? Well, not every "
14692 "mazes..."
14693 msgstr ""
14694 "Julga que o seu algoritmo é suficiente para escapar de labirintos? Bem, não "
14695 "de todos..."
14696
14697 #. type: Content of: <p>
14698 #: src/lessons/maze/island/IslandMaze.html:8
14699 msgid ""
14700 "The <i>wall follower algorithm</i> we used so far only works if the entry "
14701 "and the exit are placed near to walls connected to the external wall. But if "
14702 "the buggle begins in the middle of the maze, it may exist wall sections "
14703 "disconnected from the external wall."
14704 msgstr ""
14705 "O <i>algoritmo de seguir paredes</i> que usamos até agora só funciona se a "
14706 "entrada e a saída estão próximas de paredes conectadas ao muro externo. Mas "
14707 "se o buggle começa na metade do labirinto, podem existir sessões de paredes "
14708 "desconectadas da parede externa."
14709
14710 #. type: Content of: <p><p>
14711 #: src/lessons/maze/island/IslandMaze.html:13
14712 msgid ""
14713 "That is why the previous strategy would let the buggle round around for "
14714 "ever. Indeed, the maze you should now escape from contains islands, and the "
14715 "buggle does not start along one of the external walls. Just give it a try if "
14716 "you want: copy your code over, push the run button and see your previous "
14717 "solution failing miserabily."
14718 msgstr ""
14719 "É por isto que a estratégia anterior pode deixar o buggle a dar voltas para "
14720 "sempre. Na verdade, o labirinto do qual deve escapar agora contém ilhas e o "
14721 "buggle não começa próximo de um dos muros externos. Experimente se quiser: "
14722 "copie o seu código aqui, aperte o botão executar e veja a sua solução "
14723 "anterior falhar vergonhosamente."
14724
14725 #. type: Content of: <p><p>
14726 #: src/lessons/maze/island/IslandMaze.html:19
14727 msgid ""
14728 "The method of following a wall is still good and allow to escape very "
14729 "efficiently some sections of the maze, so we do not want to remove it "
14730 "entierely. Instead, we want to stop following the wall under some "
14731 "conditions. Notice that the baggle lays near to the external border of the "
14732 "maze. So, we want to reach the border and then follow that wall. We need for "
14733 "example to search for the north wall before following it to the baggle."
14734 msgstr ""
14735 "O método de seguir uma parede ainda é bom e permite escapar com muita "
14736 "eficiência de algumas secções do labirinto, por isso não precisamos removê-"
14737 "lo inteiramente. Ao invés disto, queremos parar de seguir a parede sob "
14738 "certas condições. Observe que o baggle fica próximo da borda externa do "
14739 "labirinto. Queremos chegar à borda e então seguir aquela parede. Precisamos, "
14740 "por exemplo, procurar a parede norte antes de segui-la até ao baggle."
14741
14742 #. type: Content of: <p><p><p>
14743 #: src/lessons/maze/island/IslandMaze.html:27
14744 msgid ""
14745 "To find the north wall, you simply run to the north as long as it's "
14746 "possible, and when facing an obstacle, you avoid it (using previous method)."
14747 msgstr ""
14748 "Para encontrar a parede do norte, simplesmente ande para o norte enquanto "
14749 "for possível e quando encontrar um obstáculo, deve desviar dele (a usar o "
14750 "método anterior)."
14751
14752 #. type: Attribute 'alt' of: <p><p><div>
14753 #: src/lessons/maze/island/IslandMaze.html:31
14754 msgid "I'm lost now, please give me some extra indications"
14755 msgstr "Estou perdido agora, por favor dê-me algumas orientações adicionais"
14756
14757 #. type: Content of: <p><p><div>
14758 #: src/lessons/maze/island/IslandMaze.html:32
14759 msgid ""
14760 "Our new run() method will consist in two modes: our buggle will alternate "
14761 "between the \"north runner mode\" and the \"left follower mode\". You begin "
14762 "in \"north runner mode\", and switch to \"left follower\" when you have a "
14763 "wall at the north (do not forget to make sure you have a wall at your left "
14764 "before switching to \"left follower\" mode). You switch to \"north runner\" "
14765 "as soon as your buggle is facing north and is not in front of a wall during "
14766 "its trip around its left wall. The easiest way to write such a state machine "
14767 "is something like"
14768 msgstr ""
14769 "O nosso novo método run() consistirá de dois modos: o nosso buggle vai "
14770 "alternar entre o \"modo de andar para o norte\" e o \"modo de seguir à "
14771 "esquerda\". Começa no \"modo de andar para o norte\" e alternar para \"seguir"
14772 " à esquerda\" quando tiver uma parede ao norte (não se esqueça de garantir "
14773 "que tem uma parede à sua esquerda antes de alternar para o modo \"seguir a "
14774 "esquerda\"). Alterna para \"andar para o norte\" assim que o seu buggle "
14775 "estiver a olhar para o norte e não estiver em frente de um muro durante a "
14776 "sua viagem ao redor do muro à esquerda dele. O mais fácil de escrever tal "
14777 "máquina de estado é algo como"
14778
14779 #. type: Content of: <p><p><div><pre>
14780 #: src/lessons/maze/island/IslandMaze.html:40
14781 #, no-wrap
14782 msgid ""
14783 "[!scala]var state=0;\n"
14784 "state match {\n"
14785 " case 0 => // North runner\n"
14786 " ...\n"
14787 " state = 1;\n"
14788 " case 1 => // Left follower\n"
14789 " ...\n"
14790 " state = 0;\n"
14791 " case _ => println(\"This case should not happen. Please fix me\")\n"
14792 "}[/!][!java|c]int state=0;\n"
14793 "switch (state) {\n"
14794 " case 0: // North runner\n"
14795 " ...\n"
14796 " state = 1;\n"
14797 " break;\n"
14798 " case 1: // Left follower\n"
14799 " ...\n"
14800 " state = 0;\n"
14801 " break;\n"
14802 "}[/!][!python]northRunner = True\n"
14803 "if northRunner:\n"
14804 " ...\n"
14805 " northRunner = False\n"
14806 "else: # left follower\n"
14807 " ...\n"
14808 " northRunner = True[/!]"
14809 msgstr ""
14810 "[!scala]var state=0;\n"
14811 "state match {\n"
14812 " case 0 => // para o norte\n"
14813 " ...\n"
14814 " state = 1;\n"
14815 " case 1 => // seguir a esquerda\n"
14816 " ...\n"
14817 " state = 0;\n"
14818 " case _ => println(\"Isto não deveria acontecer. Favor me conserte\")\n"
14819 "}[/!][!java|c]int state=0;\n"
14820 "switch (state) {\n"
14821 " case 0: // para o norte\n"
14822 " ...\n"
14823 " state = 1;\n"
14824 " break;\n"
14825 " case 1: // seguir a esquerda\n"
14826 " ...\n"
14827 " state = 0;\n"
14828 " break;\n"
14829 "}[/!][!python]northRunner = True\n"
14830 "if northRunner:\n"
14831 " ...\n"
14832 " northRunner = False\n"
14833 "else: # left follower\n"
14834 " ...\n"
14835 " northRunner = True[/!]"
14836
14837 #. type: Content of: <p><p><div>
14838 #: src/lessons/maze/island/IslandMaze.html:67
14839 msgid ""
14840 "Don't forget the default case (matching _), or scala will issue an error "
14841 "since your matching would be incomplete.[/!]"
14842 msgstr ""
14843 "Não se esqueça do caso default (matching _), ou scala irá dar um erro já que "
14844 "o seu \"matching\" vai estar incompleto.[/!]"
14845
14846 #. type: Content of: <p><p><p>
14847 #: src/lessons/maze/island/IslandMaze.html:70
14848 msgid "Don't forget to let the buggle pick the baggle at the end of your code."
14849 msgstr "Não se esqueça de deixar o buggle apanhar o baggle no final do código."
14850
14851 #. type: Content of: <p><p><p>
14852 #: src/lessons/maze/island/IslandMaze.html:73
14853 msgid ""
14854 "You're up. That should be enough for you to figure out how to escape this "
14855 "maze, but if not, you can always request for the tip. But you do not need "
14856 "any more help, do you?"
14857 msgstr ""
14858 "Tudo pronto. Isto deve ser o suficiente para descobrir como sair deste "
14859 "labirinto e se não for o caso, sempre pode pedir uma dica. Mas não vai "
14860 "precisar, correto?"
14861
14862 #. type: Content of: <h2>
14863 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:2
14864 msgid "Basic Shortest Path algorithm"
14865 msgstr "Algoritmo básico do caminho mais curto"
14866
14867 #. type: Content of: <p>
14868 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:4
14869 msgid ""
14870 "To conclude with this introductory lesson to maze solving algorithms, we "
14871 "will investigate another way to find the exit. The buggle in this lesson is "
14872 "a special buggle: he is a jedi. He can feel the Force. This means he is able "
14873 "to feel his environment."
14874 msgstr ""
14875 "Para concluir com esta lição introdutória em algoritmos de resolução de "
14876 "labirintos, vamos investigar outra forma de encontrar a saída. O buggle "
14877 "nesta lição é um buggle especial: é um jedi. Pode sentir a Força. Isto "
14878 "significa que pode sentir o ambiente."
14879
14880 #. type: Content of: <p>
14881 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:8
14882 msgid ""
14883 "Without even leaving his position, he can retrieve information about the "
14884 "world he is leaving in, with the following functions:"
14885 msgstr ""
14886 "Sem nem sequer sair da posição dele, pode recuperar informações sobre o "
14887 "mundo que está a viver, com as seguintes funções:"
14888
14889 #. type: Content of: <ul><li>
14890 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:10
14891 msgid "<code>getWorldWidth()</code> gives the width of its world."
14892 msgstr "<code>getWorldWidth()</code> da a largura (\"width\") do mundo."
14893
14894 #. type: Content of: <ul><li>
14895 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:11
14896 msgid "<code>getWorldHeight()</code> gives the height of its world."
14897 msgstr "<code>getWorldHeight()</code> da a altura (\"height\") do mundo."
14898
14899 #. type: Content of: <ul><li>
14900 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:12
14901 msgid ""
14902 "<code>hasTopWall(x,y)</code> tells whether the cell (x,y) of this world has "
14903 "a wall on top."
14904 msgstr ""
14905 "<code>hasTopWall(x,y)</code> diz se a célula (x,y) deste mundo tem uma "
14906 "parede no topo."
14907
14908 #. type: Content of: <ul><li>
14909 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:13
14910 msgid ""
14911 "<code>hasLeftWall(x,y)</code> tells whether the cell (x,y) of this world has "
14912 "a wall on the left."
14913 msgstr ""
14914 "<code>hasLeftWall(x,y)</code> diz se a célula (x,y) deste mundo tem uma "
14915 "parede na esquerda."
14916
14917 #. type: Content of: <ul><li>
14918 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:14
14919 msgid ""
14920 "<code>hasBaggle(x,y)</code> tells whether the cell (x,y) of this world has a "
14921 "baggle."
14922 msgstr ""
14923 "<code>hasBaggle(x,y)</code> diz se a célula (x,y) deste mundo tem um baggle."
14924
14925 #. type: Content of: <ul><li>
14926 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:15
14927 msgid ""
14928 "<code>setIndication(x,y,i)</code> adds the integer indication <code>i</code> "
14929 "to the cell (x,y)."
14930 msgstr ""
14931 "<code>setIndication(x,y,i)</code> adiciona a indicação inteira <code>i</"
14932 "code> à célula (x,y)."
14933
14934 #. type: Content of: <ul><li>
14935 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:16
14936 msgid ""
14937 "<code>getIndication(x,y,i)</code> retrieves the integer indication of the "
14938 "cell (x,y) (or 9999 if there is no indication)."
14939 msgstr ""
14940 "<code>getIndication(x,y,i)</code> obtém a indicação inteira da célula (x,y) ("
14941 "ou 9999 se não houver indicação)."
14942
14943 #. type: Content of: <p>
14944 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:19
14945 msgid ""
14946 "It has to be noted that it is not possible to build a wall on the bottom "
14947 "edge or on the right edge of a cell. Therefore when such wall exists, it "
14948 "means it was built on a sibling cells -- as a top (respectively left) wall "
14949 "on the cell that is located below (respectively at the right of) the current "
14950 "cell."
14951 msgstr ""
14952 "Note que não é possível construir uma parede na borda de baixo ou na borda à "
14953 "direita de uma célula. Portanto, se tal parede existe, significa que foi "
14954 "construído nas células vizinhas -- como uma parede na borda de cima ("
14955 "respetivamente da esquerda) da célula que é localizada abaixo ("
14956 "respetivamente à direita) da célula atual."
14957
14958 #. type: Content of: <p>
14959 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:25
14960 msgid ""
14961 "Your buggle should first write the distance to the exit on each cell (or at "
14962 "least the useful ones)."
14963 msgstr ""
14964 "O seu buggle deve primeiro escrever a distância à saída em cada célula (ou "
14965 "pelo menos nas células úteis)."
14966
14967 #. type: Content of: <p>
14968 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:26
14969 msgid ""
14970 "For that, find the exit and write 0 there. Then, write 1 on every "
14971 "neighboring cells that is not separated from the exit with a wall. And then "
14972 "mark every cells from which you can reach the exit in 2 steps, and iterate "
14973 "for all cells until all cells are marked."
14974 msgstr ""
14975 "Para isto, encontre a saída e escreva 0 lá. Então, escreva 1 em cada célula "
14976 "vizinha que não esteja separada da saída por uma parede. E depois marque "
14977 "cada célula a partir da qual possa alcançar a saída em 2 passos e itere para "
14978 "todas as células até que todas as células estejam marcadas."
14979
14980 #. type: Content of: <p>
14981 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:31
14982 msgid ""
14983 "Once the cells are marked, get your jedi buggle to follow the shortest "
14984 "path. Basically the buggle has only to walk on each case with the lesser "
14985 "distance from the exit. You can use the method "
14986 "<code>setDirection(direction)</code> to make your buggle look at the "
14987 "specific direction such as "
14988 "<code>[!scala|java|python]Direction.[/!]NORTH</code> or "
14989 "<code>[!scala|java|python]Direction.[/!]EAST</code>."
14990 msgstr ""
14991 "Uma vez que as células estejam marcadas, faça o seu buggle jedi percorrer a "
14992 "caminho mais curto. Basicamente o buggle tem apenas que andar em cada caso "
14993 "com a menor distância à saída. Pode usar o método "
14994 "<code>setDirection(direction)</code> para fazer o seu buggle virar para a "
14995 "direção específica como <code>[!scala|java|python]Direction.[/!]NORTH</code> "
14996 "ou <code>[!scala|java|python]Direction.[/!]EAST</code>."
14997
14998 #. type: Attribute 'alt' of: <div>
14999 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:36
15000 msgid "I'm lost now. Please give me some extra indications."
15001 msgstr "Estou perdido agora. Por favor, dê-me algumas indicações adicionais."
15002
15003 #. type: Content of: <div>
15004 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:37
15005 msgid "Use the Force, Luke!"
15006 msgstr "Usa a Força, Luke!"
15007
15008 #. type: Content of: <h2>
15009 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:2
15010 msgid "Finding the walls to follow"
15011 msgstr "Encontrar as paredes para seguir"
15012
15013 #. type: Content of: <p>
15014 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:4
15015 msgid ""
15016 "This is exactly the same maze than before, but the buggle does not start at "
15017 "the same location. In particular, it does not have any wall to its left at "
15018 "the beginning."
15019 msgstr ""
15020 "Este é o mesmo labirinto que o anterior, mas o buggle não inicia na mesma "
15021 "localização. Em particular, não existe nenhuma parede à esquerda dele no "
15022 "início."
15023
15024 #. type: Content of: <p>
15025 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:8
15026 msgid ""
15027 "As a result, the method you wrote for the previous exercise probably don't "
15028 "work for this one. If you use it here with no modification, your buggle "
15029 "probably start looping over the four free cells around its start position "
15030 "(if that's not the case, well, you didn't really stick to the mission on "
15031 "previous exercise. Feel lucky and proceed to the next :)"
15032 msgstr ""
15033 "O resultado é que o método que escreveu para o exercício anterior "
15034 "provavelmente não vai funcionar neste agora. Se usá-lo aqui sem "
15035 "modificações, o seu buggle provavelmente vai iniciar a percorrer as quatro "
15036 "células ao redor do ponto inicial (se este não é o caso, bem, é porque não "
15037 "fez o exercício anterior completamente. Sinta-se sortudo e vá para o próximo "
15038 "exercício :)"
15039
15040 #. type: Content of: <p>
15041 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:15
15042 msgid ""
15043 "This is because your <code>keepHandOnSideWall()</code> method has an "
15044 "implicit <b>pre-condition</b>: it works well if and only if the buggle has a "
15045 "wall to its left when you call it. Such pre-condition are very heavily used "
15046 "when programming. Specifying them explicitly helps understanding the code "
15047 "written by other, and they even allow sometimes to prove that the code works "
15048 "correctly."
15049 msgstr ""
15050 "Isto é porque o seu método <code>keepHandOnSideWall()</code> tem uma "
15051 "<b>pré-condição</b> implícita: funciona bem apenas se o buggle tem uma "
15052 "parede à esquerda quando o chama. Tais pré-condições são muito usadas em "
15053 "programação. Especificá-las explicitamente ajuda a entender o código escrito "
15054 "por outros e até servem, às vezes, para provar que o código funciona "
15055 "corretamente."
15056
15057 #. type: Content of: <p>
15058 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:25
15059 msgid ""
15060 "Fixing the problem should be very easy. Simply make sure that the "
15061 "pre-condition of <code>keepHandOnSideWall()</code> is verified before "
15062 "calling it. For that, update your code to first look for a wall on its left "
15063 "before the big <code>while</code> loop."
15064 msgstr ""
15065 "Consertar o problema deve ser bem fácil. Simplesmente garanta que a pré-"
15066 "condição de <code>keepHandOnSideWall()</code> seja verificada antes de chamá-"
15067 "lo. Para isto, atualize o seu código para primeiro olhar a uma parede à sua "
15068 "esquerda antes do loop <code>while</code> maior."
15069
15070 #. type: Content of: <h3>
15071 #: src/lessons/lightbot/universe/LightBotWorld.html:2
15072 #: src/lessons/lightbot/Main.html:2 src/lessons/lightbot/short_desc.html:2
15073 msgid "LightBot"
15074 msgstr "LightBot"
15075
15076 #. type: Content of: outside any tag (error?)
15077 #: src/lessons/lightbot/universe/LightBotWorld.html:4
15078 msgid ""
15079 "This universe introduces a little programming puzzle which can somehow be "
15080 "used to introduce programmation to non-reading kids since it is programmed "
15081 "graphically. The goal of each board is to light up all the lights. Your "
15082 "robot understands the following orders:"
15083 msgstr ""
15084 "Este universo introduz um pequeno quebra-cabeças de programação que pode num "
15085 "sentido ser usado para introduzir programação a crianças que não sabem ler "
15086 "desde ser programado graficamente. O objetivo de cada tabuleiro é ligar "
15087 "todas as luzes. O seu robô entende as seguintes ordens:"
15088
15089 #. type: Content of: <table><tr><td>
15090 #: src/lessons/lightbot/universe/LightBotWorld.html:8
15091 msgid "<b>Order</b>"
15092 msgstr "<b>Order</b>"
15093
15094 #. type: Content of: <table><tr><td>
15095 #: src/lessons/lightbot/universe/LightBotWorld.html:8
15096 msgid "<b>Meaning</b>"
15097 msgstr "<b>Meaning</b>"
15098
15099 #. type: Content of: <table><tr><td>
15100 #: src/lessons/lightbot/universe/LightBotWorld.html:9
15101 msgid "<b>Move forward</b>"
15102 msgstr "<b>Mover para frente</b>"
15103
15104 #. type: Content of: <table><tr><td>
15105 #: src/lessons/lightbot/universe/LightBotWorld.html:9
15106 msgid "Cannot be done if the destination cell is of another height than source cell"
15107 msgstr ""
15108 "Não pode ser feito se a célula de destino é de outra altura que a célula de "
15109 "origem"
15110
15111 #. type: Content of: <table><tr><td>
15112 #: src/lessons/lightbot/universe/LightBotWorld.html:10
15113 msgid "<b>Jump forward</b>"
15114 msgstr "<b>Pular pra frente</b>"
15115
15116 #. type: Content of: <table><tr><td>
15117 #: src/lessons/lightbot/universe/LightBotWorld.html:10
15118 msgid ""
15119 "Can only be done if the destination cell is one step higher than source "
15120 "cell, or if destination is lower than source. Cannot be used for plain "
15121 "moves."
15122 msgstr ""
15123 "Só pode ser feito se a célula de destino está um passo mais alto que a "
15124 "célula de origem, ou se o destino é mais baixo que a origem. Não pode ser "
15125 "usado para movimentos normais."
15126
15127 #. type: Content of: <table><tr><td>
15128 #: src/lessons/lightbot/universe/LightBotWorld.html:11
15129 msgid "<b>Turn left</b>."
15130 msgstr "<b>Virar à esquerda</b>."
15131
15132 #. type: Content of: <table><tr><td>
15133 #: src/lessons/lightbot/universe/LightBotWorld.html:12
15134 msgid "<b>Turn right</b>."
15135 msgstr "<b>Virar à direita</b>."
15136
15137 #. type: Content of: <table><tr><td>
15138 #: src/lessons/lightbot/universe/LightBotWorld.html:13
15139 msgid "<b>Switch the light</b>."
15140 msgstr "<b>trocar a luz</b>."
15141
15142 #. type: Content of: <table><tr><td>
15143 #: src/lessons/lightbot/universe/LightBotWorld.html:13
15144 msgid ""
15145 "Turn it on if it was off, and off if it was on. No effect if the cell does "
15146 "not contain any light."
15147 msgstr ""
15148 "Liga-a se estiver desligada e desliga-a se estiver ligada. Sem efeito se a "
15149 "célula não contém nenhuma luz."
15150
15151 #. type: Content of: <table><tr><td>
15152 #: src/lessons/lightbot/universe/LightBotWorld.html:14
15153 msgid "<b>Call function 1</b>."
15154 msgstr "<b>Chamar função 1</b>."
15155
15156 #. type: Content of: <table><tr><td>
15157 #: src/lessons/lightbot/universe/LightBotWorld.html:15
15158 msgid "<b>Call function 2</b>."
15159 msgstr "<b>Chamar função 2</b>."
15160
15161 #. type: Content of: <p>
15162 #: src/lessons/lightbot/universe/LightBotWorld.html:18
15163 msgid ""
15164 "Please note that this world is not completely suited to small kids since the "
15165 "main difficulty comes from the fact that your are highly limited in the "
15166 "amount of instructions you can give to your robot. Advanced levels thus "
15167 "require to write sound functions, and are often above the capacities of "
15168 "small kids."
15169 msgstr ""
15170 "Por favor observe que este mundo não é completamente adequado para crianças "
15171 "pequenas uma vez que a principal dificuldade vem do fato de que a quantidade "
15172 "de instruções é muito limitada. Níveis avançados então necessitam que "
15173 "algumas funções de sons são escritas e estão acima das capacidades de "
15174 "crianças pequenas."
15175
15176 #. type: Content of: <p>
15177 #: src/lessons/lightbot/universe/LightBotWorld.html:20
15178 msgid ""
15179 "This game is heavily inspirated from a flash game of the same name, which "
15180 "can for example be played on kongregate.com. It was written by Danny "
15181 "Yaroslavski (Coolio-Niato), the original idea being of Matt Chase."
15182 msgstr ""
15183 "Este jogo é fortemente inspirado dum jogo de flash com o mesmo nome, que "
15184 "pode, por exemplo, ser jogado em kongregate.com. Foi escrito por Danny "
15185 "Yaroslavski (Coolio-Niato) e a ideia original é de Matt Chase."
15186
15187 #. type: Content of: outside any tag (error?)
15188 #: src/lessons/lightbot/Main.html:3
15189 msgid ""
15190 "This lesson introduces a little programming puzzle inspired from a flash "
15191 "game."
15192 msgstr ""
15193 "Esta lição introduz um pequeno quebra-cabeças de programação inspirado num "
15194 "jogo em flash."
15195
15196 #. type: Content of: <p>
15197 #: src/lessons/lightbot/Main.html:5
15198 msgid "See the <i>About this world</i> dialog for more details."
15199 msgstr "Veja o diálogo <i>Sobre este mundo</i> para mais detalhes."
15200
15201 #. type: Content of: <p>
15202 #: src/lessons/lightbot/short_desc.html:4
15203 msgid ""
15204 "This lesson constitutes a little brain teaser for programmers. You have to "
15205 "instruct your robot to turn off all lights. The trick is that you program "
15206 "your robot graphically, and that you are limited in the amount of "
15207 "instructions."
15208 msgstr ""
15209 "Esta lição constitui um pequeno \"brain teaser\" para programadores. Tem que "
15210 "instruir o seu robô a desligar todas as luzes. O truque é que programa o seu "
15211 "robô graficamente e tem uma quantidade limitada de instruções."
15212
15213 #. type: Content of: <p>
15214 #: src/lessons/lightbot/short_desc.html:9
15215 msgid "No previous experience is expected to take this lesson."
15216 msgstr "Espera-se experiência prévia para fazer esta lição."
15217
15218 #. type: Content of: <h1>
15219 #: src/lessons/lightbot/Board01TwoSteps.html:2
15220 msgid "Welcome"
15221 msgstr "Bem-vindo"
15222
15223 #. type: Content of: <p>
15224 #: src/lessons/lightbot/Board01TwoSteps.html:4
15225 msgid ""
15226 "Welcome to the lightbot world. This is merely a programmer puzzle rather "
15227 "than a real lesson (although some use it to teach programming). The robot "
15228 "is not programmed in Java, but rather graphically. You can see the existing "
15229 "orders in the documentation using the <i>About this world</i> menu."
15230 msgstr ""
15231 "Bem-vindo ao mundo lightbot. Este é apenas um quebra-cabeça para "
15232 "programadores ao invés de uma lição real (embora algumas pessoas usem isto "
15233 "para ensinar programação). O robô não é programado em Java, mas sim "
15234 "graficamente. Pode ver as ordens existentes na documentação a usar o menu "
15235 "<i>Sobre este mundo</i>."
15236
15237 #. type: Content of: <p><</p><p>
15238 #: src/lessons/lightbot/Board01TwoSteps.html:7
15239 msgid ""
15240 "The goal of each board is simply to switch on every lights of the board "
15241 "using your little robot."
15242 msgstr ""
15243 "O objetivo de cada tabuleiro é simplesmente ligar todas as luzes do "
15244 "tabuleiro a usar o seu pequeno robô."
15245
15246 #. type: Content of: <p><</p><p>
15247 #: src/lessons/lightbot/Board01TwoSteps.html:9
15248 msgid ""
15249 "This is a introduction exercise, which should be solvable by only moving "
15250 "forward and switching the light, using respectively"
15251 msgstr ""
15252 "Este é um exercício introdutório, que pode ser resolvido simplesmente a "
15253 "mover em frente e a apertar o interruptor, a usar respetivamente"
15254
15255 #. type: Content of: <p>
15256 #: src/lessons/lightbot/Board01TwoSteps.html:11
15257 #: src/lessons/lightbot/Board02Turn.html:5
15258 #: src/lessons/lightbot/Board06Func.html:4
15259 msgid "and"
15260 msgstr "e"
15261
15262 #. type: Content of: <p><</p><p>
15263 #: src/lessons/lightbot/Board01TwoSteps.html:11
15264 msgid "."
15265 msgstr "."
15266
15267 #. type: Content of: <h1>
15268 #: src/lessons/lightbot/Board02Turn.html:2
15269 msgid "Turn around"
15270 msgstr "Virar"
15271
15272 #. type: Content of: <p>
15273 #: src/lessons/lightbot/Board02Turn.html:4
15274 msgid "Now, you probably need to turn in addition (using"
15275 msgstr "Agora, provavelmente precisa virar adicionalmente (a usar"
15276
15277 #. type: Content of: <p>
15278 #: src/lessons/lightbot/Board02Turn.html:5
15279 msgid ")."
15280 msgstr ")."
15281
15282 #. type: Content of: <h1>
15283 #: src/lessons/lightbot/Board03Jump.html:2
15284 msgid "Jump"
15285 msgstr "Pular"
15286
15287 #. type: Content of: <p>
15288 #: src/lessons/lightbot/Board03Jump.html:4
15289 msgid "You can also jump using"
15290 msgstr "Também pode pular a usar"
15291
15292 #. type: Content of: <p>
15293 #: src/lessons/lightbot/Board03Jump.html:4
15294 msgid ""
15295 "to pass obstacles. You can either jump one level up or any amount of levels "
15296 "down, but you cannot jump to go on a cell of the same height."
15297 msgstr ""
15298 "para passar obstáculos. Pode tanto pular um nível ou qualquer quantidade de "
15299 "níveis para baixo, mas não pode pular para uma célula da mesma altura."
15300
15301 #. type: Content of: <h1>
15302 #: src/lessons/lightbot/Board04Stairs.html:2
15303 msgid "Stairs"
15304 msgstr "Degraus"
15305
15306 #. type: Content of: <p>
15307 #: src/lessons/lightbot/Board04Stairs.html:4
15308 msgid "Can you pass these stairs?"
15309 msgstr "Pode passar estes degraus?"
15310
15311 #. type: Content of: <h1>
15312 #: src/lessons/lightbot/Board05Higher.html:2
15313 msgid "Higher"
15314 msgstr "Mais alto"
15315
15316 #. type: Content of: <p>
15317 #: src/lessons/lightbot/Board05Higher.html:4
15318 msgid "Let's go higher"
15319 msgstr "Vamos mais alto"
15320
15321 #. type: Content of: <p>
15322 #: src/lessons/lightbot/Board06Func.html:4
15323 msgid "You can use"
15324 msgstr "Pode usar"
15325
15326 #. type: Content of: <p>
15327 #: src/lessons/lightbot/Board06Func.html:4
15328 msgid ""
15329 "to call respectively the first and second functions. Define their code in "
15330 "their own tab."
15331 msgstr ""
15332 "chamar respetivamente as primeira e segunda funções. Defina o código na "
15333 "própria guia dele."
15334
15335 #. type: Content of: <p><p>
15336 #: src/lessons/lightbot/Board06Func.html:6
15337 msgid "This is great if you get out of space in your main function"
15338 msgstr "Isto é muito bom se ficar sem espaço na sua função principal"
15339
15340 #. type: Content of: <h1>
15341 #: src/lessons/lightbot/Board07Repeat.html:2
15342 msgid "Repetitive tasks"
15343 msgstr "Tarefas repetitivas"
15344
15345 #. type: Content of: <p>
15346 #: src/lessons/lightbot/Board07Repeat.html:4
15347 msgid "Functions are also of great use for repetitive tasks"
15348 msgstr "Funções também são muitos úteis para tarefas repetitivas"
15349
15350 #. type: Content of: <h1>
15351 #: src/lessons/lightbot/Board08Rec.html:2
15352 msgid "Calling functions from functions"
15353 msgstr "Chamar funções de dentro de funções"
15354
15355 #. type: Content of: <p>
15356 #: src/lessons/lightbot/Board08Rec.html:4
15357 msgid "It is perfectly okay to call a function from within a function!"
15358 msgstr "Não tem nada de errado em chamar uma função de dentro de uma função!"
15359
15360 #. type: Content of: <h1>
15361 #: src/lessons/lightbot/Board09Castle.html:2
15362 msgid "Castle"
15363 msgstr "Castelo"
15364
15365 #. type: Content of: <p>
15366 #: src/lessons/lightbot/Board09Castle.html:4
15367 msgid "You're getting good at this..."
15368 msgstr "Está a ficar bom nisto..."
15369
15370 #. type: Content of: <h1>
15371 #: src/lessons/lightbot/Board10Wall.html:2
15372 msgid "Wall"
15373 msgstr "Parede"
15374
15375 #. type: Content of: <p>
15376 #: src/lessons/lightbot/Board10Wall.html:4
15377 msgid "Ready to climb the wall?"
15378 msgstr "Preparado para subir a parede?"
15379
15380 #. type: Content of: <h1>
15381 #: src/lessons/lightbot/Board11Sea.html:2
15382 msgid "Sea"
15383 msgstr "Mar"
15384
15385 #. type: Content of: <p>
15386 #: src/lessons/lightbot/Board11Sea.html:4
15387 msgid "You now have to surf these waves of lamps."
15388 msgstr "Agora vai ter que surfar neste mar de lâmpadas."
15389
15390 #. type: Content of: <h1>
15391 #: src/lessons/lightbot/Board12Escher.html:2
15392 msgid "Escher Castle"
15393 msgstr "Castelo de Escher"
15394
15395 #. type: Content of: <p>
15396 #: src/lessons/lightbot/Board12Escher.html:4
15397 msgid "This one aint easy."
15398 msgstr "Este não é fácil."
15399
15400 #. type: Content of: <h1>
15401 #: src/lessons/welcome/bat/bool1/Close10.html:2
15402 msgid "Close to 10"
15403 msgstr "Próximo de 10"
15404
15405 #. type: Content of: <p>
15406 #: src/lessons/welcome/bat/bool1/Close10.html:3
15407 msgid ""
15408 "Given 2 int values, return whichever value is nearest to the value 10, or "
15409 "return 0 in the event of a tie. [!java|scala]Note that Math.abs(n) returns "
15410 "the absolute value of a number.[/!] [!python]Note that math.fabs(n) returns "
15411 "the absolute value of a number. This function can only be used if you "
15412 "imported the math module.[/!]"
15413 msgstr ""
15414 "Dados dois valores int, retorne o valor que for mais próximo do 10 ou "
15415 "retorne 0 no caso de um empate. [!java|scala]Note que Math.abs(n) retorna o "
15416 "valor absoluto de um número.[/!] [!python]Note que math.fabs(n) retorna o "
15417 "valor absoluto de um número. Esta função só pode ser usada se importar o "
15418 "módulo math.[/!]"
15419
15420 #. type: Content of: <h1>
15421 #: src/lessons/welcome/bat/bool1/CountTeen.html:2
15422 msgid "Count Teen"
15423 msgstr "Contar Adolescentes"
15424
15425 #. type: Content of: <p>
15426 #: src/lessons/welcome/bat/bool1/CountTeen.html:3
15427 msgid ""
15428 "We'll say that a number is \"teen\" if it is in the range 13..19 "
15429 "inclusive. Given 4 int values, return the amount of teen ones."
15430 msgstr ""
15431 "Diremos que um número é \"adolescente\" se estiver no intervalo 13..19 "
15432 "inclusive. Dados 4 valores int, retorne a quantidade de adolescentes."
15433
15434 #. type: Content of: <h1>
15435 #: src/lessons/welcome/bat/bool1/Diff21.html:2
15436 msgid "Diff 21"
15437 msgstr "Diferença 21"
15438
15439 #. type: Content of: outside any tag (error?)
15440 #: src/lessons/welcome/bat/bool1/Diff21.html:3
15441 msgid ""
15442 "Given an int n, return the absolute difference between n and 21, except "
15443 "return double the absolute difference if n is over 21."
15444 msgstr ""
15445 "Dado um int n, retorne a diferença absoluta entre n e 21, exceto que retorna "
15446 "a diferença absoluta, se n for maior que 21."
15447
15448 #. type: Content of: <h1>
15449 #: src/lessons/welcome/bat/bool1/HasTeen.html:2
15450 msgid "Has Teen"
15451 msgstr "Tem Adolescente"
15452
15453 #. type: Content of: outside any tag (error?)
15454 #: src/lessons/welcome/bat/bool1/HasTeen.html:3
15455 msgid ""
15456 "We'll say that a number is \"teen\" if it is in the range 13..19 "
15457 "inclusive. Given 3 int values, return true if 1 or more of them are teen."
15458 msgstr ""
15459 "Diremos que um número é \"adolescente\" se está entre 13..19 inclusive. "
15460 "dados 3 valores int, retorne true se 1 ou mais deles são adolescentes."
15461
15462 #. type: Content of: <h1>
15463 #: src/lessons/welcome/bat/bool1/IcyHot.html:2
15464 msgid "Icy Hot"
15465 msgstr "Frio Quente"
15466
15467 #. type: Content of: outside any tag (error?)
15468 #: src/lessons/welcome/bat/bool1/IcyHot.html:3
15469 msgid ""
15470 "Given two temperatures, return true if one is less than 0 and the other is "
15471 "greater than 100."
15472 msgstr ""
15473 "Dadas duas temperaturas, retorne true se uma é menor que 0 e a outra é maior "
15474 "que 100."
15475
15476 #. type: Content of: <h1>
15477 #: src/lessons/welcome/bat/bool1/In1020.html:2
15478 msgid "In [10;20]"
15479 msgstr "In [10;20]"
15480
15481 #. type: Content of: outside any tag (error?)
15482 #: src/lessons/welcome/bat/bool1/In1020.html:3
15483 msgid ""
15484 "Given 2 int values, return true if either of them is in the range 10..20 "
15485 "inclusive."
15486 msgstr ""
15487 "Dados 2 valores int, retorne true se qualquer um deles estiver no intervalo "
15488 "10..20 inclusive."
15489
15490 #. type: Content of: <h1>
15491 #: src/lessons/welcome/bat/bool1/In3050.html:2
15492 msgid "In [30;50]"
15493 msgstr "In [30;50]"
15494
15495 #. type: Content of: outside any tag (error?)
15496 #: src/lessons/welcome/bat/bool1/In3050.html:3
15497 msgid ""
15498 "Given 2 int values, return true if they are both in the range 30..40 "
15499 "inclusive, or they are both in the range 40..50 inclusive."
15500 msgstr ""
15501 "Dados 2 valores int, retorne true se estão ambos no intervalo 30..40 "
15502 "inclusive, ou se eles estão ambos no intervalo 40..50 inclusive."
15503
15504 #. type: Content of: <h1>
15505 #: src/lessons/welcome/bat/bool1/LastDigit.html:2
15506 msgid "LastDigit"
15507 msgstr "Último Dígito"
15508
15509 #. type: Content of: outside any tag (error?)
15510 #: src/lessons/welcome/bat/bool1/LastDigit.html:3
15511 msgid ""
15512 "Given two non-negative int values, return true if they have the same last "
15513 "digit, such as with 27 and 57. Note that the % \"mod\" operator computes "
15514 "remainders, so 17 % 10 is 7."
15515 msgstr ""
15516 "Dados dois valores int não negativos, retorne true se têm o mesmo dígito "
15517 "final, como com 27 e 57. Note que o operador % \"mod\" calcula os restos, "
15518 "pois 17 % 10 é 7."
15519
15520 #. type: Content of: <p>
15521 #: src/lessons/welcome/bat/bool1/LastDigit.html:10
15522 #: src/lessons/welcome/bat/bool2/ShareDigit.html:10
15523 msgid ""
15524 "This exercise was converted to PLM from the excellent exercising site "
15525 "http://javabat.com/"
15526 msgstr ""
15527 "Este exercício foi convertido para o PLM do excelente sítio de exercícios "
15528 "http://javabat.com/"
15529
15530 #. type: Content of: <h1>
15531 #: src/lessons/welcome/bat/bool1/LoneTeen.html:2
15532 msgid "Lone Teen"
15533 msgstr "Lone Teen"
15534
15535 #. type: Content of: outside any tag (error?)
15536 #: src/lessons/welcome/bat/bool1/LoneTeen.html:3
15537 msgid ""
15538 "We'll say that a number is \"teen\" if it is in the range 13..19 "
15539 "inclusive. Given 2 int values, return true if one or the other is teen, but "
15540 "not both."
15541 msgstr ""
15542 "Diremos que um número é \"adolescente\" se está no intervalo entre 13..19 "
15543 "inclusive. Dados 2 valores, retorne true se um ou o outro é adolescente, mas "
15544 "não ambos."
15545
15546 #. type: Content of: <h1>
15547 #: src/lessons/welcome/bat/bool1/Main.html:2
15548 msgid "Boolean fun"
15549 msgstr "Boolean fun"
15550
15551 #. type: Content of: <p>
15552 #: src/lessons/welcome/bat/bool1/Main.html:4
15553 msgid ""
15554 "Boolean operations are one of the very basic task in programming. As long "
15555 "as you cannot write a not so simple boolean test under the minute, you "
15556 "probably will have a very bad time writing a real program."
15557 msgstr ""
15558 "Operações booleanas são algumas das mais básicas tarefas na programação. "
15559 "Enquanto não puder escrever um teste booleano não muito simples em menos de "
15560 "um minuto, provavelmente terá dificuldades em escrever programas no mundo "
15561 "real."
15562
15563 #. type: Content of: <p>
15564 #: src/lessons/welcome/bat/bool1/Main.html:9
15565 msgid ""
15566 "That is why this lesson provides you a bunch of such exercises, so that you "
15567 "can get trained in this."
15568 msgstr ""
15569 "É por isto que esta lição fornece vários exercícios deste tipo, de forma que "
15570 "fique treinado nisto."
15571
15572 #. type: Content of: <h1>
15573 #: src/lessons/welcome/bat/bool1/Makes10.html:2
15574 msgid "Makes 10"
15575 msgstr "Makes 10"
15576
15577 #. type: Content of: outside any tag (error?)
15578 #: src/lessons/welcome/bat/bool1/Makes10.html:3
15579 msgid ""
15580 "Given 2 ints, a and b, return true if one of them is 10 or if their sum is "
15581 "10."
15582 msgstr ""
15583 "Dados 2 inteiros, a e b, retorne true se um deles é 10 ou se a a soma deles "
15584 "é 10."
15585
15586 #. type: Content of: <h1>
15587 #: src/lessons/welcome/bat/bool1/Max1020.html:2
15588 msgid "Max1020"
15589 msgstr "Max1020"
15590
15591 #. type: Content of: <p>
15592 #: src/lessons/welcome/bat/bool1/Max1020.html:3
15593 msgid ""
15594 "Given 2 positive int values, return the larger value that is in the range "
15595 "10..20 inclusive, or return 0 if neither is in that range."
15596 msgstr ""
15597 "Dados 2 valores int positivos, retorne o maior valor que está no intervalo "
15598 "10..20 inclusive, ou retorne 0 se nenhum dos dois estiver neste intervalo."
15599
15600 #. type: Content of: <p>
15601 #: src/lessons/welcome/bat/bool1/Max1020.html:6
15602 msgid ""
15603 "Note that Math.max(Int,Int):Int and Math.min(Int,Int):Int return the maximum "
15604 "and minimum of two integers"
15605 msgstr ""
15606 "Observe que Math.max(Int,Int):Int e Math.min(Int,Int):Int retornam o máximo "
15607 "e o mínimo de dois inteiros"
15608
15609 #. type: Content of: <h1>
15610 #: src/lessons/welcome/bat/bool1/MonkeyTrouble.html:2
15611 msgid "MonkeyTrouble"
15612 msgstr "MonkeyTrouble"
15613
15614 #. type: Content of: outside any tag (error?)
15615 #: src/lessons/welcome/bat/bool1/MonkeyTrouble.html:4
15616 msgid ""
15617 "We have two monkeys, a and b, and the parameters aSmile and bSmile indicate "
15618 "if each is smiling. We are in trouble if they are both smiling or if "
15619 "neither of them is smiling. Return true if we are in trouble."
15620 msgstr ""
15621 "Temos dois macacos, a e b, e os parâmetros aSmile e bSmile indicam se cada "
15622 "um está a sorrir. Teremos problemas se os dois estiverem a sorrir ou nenhum "
15623 "deles estiver a sorrir. Retorne true se estivermos com problemas."
15624
15625 #. type: Content of: <h1>
15626 #: src/lessons/welcome/bat/bool1/NearHundred.html:2
15627 msgid "Near Hundred"
15628 msgstr "Near Hundred"
15629
15630 #. type: Content of: <p>
15631 #: src/lessons/welcome/bat/bool1/NearHundred.html:3
15632 msgid ""
15633 "Given an int n, return true if it is within 10 of 100 or 200. "
15634 "[!java|scala]Note that Math.abs(n) returns the absolute value of a "
15635 "number.[/!] [!python]Note that math.fabs(n) returns the absolute value of a "
15636 "number. This function can only be used if you imported the math module.[/!]"
15637 msgstr ""
15638 "Dado um int n, retorna true se estiver entre 10 a 100 ou 200. [!java|scala]"
15639 "Note que Math.abs(n) retorna o valor absoluto de um número.[/!] [!python]"
15640 "Note que math.fabs(n) retorna o valor absoluto de um número. Esta função só "
15641 "pode ser usada se importar o módulo math.[/!]"
15642
15643 #. type: Content of: <h1>
15644 #: src/lessons/welcome/bat/bool1/ParotTrouble.html:2
15645 msgid "Parot Trouble"
15646 msgstr "Parot Trouble"
15647
15648 #. type: Content of: outside any tag (error?)
15649 #: src/lessons/welcome/bat/bool1/ParotTrouble.html:4
15650 msgid ""
15651 "We have a loud talking parrot. The \"hour\" parameter is the current hour "
15652 "time in the range 0..23. We are in trouble if the parrot is talking and the "
15653 "hour is before 7 or after 20. Return true if we are in trouble."
15654 msgstr ""
15655 "Temos um papagaio que fala alto. O parâmetro \"hora\" é a hora atual no "
15656 "intervalo 0..23. Estamos com problemas se o papagaio fala e a hora for antes "
15657 "de 7 ou depois de 20. Retorne true se estivermos com problemas."
15658
15659 #. type: Content of: <h1>
15660 #: src/lessons/welcome/bat/bool1/PosNeg.html:2
15661 msgid "Positive Negative"
15662 msgstr "Positivo Negativo"
15663
15664 #. type: Content of: outside any tag (error?)
15665 #: src/lessons/welcome/bat/bool1/PosNeg.html:3
15666 msgid ""
15667 "Given 2 int values, return true if one is negative and one is "
15668 "positive. Unless negative is true, then they both must be negative."
15669 msgstr ""
15670 "Dados 2 valores int, retorne true se um é negativo e o outro é positivo. A "
15671 "menos que o negativo seja true, neste caso ambos devem ser negativos."
15672
15673 #. type: Content of: <h1>
15674 #: src/lessons/welcome/bat/bool1/SleepIn.html:2
15675 msgid "SleepDay"
15676 msgstr "SleepDay"
15677
15678 #. type: Content of: outside any tag (error?)
15679 #: src/lessons/welcome/bat/bool1/SleepIn.html:4
15680 msgid ""
15681 "The parameter weekday is true if it is a weekday, and the parameter vacation "
15682 "is true if we are on vacation. We sleep in if it is not a weekday or we're "
15683 "on vacation. Return true if we sleep in."
15684 msgstr ""
15685 "O parâmetro dia da semana é true se estivermos num dia de semana e o "
15686 "parâmetro vacation (férias) é true se estivermos de férias. Dormimos de "
15687 "manhã se não for dia de semana ou se estivermos de férias. Retorne true se "
15688 "dormimos de manhã."
15689
15690 #. type: Content of: <h1>
15691 #: src/lessons/welcome/bat/bool1/SumDouble.html:2
15692 msgid "Sum Double"
15693 msgstr "Soma dupla"
15694
15695 #. type: Content of: outside any tag (error?)
15696 #: src/lessons/welcome/bat/bool1/SumDouble.html:3
15697 msgid ""
15698 "Given two int values, return their sum. Unless the two values are the same, "
15699 "then return double their sum."
15700 msgstr ""
15701 "Dados dois valores int, retorne a soma deles. A menos que dois valores sejam "
15702 "os mesmos, neste caso retorne o dobro da soma dele."
15703
15704 #. type: Content of: <h1>
15705 #: src/lessons/welcome/bat/bool2/AlarmClock.html:2
15706 msgid "AlarmClock"
15707 msgstr "Despertador"
15708
15709 #. type: Content of: outside any tag (error?)
15710 #: src/lessons/welcome/bat/bool2/AlarmClock.html:3
15711 msgid ""
15712 "Given a day of the week encoded as 0=Sun, 1=Mon, 2=Tue, ...6=Sat, and a "
15713 "boolean indicating if we are on vacation, return a string of the form "
15714 "\"7:00\" indicating when the alarm clock should ring. Weekdays, the alarm "
15715 "should be \"7:00\" and on the weekend it should be \"10:00\". Unless we are "
15716 "on vacation -- then on weekdays it should be \"10:00\" and weekends it "
15717 "should be \"off\"."
15718 msgstr ""
15719 "Dado o dia da semana, codificado da seguinte forma: 0=Domingo, 1=Segunda, "
15720 "2=Terça, ... 6=Sábado e um booleano férias a indicar se estamos de férias, "
15721 "retorne uma cadeia de caracteres da forma \"7:00\" que indica a que horas "
15722 "devemos tocar o despertador. Nos dias da semana, devemos acordar às 7h e nos "
15723 "finais de semana às 10h. Durante as férias, devemos acordar às 10h e nos "
15724 "finais de semana desligar o despertador."
15725
15726 #. type: Content of: <h1>
15727 #: src/lessons/welcome/bat/bool2/AnswerCell.html:2
15728 msgid "AnswerCell"
15729 msgstr "secretária eletrônica"
15730
15731 #. type: Content of: outside any tag (error?)
15732 #: src/lessons/welcome/bat/bool2/AnswerCell.html:3
15733 msgid ""
15734 "Your cell phone rings. Return true if you should answer it. Normally you "
15735 "answer, except in the morning you only answer if it is your mom calling. In "
15736 "all cases, if you are asleep, you do not answer."
15737 msgstr ""
15738 "O seu telemóvel toca. Retorne true se deve atender. Normalmente responde, "
15739 "exceto de manhã, quando só a sua mãe lhe liga. De qualquer forma, se estiver "
15740 "a dormir, não responde."
15741
15742 #. type: Content of: <h1>
15743 #: src/lessons/welcome/bat/bool2/BlueTicket.html:2
15744 msgid "BlueTicket"
15745 msgstr "bilhete azul"
15746
15747 #. type: Content of: outside any tag (error?)
15748 #: src/lessons/welcome/bat/bool2/BlueTicket.html:3
15749 msgid ""
15750 "You have a blue lottery ticket, with ints a, b, and c on it. This makes "
15751 "three pairs, which we'll call ab, bc, and ac. Consider the sum of the "
15752 "numbers in each pair. If any pair sums to exactly 10, the result is 10. "
15753 "Otherwise if the ab sum is exactly 10 more than either bc or ac sums, the "
15754 "result is 5. Otherwise the result is 0."
15755 msgstr ""
15756 "Tem um bilhete de loteria azul, com os inteiros a, b e c. Eles fazem três "
15757 "pares que chamaremos de ab, bc e ac. Considere a soma dos números de cada "
15758 "par. Se a soma de um dos pares vale exatamente 10, o resultado é 10. Senão, "
15759 "se a soma ab vale exatamente 10 mais que bc ou ac, o resultado é 5. Senão, o "
15760 "resultado é 0."
15761
15762 #. type: Content of: <h1>
15763 #: src/lessons/welcome/bat/bool2/CaughtSpeeding.html:2
15764 msgid "CaughtSpeeding"
15765 msgstr "Radar de velocidade"
15766
15767 #. type: Content of: outside any tag (error?)
15768 #: src/lessons/welcome/bat/bool2/CaughtSpeeding.html:3
15769 msgid ""
15770 "You are driving a little too fast, and a police officer stops you. Write "
15771 "code to compute the result, encoded as an int value: 0=no ticket, 1=small "
15772 "ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is "
15773 "between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the "
15774 "result is 2. Unless it is your birthday -- on that day, your speed can be 5 "
15775 "higher in all cases."
15776 msgstr ""
15777 "Está a conduzir um pouco rápido demais e um guarda o para. Escreva o código "
15778 "para calcular o resultado, codificado na forma de um inteiro: 0=sem multa, "
15779 "1=multa leve, 2=multa pesada. Se a velocidade é inferior a 60, o resultado é "
15780 "0. Se a velocidade está entre 61 e 80 (inclusive), o resultado é 1. Se a "
15781 "velocidade é 81 ou maior, o resultado é 2. Estes casos são para dias que não "
15782 "são o seu aniversário. No seu dia de aniversário a sua velocidade pode ser 5 "
15783 "maior em todos os casos."
15784
15785 #. type: Content of: <h1>
15786 #: src/lessons/welcome/bat/bool2/CigarParty.html:2
15787 msgid "CigarParty"
15788 msgstr "Festa dos charutos"
15789
15790 #. type: Content of: outside any tag (error?)
15791 #: src/lessons/welcome/bat/bool2/CigarParty.html:3
15792 msgid ""
15793 "When squirrels get together for a party, they like to have cigars. A "
15794 "squirrel party is successful when the number of cigars is between 40 and 60, "
15795 "inclusive. Unless it is the weekend, in which case there is no upper bound "
15796 "on the number of cigars. Return true if the party was successful."
15797 msgstr ""
15798 "Quando os esquilos fazem uma festa, eles gostam de ter charutos. Uma festa "
15799 "de esquilos é boa quando a quantidade de charutos está entre 40 e 60 "
15800 "(inclusive). A menos que seja finais de semana, onde não há limite superior "
15801 "para a quantidade de charutos. Retorne true se a festa foi um sucesso."
15802
15803 #. type: Content of: <h1>
15804 #: src/lessons/welcome/bat/bool2/DateFashion.html:2
15805 msgid "DateFashion"
15806 msgstr "Encontro elegante"
15807
15808 #. type: Content of: outside any tag (error?)
15809 #: src/lessons/welcome/bat/bool2/DateFashion.html:3
15810 msgid ""
15811 "You and your date are trying to get a table at a restaurant. The parameter "
15812 "\"you\" is the stylishness of your clothes, in the range 0..10, and \"date\" "
15813 "is the stylishness of your date's clothes. The result getting the table is "
15814 "encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very "
15815 "stylish, 8 or more, then the result is 2 (yes). With the exception that if "
15816 "either of you has style of 2 or less, then the result is 0 (no). Otherwise "
15817 "the result is 1 (maybe)."
15818 msgstr ""
15819 "Você e o seu par estão a tentar conseguir uma mesa no restaurante. O "
15820 "parâmetro \"you\" (você) é o nível de elegância das suas roupas, no "
15821 "intervalo 0..10 e \"date\" (par) é o nível de elegância do seu par. O "
15822 "resultado da tentativa de obter uma mesa é codificado como um valor inteiro "
15823 "com 0=no (não), 1=maybe (talvez), 2=yes (sim). Se um de vocês está muito "
15824 "elegante, 8 ou mais, o resultado é 2 (yes). Com uma exceção: se um dos dois "
15825 "tem um estilo de 2 ou menos o resultado é 0 (no). Caso contrário o resultado "
15826 "é 1 (maybe)."
15827
15828 #. type: Content of: <h1>
15829 #: src/lessons/welcome/bat/bool2/FizzBuzz.html:2
15830 msgid "Fizz Buzz"
15831 msgstr "Fizz Buzz"
15832
15833 #. type: Content of: <p>
15834 #: src/lessons/welcome/bat/bool2/FizzBuzz.html:3
15835 msgid ""
15836 "According to Wikipedia, Fizz buzz is a group word game for children to teach "
15837 "them about division. Players take turns to count incrementally, replacing "
15838 "any number divisible by three with the word \"Fizz\", and any number "
15839 "divisible by five with the word \"Buzz\". Any number that is divisible by "
15840 "both three and five is replaced with the string \"Fizz Buzz\"."
15841 msgstr ""
15842 "De acordo com a Wikipedia, Fizz buzz é um jogo de \"group word\" para "
15843 "crianças para ensinar divisão. Os jogadores jogam em turnos numéricos que "
15844 "vão a aumentar, a substituir qualquer número divisível por três com a "
15845 "palavra \"Fizz\" e qualquer número divisível por cinco com a palavra \"Buzz\""
15846 ". Qualquer número que é divisível tanto por 3 quanto por 5 é substituído "
15847 "pela cadeia \"Fizz Buzz\"."
15848
15849 #. type: Content of: <p>
15850 #: src/lessons/welcome/bat/bool2/FizzBuzz.html:8
15851 msgid ""
15852 "Unchanged numbers are simply returned as a string. [!java|scala]The easiest "
15853 "for that is to use that [!thelang] idiomatic: <code>\"\"+a</code>[/!] "
15854 "[!python]The function <code>str(a)</code> changes an integer <code>a</code> "
15855 "into a string.[/!]"
15856 msgstr ""
15857 "números que não são substituídos são simplesmente retornados como uma "
15858 "cadeia [!java|scala]O eito mais fácil é usar esta construção em [!thelang]: "
15859 "<code>\"\"+a</code>[/!] [!python]A função <code>str(a)</code> transforma um "
15860 "inteiro <code>a</code> numa cadeia.[/!]"
15861
15862 #. type: Content of: <h1>
15863 #: src/lessons/welcome/bat/bool2/GreenTicket.html:2
15864 msgid "GreenTicket"
15865 msgstr "bilhete verde"
15866
15867 #. type: Content of: outside any tag (error?)
15868 #: src/lessons/welcome/bat/bool2/GreenTicket.html:3
15869 msgid ""
15870 "You have a green lottery ticket, with ints a, b, and c on it. If the numbers "
15871 "are all different from each other, the result is 0. If all of the numbers "
15872 "are the same, the result is 20. If two of the numbers are the same, the "
15873 "result is 10."
15874 msgstr ""
15875 "Tem um bilhete de loteria verde, com os inteiros a, b e c inscritos nele. Se "
15876 "os números são todos diferentes uns dos outros, o resultado é 0. Se todos os "
15877 "números são idênticos, o resultado é 20. Se dois dos números são os mesmos, "
15878 "o resultado é 10."
15879
15880 #. type: Content of: <h1>
15881 #: src/lessons/welcome/bat/bool2/In1To10.html:2
15882 msgid "In1To10"
15883 msgstr "De 1 a 10"
15884
15885 #. type: Content of: outside any tag (error?)
15886 #: src/lessons/welcome/bat/bool2/In1To10.html:3
15887 msgid ""
15888 "Given a number n, return true if n is in the range 1..10, inclusive. Unless "
15889 "\"outsideMode\" is true, in which case return true if the number is less or "
15890 "equal to 1, or greater or equal to 10."
15891 msgstr ""
15892 "Seja um número n, retorne true se n está no intervalo [1..10]. Exceto se "
15893 "\"outsideMode\" é true e neste caso retorne true se o número é menor ou "
15894 "igual a 1, ou maior ou igual a 10."
15895
15896 #. type: Content of: <h1>
15897 #: src/lessons/welcome/bat/bool2/InOrderEqual.html:2
15898 msgid "InOrderEqual"
15899 msgstr "Em ordem crescente"
15900
15901 #. type: Content of: outside any tag (error?)
15902 #: src/lessons/welcome/bat/bool2/InOrderEqual.html:3
15903 msgid ""
15904 "Given three ints, a b c, return true if they are in strict increasing order, "
15905 "such as 2 5 11, or 5 6 7, but not 6 5 7 or 5 5 7. However, with the "
15906 "exception that if \"equalOk\" is true, equality is allowed, such as 5 5 7 or "
15907 "5 5 5."
15908 msgstr ""
15909 "Dados três inteiros, a b c, retorne true se estão em ordem estritamente "
15910 "crescente, como 2 5 11, ou 5 6 7, mas não 6 5 7 ou 5 5 7. Entretanto, com a "
15911 "exceção de se \"equalOk\" for true, igualdade é permitida, como 5 5 7 ou 5 5 "
15912 "5."
15913
15914 #. type: Content of: <h1>
15915 #: src/lessons/welcome/bat/bool2/InOrder.html:2
15916 msgid "InOrder"
15917 msgstr "Na ordem"
15918
15919 #. type: Content of: outside any tag (error?)
15920 #: src/lessons/welcome/bat/bool2/InOrder.html:3
15921 msgid ""
15922 "Given three ints, a b c, return true if b is greater than a, and c is "
15923 "greater than b. However, with the exception that if \"bOk\" is true, b does "
15924 "not need to be greater than a."
15925 msgstr ""
15926 "Dados três inteiros, a b c, retorne true se b é maior que a, e c é maior que "
15927 "b. Entretanto, com a exceção que se \"bOk\" é true, b não precisa ser maior "
15928 "que a."
15929
15930 #. type: Content of: <h1>
15931 #: src/lessons/welcome/bat/bool2/LastDigit2.html:2
15932 msgid "LastDigit 2"
15933 msgstr "Último dígito 2"
15934
15935 #. type: Content of: outside any tag (error?)
15936 #: src/lessons/welcome/bat/bool2/LastDigit2.html:3
15937 msgid ""
15938 "Given three ints, a b c, return true if two or more of them have the same "
15939 "rightmost digit. The ints are non-negative. Note: the % \"mod\" operator "
15940 "computes the remainder, e.g. 17 % 10 is 7."
15941 msgstr ""
15942 "Dados três inteiros, a b c, retorne true se dois ou mais deles têm o mesmo "
15943 "último dígito. Os inteiros são não negativos. Nota: o operador % \"mod\" "
15944 "calcula o resto, p.ex. 17 % 10 é 7."
15945
15946 #. type: Content of: <h1>
15947 #: src/lessons/welcome/bat/bool2/LessBy10.html:2
15948 msgid "LessBy10"
15949 msgstr "Menor por 10"
15950
15951 #. type: Content of: outside any tag (error?)
15952 #: src/lessons/welcome/bat/bool2/LessBy10.html:3
15953 msgid ""
15954 "Given three ints, a b c, return true if one of them is 10 or more less than "
15955 "one of the others."
15956 msgstr ""
15957 "Dados três inteiros, a b c, retorne true se um deles é 10 ou menor que um "
15958 "dos outros."
15959
15960 #. type: Content of: <h1>
15961 #: src/lessons/welcome/bat/bool2/Main.html:2
15962 msgid "Boolean (even more) fun"
15963 msgstr "(mais) diversão com booleanos"
15964
15965 #. type: Content of: <p>
15966 #: src/lessons/welcome/bat/bool2/Main.html:4
15967 msgid ""
15968 "A very good introduction to this type is available here: "
15969 "http://codingbat.com/doc/java-if-boolean-logic.html"
15970 msgstr ""
15971 "Uma ótima introdução a este tipo está disponível em: http://codingbat.com/"
15972 "doc/java-if-boolean-logic.html"
15973
15974 #. type: Content of: <h1>
15975 #: src/lessons/welcome/bat/bool2/MaxMod5.html:2
15976 msgid "MaxMod5"
15977 msgstr "MaxMod5"
15978
15979 #. type: Content of: outside any tag (error?)
15980 #: src/lessons/welcome/bat/bool2/MaxMod5.html:3
15981 msgid ""
15982 "Given two int values, return whichever value is larger. However if the two "
15983 "values have the same remainder when divided by 5, then the return the "
15984 "smaller value. However, in all cases, if the two values are the same, return "
15985 "0. Note: the % \"mod\" operator computes the remainder, e.g. 7 % 5 is 2."
15986 msgstr ""
15987 "Sejam dois valores inteiros, retorne o maior dos dois. Entretanto, se os "
15988 "dois valores possuem o mesmo resto quando divididos por 5, retorne o menor "
15989 "dos dois. Entretanto, em todo caso, se os dois valores forem iguais, retorne "
15990 "0. Nota: o operador % \"mod\" calcula o resto, p.ex. 7 % 5 é 2."
15991
15992 #. type: Content of: <h1>
15993 #: src/lessons/welcome/bat/bool2/NearTen.html:2
15994 msgid "NearTen"
15995 msgstr "Próximo de dez"
15996
15997 #. type: Content of: outside any tag (error?)
15998 #: src/lessons/welcome/bat/bool2/NearTen.html:3
15999 msgid ""
16000 "Given a non-negative number \"num\", return true if num is within 2 of a "
16001 "multiple of 10. Note: (a % b) is the remainder of dividing a by b, so (7 % "
16002 "5) is 2."
16003 msgstr ""
16004 "Dado um inteiro positivo \"num\", retorne true se num estiver dentro de 2 de "
16005 "um múltiplo de 10. Nota: ( a % b ) é o resto da divisão de a por b, assim (7 "
16006 "% 5) é 2."
16007
16008 #. type: Content of: <h1>
16009 #: src/lessons/welcome/bat/bool2/RedTicket.html:2
16010 msgid "RedTicket"
16011 msgstr "Bilhete vermelho"
16012
16013 #. type: Content of: outside any tag (error?)
16014 #: src/lessons/welcome/bat/bool2/RedTicket.html:3
16015 msgid ""
16016 "You have a red lottery ticket showing ints a, b, and c, each of which is 0, "
16017 "1, or 2. If they are all the value 2, the result is 10. Otherwise if they "
16018 "are all the same, the result is 5. Otherwise so long as both b and c are "
16019 "different from a, the result is 1. Otherwise the result is 0."
16020 msgstr ""
16021 "Tem um bilhete de loteria vermelho com três inteiros a, b e c. Cada um com o "
16022 "valor 0, 1, ou 2. Se todos têm o valor 2, o resultado é 10. Senão, se eles "
16023 "são iguais, o resultado é 5. Senão, e se b e c são diferentes de a, o "
16024 "resultado é 1. Senão, o resultado é 0."
16025
16026 #. type: Content of: <h1>
16027 #: src/lessons/welcome/bat/bool2/ShareDigit.html:2
16028 msgid "ShareDigit"
16029 msgstr "dígitos compartilhados"
16030
16031 #. type: Content of: outside any tag (error?)
16032 #: src/lessons/welcome/bat/bool2/ShareDigit.html:3
16033 msgid ""
16034 "Given two ints, each in the range 10..99, return true if there is a digit "
16035 "that appears in both numbers, such as the 2 in 12 and 23. (Note: division, "
16036 "e.g. n/10, gives the left digit while the % \"mod\" n%10 gives the right "
16037 "digit.)"
16038 msgstr ""
16039 "Dados dois inteiros, cada um no intervalo 10..99, retorne true se existe um "
16040 "dígito que aparece nos dois números, como 2 em 12 e 23. (Nota: divisão, "
16041 "p.ex. n/10, retorna o dígito à esquerda e % \"mod\" n%10 retorna o dígito a "
16042 "direita.)"
16043
16044 #. type: Content of: <h1>
16045 #: src/lessons/welcome/bat/bool2/SortaSum.html:2
16046 msgid "SortaSum"
16047 msgstr "Soma de inteiros"
16048
16049 #. type: Content of: outside any tag (error?)
16050 #: src/lessons/welcome/bat/bool2/SortaSum.html:3
16051 msgid ""
16052 "Given 2 ints, a and b, return their sum. However, sums in the range 10..19 "
16053 "inclusive, are forbidden, so in that case just return 20."
16054 msgstr ""
16055 "Dados 2 inteiros, a e b, retorne a soma deles. Entretanto, somas no "
16056 "intervalo 10..19 inclusive, são proibidas. Neste caso, simplesmente retorne "
16057 "20."
16058
16059 #. type: Content of: <h1>
16060 #: src/lessons/welcome/bat/bool2/SquirrelPlay.html:2
16061 msgid "SquirrelPlay"
16062 msgstr "Jogo do Esquilo"
16063
16064 #. type: Content of: outside any tag (error?)
16065 #: src/lessons/welcome/bat/bool2/SquirrelPlay.html:3
16066 msgid ""
16067 "The squirrels in Palo Alto spend most of the day playing. In particular, "
16068 "they play if the temperature is between 60 and 90 (inclusive). Unless it is "
16069 "summer, then the upper limit is 100 instead of 90. Given an int temperature "
16070 "and a boolean isSummer, return true if the squirrels play and false "
16071 "otherwise."
16072 msgstr ""
16073 "Os esquilos em Palo Alto passam a maior parte do dia a jogar. Em particular, "
16074 "eles jogam se a temperatura está entre 60 e 90 °F (inclusive). A menos que "
16075 "seja verão e neste caso o limite superior é de 100 ao invés de 90. Seja uma "
16076 "temperatura inteira e um isSummer (éVerão) booleano. Retorne true se eles "
16077 "jogam e false caso contrário."
16078
16079 #. type: Content of: <h1>
16080 #: src/lessons/welcome/bat/bool2/TeaParty.html:2
16081 msgid "TeaParty"
16082 msgstr "Festa do chá"
16083
16084 #. type: Content of: outside any tag (error?)
16085 #: src/lessons/welcome/bat/bool2/TeaParty.html:3
16086 msgid ""
16087 "We are having a party with amounts of tea and candy. Return the int outcome "
16088 "of the party encoded as 0=bad, 1=good, or 2=great. A party is good (1) if "
16089 "both tea and candy are at least 5. However, if either tea or candy is at "
16090 "least double the amount of the other one, the party is great (2). However, "
16091 "in all cases, if either tea or candy is less than 5, the party is always bad "
16092 "(0)."
16093 msgstr ""
16094 "Estamos a ter uma festa com chá e doces. Retorne o resultado inteiro da "
16095 "festa codificado como 0=ruim, 1=bom, ou 2=excelente. Uma festa é boa (1) se "
16096 "o chá e os doces são pelo menos 5. Entretanto, se tanto os doces como o chá "
16097 "forem pelo menos o dobro do outro, a festa é excelente (2). Entretanto, em "
16098 "todo caso, se tanto o chá quanto os doces forem menos que 5, a festa é "
16099 "sempre ruim (0)."
16100
16101 #. type: Content of: <h1>
16102 #: src/lessons/welcome/bat/bool2/TeenSum.html:2
16103 msgid "TeenSum"
16104 msgstr "Soma de adolescentes"
16105
16106 #. type: Content of: outside any tag (error?)
16107 #: src/lessons/welcome/bat/bool2/TeenSum.html:3
16108 msgid ""
16109 "Given 2 ints, a and b, return their sum. However, \"teen\" values in the "
16110 "range 13..19 inclusive, are extra lucky. So if either value is a teen, just "
16111 "return 19."
16112 msgstr ""
16113 "Dados dois números inteiros (a e b), retorne a soma deles. Entretanto, os "
16114 "valores adolescentes no intervalo 13..19 são particularmente sortudos. "
16115 "Portanto, se um dos números for um adolescente, retorne simplesmente 19."
16116
16117 #. type: Content of: <h1>
16118 #: src/lessons/welcome/bat/bool2/TwoAsOne.html:2
16119 msgid "TwoAsOne"
16120 msgstr "Dois como um"
16121
16122 #. type: Content of: outside any tag (error?)
16123 #: src/lessons/welcome/bat/bool2/TwoAsOne.html:3
16124 msgid ""
16125 "Given three ints, a b c, return true if it is possible to add two of the "
16126 "ints to get the third."
16127 msgstr ""
16128 "Dados três inteiros a, b e c, retorne true se é possível adicionar dois "
16129 "deles e o resultado ser o terceiro."
16130
16131 #. type: Content of: <h1>
16132 #: src/lessons/welcome/bat/bool2/WithoutDoubles.html:2
16133 msgid "WithoutDoubles"
16134 msgstr "Sem dobros"
16135
16136 #. type: Content of: outside any tag (error?)
16137 #: src/lessons/welcome/bat/bool2/WithoutDoubles.html:3
16138 msgid ""
16139 "Return the sum of two 6-sided dice rolls, each in the range 1..6. However, "
16140 "if noDoubles is true, if the two dice show the same value, increment one die "
16141 "to the next value, wrapping around to 1 if its value was 6."
16142 msgstr ""
16143 "Retorne a soma das rolagens de dois dados de 6 lados. Entretanto, se "
16144 "noDoubles é true e os dois dados derem o mesmo valor, incremente um dos "
16145 "dados para o valor seguinte, e volte a 1 se o valor for 6."
16146
16147 #. type: Content of: <h1>
16148 #: src/lessons/bat/string1/Main.html:2
16149 msgid "String fun"
16150 msgstr "Diversão com cadeias"
16151
16152 #. type: Content of: <p>
16153 #: src/lessons/bat/string1/Main.html:4
16154 msgid ""
16155 "Strings are the simplest of the complex data types :) They provide several "
16156 "operations, such as getting the length of the string, or a substring of it."
16157 msgstr ""
16158 "Cadeias são os mais simples dos tipos de dados complexos :) Elas fornecem "
16159 "diferentes operações, como obter o tamanho da cadeia ou uma sub-cadeia."
16160
16161 #. type: Content of: <p>
16162 #: src/lessons/bat/string1/Main.html:8
16163 msgid ""
16164 "A very good introduction to this type is available here: "
16165 "http://codingbat.com/doc/java-string-introduction.html"
16166 msgstr ""
16167 "Uma introdução muito boa a este tipo encontra-se em: http://codingbat.com/"
16168 "doc/java-string-introduction.html"
16169
16170 #. type: Content of: <h3>
16171 #: src/lessons/bat/string1/short_desc.html:2
16172 msgid "Small exercises about strings"
16173 msgstr "Pequenos exercícios com cadeias"
16174
16175 #. type: Content of: <p>
16176 #: src/lessons/bat/string1/short_desc.html:4
16177 msgid ""
16178 "These are some training exercises around strings. But unfortunately, its "
16179 "integration within PLM is still ongoing."
16180 msgstr ""
16181 "Aqui estão alguns exercícios sobre cadeias. Mas infelizmente, a integração "
16182 "dele no PLM ainda está a ser construída."
16183
16184 #. type: Content of: <p>
16185 #: src/lessons/bat/string1/short_desc.html:7
16186 msgid "Please be patient with us."
16187 msgstr "Por favor seja paciente conosco."
16188
16189 #. type: Content of: <h1>
16190 #: src/lessons/bat/string1/AltPairs.html:2
16191 msgid "AltPairs"
16192 msgstr "Pares alternados"
16193
16194 #. type: Content of: outside any tag (error?)
16195 #: src/lessons/bat/string1/AltPairs.html:3
16196 msgid ""
16197 "Given a string, return a string made of the chars at indexes 0,1, 4,5, 8,9 "
16198 "... so \"kittens\" yields \"kien\"."
16199 msgstr ""
16200 "Dada uma cadeia, retorne outra cadeia feita com os caracteres de índices "
16201 "0,1, 4,5, 8,9 ... por exemplo \"kittens\" retorna \"kien\"."
16202
16203 #. type: Content of: <h1>
16204 #: src/lessons/bat/string1/FrontTimes.html:2
16205 msgid "FrontTimes"
16206 msgstr "FrontTimes"
16207
16208 #. type: Content of: outside any tag (error?)
16209 #: src/lessons/bat/string1/FrontTimes.html:3
16210 msgid ""
16211 "Given a string and a non-negative int n, we'll say that the front of the "
16212 "string is the first 3 chars, or whatever is there if the string is less than "
16213 "length 3. Return n copies of the front;"
16214 msgstr ""
16215 "Seja uma cadeia e um inteiro n. Definiremos o começo de uma cadeia como os "
16216 "três primeiros caracteres dela, ou toda se o comprimento dela é menor que 3. "
16217 "Retorne n cópias do começo de uma cadeia;"
16218
16219 #. type: Content of: <h1>
16220 #: src/lessons/bat/string1/Last2.html:2
16221 msgid "Last2"
16222 msgstr "Último2"
16223
16224 #. type: Content of: <p>
16225 #: src/lessons/bat/string1/Last2.html:4
16226 msgid ""
16227 "Given a string, return the amount of times that the two last letters appear "
16228 "as a substring of the string. So \"hixxxhi\" yields 1 (we won't count the "
16229 "end substring) while \"aaaNaa\" yields 2 (substrings may overlap)."
16230 msgstr ""
16231 "Dada uma cadeia retorne a quantidade de vezes que os dois últimos dígitos "
16232 "aparecem como uma sub-cadeia. Assim, \"hixxxhi\" retorna 1 (não contamos a "
16233 "última sub-cadeia) enquanto \"aaaNaa\" retorna 2 (as ocorrências podem "
16234 "sobrepor-se parcialmente)."
16235
16236 #. type: Content of: <h1>
16237 #: src/lessons/bat/string1/StringBits.html:2
16238 msgid "StringBits"
16239 msgstr "StringBits"
16240
16241 #. type: Content of: outside any tag (error?)
16242 #: src/lessons/bat/string1/StringBits.html:3
16243 msgid ""
16244 "Given a string, return a new string made of every other char starting with "
16245 "the first, so \"Hello\" yields \"Hlo\"."
16246 msgstr ""
16247 "Dada uma cadeia, retorne uma nova cadeia formada a escolher um caractere "
16248 "sim, outro não, a começar com o primeiro. Assim, \"Primeiro\" torna-se \"Pier"
16249 "\"."
16250
16251 #. type: Content of: <h1>
16252 #: src/lessons/bat/string1/StringMatch.html:2
16253 msgid "StringMatch"
16254 msgstr "Comparação de cadeia"
16255
16256 #. type: Content of: outside any tag (error?)
16257 #: src/lessons/bat/string1/StringMatch.html:3
16258 msgid ""
16259 "Given 2 strings, a and b, return the number of the positions where they "
16260 "contain the same length 2 substring. So \"xxcaazz\" and \"xxbaaz\" yields 3, "
16261 "since the \"xx\", \"aa\", and \"az\" substrings appear in the same place in "
16262 "both strings."
16263 msgstr ""
16264 "Sejam duas cadeia a e b, retorne a quantidade de posições onde elas contêm a "
16265 "mesma subcadeia de tamanho 2. Assim, \"xxcaazz\" e \"xxbaaz\" retornam 3, "
16266 "pois as subcadeias \"xx\", \"aa\" e \"az\" aparecem nas mesmas posições nas "
16267 "duas cadeias."
16268
16269 #. type: Content of: <h1>
16270 #: src/lessons/bat/string1/StringSplosion.html:2
16271 msgid "StringSplosion"
16272 msgstr "Explosão de cadeias"
16273
16274 #. type: Content of: outside any tag (error?)
16275 #: src/lessons/bat/string1/StringSplosion.html:3
16276 msgid "Given a non-empty string like \"Code\" return a string like \"CCoCodCode\"."
16277 msgstr ""
16278 "Dada uma cadeia não vazia como \"Code\" retorna uma cadeia como \"CCoCodCode"
16279 "\"."
16280
16281 #. type: Content of: <h1>
16282 #: src/lessons/bat/string1/StringTimes.html:2
16283 msgid "StringTimes"
16284 msgstr "Multiplicação de cadeias"
16285
16286 #. type: Content of: outside any tag (error?)
16287 #: src/lessons/bat/string1/StringTimes.html:3
16288 msgid ""
16289 "Given a string and a non-negative int n, return a larger string that is n "
16290 "copies of the original string."
16291 msgstr ""
16292 "Dada uma cadeia e um inteiro positivo retorna uma cadeia mais comprida que "
16293 "consiste em n cópias da cadeia original."
16294
16295 #. type: Content of: <h1>
16296 #: src/lessons/bat/string1/StringX.html:2
16297 msgid "StringX"
16298 msgstr "StringX"
16299
16300 #. type: Content of: outside any tag (error?)
16301 #: src/lessons/bat/string1/StringX.html:3
16302 msgid ""
16303 "Given a string, return a version where all the \"x\" have been "
16304 "removed. Except an \"x\" at the very start or end should not be removed."
16305 msgstr ""
16306 "Dada uma cadeia, retorne uma versão onde todos os \"x\" são removidos. "
16307 "Exceto os \"x\" no começo e no final que devem permanecer."
16308
16309 #. type: Content of: <h1>
16310 #: src/lessons/bat/string1/StringYak.html:2
16311 msgid "StringYak"
16312 msgstr "StringYak"
16313
16314 #. type: Content of: outside any tag (error?)
16315 #: src/lessons/bat/string1/StringYak.html:3
16316 msgid ""
16317 "Suppose the string \"yak\" is unlucky. Given a string, return a version "
16318 "where all the \"yak\" are removed, but the \"a\" can be any char. The "
16319 "\"yak\" strings will not overlap."
16320 msgstr ""
16321 "A string \"yak\" não tem sorte. Dada uma cadeia, retorna uma versão onde "
16322 "todas as \"yak\" são removidas (qualquer que seja o caractere no lugar do "
16323 "'a'). As diferentes cadeias \"yak\" não se sobrepõem."
16324
16325 #. type: Content of: <h2>
16326 #: src/lessons/lander/Main.html:2 src/lessons/lander/short_desc.html:2
16327 #: src/lessons/lander/universe/DelegatingLanderWorld.html:2
16328 msgid "Lunar Lander"
16329 msgstr "Módulo lunar"
16330
16331 #. type: Content of: <p>
16332 #: src/lessons/lander/Main.html:4 src/lessons/lander/short_desc.html:4
16333 msgid ""
16334 "In this lesson you pilot a lunar landing module in increasingly complex "
16335 "situations."
16336 msgstr ""
16337 "Nesta lição vai pilotar um módulo lunar em situações de complexidade "
16338 "crescente."
16339
16340 #. type: Content of: <p>
16341 #: src/lessons/lander/Main.html:7
16342 msgid ""
16343 "At each step of the simulation, the player issues a command controlling how "
16344 "much the angle and thrust of the lander should change"
16345 msgstr ""
16346 "A cada passo da simulação, o jogador envia um comando a controlar quanto o "
16347 "ângulo e a potência do módulo devem mudar"
16348
16349 #. type: Content of: <p>
16350 #: src/lessons/lander/Main.html:10
16351 msgid "Ideas concerning the progression of exercises:"
16352 msgstr "Ideias a respeito da progressão dos exercícios:"
16353
16354 #. type: Content of: <ul><li>
16355 #: src/lessons/lander/Main.html:12
16356 msgid ""
16357 "A lander in vertical position above flat ground, the player can only control "
16358 "thrust (done)"
16359 msgstr ""
16360 "Um módulo em posição vertical sobre solo plano, o jogador só controla a "
16361 "potência (feito)"
16362
16363 #. type: Content of: <ul><li>
16364 #: src/lessons/lander/Main.html:14
16365 msgid ""
16366 "A lander in vertical position not above flat ground, the player control "
16367 "thrust and angle (done)"
16368 msgstr ""
16369 "Um módulo em posição vertical sobre solo inclinado, o jogador controla "
16370 "potência e ângulo (feito)"
16371
16372 #. type: Content of: <ul><li>
16373 #: src/lessons/lander/Main.html:16
16374 msgid ""
16375 "A lander with difficult angle and speed not above flat ground, the player "
16376 "control thrust and angle"
16377 msgstr ""
16378 "Um módulo com ângulo ruim e rápido sobre solo inclinado, o jogador controla "
16379 "potência e ângulo"
16380
16381 #. type: Content of: <ul><li>
16382 #: src/lessons/lander/Main.html:18
16383 msgid ""
16384 "A lander with difficult angle and speed not above flat ground, with "
16385 "difficult ground, the player control thrust and angle"
16386 msgstr ""
16387 "Um módulo com ângulo difícil e rápido sobre superfície inclinada, com solo "
16388 "difícil, o jogador controla potência e ângulo"
16389
16390 #. type: Content of: <ul><li>
16391 #: src/lessons/lander/Main.html:20
16392 msgid "Same with wind?"
16393 msgstr "O mesmo com vento?"
16394
16395 #. type: Content of: <p>
16396 #: src/lessons/lander/short_desc.html:7
16397 msgid "This lesson assumes some basic programming and physics skills."
16398 msgstr "Esta lição assume algum conhecimento de física e programação básica."
16399
16400 #. type: Content of: <p>
16401 #: src/lessons/lander/universe/DelegatingLanderWorld.html:4
16402 msgid ""
16403 "In this universe you pilot a lunar lander. At each simulation step you're "
16404 "given the lander's position, speed, angle and thrust and must issue a "
16405 "command adjusting its angle and thrust."
16406 msgstr ""
16407 "Pilota um módulo lunar neste universo. A cada passo da simulação recebe a "
16408 "posição, velocidade, ângulo e potência do módulo e deve enviar um comando a "
16409 "ajustar o ângulo e a potência."
16410
16411 #. type: Content of: outside any tag (error?)
16412 #: src/lessons/lander/universe/DelegatingLanderWorld.html:12
16413 msgid "Get the X and Y position of the lander."
16414 msgstr "Obter (Get) as posições X e Y do módulo."
16415
16416 #. type: Content of: <pre>
16417 #: src/lessons/lander/universe/DelegatingLanderWorld.html:13
16418 #, no-wrap
16419 msgid ""
16420 "[!java|c]double [/!]getSpeedX()[!scala]:Double[/!]\n"
16421 "[!java|c]double [/!]getSpeedY()[!scala]:Double[/!]"
16422 msgstr ""
16423 "[!java|c]double [/!]getSpeedX()[!scala]:Double[/!]\n"
16424 "[!java|c]double [/!]getSpeedY()[!scala]:Double[/!]"
16425
16426 #. type: Content of: outside any tag (error?)
16427 #: src/lessons/lander/universe/DelegatingLanderWorld.html:15
16428 msgid "Get the horizontal and vertical speed of the lander."
16429 msgstr "Obter a velocidade horizontal e vertical do módulo."
16430
16431 #. type: Content of: <pre>
16432 #: src/lessons/lander/universe/DelegatingLanderWorld.html:17
16433 #, no-wrap
16434 msgid ""
16435 "[!java|c]double [/!]getAngle()[!scala]:Double[/!]\n"
16436 "[!java|c]void [/!]setDesiredAngle([!java|c]double "
16437 "[/!]desiredAngle[!scala]:Double[/!])"
16438 msgstr ""
16439 "[!java|c]double [/!]getAngle()[!scala]:Double[/!]\n"
16440 "[!java|c]void [/!]setDesiredAngle([!java|c]double "
16441 "[/!]desiredAngle[!scala]:Double[/!])"
16442
16443 #. type: Content of: outside any tag (error?)
16444 #: src/lessons/lander/universe/DelegatingLanderWorld.html:19
16445 msgid "Get or set the angle of the lander."
16446 msgstr "Obter ou ajustar o ângulo do módulo."
16447
16448 #. type: Content of: outside any tag (error?)
16449 #: src/lessons/lander/universe/DelegatingLanderWorld.html:20
16450 msgid ""
16451 "An angle of 0° denotes a vertical position where the \"head\" of the lander "
16452 "points up. This is the angle you must land with. A positive angle denotes a "
16453 "left-leaning lander, a negative angle a right-leaning one. You cannot lean "
16454 "more than by ±90°, and the angle can vary by at most ±5° in one step."
16455 msgstr ""
16456 "Um ângulo de 0° denota uma posição vertical onde a \"cabeça\" do módulo "
16457 "aponta para cima. É o ângulo com que deve pousar. Um ângulo positivo denota "
16458 "a inclinação para a esquerda, um ângulo negativo denota inclinação para a "
16459 "direita. Não pode inclinar mais que ±90° e o ângulo pode sofrer uma variação "
16460 "de no máximo ±5° a cada passo."
16461
16462 #. type: Content of: <pre>
16463 #: src/lessons/lander/universe/DelegatingLanderWorld.html:25
16464 #, no-wrap
16465 msgid ""
16466 "[!java|c]int [/!]getThrust()[!scala]:Int[/!]\n"
16467 "[!java|c]void [/!]setDesiredThrust([!java|c]int [/!]thrust[!scala]:Int[/!])"
16468 msgstr ""
16469 "[!java|c]int [/!]getThrust()[!scala]:Int[/!]\n"
16470 "[!java|c]void [/!]setDesiredThrust([!java|c]int [/!]thrust[!scala]:Int[/!])"
16471
16472 #. type: Content of: outside any tag (error?)
16473 #: src/lessons/lander/universe/DelegatingLanderWorld.html:27
16474 msgid "Get or set the thrust of the lander."
16475 msgstr "Obter ou ajustar a potência do módulo."
16476
16477 #. type: Content of: outside any tag (error?)
16478 #: src/lessons/lander/universe/DelegatingLanderWorld.html:27
16479 msgid ""
16480 "You can only increment or decrement the thrust by 1 between two simulation "
16481 "steps, so if the current thrust is 2 and you ask for 4, you'll only get 3 in "
16482 "the next step. If you ask for less than 0 (resp. more than 4), everything "
16483 "will be as if you had asked for 0 (resp. 4)."
16484 msgstr ""
16485 "Só pode aumentar ou diminuir a potência de 1 a cada passo. pois se a "
16486 "potência atual é 2 e pede 4, ela vai mudar para 3 no próximo passo. Se pedir "
16487 "menos que 0 (ou, respetivamente, mais que 4), vai ser como se tivesse pedido "
16488 "0 (ou, respetivamente, 4)."
16489
16490 #. type: Content of: <pre>
16491 #: src/lessons/lander/universe/DelegatingLanderWorld.html:33
16492 #, no-wrap
16493 msgid "[!java|c]int [/!]getFuel()[!scala]:Int[/!]"
16494 msgstr "[!java|c]int [/!]getFuel()[!scala]:Int[/!]"
16495
16496 #. type: Content of: outside any tag (error?)
16497 #: src/lessons/lander/universe/DelegatingLanderWorld.html:34
16498 msgid ""
16499 "Get the remaining fuel in the lander. At each step of the simulation the "
16500 "lander consumes as many fuel units as the current thrust. Once you run out "
16501 "of fuel you're in free fall so beware!"
16502 msgstr ""
16503 "Obter o combustível restante no módulo. A cada passo da simulação o módulo "
16504 "consome tantas unidades de combustível como a potência atual. Uma vez que "
16505 "fique sem combustível entra em queda livre. Portanto, cuidado!"
16506
16507 #. type: Content of: <pre>
16508 #: src/lessons/lander/universe/DelegatingLanderWorld.html:38
16509 #, no-wrap
16510 msgid "[!java]List&lt;Point&gt; [/!]getGround() [!scala]:List[Point][/!]"
16511 msgstr "[!java]List&lt;Point&gt; [/!]getGround() [!scala]:List[Point][/!]"
16512
16513 #. type: Content of: outside any tag (error?)
16514 #: src/lessons/lander/universe/DelegatingLanderWorld.html:39
16515 msgid ""
16516 "Get the vertices of the ground's profile from left to right. "
16517 "[!java|scala]You can retrieve the X and Y coordinates of each point with the "
16518 "corresponding methods of your point: <code>p.x()</code> and "
16519 "<code>p.y()</code>.[/!] [!python]Each point is an array of two integers "
16520 "denoting respectively the X and Y coordinates of that point.[/!]"
16521 msgstr ""
16522 "Obter os vértices do perfil do solo da esquerda para a direita. "
16523 "[!java|scala]Pode recuperar as coordenadas X e Y de cada ponto com os "
16524 "métodos correspondentes do seu ponto: <code>p.x()</code> e <code>p."
16525 "y()</code>.[/!] [!python]Cada ponto é uma array de dois inteiros a denotar "
16526 "respetivamente as coordenadas X e Y de cada ponto.[/!]"
16527
16528 #. type: Content of: <h1>
16529 #: src/lessons/lander/lvl1_lander_101/Lander101.html:2
16530 msgid "Lander 101"
16531 msgstr "Lander 101"
16532
16533 #. type: Content of: <p>
16534 #: src/lessons/lander/lvl1_lander_101/Lander101.html:4
16535 msgid ""
16536 "Congratulations! You won a (one-way) trip to Mars in a cereal box. NASA was "
16537 "kind enough to donate the Lunar Excursion Module for this mission, so that's "
16538 "what you'll be flying."
16539 msgstr ""
16540 "Parabéns! Ganhou uma viagem (só de ida) para Marte numa caixa de cereais. A "
16541 "NASA é orgulhosa em doar o módulo da excursão lunar para esta missão e é o "
16542 "que vai pilotar."
16543
16544 #. type: Content of: <p>
16545 #: src/lessons/lander/lvl1_lander_101/Lander101.html:8
16546 msgid ""
16547 "Before you take off, you must go through some basic landing simulation. You "
16548 "shouldn't have to fly the lander if all goes as planned but, as they say, "
16549 "\"better safe than sorry\"."
16550 msgstr ""
16551 "Antes de pousar, vai realizar algumas simulações de pouso. Não tem que "
16552 "pilotar o módulo se tudo for como planeado, mas, como dizem, \"é melhor "
16553 "prevenir que remediar\"."
16554
16555 #. type: Content of: <p>
16556 #: src/lessons/lander/lvl1_lander_101/Lander101.html:12
16557 msgid ""
16558 "Your mission is to <b>land the lander with a vertical speed of at most 10 "
16559 "m/s.</b> There are two ways you can influence the lander's course: by "
16560 "adjusting its angle or by adjusting its thrust. In this simulation we only "
16561 "care about adjusting the thrust, expressed in m/s²."
16562 msgstr ""
16563 "A sua missão é <b>pousar o módulo com a velocidade vertical máxima de 10 m/"
16564 "s.</b> Existem duas formas de influenciar o curso do módulo: a ajustar o "
16565 "ângulo dele ou a ajustar a potência dele. Nesta simulação vamos nos "
16566 "preocupar apenas a ajustar a potência, expressa em m/s²."
16567
16568 #. type: Content of: <p>
16569 #: src/lessons/lander/lvl1_lander_101/Lander101.html:17
16570 msgid ""
16571 "The [!python]<code>step()</code> function[/!][!scala|java|c]code[/!] that "
16572 "you should write now will be called every 0.1 second during the "
16573 "simulation. Make sure that your code does not last too long, with no while "
16574 "loop! It should only set the desired thrust of the next simulation step, by "
16575 "calling <code>[!java]void [/!]setDesiredThrust([!java]int "
16576 "[/!]desiredThrust[!scala]:Integer[/!])</code> where "
16577 "<code>desiredThrust</code> is some integer between 0 and 4 (that is, a "
16578 "thrust between 0 m/s² and 4 m/s²). You can only increment or decrement the "
16579 "thrust by 1 between two simulation steps, so if the current thrust is 2 and "
16580 "you ask for 4, you'll only get 3 in the next step. If you ask for less than "
16581 "0 (resp. more than 4), everything will be as if you had asked for 0 "
16582 "(resp. 4)."
16583 msgstr ""
16584 "[!scala|java|c]O código[/!] [!python] da função <code>step()</code> [/!], "
16585 "que vai escrever, agora vai ser chamada a cada 0,1 segundos durante a "
16586 "simulação. Certifique-se que o seu código não demora muito para executar, "
16587 "sem usar o loop while! Apenas deve ajustar a potência desejada para o "
16588 "próximo passo da simulação, a chamar <code>[!java]void "
16589 "[/!]setDesiredThrust([!java]int [/!]desiredThrust[!scala]:Integer[/!])</"
16590 "code> onde <code>desiredThrust</code> é algum inteiro entre 0 e 4 (ou seja, "
16591 "uma potência entre 0 m/s² e 4 m/s²). Só pode aumentar ou diminuir a potência "
16592 "por 1 entre dois passos da simulação. Portanto, se a potência atual é 2 e "
16593 "pede 4, vai conseguir apenas 3 no próximo passo. Se pede por menos que 0 ("
16594 "ou, respetivamente, mais que 4), vai ser como se tivesse pedido 0 (ou, "
16595 "respetivamente, 4)."
16596
16597 #. type: Content of: <p>
16598 #: src/lessons/lander/lvl1_lander_101/Lander101.html:28
16599 msgid ""
16600 "In order to take informed decisions, you can query the lander's state. In "
16601 "this simulation you'll probably be interested in its vertical position: "
16602 "<code>[!java]double [/!]getY()[!scala]:Double[/!]</code>, and its vertical "
16603 "speed: <code>[!java]double [/!]getSpeedY()[!scala]:Double[/!]</code>. You "
16604 "can also ask for the thrust via <code>[!java]int "
16605 "[/!]getThrust()[!scala]:Integer[/!]</code> in case you don't remember what "
16606 "you asked for. Remember that Mars' gravity is 3.711 m/s², it might come in "
16607 "handy."
16608 msgstr ""
16609 "Para tomar decisões informadas, pode consultar o estado do módulo. Nesta "
16610 "simulação provavelmente vai estar interessado na posição vertical: "
16611 "<code>[!java]double [/!]getY()[!scala]:Double[/!]</code> e na velocidade "
16612 "vertical: <code>[!java]double [/!]getSpeedY()[!scala]:Double[/!]</code>. "
16613 "Também pode pedir a potência com <code>[!java]int "
16614 "[/!]getThrust()[!scala]:Integer[/!]</code> caso não se lembre o que pediu. "
16615 "Lembre-se que a gravidade de Marte é 3,711 m/s². Isto pode ser útil."
16616
16617 #. type: Content of: <p>
16618 #: src/lessons/lander/lvl1_lander_101/Lander101.html:36
16619 msgid ""
16620 "One last thing: the lander is pretty small so you don't have much fuel. At "
16621 "each step of the simulation the lander consumes as many fuel units as the "
16622 "current thrust. Once you run out of fuel you're in free fall so beware! You "
16623 "can consult the remaining amount of available fuel units using "
16624 "<code>[!java]int [/!]getFuel()[!scala]:Integer[/!]</code>."
16625 msgstr ""
16626 "Uma última coisa: o módulo é bem pequeno, logo não tem muito combustível. Em "
16627 "cada passo da simulação o módulo consome tantas unidades de combustível "
16628 "quanto a potência atual. Uma vez que fique sem combustível vai cair em queda "
16629 "livre, portanto cuidado! Pode consultar a quantidade de unidades de "
16630 "combustível restante a usar <code>[!java]int "
16631 "[/!]getFuel()[!scala]:Integer[/!]</code>."
16632
16633 #. type: Content of: <h2>
16634 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:2
16635 msgid "Locate a Landing Zone"
16636 msgstr "Localizar uma área de pouso"
16637
16638 #. type: Content of: <p>
16639 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:4
16640 msgid ""
16641 "After 200 days of traveling space and eating cereals you finally reach "
16642 "Mars. Time to land at last!"
16643 msgstr ""
16644 "Depois de 200 dias a viajar no espaço e a comer cereais finalmente chegou ao "
16645 "Marte. Hora de pousar, finalmente!"
16646
16647 #. type: Content of: <p>
16648 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:7
16649 msgid ""
16650 "The lander is on autopilot and all you have to do is look around and tell it "
16651 "where to land. The lander must <b>land on a flat zone</b> if you want to "
16652 "remain in one piece. You indicate the lander where to land by modifying the "
16653 "<code>getLandingZone</code> function so that it returns a "
16654 "[!java|scala]<code>Segment</code> representing the zone of your choice."
16655 msgstr ""
16656 "O módulo está no piloto-automático e tudo que tem que fazer é dar uma olhada "
16657 "e dizer ao módulo onde pousar. O módulo deve <b>pousar numa área plana</b> "
16658 "se quiser ficar inteiro. Indica ao módulo onde pousar a modificar a função "
16659 "<code>getLandingZone</code> de forma que retorne um "
16660 "[!java|scala]<code>Segment</code> a representar a área da sua escolha."
16661
16662 #. type: Content of: <p><p>
16663 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:13
16664 msgid ""
16665 "A segment is composed of two <code>Point</code>s, each of them composed of "
16666 "two <code>double</code>s. A segment is built via the "
16667 "<code>Segment([!java]Point [/!]start[!scala]:Point[/!], [!java]Point "
16668 "[/!]end[!scala]:Point[/!])</code> constructor. A point is built via the "
16669 "<code>Point([!java]double [/!]x[!scala]:Double[/!], [!java]double "
16670 "[/!]y[!scala]:Double[/!])</code> constructor. A point's coordinates are "
16671 "accessible via its <code>[!java]double [/!]x()[!scala]:Double[/!]</code> and "
16672 "<code>[!java]double [/!]y()[!scala]:Double[/!]</code> methods."
16673 msgstr ""
16674 "Um segmento é composto de dois <code>Ponto</code>s, cada um deles composto "
16675 "de dois <code>double</code>s. Um segmento é construído com o construtor "
16676 "<code>Segment([!java]Point [/!]start[!scala]:Point[/!], [!java]Point "
16677 "[/!]end[!scala]:Point[/!])</code>. Um ponto é construído com o construtor "
16678 "<code>Point([!java]double [/!]x[!scala]:Double[/!], [!java]double "
16679 "[/!]y[!scala]:Double[/!])</code>. As coordenadas de um ponto são acessíveis "
16680 "através dos métodos <code>[!java]double [/!]x()[!scala]:Double[/!]</code> e "
16681 "<code>[!java]double [/!]y()[!scala]:Double[/!]</code> dele."
16682
16683 #. type: Content of: <p>
16684 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:18
16685 msgid ""
16686 "[/!] [!python]tuple of two X coordinates representing the zone of your "
16687 "choice.[/!]"
16688 msgstr ""
16689 "[/!] [!python]tupla de duas coordenadas X a representar a área escolhida.[/!]"
16690
16691 #. type: Content of: <p><p>
16692 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:22
16693 msgid ""
16694 "In order to determine which zone to return, you'll need to call "
16695 "<code>[!java]List&lt;Point&gt; "
16696 "[/!]getGround()[!scala]List[Point][/!]</code>, which returns the vertices of "
16697 "the ground's profile as a list of [!java|scala]<code>Point</code>[/!] "
16698 "[!python]tuples (x,y)[/!]."
16699 msgstr ""
16700 "Para determinar para qual área retornar, precisa chamar "
16701 "<code>[!java]List&lt;Point&gt; [/!]getGround()[!scala]List[Point][/!]</"
16702 "code>, que retorna os vértices do perfil do solo como uma lista de [!python]"
16703 "tuples (x,y)[/!] [!java|scala]<code>Point</code>s[/!]."
16704
16705 #. type: Content of: <p><p>
16706 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:27
16707 msgid ""
16708 "One more thing: your function should return a valid flat zone in any kind of "
16709 "situation, not just for the currently visualized one. That's because it will "
16710 "be not only tested against that world, but also against the one we had in "
16711 "the previous exercise. As usual, you can see the other existing worlds with "
16712 "the appropriate combobox."
16713 msgstr ""
16714 "Mais um detalhe: a sua função deve retornar uma área plana válida em "
16715 "qualquer situação, não apenas para a atualmente vista. Isto é porque não vai "
16716 "ser testado apenas neste mundo, mas também naquele do exercício anterior. "
16717 "Como sempre, pode ver os outros mundos existentes com a combobox apropriada."
16718
16719 #. type: Content of: <p><p>
16720 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:33
16721 msgid "Have a safe landing! Don't forget to put on your space suit on your way out."
16722 msgstr ""
16723 "Tenha um bom pouso! Não se esqueça de vestir seu traje espacial quando for "
16724 "sair."
16725
16726 #. type: Content of: <h1>
16727 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:2
16728 msgid "Fly the Lander!"
16729 msgstr "Pilote o módulo!"
16730
16731 #. type: Content of: <p>
16732 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:4
16733 msgid ""
16734 "After 30 days of staring at rocks and eating cereals you decide it's time to "
16735 "go explore other parts of the planet."
16736 msgstr ""
16737 "Depois de 30 dias a olhar a rochas e a comer cereais decide que é hora de "
16738 "explorar outras partes do planeta."
16739
16740 #. type: Content of: <p>
16741 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:7
16742 msgid ""
16743 "You fly for a while and suddenly realize you're almost out of fuel. "
16744 "Unfortunately you're in a delicate situation and the autopilot is helpless. "
16745 "You will have to pilot the lander yourself. Your mission is to <b>land the "
16746 "lander on a flat zone with a vertical speed less than 10 m/s, an horizontal "
16747 "speed less than 5 m/s and an angle of 0°.</b>"
16748 msgstr ""
16749 "Voa por um tempo e repentinamente repara que está quase sem combustível. "
16750 "Infelizmente, está numa situação delicada e o piloto automático é inútil. "
16751 "Você mesmo terá que pilotar o módulo. A sua missão é <b>pousar o módulo numa "
16752 "área plana com uma velocidade vertical menor que 10 m/s, uma velocidade "
16753 "horizontal menor que 5 m/s e um ângulo de 0°.</b>"
16754
16755 #. type: Content of: <p>
16756 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:13
16757 msgid ""
16758 "You must define two functions: <code>[!java]void [/!]initialize()</code> and "
16759 "<code>[!java]void [/!]step()</code>. <code>initialize()</code> is called "
16760 "once just after you press \"Run\". You can use it to chose some flat "
16761 "zone. As before, <code>step()</code> is called every 0.1 second and is used "
16762 "for adjusting the lander's thrust and angle. As in the first exercise the "
16763 "lander's thrust is adjusted via <code>[!java]void "
16764 "[/!]setDesiredThrust([!java]int "
16765 "[/!]desiredThrust[!scala]:Integer[/!])</code>. But you can also control its "
16766 "angle via <code>[!java]void [/!]setDesiredAngle([!java]double "
16767 "[/!]desiredAngle[!scala]:Double[/!])</code>. An angle of 0° denotes a "
16768 "vertical position where the \"head\" of the lander points up. This is the "
16769 "angle you must land with. A positive angle denotes a left-leaning lander, a "
16770 "negative angle a right-leaning one. You cannot lean more than by ±90°, and "
16771 "the angle can vary by at most ±5° in one step."
16772 msgstr ""
16773 "Precisa definir duas funções: <code>[!java]void [/!]initialize()</code> e "
16774 "<code>[!java]void[/!]step()</code>. <code>initialize()</code> é chamada uma "
16775 "única vez depois de apertar \"Executar\". Pode usá-lo para escolher uma área "
16776 "plana. Como antes, <code>step()</code> é chamado a cada 0,1 segundos e é "
16777 "usada para ajustar a potência e ângulo do módulo. Como no primeiro "
16778 "exercício, a potência do módulo é ajustada através de <code>[!java]void "
16779 "[/!]setDesiredThrust([!java]int [/!]desiredThrust[!scala]:Integer[/!])</"
16780 "code>. Mas também pode controlar o ângulo dele através de <code>[!java]void "
16781 "[/!]setDesiredAngle([!java]double [/!]desiredAngle[!scala]:Double[/!])</"
16782 "code>. Um ângulo de 0° denota uma posição vertical onde a \"cabeça\" do "
16783 "módulo aponta para cima. Este é o ângulo com o qual deve pousar. Um ângulo "
16784 "positivo denota um módulo inclinado para a esquerda, um ângulo negativo um "
16785 "inclinado para a direita. Não pode inclinar mais que ±90° e o ângulo pode "
16786 "mudar por no máximo ±5° em cada passo."
16787
16788 #. type: Content of: <p>
16789 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:26
16790 msgid ""
16791 "As in the previous exercise, <code>[!java]List&lt;Point&gt; "
16792 "[/!]getGround()[!scala]:List[Point][/!]</code> returns the vertices of the "
16793 "ground's profile from left to right. Please refer to the documentation "
16794 "(Help/About this world) for a reference manual of your lunar lander."
16795 msgstr ""
16796 "Como no exercício anterior, <code>[!java]List&lt;Point&gt; "
16797 "[/!]getGround()[!scala]:List[Point][/!]</code> retorna os vértices do perfil "
16798 "do solo da esquerda para a direita. Favor consulte a documentação (Ajuda/"
16799 "Sobre este mundo) para um manual de referência do módulo lunar."
16800
16801 #. type: Content of: <p>
16802 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:30
16803 msgid ""
16804 "As before, your program must safely land the lander in all the situations "
16805 "encountered so far in addition to this new one."
16806 msgstr ""
16807 "Como antes, o seu programa deve pousar o módulo com segurança em todas as "
16808 "situações encontradas além desta nova."
16809
16810 #. type: Content of: <p>
16811 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:33
16812 msgid "Good luck, try not to crash!"
16813 msgstr "Boa sorte, tente não cair!"
16814
16815 #. type: Content of: <h2>
16816 #: lib/doc/MainWindow.html:1
16817 msgid "The PLM Main Window"
16818 msgstr "A Janela Principal do PLM"
16819
16820 #. type: Content of: outside any tag (error?)
16821 #: lib/doc/MainWindow.html:3
16822 msgid ""
16823 "The PLM working environment should be self-explanatory, in particular with "
16824 "the tool tips appearing when your mouse is over the elements. Here is a "
16825 "little explanation of the components in case you fail to understand "
16826 "something. The main window is made of 5 main components:"
16827 msgstr ""
16828 "O ambiente de trabalho do PLM é auto-explicativo, principalmente com as "
16829 "dicas que aparecem quando o mouse passa sobre elementos. Aqui está uma breve "
16830 "explicação dos componentes caso não entenda algo. A janela principal é "
16831 "composta de 5 componentes principais:"
16832
16833 #. type: Content of: <ul><li>
16834 #: lib/doc/MainWindow.html:10
16835 msgid ""
16836 "<b>The menu:</b> Placed on top of the window, it gives you access to some "
16837 "advanced commands such as exiting the program, and some other that we will "
16838 "detail later."
16839 msgstr ""
16840 "<b>O menu:</b> posto na parte de cima da janela, dá-lhe acesso a alguns "
16841 "comandos avançados, como sair do programa e alguns outros que falaremos mais "
16842 "tarde."
16843
16844 #. type: Content of: <ul><li>
16845 #: lib/doc/MainWindow.html:14
16846 msgid ""
16847 "<b>The tool bar:</b> Placed just below the menu, it gives you access to the "
16848 "four main commands:"
16849 msgstr ""
16850 "<b>A barra de ferramentas:</b> Posta logo abaixo do menu, ela te dá acesso "
16851 "aos quatro comandos principais:"
16852
16853 #. type: Content of: <ul><li><ul><li>
16854 #: lib/doc/MainWindow.html:19
16855 msgid ""
16856 "The <b>Start</b> button, which begins the compilation and execution of the "
16857 "code you may have typed in the editor. At the end of the execution, it "
16858 "verifies whether you reach the situation constituting the objective of the "
16859 "exercise or not. If yes, you gain access to the next exercise using the "
16860 "<b>Exercise</b> menu. If not, you need to rework your code."
16861 msgstr ""
16862 "O botão <b>início</b>, que começa a compilação e a execução do código que "
16863 "digitou no editor. No final da execução, verifica se alcançou uma situação "
16864 "que constitui o objetivo do exercício ou não. Se sim, ganha acesso ao "
16865 "próximo exercício a usar o menu <b>Exercício</b>. Se não, vai precisar "
16866 "refazer o seu código."
16867
16868 #. type: Content of: <ul><li><ul><li>
16869 #: lib/doc/MainWindow.html:25
16870 msgid ""
16871 "The <b>Stop</b> button allows you to interupt the execution of your code, "
16872 "what may reveal useful if you encounter an <i>infinite loop</i>."
16873 msgstr ""
16874 "O botão <b>Parar</b> sempre serve para interromper a execução do seu código, "
16875 "o que pode ser útil se entrar num <i>loop infinito</i>."
16876
16877 #. type: Content of: <ul><li><ul><li>
16878 #: lib/doc/MainWindow.html:28
16879 msgid ""
16880 "The <b>Reset</b> button can be used to reset the world into its initial "
16881 "state."
16882 msgstr ""
16883 "O botão <b>Reset</b> pode ser usado para reconfigurar o mundo para o estado "
16884 "inicial."
16885
16886 #. type: Content of: <ul><li><ul><li>
16887 #: lib/doc/MainWindow.html:31
16888 msgid ""
16889 "The <b>Demo</b> button shows you the execution of the expected "
16890 "solution. During its execution, you may want to switch the seen world to see "
16891 "the different expected solutions."
16892 msgstr ""
16893 "O botão <b>Demo</b> mostra a execução da solução esperada. Durante a "
16894 "execução pode alternar o mundo visto para ver as diferentes soluções "
16895 "esperadas."
16896
16897 #. type: Content of: <ul><li><ul><li>
16898 #: lib/doc/MainWindow.html:34
16899 msgid ""
16900 "Please note that there is often several ways of achieving the awaited "
16901 "solution, and that the one presented during the demo is not more or less "
16902 "correct than the others. You are completely free to not follow strictly the "
16903 "process shown by the demo, as long as your final solution matches the "
16904 "exercise expectations."
16905 msgstr ""
16906 "Note que às vezes existem várias maneiras de alcançar a solução esperada e "
16907 "que aquela apresentada durante a demonstração não é mais ou menos certa que "
16908 "as outras. É completamente livre para não seguir estritamente o processo "
16909 "mostrado pela demonstração, desde que a sua solução final atinja o que "
16910 "exercício pede."
16911
16912 #. type: Content of: <ul><li>
16913 #: lib/doc/MainWindow.html:41
16914 msgid ""
16915 "<b>Mission and editor tabs:</b> this is were you read this very text. This "
16916 "area contains several tabs to which you can access by clicking on their name "
16917 "on the top left. The first tab (which is always named <b>Mission</b>) "
16918 "contains a presentation of the current exercise. To solve an exercise, you "
16919 "need to write your code in the other tabs. For example, you can now clic on "
16920 "the <b>Source Code</b> tab to see the actual source. If it is empty, that's "
16921 "because you did not write any code yet."
16922 msgstr ""
16923 "<b>Guias de missão e editor:</b> é onde está a ler este texto. Esta área "
16924 "contém várias abas as quais pode acessar a clicar no nome deles no canto "
16925 "superior esquerdo. A primeira guia (que se chama sempre <b>Missão</b>) "
16926 "contém uma apresentação do exercício atual. Para resolver um exercício, "
16927 "precisa escrever o seu código nas outras guias. Por exemplo, pode agora "
16928 "clicar na guia <b>Código Fonte</b> para ver o código real. Se estiver vazia, "
16929 "é por que ainda não escreveu nenhum código."
16930
16931 #. type: Content of: <ul><li>
16932 #: lib/doc/MainWindow.html:49
16933 msgid ""
16934 "<b>The console:</b> Placed under the tabs, this is where any messages of the "
16935 "application will appear. This area is initially empty and white."
16936 msgstr ""
16937 "<b>O console:</b> localizado abaixo das abas, é onde aparece qualquer "
16938 "mensagem da aplicação. Esta área inicialmente é vazia e branca."
16939
16940 #. type: Content of: <ul><li>
16941 #: lib/doc/MainWindow.html:52
16942 msgid ""
16943 "<b>World view</b> Placed on the right of the tabs, it is constituted of five "
16944 "elements:"
16945 msgstr ""
16946 "<b>Visão do mundo</b> localizada à direita das abas, é constituída de cinco "
16947 "elementos:"
16948
16949 #. type: Content of: <ul><li><ul><li>
16950 #: lib/doc/MainWindow.html:57
16951 msgid ""
16952 "A scrolling menu allows to choose the world. Indeed, the program you write "
16953 "may be executed in several worlds to test it in differing conditions. This "
16954 "menu allows you to choose the world you want to see. Note that this "
16955 "scrolling menu is hidden if there is only one world in your exercise."
16956 msgstr ""
16957 "Um menu rolante serve para escolher o mundo. Na verdade, o programa que "
16958 "escreveu pode ser executado em vários mundos para testá-lo em diferentes "
16959 "condições. Este menu é para escolher o mundo que quer ver. Observe que este "
16960 "menu rolante fica oculto se houver apenas um mundo no seu exercício."
16961
16962 #. type: Content of: <ul><li><ul><li>
16963 #: lib/doc/MainWindow.html:62
16964 msgid ""
16965 "A slider placed right bellow allows to choose the animation speed of the "
16966 "world. More precisely, it allows to choose the delay (in milliseconds) that "
16967 "the buggles must wait after each action to allow you to see what they are "
16968 "doing."
16969 msgstr ""
16970 "Um \"slider\" posto logo abaixo serve para escolher a velocidade da animação "
16971 "do mundo. Mais precisamente, permite escolher o atraso (em milisegundos) que "
16972 "os buggles devem esperar depois de cada ação para permitir que veja o que "
16973 "eles estão a fazer."
16974
16975 #. type: Content of: <ul><li><ul><li>
16976 #: lib/doc/MainWindow.html:67
16977 msgid ""
16978 "A tab <b>World</b> represents the view of the world currently selected (from "
16979 "the scrolling menu). This view is thus constitued of a grid forming the "
16980 "several cells of the world, as well as several <i>buggles</i> awaiting for "
16981 "your orders."
16982 msgstr ""
16983 "Uma guia <b>Mundo</b> representa a visão de mundo atualmente selecionada (de "
16984 "menu rolante). Esta visão é então constituída de uma grade a formar várias "
16985 "células do mundo, assim como vários \"<i>buggles</i>\" a esperar as suas "
16986 "ordens."
16987
16988 #. type: Content of: <ul><li><ul><li>
16989 #: lib/doc/MainWindow.html:72
16990 msgid ""
16991 "An <b>Objective</b> tab displaying the world as it must be by the end of the "
16992 "exercise."
16993 msgstr ""
16994 "Uma guia <b>Objetivo</b> a mostrar o mundo como deveria ser no final do "
16995 "exercício."
16996
16997 #. type: Content of: <ul><li><ul><li>
16998 #: lib/doc/MainWindow.html:76
16999 msgid ""
17000 "<b>The interactive controls</b>. Placed under the world view, these buttons "
17001 "allows you to interactively control the buggles. This way, you can try to "
17002 "<i>manually</i> bring your buggle to the scenario objective before writting "
17003 "the needed code in the editor."
17004 msgstr ""
17005 "<b>Os controles interativos</b>. Localizados abaixo da Visão do mundo, estes "
17006 "botões servem para controlar interativamente os buggles. Desta forma, pode "
17007 "tentar trazer <i>manualmente</i> o seu buggle ao objetivo do cenário antes "
17008 "de escrever o código necessário no editor."
17009
17010 #. type: Content of: <ul><li><ul><li><ul><li>
17011 #: lib/doc/MainWindow.html:82
17012 msgid "A scrolling menu allows to select the buggle you want to control."
17013 msgstr "Um menu rolante serve para selecionar o \"buggle\" que quer controlar."
17014
17015 #. type: Content of: <ul><li><ul><li><ul><li>
17016 #: lib/doc/MainWindow.html:84
17017 msgid "The <b>Forward</b> button let your buggle do one step forward."
17018 msgstr "O botão <b>Avançar</b> faz o seu \"buggle\" dar um passo à frente."
17019
17020 #. type: Content of: <ul><li><ul><li><ul><li>
17021 #: lib/doc/MainWindow.html:86
17022 msgid "The <b>Backward</b> button let it do one step backward."
17023 msgstr "O botão <b>Recuar</b> fá-lo dar um passo para trás."
17024
17025 #. type: Content of: <ul><li><ul><li><ul><li>
17026 #: lib/doc/MainWindow.html:88
17027 msgid "The <b>Turn left</b> button ask your buggle to turn of 90° to its left."
17028 msgstr ""
17029 "O botão <b>Virar à esquerda</b> manda o seu \"buggle\" virar 90° à esquerda."
17030
17031 #. type: Content of: <ul><li><ul><li><ul><li>
17032 #: lib/doc/MainWindow.html:90
17033 msgid ""
17034 "The <b>Turn right</b> button asks the buggle to turn to the right (isn't "
17035 "this amazing?)."
17036 msgstr ""
17037 "O botão <b>Virar à direita</b> manda o seu \"buggle\" virar à direita ("
17038 "surpreendente, né?)."
17039
17040 #. type: Content of: <ul><li><ul><li><ul><li>
17041 #: lib/doc/MainWindow.html:93
17042 msgid ""
17043 "The <b>Mark</b> button requests your buggle to leave a mark behind it when "
17044 "it goes."
17045 msgstr ""
17046 "O botão <b>Marcar</b> pede que o seu \"buggle\" deixe uma marca atrás dele "
17047 "depois que sair."
55 msgid ""
66 msgstr ""
77 "Project-Id-Version: PLM mission texts\n"
8 "POT-Creation-Date: 2020-09-20 15:30+0200\n"
8 "POT-Creation-Date: 2020-09-25 22:29+0200\n"
99 "PO-Revision-Date: 2015-11-10 21:13+0100\n"
1010 "Last-Translator: Fred Maranhão <fred.maranhao@gmail.com>\n"
1111 "Language-Team: none\n"
11101110 "não faz de má-vontade. Se você olhar de perto, a solução para o problema "
11111111 "está escrita no meio daquelas mensagens complicadas. Você vai notar que com "
11121112 "um pouco de hábito a gente se acostuma."
1113
1114 #. type: Content of: <h3>
1115 #: src/lessons/welcome/environment/Environment.html:36
1116 #, fuzzy
1117 #| msgid "Data in [!thelang]"
1118 msgid "But that's [!thelang]!"
1119 msgstr "Dados em [!thelang]"
1120
1121 #. type: Content of: outside any tag (error?)
1122 #: src/lessons/welcome/environment/Environment.html:37
1123 msgid ""
1124 "Currently, the PLM is configured to accept [!thelang] programs, but it can "
1125 "also accept [!java]Python or Scala[/!][!scala]Java or Python[/!][!"
1126 "python]Java or Scala[/!] programs. Either click on the language icon at the "
1127 "very bottom right of the window, or head to the <tt>Language/Computer</tt> "
1128 "menu item to change it."
1129 msgstr ""
11131130
11141131 #. type: Content of: outside any tag (error?)
11151132 #: src/lessons/welcome/instructions/Instructions.html:4
1281112828 " esquerda(90);\n"
1281212829 " espiral(0,90,12,3);\n"
1281312830
12831 #. type: Content of: outside any tag (error?)
12832 #: src/lessons/recursion/lego/spiral/Spiral.html:30
12833 msgid ""
12834 "Note that you only have to write the function, not the initial call. Each "
12835 "world will provide a specific set of initial parameters (use the combobox to "
12836 "switch to other worlds). For example, the \"Square Pyramid\" world will call "
12837 "your function as follows:"
12838 msgstr ""
12839
12840 #. type: Content of: <pre>
12841 #: src/lessons/recursion/lego/spiral/Spiral.html:36
12842 #, no-wrap
12843 msgid "spiral(100, 90, 0, 3);\n"
12844 msgstr ""
12845
1281412846 #. type: Content of: <h2>
1281512847 #: src/lessons/recursion/lego/spiral/SpiralUse.html:2
1281612848 msgid "Drawing spirals"
0 # SOME DESCRIPTIVE TITLE
1 # Copyright (C) YEAR Free Software Foundation, Inc.
2 # This file is distributed under the same license as the PACKAGE package.
3 # Kristoffer Grundström <lovaren@gmail.com>, 2020.
4 msgid ""
5 msgstr ""
6 "Project-Id-Version: PACKAGE VERSION\n"
7 "POT-Creation-Date: 2020-09-25 22:29+0200\n"
8 "PO-Revision-Date: 2020-10-06 07:43+0000\n"
9 "Last-Translator: Kristoffer Grundström <lovaren@gmail.com>\n"
10 "Language-Team: Swedish <https://hosted.weblate.org/projects/"
11 "programmers-learning-machine/missions/sv/>\n"
12 "Language: sv\n"
13 "MIME-Version: 1.0\n"
14 "Content-Type: text/plain; charset=UTF-8\n"
15 "Content-Transfer-Encoding: 8bit\n"
16 "Plural-Forms: nplurals=2; plural=n != 1;\n"
17 "X-Generator: Weblate 4.3-dev\n"
18
19 #. type: Content of: <h1>
20 #: src/plm/universe/bugglequest/BuggleWorld.html:2
21 msgid "BuggleWorld"
22 msgstr ""
23
24 #. type: Content of: outside any tag (error?)
25 #: src/plm/universe/bugglequest/BuggleWorld.html:3
26 msgid ""
27 "This world was invented by Lyn Turbak, at Wellesley College. It is full of "
28 "Buggles, little animals understanding simple orders, and offers numerous "
29 "possibilities of interaction with the world: taking or dropping objects, "
30 "paint the ground, hit walls, etc."
31 msgstr ""
32
33 #. type: Content of: <h2>
34 #: src/plm/universe/bugglequest/BuggleWorld.html:8
35 msgid "Methods understood by buggles"
36 msgstr ""
37
38 #. type: Content of: <table><tr><td>
39 #: src/plm/universe/bugglequest/BuggleWorld.html:10
40 msgid "<b>Moving</b>"
41 msgstr "<b>Flyttar</b>"
42
43 #. type: Content of: <table><tr><td>
44 #: src/plm/universe/bugglequest/BuggleWorld.html:10
45 msgid "(See also the note on exceptions, below)"
46 msgstr ""
47
48 #. type: Content of: <table><tr><td><b>
49 #: src/plm/universe/bugglequest/BuggleWorld.html:11
50 #: src/lessons/turmites/universe/TurmiteWorld.html:10
51 msgid "<b>Turn left"
52 msgstr "<b>Sväng vänster"
53
54 #. type: Content of: <table><tr><td><b>
55 #: src/plm/universe/bugglequest/BuggleWorld.html:11
56 #: src/lessons/turmites/universe/TurmiteWorld.html:10
57 msgid "Turn right"
58 msgstr "Sväng höger"
59
60 #. type: Content of: <table><tr><td><b>
61 #: src/plm/universe/bugglequest/BuggleWorld.html:11
62 #: src/lessons/turmites/universe/TurmiteWorld.html:10
63 msgid "Turn back"
64 msgstr "Kör tillbaka"
65
66 #. type: Content of: <table><tr><td><b>
67 #: src/plm/universe/bugglequest/BuggleWorld.html:11
68 #: src/lessons/turmites/universe/TurmiteWorld.html:10
69 msgid "Moving forward"
70 msgstr "Kör framåt"
71
72 #. type: Content of: <table><tr><td>
73 #: src/plm/universe/bugglequest/BuggleWorld.html:11
74 #: src/lessons/turmites/universe/TurmiteWorld.html:10
75 msgid "Moving back</b>"
76 msgstr "Backar</b>"
77
78 #. type: Content of: <table><tr><td>
79 #: src/plm/universe/bugglequest/BuggleWorld.html:12
80 #: src/lessons/turmites/universe/TurmiteWorld.html:11
81 msgid "[!java|c]void [/!]left()"
82 msgstr "[!java|c]void [/!]vänster()"
83
84 #. type: Content of: <table><tr><td>
85 #: src/plm/universe/bugglequest/BuggleWorld.html:13
86 #: src/lessons/turmites/universe/TurmiteWorld.html:11
87 msgid "[!java|c]void [/!]right()"
88 msgstr "[!java|c]void [/!]höger()"
89
90 #. type: Content of: <table><tr><td>
91 #: src/plm/universe/bugglequest/BuggleWorld.html:14
92 #: src/lessons/turmites/universe/TurmiteWorld.html:11
93 msgid "[!java|c]void [/!]back()"
94 msgstr "[!java|c]void [/!]backa()"
95
96 #. type: Content of: <table><tr><td>
97 #: src/plm/universe/bugglequest/BuggleWorld.html:15
98 msgid ""
99 "[!java|c]void [/!][!python|java|scala]forward()[/!][!c]stepForward()[/!] or "
100 "[!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])"
101 msgstr ""
102
103 #. type: Content of: <table><tr><td>
104 #: src/plm/universe/bugglequest/BuggleWorld.html:16
105 msgid ""
106 "[!java|c]void [/!][!python|java|scala]backward()[/!][!c]stepBackward()[/!] "
107 "or [!java]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])"
108 msgstr ""
109
110 #. type: Content of: <table><tr><td><b>
111 #: src/plm/universe/bugglequest/BuggleWorld.html:17
112 msgid "<b>Get X coordinate"
113 msgstr ""
114
115 #. type: Content of: <table><tr><td><b>
116 #: src/plm/universe/bugglequest/BuggleWorld.html:17
117 msgid "Get Y coordinate"
118 msgstr "Hämta Y-koordinat"
119
120 #. type: Content of: <table><tr><td><b>
121 #: src/plm/universe/bugglequest/BuggleWorld.html:17
122 msgid "Set X coordinate"
123 msgstr ""
124
125 #. type: Content of: <table><tr><td><b>
126 #: src/plm/universe/bugglequest/BuggleWorld.html:17
127 msgid "Set Y coordinate"
128 msgstr ""
129
130 #. type: Content of: <table><tr><td>
131 #: src/plm/universe/bugglequest/BuggleWorld.html:17
132 msgid "Set position</b>"
133 msgstr "Ställ in plats</b>"
134
135 #. type: Content of: <table><tr><td>
136 #: src/plm/universe/bugglequest/BuggleWorld.html:18
137 msgid "[!java|c]int [/!]getX()[!scala]:Int[/!]"
138 msgstr ""
139
140 #. type: Content of: <table><tr><td>
141 #: src/plm/universe/bugglequest/BuggleWorld.html:19
142 msgid "[!java|c]int [/!]getY()[!scala]:Int[/!]"
143 msgstr ""
144
145 #. type: Content of: <table><tr><td>
146 #: src/plm/universe/bugglequest/BuggleWorld.html:20
147 msgid "[!java|c]void [/!]setX([!java|c]int [/!]x[!scala]:Int[/!])"
148 msgstr ""
149
150 #. type: Content of: <table><tr><td>
151 #: src/plm/universe/bugglequest/BuggleWorld.html:21
152 msgid "[!java|c]void [/!]setY([!java|c]int [/!]y[!scala]:Int[/!])"
153 msgstr ""
154
155 #. type: Content of: <table><tr><td>
156 #: src/plm/universe/bugglequest/BuggleWorld.html:22
157 msgid ""
158 "[!java|c]void [/!]setPos([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int "
159 "[/!]y[!scala]:Int[/!])"
160 msgstr ""
161
162 #. type: Content of: <table><tr><td>
163 #: src/plm/universe/bugglequest/BuggleWorld.html:23
164 msgid ""
165 "Note that the point (0,0) is on the top left corner, as it is often the case "
166 "in Computer Science."
167 msgstr ""
168
169 #. type: Content of: <table><tr><td>
170 #: src/plm/universe/bugglequest/BuggleWorld.html:25
171 msgid "<b>Information on the buggle</b>"
172 msgstr ""
173
174 #. type: Content of: <table><tr><td><b>
175 #: src/plm/universe/bugglequest/BuggleWorld.html:26
176 msgid "<b>Get the color of the body"
177 msgstr ""
178
179 #. type: Content of: <table><tr><td>
180 #: src/plm/universe/bugglequest/BuggleWorld.html:26
181 msgid "Set the color of the body</b>"
182 msgstr ""
183
184 #. type: Content of: <table><tr><td>
185 #: src/plm/universe/bugglequest/BuggleWorld.html:27
186 msgid "[!java|c]Color [/!]getBodyColor()[!scala]:Color[/!]"
187 msgstr ""
188
189 #. type: Content of: <table><tr><td>
190 #: src/plm/universe/bugglequest/BuggleWorld.html:28
191 msgid "[!java|c]void [/!]setBodyColor([!java|c]Color [/!]c[!scala]:Color[/!])"
192 msgstr ""
193
194 #. type: Content of: <table><tr><td><b>
195 #: src/plm/universe/bugglequest/BuggleWorld.html:29
196 msgid "<b>Look for a wall forward"
197 msgstr ""
198
199 #. type: Content of: <table><tr><td>
200 #: src/plm/universe/bugglequest/BuggleWorld.html:29
201 msgid "Look for a wall backward</b>"
202 msgstr ""
203
204 #. type: Content of: <table><tr><td>
205 #: src/plm/universe/bugglequest/BuggleWorld.html:30
206 msgid "[!java]boolean [/!][!c]int [/!]isFacingWall()[!scala]:Boolean[/!]"
207 msgstr ""
208
209 #. type: Content of: <table><tr><td>
210 #: src/plm/universe/bugglequest/BuggleWorld.html:31
211 msgid "[!java]boolean [/!][!c]int [/!]isBackingWall()[!scala]:Boolean[/!]"
212 msgstr ""
213
214 #. type: Content of: <table><tr><td><b>
215 #: src/plm/universe/bugglequest/BuggleWorld.html:32
216 msgid "<b>Get heading"
217 msgstr ""
218
219 #. type: Content of: <table><tr><td>
220 #: src/plm/universe/bugglequest/BuggleWorld.html:32
221 msgid "Set heading</b>"
222 msgstr ""
223
224 #. type: Content of: <table><tr><td>
225 #: src/plm/universe/bugglequest/BuggleWorld.html:32
226 msgid "valid directions are:"
227 msgstr ""
228
229 #. type: Content of: <table><tr><td>
230 #: src/plm/universe/bugglequest/BuggleWorld.html:33
231 msgid "[!java|c]Direction [/!]getDirection()[!scala]:Direction[/!]"
232 msgstr ""
233
234 #. type: Content of: <table><tr><td>
235 #: src/plm/universe/bugglequest/BuggleWorld.html:34
236 msgid ""
237 "[!java|c]void [/!]setDirection([!java|c]Direction "
238 "[/!]dir[!scala]:Direction[/!])"
239 msgstr ""
240
241 #. type: Content of: <table><tr><td>
242 #: src/plm/universe/bugglequest/BuggleWorld.html:35
243 msgid ""
244 "[!scala|java|python]Direction.[/!]NORTH, "
245 "[!scala|java|python]Direction.[/!]EAST, "
246 "[!scala|java|python]Direction.[/!]SOUTH and "
247 "[!scala|java|python]Direction.[/!]WEST"
248 msgstr ""
249
250 #. type: Content of: <table><tr><td>
251 #: src/plm/universe/bugglequest/BuggleWorld.html:36
252 msgid "Check whether the buggle is currently <b>selected in the interface</b>"
253 msgstr ""
254
255 #. type: Content of: <pre>
256 #: src/plm/universe/bugglequest/BuggleWorld.html:37
257 #: src/plm/universe/turtles/TurtleWorld.html:76
258 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:27
259 #, no-wrap
260 msgid "[!java]boolean [/!][!c]int [/!]isSelected()[!scala]:Boolean[/!]"
261 msgstr ""
262
263 #. type: Content of: <table><tr><td>
264 #: src/plm/universe/bugglequest/BuggleWorld.html:39
265 msgid "<b>About the brush</b>"
266 msgstr ""
267
268 #. type: Content of: <table><tr><td><b>
269 #: src/plm/universe/bugglequest/BuggleWorld.html:40
270 msgid "<b>Brush down"
271 msgstr ""
272
273 #. type: Content of: <table><tr><td><b>
274 #: src/plm/universe/bugglequest/BuggleWorld.html:40
275 msgid "Brush up"
276 msgstr ""
277
278 #. type: Content of: <table><tr><td>
279 #: src/plm/universe/bugglequest/BuggleWorld.html:40
280 msgid "Get brush position</b>"
281 msgstr ""
282
283 #. type: Content of: <table><tr><td>
284 #: src/plm/universe/bugglequest/BuggleWorld.html:41
285 msgid "[!java|c]void [/!]brushUp()"
286 msgstr ""
287
288 #. type: Content of: <table><tr><td>
289 #: src/plm/universe/bugglequest/BuggleWorld.html:42
290 msgid "[!java|c]void [/!]brushDown()"
291 msgstr ""
292
293 #. type: Content of: <table><tr><td>
294 #: src/plm/universe/bugglequest/BuggleWorld.html:43
295 msgid "[!java]boolean [/!][!c]int [/!]isBrushDown()[!scala]:Boolean[/!]"
296 msgstr ""
297
298 #. type: Content of: <table><tr><td><b>
299 #: src/plm/universe/bugglequest/BuggleWorld.html:44
300 msgid "<b>Change the brush color"
301 msgstr ""
302
303 #. type: Content of: <table><tr><td>
304 #: src/plm/universe/bugglequest/BuggleWorld.html:44
305 msgid "Get the color of the brush</b>"
306 msgstr ""
307
308 #. type: Content of: <table><tr><td>
309 #: src/plm/universe/bugglequest/BuggleWorld.html:45
310 msgid "[!java|c]void [/!]setBrushColor([!java|c]Color [/!]c[!scala]:Color[/!])"
311 msgstr ""
312
313 #. type: Content of: <table><tr><td>
314 #: src/plm/universe/bugglequest/BuggleWorld.html:46
315 msgid "[!java|c]Color [/!]getBrushColor()[!scala]:Color[/!]"
316 msgstr ""
317
318 #. type: Content of: <table><tr><td>
319 #: src/plm/universe/bugglequest/BuggleWorld.html:48
320 msgid "<b>Interacting with the world</b>"
321 msgstr ""
322
323 #. type: Content of: <table><tr><td>
324 #: src/plm/universe/bugglequest/BuggleWorld.html:49
325 #: src/lessons/turmites/universe/TurmiteWorld.html:15
326 msgid "<b>Get the color of the ground</b>"
327 msgstr ""
328
329 #. type: Content of: <table><tr><td>
330 #: src/plm/universe/bugglequest/BuggleWorld.html:50
331 #: src/lessons/turmites/universe/TurmiteWorld.html:15
332 msgid "[!java|c]Color [/!]getGroundColor()[!scala]:Color[/!]"
333 msgstr ""
334
335 #. type: Content of: <table><tr><td><b>
336 #: src/plm/universe/bugglequest/BuggleWorld.html:52
337 msgid "<b>Look for a baggle on the ground"
338 msgstr ""
339
340 #. type: Content of: <table><tr><td><b>
341 #: src/plm/universe/bugglequest/BuggleWorld.html:52
342 msgid "Look for a baggle in bag"
343 msgstr ""
344
345 #. type: Content of: <table><tr><td><b>
346 #: src/plm/universe/bugglequest/BuggleWorld.html:52
347 msgid "Pickup a baggle"
348 msgstr ""
349
350 #. type: Content of: <table><tr><td>
351 #: src/plm/universe/bugglequest/BuggleWorld.html:52
352 msgid "Drop a baggle</b>"
353 msgstr ""
354
355 #. type: Content of: <table><tr><td>
356 #: src/plm/universe/bugglequest/BuggleWorld.html:53
357 msgid "(see the note on exceptions)"
358 msgstr ""
359
360 #. type: Content of: <table><tr><td>
361 #: src/plm/universe/bugglequest/BuggleWorld.html:54
362 msgid "[!java]boolean [/!][!c]int [/!]isOverBaggle()[!scala]:Boolean[/!]"
363 msgstr ""
364
365 #. type: Content of: <table><tr><td>
366 #: src/plm/universe/bugglequest/BuggleWorld.html:55
367 msgid "[!java]boolean [/!][!c]int [/!]isCarryingBaggle()[!scala]:Boolean[/!]"
368 msgstr ""
369
370 #. type: Content of: <table><tr><td>
371 #: src/plm/universe/bugglequest/BuggleWorld.html:56
372 msgid "[!java]void [/!]pickupBaggle()"
373 msgstr ""
374
375 #. type: Content of: <table><tr><td>
376 #: src/plm/universe/bugglequest/BuggleWorld.html:57
377 msgid "[!java]void [/!]dropBaggle()"
378 msgstr ""
379
380 #. type: Content of: <table><tr><td>
381 #: src/plm/universe/bugglequest/BuggleWorld.html:58
382 #: src/plm/universe/bugglequest/BuggleWorld.html:70
383 #: src/plm/universe/bugglequest/BuggleWorld.html:71
384 #: src/plm/universe/bugglequest/BuggleWorld.html:72
385 #: src/plm/universe/bugglequest/BuggleWorld.html:73
386 #: src/plm/universe/bugglequest/BuggleWorld.html:74
387 #: src/plm/universe/bugglequest/BuggleWorld.html:75
388 #: src/plm/universe/bugglequest/BuggleWorld.html:76
389 #: src/plm/universe/bugglequest/BuggleWorld.html:77
390 #: src/plm/universe/bugglequest/BuggleWorld.html:78
391 #: src/plm/universe/bugglequest/BuggleWorld.html:79
392 #: src/plm/universe/bugglequest/BuggleWorld.html:80
393 #: src/plm/universe/bugglequest/BuggleWorld.html:81
394 #: src/plm/universe/bugglequest/BuggleWorld.html:82
395 #: src/lessons/welcome/Main.html:9 src/lessons/welcome/Main.html:92
396 #: src/lessons/welcome/Main.html:175 src/lessons/welcome/Main.html:255
397 #: src/lessons/welcome/Main.html:349 src/lessons/welcome/Main.html:429
398 #: src/lessons/welcome/Main.html:469
399 #: src/plm/universe/turtles/TurtleWorld.html:82
400 #: src/plm/universe/turtles/TurtleWorld.html:83
401 #: src/plm/universe/turtles/TurtleWorld.html:84
402 #: src/plm/universe/turtles/TurtleWorld.html:85
403 #: src/plm/universe/turtles/TurtleWorld.html:86
404 #: src/plm/universe/turtles/TurtleWorld.html:87
405 #: src/plm/universe/turtles/TurtleWorld.html:88
406 #: src/plm/universe/turtles/TurtleWorld.html:89
407 #: src/plm/universe/turtles/TurtleWorld.html:90
408 #: src/plm/universe/turtles/TurtleWorld.html:91
409 #: src/plm/universe/turtles/TurtleWorld.html:92
410 #: src/plm/universe/turtles/TurtleWorld.html:93
411 #: src/plm/universe/turtles/TurtleWorld.html:94
412 msgid "&nbsp;"
413 msgstr ""
414
415 #. type: Content of: <table><tr><td><b>
416 #: src/plm/universe/bugglequest/BuggleWorld.html:60
417 msgid "<b>Look for a message"
418 msgstr ""
419
420 #. type: Content of: <table><tr><td><b>
421 #: src/plm/universe/bugglequest/BuggleWorld.html:60
422 msgid "Add a message"
423 msgstr ""
424
425 #. type: Content of: <table><tr><td><b>
426 #: src/plm/universe/bugglequest/BuggleWorld.html:60
427 msgid "Read the message"
428 msgstr ""
429
430 #. type: Content of: <table><tr><td>
431 #: src/plm/universe/bugglequest/BuggleWorld.html:60
432 msgid "Erase the message</b>"
433 msgstr ""
434
435 #. type: Content of: <table><tr><td>
436 #: src/plm/universe/bugglequest/BuggleWorld.html:61
437 msgid "[!java]boolean [/!][!c]int [/!]isOverMessage()[!scala]:Boolean[/!]"
438 msgstr ""
439
440 #. type: Content of: <table><tr><td>
441 #: src/plm/universe/bugglequest/BuggleWorld.html:62
442 msgid ""
443 "[!java]void [/!]writeMessage([!java]String [/!][!c]char* "
444 "[/!]msg[!scala]:String[/!])"
445 msgstr ""
446
447 #. type: Content of: <table><tr><td>
448 #: src/plm/universe/bugglequest/BuggleWorld.html:63
449 msgid "[!java]String [/!][!c]char* [/!]readMessage()[!scala]:String[/!]"
450 msgstr ""
451
452 #. type: Content of: <table><tr><td>
453 #: src/plm/universe/bugglequest/BuggleWorld.html:64
454 msgid "[!java]void [/!]clearMessage()"
455 msgstr ""
456
457 #. type: Content of: <h2>
458 #: src/plm/universe/bugglequest/BuggleWorld.html:67
459 #: src/plm/universe/turtles/TurtleWorld.html:79
460 msgid "Valid colors"
461 msgstr ""
462
463 #. type: Content of: <table><tr><td>
464 #: src/plm/universe/bugglequest/BuggleWorld.html:69
465 #: src/plm/universe/turtles/TurtleWorld.html:81
466 msgid "Name"
467 msgstr ""
468
469 #. type: Content of: <table><tr><td>
470 #: src/plm/universe/bugglequest/BuggleWorld.html:69
471 #: src/plm/universe/turtles/TurtleWorld.html:81
472 msgid "Color"
473 msgstr ""
474
475 #. type: Content of: <table><tr><td>
476 #: src/plm/universe/bugglequest/BuggleWorld.html:70
477 #: src/plm/universe/turtles/TurtleWorld.html:82
478 msgid "[!scala|java|python]Color.[/!]black"
479 msgstr ""
480
481 #. type: Content of: <table><tr><td>
482 #: src/plm/universe/bugglequest/BuggleWorld.html:71
483 #: src/plm/universe/turtles/TurtleWorld.html:83
484 msgid "[!scala|java|python]Color.[/!]blue"
485 msgstr ""
486
487 #. type: Content of: <table><tr><td>
488 #: src/plm/universe/bugglequest/BuggleWorld.html:72
489 #: src/plm/universe/turtles/TurtleWorld.html:84
490 msgid "[!scala|java|python]Color.[/!]cyan"
491 msgstr ""
492
493 #. type: Content of: <table><tr><td>
494 #: src/plm/universe/bugglequest/BuggleWorld.html:73
495 #: src/plm/universe/turtles/TurtleWorld.html:85
496 msgid "[!scala|java|python]Color.[/!]darkGray"
497 msgstr ""
498
499 #. type: Content of: <table><tr><td>
500 #: src/plm/universe/bugglequest/BuggleWorld.html:74
501 #: src/plm/universe/turtles/TurtleWorld.html:86
502 msgid "[!scala|java|python]Color.[/!]gray"
503 msgstr ""
504
505 #. type: Content of: <table><tr><td>
506 #: src/plm/universe/bugglequest/BuggleWorld.html:75
507 #: src/plm/universe/turtles/TurtleWorld.html:87
508 msgid "[!scala|java|python]Color.[/!]green"
509 msgstr ""
510
511 #. type: Content of: <table><tr><td>
512 #: src/plm/universe/bugglequest/BuggleWorld.html:76
513 #: src/plm/universe/turtles/TurtleWorld.html:88
514 msgid "[!scala|java|python]Color.[/!]lightGray"
515 msgstr ""
516
517 #. type: Content of: <table><tr><td>
518 #: src/plm/universe/bugglequest/BuggleWorld.html:77
519 #: src/plm/universe/turtles/TurtleWorld.html:89
520 msgid "[!scala|java|python]Color.[/!]magenta"
521 msgstr ""
522
523 #. type: Content of: <table><tr><td>
524 #: src/plm/universe/bugglequest/BuggleWorld.html:78
525 #: src/plm/universe/turtles/TurtleWorld.html:90
526 msgid "[!scala|java|python]Color.[/!]orange"
527 msgstr ""
528
529 #. type: Content of: <table><tr><td>
530 #: src/plm/universe/bugglequest/BuggleWorld.html:79
531 #: src/plm/universe/turtles/TurtleWorld.html:91
532 msgid "[!scala|java|python]Color.[/!]pink"
533 msgstr ""
534
535 #. type: Content of: <table><tr><td>
536 #: src/plm/universe/bugglequest/BuggleWorld.html:80
537 #: src/plm/universe/turtles/TurtleWorld.html:92
538 msgid "[!scala|java|python]Color.[/!]red"
539 msgstr ""
540
541 #. type: Content of: <table><tr><td>
542 #: src/plm/universe/bugglequest/BuggleWorld.html:81
543 #: src/plm/universe/turtles/TurtleWorld.html:93
544 msgid "[!scala|java|python]Color.[/!]white"
545 msgstr ""
546
547 #. type: Content of: <table><tr><td>
548 #: src/plm/universe/bugglequest/BuggleWorld.html:82
549 #: src/plm/universe/turtles/TurtleWorld.html:94
550 msgid "[!scala|java|python]Color.[/!]yellow"
551 msgstr ""
552
553 #. type: Content of: <h2>
554 #: src/plm/universe/bugglequest/BuggleWorld.html:85
555 msgid "Note on exceptions"
556 msgstr ""
557
558 #. type: Content of: outside any tag (error?)
559 #: src/plm/universe/bugglequest/BuggleWorld.html:86
560 msgid ""
561 "Regular buggles throw a BuggleWallException exception if you ask them to "
562 "traverse a wall. They throw a NoBaggleUnderBuggleException exception if you "
563 "ask them to pickup a baggle from an empty cell, or a "
564 "AlreadyHaveBaggleException exception if they already carry a baggle. Trying "
565 "to drop a baggle on a cell already containing one throws an "
566 "AlreadyHaveBaggleException exception. Dropping a baggle when you have none "
567 "throws a DontHaveBaggleException."
568 msgstr ""
569
570 #. type: Content of: <p>
571 #: src/plm/universe/bugglequest/BuggleWorld.html:93
572 msgid ""
573 "SimpleBuggles (ie, the one used in first exercises) display an error message "
574 "on problem so that you don't need to know what an exception is."
575 msgstr ""
576
577 #. type: Content of: <h1>
578 #: src/plm/universe/bat/BatWorld.html:2
579 msgid "BatWorld"
580 msgstr ""
581
582 #. type: Content of: <p>
583 #: src/plm/universe/bat/BatWorld.html:4
584 msgid ""
585 "This world is a simplistic testing environment largely inspired from the "
586 "http://codingbat.com invented by Nick Parlente."
587 msgstr ""
588
589 #. type: Content of: <p>
590 #: src/plm/universe/bat/BatWorld.html:7
591 msgid ""
592 "The typical exercises are very short ones, aiming at improving the tactical "
593 "programming abilities of the students. That is to say that you will be "
594 "presented a quite long list of very little exercises about rather simple "
595 "things. The idea is to train you on these issues until they become automatic "
596 "to you."
597 msgstr ""
598
599 #. type: Content of: <p>
600 #: src/plm/universe/bat/BatWorld.html:13
601 msgid ""
602 "In contrary to the other worlds, the BatWorld does not provide any fancy "
603 "abstraction nor visualization. You have to fill a function, which gets "
604 "called for a bunch of parameter sets, and that's it."
605 msgstr ""
606
607 #. type: Content of: <p>
608 #: src/plm/universe/bat/BatWorld.html:17
609 msgid ""
610 "For more information, you should refer to the CodingBat.com documentation, "
611 "which contains for example a very useful documentation on boolean operators: "
612 "http://codingbat.com/doc/ifboolean.html"
613 msgstr ""
614
615 #. type: Content of: <h3>
616 #: src/lessons/welcome/Main.html:2 src/lessons/welcome/short_desc.html:2
617 msgid "First steps"
618 msgstr ""
619
620 #. type: Content of: outside any tag (error?)
621 #: src/lessons/welcome/Main.html:4
622 msgid ""
623 "This first lesson will lead your first steps in programming. It is intended "
624 "for beginners. List of seen notions per exercise:"
625 msgstr ""
626
627 #. type: Content of: <h2>
628 #: src/lessons/welcome/Main.html:10 src/lessons/welcome/Main.html:93
629 #: src/lessons/welcome/Main.html:176 src/lessons/welcome/Main.html:256
630 #: src/lessons/welcome/Main.html:350 src/lessons/welcome/Main.html:430
631 #: src/lessons/welcome/Main.html:470
632 #: src/lessons/welcome/instructions/Instructions.html:2
633 msgid "Instructions"
634 msgstr ""
635
636 #. type: Content of: <table><tr><td>
637 #: src/lessons/welcome/Main.html:11 src/lessons/welcome/Main.html:94
638 #: src/lessons/welcome/Main.html:177 src/lessons/welcome/Main.html:257
639 #: src/lessons/welcome/Main.html:351 src/lessons/welcome/Main.html:431
640 #: src/lessons/welcome/Main.html:471
641 msgid "Comments"
642 msgstr ""
643
644 #. type: Content of: <table><tr><td>
645 #: src/lessons/welcome/Main.html:12 src/lessons/welcome/Main.html:95
646 #: src/lessons/welcome/Main.html:178 src/lessons/welcome/Main.html:258
647 #: src/lessons/welcome/Main.html:352 src/lessons/welcome/Main.html:432
648 #: src/lessons/welcome/Main.html:472
649 msgid "Conditionals/ Expressions"
650 msgstr ""
651
652 #. type: Content of: <h2>
653 #: src/lessons/welcome/Main.html:13 src/lessons/welcome/Main.html:79
654 #: src/lessons/welcome/Main.html:96 src/lessons/welcome/Main.html:179
655 #: src/lessons/welcome/Main.html:259 src/lessons/welcome/Main.html:353
656 #: src/lessons/welcome/Main.html:433 src/lessons/welcome/Main.html:473
657 #: src/lessons/welcome/loopwhile/LoopWhile.html:2
658 msgid "While loops"
659 msgstr ""
660
661 #. type: Content of: <table><tr><td>
662 #: src/lessons/welcome/Main.html:14 src/lessons/welcome/Main.html:97
663 #: src/lessons/welcome/Main.html:180 src/lessons/welcome/Main.html:260
664 #: src/lessons/welcome/Main.html:354 src/lessons/welcome/Main.html:434
665 #: src/lessons/welcome/Main.html:474
666 msgid "Variables"
667 msgstr ""
668
669 #. type: Content of: <h2>
670 #: src/lessons/welcome/Main.html:15 src/lessons/welcome/Main.html:98
671 #: src/lessons/welcome/Main.html:134 src/lessons/welcome/Main.html:181
672 #: src/lessons/welcome/Main.html:261 src/lessons/welcome/Main.html:355
673 #: src/lessons/welcome/Main.html:435 src/lessons/welcome/Main.html:475
674 #: src/lessons/welcome/loopfor/LoopFor.html:2
675 msgid "For loops"
676 msgstr ""
677
678 #. type: Content of: <table><tr><td>
679 #: src/lessons/welcome/Main.html:16 src/lessons/welcome/Main.html:99
680 #: src/lessons/welcome/Main.html:182 src/lessons/welcome/Main.html:262
681 #: src/lessons/welcome/Main.html:356 src/lessons/welcome/Main.html:436
682 #: src/lessons/welcome/Main.html:476
683 msgid "Do/While loops"
684 msgstr ""
685
686 #. type: Content of: <h2>
687 #: src/lessons/welcome/Main.html:17 src/lessons/welcome/Main.html:100
688 #: src/lessons/welcome/Main.html:162 src/lessons/welcome/Main.html:183
689 #: src/lessons/welcome/Main.html:263 src/lessons/welcome/Main.html:357
690 #: src/lessons/welcome/Main.html:437 src/lessons/welcome/Main.html:477
691 #: src/lessons/welcome/methods/basics/Methods.html:2
692 msgid "Methods"
693 msgstr ""
694
695 #. type: Content of: <table><tr><td>
696 #: src/lessons/welcome/Main.html:18 src/lessons/welcome/Main.html:101
697 #: src/lessons/welcome/Main.html:184 src/lessons/welcome/Main.html:264
698 #: src/lessons/welcome/Main.html:358 src/lessons/welcome/Main.html:438
699 #: src/lessons/welcome/Main.html:478
700 msgid "Switch"
701 msgstr ""
702
703 #. type: Content of: <table><tr><td>
704 #: src/lessons/welcome/Main.html:19 src/lessons/welcome/Main.html:102
705 #: src/lessons/welcome/Main.html:185 src/lessons/welcome/Main.html:265
706 #: src/lessons/welcome/Main.html:359 src/lessons/welcome/Main.html:439
707 #: src/lessons/welcome/Main.html:479
708 msgid "Arrays"
709 msgstr ""
710
711 #. type: Content of: <table><tr><td>
712 #: src/lessons/welcome/Main.html:23
713 msgid "Welcome in the Buggles' World"
714 msgstr ""
715
716 #. type: Content of: <table><tr><td>
717 #: src/lessons/welcome/Main.html:37
718 msgid "Java Instructions"
719 msgstr ""
720
721 #. type: Content of: <h2>
722 #: src/lessons/welcome/Main.html:51
723 #: src/lessons/welcome/instructions/InstructionsDrawG.html:2
724 msgid "Writing more complex programs"
725 msgstr ""
726
727 #. type: Content of: <h2>
728 #: src/lessons/welcome/Main.html:65
729 #: src/lessons/welcome/conditions/Conditions.html:2
730 msgid "Conditional instructions"
731 msgstr ""
732
733 #. type: Content of: <h2>
734 #: src/lessons/welcome/Main.html:106
735 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:2
736 msgid "Baggle Seeking"
737 msgstr ""
738
739 #. type: Content of: <h2>
740 #: src/lessons/welcome/Main.html:120
741 #: src/lessons/welcome/variables/Variables.html:2
742 msgid "Storing and manipulating data"
743 msgstr ""
744
745 #. type: Content of: <h2>
746 #: src/lessons/welcome/Main.html:148
747 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:2
748 msgid "Do .. while loops"
749 msgstr ""
750
751 #. type: Content of: <h2>
752 #: src/lessons/welcome/Main.html:188
753 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:2
754 msgid "Building methodically"
755 msgstr ""
756
757 #. type: Content of: <table><tr><td>
758 #: src/lessons/welcome/Main.html:202
759 msgid "Methods returning a result"
760 msgstr ""
761
762 #. type: Content of: <h2>
763 #: src/lessons/welcome/Main.html:215
764 #: src/lessons/welcome/methods/args/MethodsArgs.html:2
765 msgid "Methods with parameters"
766 msgstr ""
767
768 #. type: Content of: <h2>
769 #: src/lessons/welcome/Main.html:229
770 #: src/lessons/welcome/methods/picture/PictureMono1.html:2
771 msgid "Methodically drawing"
772 msgstr ""
773
774 #. type: Content of: <h2>
775 #: src/lessons/welcome/Main.html:242
776 #: src/lessons/welcome/methods/picture/PictureMono2.html:2
777 msgid "Methodically drawing (only bigger)"
778 msgstr ""
779
780 #. type: Content of: <h2>
781 #: src/lessons/welcome/Main.html:268
782 #: src/lessons/welcome/methods/picture/PictureMono3.html:2
783 msgid "Drawing bigger and bigger"
784 msgstr ""
785
786 #. type: Content of: <table><tr><td>
787 #: src/lessons/welcome/Main.html:281
788 msgid "Even more pattern to draw"
789 msgstr ""
790
791 #. type: Content of: <table><tr><td>
792 #: src/lessons/welcome/Main.html:295
793 msgid "Buggle Dance Revolution"
794 msgstr ""
795
796 #. type: Content of: <table><tr><td>
797 #: src/lessons/welcome/Main.html:309
798 msgid "Buggle Dance Revolution 2"
799 msgstr ""
800
801 #. type: Content of: <h2>
802 #: src/lessons/welcome/Main.html:323
803 #: src/lessons/welcome/methods/slug/SlugHunting.html:2
804 msgid "Slug Hunting"
805 msgstr ""
806
807 #. type: Content of: <h2>
808 #: src/lessons/welcome/Main.html:336
809 #: src/lessons/welcome/methods/slug/SlugTracking.html:2
810 msgid "Slug Tracking"
811 msgstr ""
812
813 #. type: Content of: <h2>
814 #: src/lessons/welcome/Main.html:362 src/lessons/welcome/traversal/Snake.html:2
815 msgid "Snake World"
816 msgstr ""
817
818 #. type: Content of: <table><tr><td>
819 #: src/lessons/welcome/Main.html:376
820 msgid "Knitting and Arrays"
821 msgstr ""
822
823 #. type: Content of: <table><tr><td>
824 #: src/lessons/welcome/Main.html:390
825 msgid "Knitting, Arrays and modulos"
826 msgstr ""
827
828 #. type: Content of: <h2>
829 #: src/lessons/welcome/Main.html:403
830 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:2
831 msgid "Traversal by column"
832 msgstr ""
833
834 #. type: Content of: <h2>
835 #: src/lessons/welcome/Main.html:416
836 #: src/lessons/welcome/traversal/line/TraversalByLine.html:2
837 msgid "Traversal by line"
838 msgstr ""
839
840 #. type: Content of: <h2>
841 #: src/lessons/welcome/Main.html:442
842 #: src/lessons/welcome/traversal/zigzag/TraversalZigZag.html:2
843 msgid "Zig-zag traversal"
844 msgstr ""
845
846 #. type: Content of: <h2>
847 #: src/lessons/welcome/Main.html:455
848 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:2
849 msgid "Diagonal Traversal"
850 msgstr ""
851
852 #. type: Content of: <h2>
853 #: src/lessons/welcome/Main.html:483
854 msgid "Meaning of the symbols"
855 msgstr ""
856
857 #. type: Content of: <table><tr><td>
858 #: src/lessons/welcome/Main.html:486
859 msgid "Introducing the concept"
860 msgstr ""
861
862 #. type: Content of: <table><tr><td>
863 #: src/lessons/welcome/Main.html:489
864 msgid "Working on the concept"
865 msgstr ""
866
867 #. type: Content of: <table><tr><td>
868 #: src/lessons/welcome/Main.html:492
869 msgid "Concept assumed mastered"
870 msgstr ""
871
872 #. type: Content of: <table><tr><td>
873 #: src/lessons/welcome/Main.html:495
874 msgid "Concept not mandated by the exercise"
875 msgstr ""
876
877 #. type: Content of: <h2>
878 #: src/lessons/welcome/Main.html:501
879 msgid "What will I learn?"
880 msgstr ""
881
882 #. type: Content of: <p>
883 #: src/lessons/welcome/Main.html:502
884 msgid ""
885 "You will learn the very basics of programming. At least, you will be "
886 "presented the most important concepts, allowing you to read most simple "
887 "algorithms. You will not be able to write or read full programs because you "
888 "will still not know about objects, but you will master what is called "
889 "\"Tactical programming\", meaning that you will master the syntax enough to "
890 "not have any issue with it, allowing you to focus on the fundamental "
891 "problems of what you want to solve instead of struggling with syntactic "
892 "difficulties."
893 msgstr ""
894
895 #. type: Content of: <p>
896 #: src/lessons/welcome/short_desc.html:3
897 msgid ""
898 "This first lesson will lead your first steps in programming. It is intended "
899 "for beginners."
900 msgstr ""
901
902 #. type: Content of: <p>
903 #: src/lessons/welcome/short_desc.html:6
904 msgid ""
905 "If you are not sure, go for this lesson that will teach you the bases of "
906 "programming."
907 msgstr ""
908
909 #. type: Content of: <h2>
910 #: src/lessons/welcome/environment/Environment.html:3
911 msgid "Welcome to the PLM"
912 msgstr ""
913
914 #. type: Content of: <p>
915 #: src/lessons/welcome/environment/Environment.html:5
916 msgid ""
917 "The goal of this first exercise is to instruct your buggle to move forward "
918 "by one step. Switch between the views on the right for more "
919 "info. <i>World</i> depicts the world as it is now, while <i>Objective</i> "
920 "depicts what you should get."
921 msgstr ""
922
923 #. type: Content of: <h3>
924 #: src/lessons/welcome/environment/Environment.html:10
925 msgid "My <i>buggle</i>? What is this??"
926 msgstr ""
927
928 #. type: Content of: <p>
929 #: src/lessons/welcome/environment/Environment.html:12
930 msgid ""
931 "Buggles are little animals obeying any order you may give them. Currently, "
932 "you must use the [!thelang/] programming language for that, but you can "
933 "change the language from the menu, or by clicking the icon in the status "
934 "bar."
935 msgstr ""
936
937 #. type: Content of: <h3>
938 #: src/lessons/welcome/environment/Environment.html:17
939 msgid "How to proceed?"
940 msgstr ""
941
942 #. type: Content of: <p>
943 #: src/lessons/welcome/environment/Environment.html:19
944 msgid "Write your program in the \"Code\" pane. It should read as follows:"
945 msgstr ""
946
947 #. type: Content of: <pre>
948 #: src/lessons/welcome/environment/Environment.html:20
949 #: src/lessons/welcome/instructions/Instructions.html:53
950 #, no-wrap
951 msgid "[!java|scala|python]forward()[!java];[/!][/!][!c]stepForward();[/!]"
952 msgstr ""
953
954 #. type: Content of: outside any tag (error?)
955 #: src/lessons/welcome/environment/Environment.html:21
956 #: src/lessons/welcome/loopfor/LoopFor.html:57
957 #: src/lessons/welcome/bdr/BDR.html:189
958 msgid "[!java|c]"
959 msgstr ""
960
961 #. type: Content of: <p>
962 #: src/lessons/welcome/environment/Environment.html:21
963 msgid ""
964 "Do not forget the final <code>;</code> which tells the compiler that the "
965 "instruction is over (yes, computers are so dumb that they cannot "
966 "<i>guess</i> obvious stuff like this)."
967 msgstr ""
968
969 #. type: Content of: outside any tag (error?)
970 #: src/lessons/welcome/environment/Environment.html:23
971 #: src/lessons/welcome/variables/Variables.html:78
972 #: src/lessons/welcome/variables/Variables.html:152
973 #: src/lessons/welcome/loopfor/LoopFor.html:80
974 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:54
975 #: src/lessons/welcome/loopdowhile/Poucet2.html:25
976 #: src/lessons/welcome/array/basics/Array1.html:183
977 #: src/lessons/welcome/array/basics/Array1.html:209
978 #: src/lessons/welcome/methods/args/MethodsArgs.html:66
979 #: src/lessons/welcome/methods/picture/MethodsPicture.html:40
980 #: src/lessons/welcome/bdr/BDR.html:61 src/lessons/welcome/bdr/BDR.html:196
981 #: src/lessons/welcome/bdr/BDR2.html:130
982 #: src/lessons/turmites/langton/Langton.html:32
983 #: src/lessons/turmites/helloturmite/HelloTurmite.html:65
984 #: src/lessons/sort/basic/comb/AlgCombSort.html:39
985 #: src/lessons/recursion/cons/universe/ConsWorld.html:35
986 #: src/lessons/recursion/cons/Length.html:8
987 #: src/lessons/recursion/lego/square/FourSquare.html:46
988 #: src/lessons/maze/pledge/PledgeMaze.html:68
989 #: src/lessons/welcome/bat/bool1/Max1020.html:6
990 msgid "[/!]"
991 msgstr ""
992
993 #. type: Content of: <p>
994 #: src/lessons/welcome/environment/Environment.html:25
995 msgid "Once done, click on Run to execute your code."
996 msgstr ""
997
998 #. type: Content of: <p>
999 #: src/lessons/welcome/environment/Environment.html:27
1000 msgid ""
1001 "If your code contains errors, that's perfectly OK: Even talented programmers "
1002 "struggle on their code. The computer will display error messages in the "
1003 "console to help you fixing them. These messages may sound scary at first "
1004 "glance, but don't panic. The compiler is only somehow limited in its "
1005 "communication abilities, but it's not mean. If you look closer, the solution "
1006 "to solve your issue is written somewhere in those cryptic messages. You will "
1007 "see, with a bit of habit, we get used to it."
1008 msgstr ""
1009
1010 #. type: Content of: <h3>
1011 #: src/lessons/welcome/environment/Environment.html:36
1012 msgid "But that's [!thelang]!"
1013 msgstr ""
1014
1015 #. type: Content of: outside any tag (error?)
1016 #: src/lessons/welcome/environment/Environment.html:37
1017 msgid ""
1018 "Currently, the PLM is configured to accept [!thelang] programs, but it can "
1019 "also accept [!java]Python or Scala[/!][!scala]Java or "
1020 "Python[/!][!python]Java or Scala[/!] programs. Either click on the language "
1021 "icon at the very bottom right of the window, or head to the "
1022 "<tt>Language/Computer</tt> menu item to change it."
1023 msgstr ""
1024
1025 #. type: Content of: outside any tag (error?)
1026 #: src/lessons/welcome/instructions/Instructions.html:4
1027 msgid ""
1028 "Congratulations! You just wrote your first program! You got the idea now: "
1029 "programming is nothing more than giving simple instructions to the computer "
1030 "that blindly apply them. The main difficulty is to explain stuff to "
1031 "something as stupid as a computer..."
1032 msgstr ""
1033
1034 #. type: Content of: <p>
1035 #: src/lessons/welcome/instructions/Instructions.html:9
1036 msgid ""
1037 "Our second program will be a bit more complicated, but not much. The goal "
1038 "for your buggle is simply to draw a house (a box), and hide inside. Check "
1039 "the objective world to see exactly what this means."
1040 msgstr ""
1041
1042 #. type: Content of: <p>
1043 #: src/lessons/welcome/instructions/Instructions.html:14
1044 msgid ""
1045 "For that, you will need <code>forward()</code>, <code>left()</code> and "
1046 "<code>right()</code>. Use your brush to mark the ground as you walk. Start "
1047 "marking the ground with <code>brushDown()</code>, and stop it with "
1048 "<code>brushUp()</code> afterward (e.g., to enter your house without marking "
1049 "its ground)."
1050 msgstr ""
1051
1052 #. type: Content of: <h3>
1053 #: src/lessons/welcome/instructions/Instructions.html:20
1054 msgid "What exactly is a program?"
1055 msgstr ""
1056
1057 #. type: Content of: <p>
1058 #: src/lessons/welcome/instructions/Instructions.html:22
1059 msgid ""
1060 "Programs are mainly suites of method calls, which are no more than a list of "
1061 "simple orders given to the machine. It is very similar to a recipe stating "
1062 "<i>Melt the chocolate pieces, add sugar, cool the mix and serve</i>. "
1063 "[!thelang] wants to have the instructions separated by semi-columns "
1064 "(;)[!python|scala] or by new lines[/!], and followed by parenthesis. Our "
1065 "little receipe would thus be written in the following way[!python|scala] "
1066 "(you can also add semi-columns at the end of the lines, but this is not "
1067 "mandatory)[/!]."
1068 msgstr ""
1069
1070 #. type: Content of: <pre>
1071 #: src/lessons/welcome/instructions/Instructions.html:33
1072 #, no-wrap
1073 msgid ""
1074 "meltTheChocolatePieces()[!java|c];[/!]\n"
1075 "addSugar()[!java|c];[/!]\n"
1076 "coolMix()[!java|c];[/!]\n"
1077 "serve()[!java|c];[/!]\n"
1078 msgstr ""
1079
1080 #. type: Content of: <p>
1081 #: src/lessons/welcome/instructions/Instructions.html:39
1082 msgid ""
1083 "Do not write it all on one line only even if the computer would accept it "
1084 "[!python|scala](provided that you don't omit the semi-columns)[/!]. This is "
1085 "a <b>really bad idea</b>, hindering the readability. <i>Programs must be "
1086 "written for people to read, and only incidentally for machines to "
1087 "execute,</i> as said Harold Abelson."
1088 msgstr ""
1089
1090 #. type: Content of: <p>
1091 #: src/lessons/welcome/instructions/Instructions.html:46
1092 msgid ""
1093 "There is a limited set of instructions that buggles understand, and we will "
1094 "eventually learn how to define new ones. For now, there is a method for each "
1095 "button of the interactive control panel. To achieve the same effect than the "
1096 "<b>forward</b> button (making the buggle moving one step forward), you need "
1097 "to write the following in the editor:"
1098 msgstr ""
1099
1100 #. type: Content of: <p>
1101 #: src/lessons/welcome/instructions/Instructions.html:54
1102 msgid ""
1103 "Likewise, to achieve the same effect than the "
1104 "<b>[!java|scala|python]backward[/!][!c]stepBackward[/!]</b>, <b>left</b> and "
1105 "<b>right</b> buttons, you need to use respectively:"
1106 msgstr ""
1107
1108 #. type: Content of: <pre>
1109 #: src/lessons/welcome/instructions/Instructions.html:58
1110 #, no-wrap
1111 msgid ""
1112 "backward()[!java|c];[/!]\n"
1113 "left()[!java|c];[/!]\n"
1114 "right()[!java|c];[/!]\n"
1115 msgstr ""
1116
1117 #. type: Content of: <p>
1118 #: src/lessons/welcome/instructions/Instructions.html:63
1119 msgid ""
1120 "The <b>mark</b> button is a bit particular, since it correspond to two "
1121 "methods: the first one moves the pen up while the second moves it down."
1122 msgstr ""
1123
1124 #. type: Content of: <pre>
1125 #: src/lessons/welcome/instructions/Instructions.html:67
1126 #, no-wrap
1127 msgid ""
1128 "brushUp()[!java|c];[/!]\n"
1129 "brushDown()[!java|c];[/!]\n"
1130 msgstr ""
1131
1132 #. type: Content of: <p>
1133 #: src/lessons/welcome/instructions/Instructions.html:71
1134 msgid ""
1135 "The buggle offers other methods, that are presented from the \"Help/about "
1136 "this world\" menu and will be introduced on need."
1137 msgstr ""
1138
1139 #. type: Content of: outside any tag (error?)
1140 #: src/lessons/welcome/instructions/InstructionsDrawG.html:3
1141 msgid ""
1142 "Now that we know how to draw things on the board, we'll enjoy this ability "
1143 "and draw a beautiful G on the board (check Objective panel for details on "
1144 "what is expected)."
1145 msgstr ""
1146
1147 #. type: Content of: <p>
1148 #: src/lessons/welcome/instructions/InstructionsDrawG.html:7
1149 msgid ""
1150 "When you write a quite complex program, it is sometimes useful to <b>add "
1151 "comments</b> to simplify the code reviews afterward. Here for example, it's "
1152 "quite easy to get lost in the drawing process, and you may want to add "
1153 "comments like <i>vertical bar done</i> or <i>finished drawing the G. Time to "
1154 "move back to initial position</i>. Commenting your code is almost mandatory "
1155 "if you (or someone else) want to read it afterward, although over-commenting "
1156 "(describing obvious stuff) is a bad idea as the important idea get lost in "
1157 "the noise."
1158 msgstr ""
1159
1160 #. type: Content of: <p>
1161 #: src/lessons/welcome/instructions/InstructionsDrawG.html:15
1162 msgid ""
1163 "There is [!java]three[/!][!python|scala|c]two[/!] types of comments in "
1164 "[!thelang], instructing the "
1165 "[!java|scala|c]compiler[/!][!python]interpreter[/!] to not read the text you "
1166 "add for humans:"
1167 msgstr ""
1168
1169 #. type: Content of: <ul><li>
1170 #: src/lessons/welcome/instructions/InstructionsDrawG.html:19
1171 msgid ""
1172 "<b>Comments on a single line</b>. When the "
1173 "[!java|scala|c]compiler[/!][!python]interpreter[/!] encounters the symbol "
1174 "[!java|scala|c]//[/!][!python]#[/!], it ignores the end of the line."
1175 msgstr ""
1176
1177 #. type: Content of: <ul><li>
1178 #: src/lessons/welcome/instructions/InstructionsDrawG.html:21
1179 msgid ""
1180 "<b>Comments on several lines</b>. The "
1181 "[!java|scala|c]compiler[/!][!python]interpreter[/!] ignores anything placed "
1182 "between [!java|scala|c]the symbols /* and */ even if they are placed on "
1183 "differing lines.[/!] [!python]a line beginning with ''' until the next line "
1184 "ending with '''.[/!]"
1185 msgstr ""
1186
1187 #. type: Content of: <pre>
1188 #: src/lessons/welcome/instructions/InstructionsDrawG.html:28
1189 #, no-wrap
1190 msgid ""
1191 "methodCallReadByThe[!java|scala|c]Compiler[/!][!python]Interpreter[/!]()[!java|c];[/!] "
1192 "<span class=\"comment\">[!java|scala|c]//[/!][!python]#[/!] all this is "
1193 "ignored</span>\n"
1194 "otherCall()[!java|c];[/!] [!java|scala|c]<span class=\"comment\">/* This "
1195 "is</span>\n"
1196 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
1197 "<span class=\"comment\"> also ignored */</span>[/!]\n"
1198 "[!python]<span class=\"comment\">''' This is</span>\n"
1199 "<span class=\"comment\">also ignored '''</span>[/!]\n"
1200 "yetAnotherCall()[!java|c];[/!]\n"
1201 msgstr ""
1202
1203 #. type: Content of: <p>
1204 #: src/lessons/welcome/instructions/InstructionsDrawG.html:35
1205 msgid ""
1206 "There is a third kind of comments in Java, between /** and */, which are "
1207 "read by a specific program called JavaDoc to generate automatically the "
1208 "documentation explaining how to use the code. These comments must follow a "
1209 "very precise formalism."
1210 msgstr ""
1211
1212 #. type: Content of: <p>
1213 #: src/lessons/welcome/instructions/InstructionsDrawG.html:40
1214 msgid ""
1215 "The comments on several lines are often used to document how to use the "
1216 "code, while others are more used to describe how this code works."
1217 msgstr ""
1218
1219 #. type: Content of: outside any tag (error?)
1220 #: src/lessons/welcome/conditions/Conditions.html:4
1221 msgid ""
1222 "Programs made of simple suite of instructions similar to previous exercise "
1223 "are quite boring. They always do the same thing, and cannot react to "
1224 "external conditions. A <b>conditional</b> let the program adapt by doing "
1225 "something like <i>if it's raining, take an umbrella</i>."
1226 msgstr ""
1227
1228 #. type: Content of: <p>
1229 #: src/lessons/welcome/conditions/Conditions.html:9
1230 msgid "The [!thelang] syntax is the following:"
1231 msgstr ""
1232
1233 #. type: Content of: <pre>
1234 #: src/lessons/welcome/conditions/Conditions.html:11
1235 #, no-wrap
1236 msgid ""
1237 "[!java|scala|c]if (<b>condition</b>) {\n"
1238 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue();</b>\n"
1239 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue();</b>\n"
1240 "}[/!][!python]if <b>condition</b>:\n"
1241 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue()</b>\n"
1242 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue()</b>[/!]\n"
1243 "<b>whatToDoAnyway()[!java|c];[/!]</b>"
1244 msgstr ""
1245
1246 #. type: Content of: <p>
1247 #: src/lessons/welcome/conditions/Conditions.html:19
1248 msgid ""
1249 "If the condition is true, the code of the next block will be executed and "
1250 "then it will continue with the rest of the code. If the condition is false, "
1251 "the next block is ignored and the execution continues after it. The "
1252 "conditional block can contain several instructions, it can even contain "
1253 "other tests, along with their sub-blocks."
1254 msgstr ""
1255
1256 #. type: Content of: <p>
1257 #: src/lessons/welcome/conditions/Conditions.html:23
1258 msgid ""
1259 "In this example, the instructions <code>whatToDoIfTrue()</code> and "
1260 "<code>whatToDoNextIfTrue()</code> will be executed if and only if the "
1261 "condition is true, while the instruction <code>whatToDoAnyway()</code> will "
1262 "be executed whether or not the condition is true."
1263 msgstr ""
1264
1265 #. type: Content of: <p>
1266 #: src/lessons/welcome/conditions/Conditions.html:28
1267 msgid ""
1268 "In [!thelang], the blocks of code are [!java|scala|c]enclosed between curly "
1269 "brackets: a { sign opens the block, while a } sign closes it. White spaces "
1270 "are not important[/!][!java|c].[/!][!scala], provided that your instructions "
1271 "are still separated with a semi-column or an end of line.[/!] "
1272 "[!java|scala|c]It is still very important to correctly indent your code to "
1273 "keep it readable.[/!] [!python]marked by the indentation: every lines that "
1274 "are a bit shifted to the right with white spaces belong to the block. Quite "
1275 "often, people use 4 spaces for indentation, but it works if you use more or "
1276 "less spaces. Simply, any lines of the block must use the same amount of "
1277 "spaces. The end of Python code blocks are not marked by any specific char. "
1278 "Indenting lines starts a block and unindenting ends it. Do not forget the "
1279 "colon (:) at the end of the <code>if</code> line, python needs it to know "
1280 "that a new block begins. The fact that python relies on indentation to "
1281 "delimit blocks is a very good property for beginners: it will force you to "
1282 "adhere to strict code presentation standards.[/!] It is very easy to get "
1283 "lost in your own code if it's not properly indented, so you want to clean it "
1284 "up so that working on your code remains pleasant and productive."
1285 msgstr ""
1286
1287 #. type: Content of: <p>
1288 #: src/lessons/welcome/conditions/Conditions.html:44
1289 msgid ""
1290 "All indentations of a given block must be consistent, and it is not possible "
1291 "to cut a block. The two following codes are incorrect and will raise errors."
1292 msgstr ""
1293
1294 #. type: Content of: <pre>
1295 #: src/lessons/welcome/conditions/Conditions.html:47
1296 #, no-wrap
1297 msgid ""
1298 "if <b>condition</b>:\n"
1299 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>\n"
1300 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span "
1301 "class=\"comment\"># one space too much </span>\n"
1302 "<b>whatToDoAnyway()</b>\n"
1303 msgstr ""
1304
1305 #. type: Content of: <pre>
1306 #: src/lessons/welcome/conditions/Conditions.html:52
1307 #, no-wrap
1308 msgid ""
1309 "if <b>condition</b>:\n"
1310 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>\n"
1311 "<b>whatToDoAnyway()</b>\n"
1312 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span class=\"comment\"># this "
1313 "block is not hanging to a condition line</span>\n"
1314 msgstr ""
1315
1316 #. type: Content of: <p>
1317 #: src/lessons/welcome/conditions/Conditions.html:58
1318 msgid ""
1319 "The condition must be a "
1320 "<code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code> "
1321 "expression. The inner block of code will get executed if the expression is "
1322 "evaluated to <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> "
1323 "and it will be ignored if it is "
1324 "<code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code>. "
1325 "[!python|scala|java]<code>[!java|scala]true[/!][!python]True[/!]</code> and "
1326 "<code>[!java|scala]false[/!][!python]False[/!]</code> are constant values "
1327 "defined by [!thelang] directly, just as 0 or 1 in mathematics.[/!]"
1328 msgstr ""
1329
1330 #. type: Content of: <p>
1331 #: src/lessons/welcome/conditions/Conditions.html:64
1332 msgid ""
1333 "The condition can be a "
1334 "<code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code> "
1335 "variable (we will come back on variables in a later exercise, don't worry) "
1336 "or an arithmetic test, such as <code>x == 5</code>, which checks whether the "
1337 "current value of <code>x</code> is 5, or such as <b>!=</b> (checking "
1338 "inequality, that is, returning "
1339 "[!c]1[/!][!java|scala]true[/!][!python]True[/!] only if the left-hand side "
1340 "is different from the right-hand side), <b>&lt;</b> (smaller than), "
1341 "<b>&gt;</b> (larger than), <b>&lt;=</b> (smaller or equal to), <b>&gt;=</b> "
1342 "(larger or equal to)."
1343 msgstr ""
1344
1345 #. type: Content of: <p>
1346 #: src/lessons/welcome/conditions/Conditions.html:71
1347 msgid ""
1348 "Beware of the classical trap, which consists in testing the equality of a "
1349 "variable using = instead of ==. Hopefully, the "
1350 "[!java|scala|c]compiler[/!][!python]interpreter[/!] detects this problem "
1351 "most of the time, but it could get trapped is some cases (such as when you "
1352 "are affecting a [!c]int[/!][!java|python|scala]boolean[/!] variable). So "
1353 "you'd better to be careful..."
1354 msgstr ""
1355
1356 #. type: Content of: <p>
1357 #: src/lessons/welcome/conditions/Conditions.html:76
1358 msgid ""
1359 "The condition can also be a call to some particular methods returning a "
1360 "boolean. For example, the <code>isFacingWall()</code> method of the buggle "
1361 "returns [!c]1[/!][!java|python|scala]true[/!] if the buggle is facing a "
1362 "wall, and [!c]0[/!][!java|python|scala]false[/!] in the other case."
1363 msgstr ""
1364
1365 #. type: Content of: <p>
1366 #: src/lessons/welcome/conditions/Conditions.html:80
1367 msgid ""
1368 "Finally, a condition can be composed of several sub-conditions connected by "
1369 "boolean operations:"
1370 msgstr ""
1371
1372 #. type: Content of: <ul><li>
1373 #: src/lessons/welcome/conditions/Conditions.html:83
1374 msgid ""
1375 "<code>cond1 [!java|scala|c]&&[/!][!python]and[/!] cond2</code> is true when "
1376 "<tt>cond1</tt> <b>and</b> <tt>cond2</tt> are both true (if <tt>cond1</tt> is "
1377 "false, <tt>cond2</tt> is not even evaluated as we already know that the "
1378 "conjunction of both propositions cannot be true)."
1379 msgstr ""
1380
1381 #. type: Content of: <ul><li>
1382 #: src/lessons/welcome/conditions/Conditions.html:86
1383 msgid ""
1384 "<code>cond1 [!java|scala|c]||[/!][!python]or[/!] cond2</code> is true if "
1385 "<tt>cond1</tt> <b>or</b> <tt>cond2</tt> is true (if <tt>cond1</tt> is true, "
1386 "<tt>cond2</tt> is not even evaluated as we already know that the disjunction "
1387 "of both propositions cannot be false)."
1388 msgstr ""
1389
1390 #. type: Content of: <ul><li>
1391 #: src/lessons/welcome/conditions/Conditions.html:89
1392 msgid ""
1393 "<code>[!java|scala|c]![/!][!python]not [/!]cond</code> is true if "
1394 "<tt>cond</tt> is false."
1395 msgstr ""
1396
1397 #. type: Content of: <ul><li>
1398 #: src/lessons/welcome/conditions/Conditions.html:90
1399 msgid ""
1400 "When the expression becomes complicated, it is better to add parenthesis to "
1401 "force the order of evaluation. Do not hesitate to add more parenthesis to "
1402 "remove any ambiguities that may appear in an expression."
1403 msgstr ""
1404
1405 #. type: Content of: <p>
1406 #: src/lessons/welcome/conditions/Conditions.html:94
1407 msgid ""
1408 "Last, it is possible to specify what to do when the condition is false using "
1409 "the following syntax. In this case, the instruction "
1410 "<code>whatToDoIfItsFalse</code> will be executed only if the condition is "
1411 "false."
1412 msgstr ""
1413
1414 #. type: Content of: <pre>
1415 #: src/lessons/welcome/conditions/Conditions.html:97
1416 #, no-wrap
1417 msgid ""
1418 "[!java|scala|c]if (<b>condition</b>) {\n"
1419 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue();</b>\n"
1420 "} else {\n"
1421 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse();</b>\n"
1422 "}[/!][!python]if (<b>condition</b>):\n"
1423 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue()</b>\n"
1424 "else:\n"
1425 "&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse()</b>[/!]"
1426 msgstr ""
1427
1428 #. type: Content of: <p>
1429 #: src/lessons/welcome/conditions/Conditions.html:106
1430 msgid ""
1431 "Don't forget the colon (:) after the else, it is indicating that a new block "
1432 "is beginning."
1433 msgstr ""
1434
1435 #. type: Content of: <h3>
1436 #: src/lessons/welcome/conditions/Conditions.html:109
1437 #: src/lessons/welcome/loopwhile/LoopWhile.html:35
1438 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:9
1439 #: src/lessons/welcome/variables/Variables.html:119
1440 #: src/lessons/welcome/loopfor/LoopFor.html:82
1441 #: src/lessons/welcome/methods/basics/Methods.html:96
1442 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:38
1443 #: src/lessons/welcome/methods/returning/MethodsReturning.html:50
1444 #: src/lessons/welcome/methods/args/MethodsArgs.html:70
1445 #: src/lessons/welcome/methods/slug/SlugHunting.html:19
1446 #: src/lessons/welcome/methods/slug/SlugTracking.html:24
1447 #: src/lessons/welcome/bdr/BDR.html:151 src/lessons/welcome/bdr/BDR2.html:132
1448 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:18
1449 #: src/lessons/maze/pledge/PledgeMaze.html:37
1450 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:23
1451 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:22
1452 msgid "Exercise goal"
1453 msgstr ""
1454
1455 #. type: Content of: outside any tag (error?)
1456 #: src/lessons/welcome/conditions/Conditions.html:109
1457 msgid ""
1458 "<a name=\"Objectives\"/> If the buggle is facing a wall, you must move one "
1459 "step back. If not, you must move one step forward. To detect whether you are "
1460 "facing a wall, simply use the <code>isFacingWall()</code> built-in, that "
1461 "every buggle understands."
1462 msgstr ""
1463
1464 #. type: Content of: <p>
1465 #: src/lessons/welcome/conditions/Conditions.html:116
1466 msgid ""
1467 "This exercise is a bit different: your code has to work for several buggles, "
1468 "each of them being in a specific initial condition. The same code will be "
1469 "executed for each of them."
1470 msgstr ""
1471
1472 #. type: Content of: <p>
1473 #: src/lessons/welcome/conditions/Conditions.html:120
1474 msgid ""
1475 "When your program works, move forward to the next exercise, that is hidden "
1476 "in a sub-tree of the selection window."
1477 msgstr ""
1478
1479 #. type: Content of: <p>
1480 #: src/lessons/welcome/loopwhile/LoopWhile.html:4
1481 msgid ""
1482 "In addition to conditionals, another handy construction is the ability to "
1483 "repeat an action while a specific condition does not appear. A while loop is "
1484 "used for that, with the following syntax."
1485 msgstr ""
1486
1487 #. type: Content of: <pre>
1488 #: src/lessons/welcome/loopwhile/LoopWhile.html:8
1489 #, no-wrap
1490 msgid ""
1491 "[!java|scala|c]while (<b>condition</b>) {\n"
1492 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>;\n"
1493 "}[/!][!python]while <b>condition</b>:\n"
1494 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>[/!]"
1495 msgstr ""
1496
1497 #. type: Content of: <p>
1498 #: src/lessons/welcome/loopwhile/LoopWhile.html:13
1499 msgid ""
1500 "The inner bloc is then executed again and again, as long as the condition "
1501 "remains true. More specifically, the buggle tests the value of the "
1502 "condition. If it's false, it ignores the bloc and continue below. If it's "
1503 "true, it executes the bloc. After that, it tests the condition. If it's now "
1504 "false (for example because the moves of the block made us facing the wall), "
1505 "it now ignores the bloc and continue. If it's still true, it execute the "
1506 "bloc and reevaluate the condition. It does so as long as the condition "
1507 "remains true."
1508 msgstr ""
1509
1510 #. type: Content of: <p>
1511 #: src/lessons/welcome/loopwhile/LoopWhile.html:20
1512 msgid ""
1513 "Naturally, if the chosen action does not modify the value of the condition, "
1514 "the buggle will do the action endlessly. The <b>stop</b> button of the "
1515 "interface becomes then handy. To test this, you can try to type the "
1516 "following code in the editor:"
1517 msgstr ""
1518
1519 #. type: Content of: <pre>
1520 #: src/lessons/welcome/loopwhile/LoopWhile.html:25
1521 #, no-wrap
1522 msgid ""
1523 "[!java|scala]while (true) {\n"
1524 "&nbsp;&nbsp;&nbsp;&nbsp;left();\n"
1525 "}[/!][!c]while (1) {\n"
1526 "&nbsp;&nbsp;&nbsp;&nbsp;left();\n"
1527 "}[/!][!python]while True:\n"
1528 "&nbsp;&nbsp;&nbsp;&nbsp;left()[/!]"
1529 msgstr ""
1530
1531 #. type: Content of: <p>
1532 #: src/lessons/welcome/loopwhile/LoopWhile.html:32
1533 msgid ""
1534 "This will let the buggle turn left as long as "
1535 "<code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> remains true "
1536 "(ie, endlessly), or until you stop it manually using the stop button."
1537 msgstr ""
1538
1539 #. type: Content of: outside any tag (error?)
1540 #: src/lessons/welcome/loopwhile/LoopWhile.html:36
1541 msgid ""
1542 "You now have to write some code so that your buggles move forward until they "
1543 "encounter a wall. The idea is thus to do something like:"
1544 msgstr ""
1545
1546 #. type: Content of: <pre>
1547 #: src/lessons/welcome/loopwhile/LoopWhile.html:39
1548 #, no-wrap
1549 msgid ""
1550 "while we are not facing a wall, do:\n"
1551 "&nbsp;&nbsp;moveForward()"
1552 msgstr ""
1553
1554 #. type: Content of: <p>
1555 #: src/lessons/welcome/loopwhile/LoopWhile.html:42
1556 msgid ""
1557 "Look at the documentation (in \"Help/About this world\") for the full list "
1558 "of buggles' methods."
1559 msgstr ""
1560
1561 #. type: Content of: <p>
1562 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:3
1563 msgid ""
1564 "The buggle world can sometimes contain some <i>baggles</i>, which are little "
1565 "biscuits that buggles can carry from one point to another. For that, they "
1566 "have to use specific methods such as <code>isOverBaggle(), "
1567 "isCarryingBaggle(), pickupBaggle()</code> or "
1568 "<code>dropBaggle()</code>. Check their documentation in \"Help/About this "
1569 "world\" for more details."
1570 msgstr ""
1571
1572 #. type: Content of: <p>
1573 #: src/lessons/welcome/loopwhile/BaggleSeeker.html:11
1574 msgid ""
1575 "Let each buggle find its baggle by adapting the code you wrote in previous "
1576 "exercise (copy/paste what you've done before if you want)."
1577 msgstr ""
1578
1579 #. type: Content of: <p>
1580 #: src/lessons/welcome/variables/Variables.html:3
1581 msgid ""
1582 "The programs we wrote so far are missing a fundamental point in computing. "
1583 "Actually, it is all about processing <b>data</b> through specific "
1584 "<b>instructions</b>. In the buggle world, the main data are a bit hidden "
1585 "behind the graphical representation, but that's no reason to never "
1586 "manipulate some data explicitly."
1587 msgstr ""
1588
1589 #. type: Content of: <h3>
1590 #: src/lessons/welcome/variables/Variables.html:9
1591 msgid "Data in [!thelang]"
1592 msgstr ""
1593
1594 #. type: Content of: <p>
1595 #: src/lessons/welcome/variables/Variables.html:10
1596 msgid ""
1597 "In a program, you can use several <i>types</i> of data, such as integers or "
1598 "strings of chars. If you want to use a data several times, you need to store "
1599 "it within a <i>variable</i>, which is a memory cell containing a value: you "
1600 "put your data (say the value '5') in the variable (say 'length'), and you "
1601 "can retrieve it later when you need it. That's very similar to a box of "
1602 "label 'gift' in which you would put some stuff, like a bottle of perfume "
1603 "\"Channel N°5\"."
1604 msgstr ""
1605
1606 #. type: Content of: <h3>
1607 #: src/lessons/welcome/variables/Variables.html:17
1608 msgid "Variable declarations"
1609 msgstr ""
1610
1611 #. type: Content of: <p>
1612 #: src/lessons/welcome/variables/Variables.html:19
1613 msgid ""
1614 "<b>Declaring</b> (ie, creating) a variable in [!thelang], is very "
1615 "simple. You just need to write [!java]its type, a space, and the variable "
1616 "name.[/!] [!scala]the <code>var</code> keyword, the variable name, a column "
1617 "(:) and the variable type an equal sign (=) and an initial value.[/!] "
1618 "[!python]the variable name, an equal sign (=) and an initial value.[/!] The "
1619 "variable name is the label to retrieve it afterward[!python].[/!] "
1620 "[!java|scala] while the type is the kind of data that this variable accepts "
1621 "to store.[/!] It is forbidden to use spaces in variable names. You can name "
1622 "a variable <code>stepAmount</code> if you want, but <code>step amount</code> "
1623 "is not a valid name."
1624 msgstr ""
1625
1626 #. type: Content of: outside any tag (error?)
1627 #: src/lessons/welcome/variables/Variables.html:29
1628 msgid "[!c|java]"
1629 msgstr ""
1630
1631 #. type: Content of: <p>
1632 #: src/lessons/welcome/variables/Variables.html:30
1633 msgid ""
1634 "So, to create a variable named <b>x</b> intended to contain integers, one "
1635 "should write:"
1636 msgstr ""
1637
1638 #. type: Content of: <pre>
1639 #: src/lessons/welcome/variables/Variables.html:31
1640 #, no-wrap
1641 msgid "int x;"
1642 msgstr ""
1643
1644 #. type: Content of: <p>
1645 #: src/lessons/welcome/variables/Variables.html:32
1646 msgid ""
1647 "If you want, you can specify the initial value of the variable by adding an "
1648 "equal sign (=) followed by the value after the declaration."
1649 msgstr ""
1650
1651 #. type: Content of: <pre>
1652 #: src/lessons/welcome/variables/Variables.html:34
1653 #, no-wrap
1654 msgid "int x=5;"
1655 msgstr ""
1656
1657 #. type: Content of: outside any tag (error?)
1658 #: src/lessons/welcome/variables/Variables.html:35
1659 #: src/lessons/welcome/variables/Variables.html:69
1660 msgid "[/!] [!python]"
1661 msgstr ""
1662
1663 #. type: Content of: <p>
1664 #: src/lessons/welcome/variables/Variables.html:38
1665 msgid ""
1666 "So, if you want that the variable contains 5 as initial value, you should "
1667 "type:"
1668 msgstr ""
1669
1670 #. type: Content of: <pre>
1671 #: src/lessons/welcome/variables/Variables.html:39
1672 #, no-wrap
1673 msgid "x = 5"
1674 msgstr ""
1675
1676 #. type: Content of: <ul><li>
1677 #: src/lessons/welcome/variables/Variables.html:40
1678 #: src/lessons/welcome/loopfor/LoopFor.html:68
1679 #: src/lessons/welcome/bdr/BDR2.html:83
1680 #: src/lessons/recursion/cons/universe/ConsWorld.html:34
1681 msgid "[/!] [!scala]"
1682 msgstr ""
1683
1684 #. type: Content of: <p>
1685 #: src/lessons/welcome/variables/Variables.html:43
1686 msgid ""
1687 "So, to create a variable named <b>x</b> intended to contain integers with 42 "
1688 "as initial value, one should write:"
1689 msgstr ""
1690
1691 #. type: Content of: <pre>
1692 #: src/lessons/welcome/variables/Variables.html:44
1693 #, no-wrap
1694 msgid "var x:Int = 42"
1695 msgstr ""
1696
1697 #. type: Content of: <p>
1698 #: src/lessons/welcome/variables/Variables.html:45
1699 msgid ""
1700 "In most cases, the compiler is able to guess the type of the variable from "
1701 "the initialization value, and you can omit it:"
1702 msgstr ""
1703
1704 #. type: Content of: <pre>
1705 #: src/lessons/welcome/variables/Variables.html:46
1706 #, no-wrap
1707 msgid "var x = 42"
1708 msgstr ""
1709
1710 #. type: Content of: <p>
1711 #: src/lessons/welcome/variables/Variables.html:47
1712 msgid ""
1713 "You still have to specify if you use some generic values as an "
1714 "initialization, such as the very particular value <code>null</code>, which "
1715 "type happens to be ambiguous. Even when the type is clear, you can still "
1716 "specify it if you prefer. So you want that the variable contains 5 as "
1717 "initial value, you should type:"
1718 msgstr ""
1719
1720 #. type: Content of: <pre>
1721 #: src/lessons/welcome/variables/Variables.html:50
1722 #, no-wrap
1723 msgid ""
1724 "var x: Int = 5 <span class=\"comment\">// I can define the type if I want "
1725 "to</span>\n"
1726 "var y = 10 <span class=\"comment\">// or I can omit the type if I "
1727 "prefer</span>"
1728 msgstr ""
1729
1730 #. type: Content of: outside any tag (error?)
1731 #: src/lessons/welcome/variables/Variables.html:52
1732 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:39
1733 msgid "[/!] [!java|scala|c]"
1734 msgstr ""
1735
1736 #. type: Content of: <p>
1737 #: src/lessons/welcome/variables/Variables.html:55
1738 msgid ""
1739 "As you can see, the variables are <b>typed</b> in [!thelang], which means "
1740 "that they are somehow specialized: A given variable can only store data of a "
1741 "given type; Don't even think of storing numbers in a variable that is "
1742 "tailored for letters! The [!thelang] language is said to be <b>statically "
1743 "typed</b>."
1744 msgstr ""
1745
1746 #. type: Content of: <p>
1747 #: src/lessons/welcome/variables/Variables.html:58
1748 msgid ""
1749 "Other languages (such as Python) are less picky and allow you to store any "
1750 "kind of data in any variable, without restriction (those languages are said "
1751 "to be <b>dynamically typed</b>). This seems easier at the first glance, but "
1752 "this kind of restriction allows the compiler to catch more logic errors for "
1753 "you, which is also good. In some sense, Python is easier to write but errors "
1754 "can sneak in more easily than in [!thelang]."
1755 msgstr ""
1756
1757 #. type: Content of: <p>
1758 #: src/lessons/welcome/variables/Variables.html:62
1759 msgid "Here are some existing types in [!thelang]:"
1760 msgstr ""
1761
1762 #. type: Content of: <ul><li>
1763 #: src/lessons/welcome/variables/Variables.html:64
1764 msgid "<b>[!java|c]int[/!][!scala]Int[/!]</b>, for integers;"
1765 msgstr ""
1766
1767 #. type: Content of: <ul><li>
1768 #: src/lessons/welcome/variables/Variables.html:65
1769 msgid "<b>[!java|c]double[/!][!scala]Double[/!]</b>, for dot numbers;"
1770 msgstr ""
1771
1772 #. type: Content of: <ul><li>
1773 #: src/lessons/welcome/variables/Variables.html:66
1774 msgid ""
1775 "<b>[!c]int[/!][!java]boolean[/!][!scala]Boolean[/!]</b>, for booleans that "
1776 "are values being either [!c]1[/!][!java|scala]true[/!] or "
1777 "[!c]0[/!][!java|scala]false[/!];"
1778 msgstr ""
1779
1780 #. type: Content of: <ul><li>
1781 #: src/lessons/welcome/variables/Variables.html:67
1782 msgid "<b>[!c]char*[/!][!java|scala]String[/!]</b>, for char strings."
1783 msgstr ""
1784
1785 #. type: Content of: <p>
1786 #: src/lessons/welcome/variables/Variables.html:72
1787 msgid ""
1788 "As you can see, the variables are not <b>typed</b> in Python, which means "
1789 "that they are not specialized in any type of data. A given variable store "
1790 "any type of data of a given type: you can store a number in a variable and "
1791 "later on store a number in the same variable. The values themselves are "
1792 "still typed, but not the variable. Python is said to be <b>dynamically "
1793 "typed</b>."
1794 msgstr ""
1795
1796 #. type: Content of: <p>
1797 #: src/lessons/welcome/variables/Variables.html:75
1798 msgid ""
1799 "Other languages (such as Java, Scala or C) are much more picky and prevent "
1800 "you to mix data types in a given variable (they are said to be <b>statically "
1801 "typed</b>). This seems annoying at the first glance, but this kind of "
1802 "restriction allows the compiler to catch more logic errors for you, which is "
1803 "also good. In some sense, Python is easier to write but errors can sneak in "
1804 "more easily."
1805 msgstr ""
1806
1807 #. type: Content of: <p>
1808 #: src/lessons/welcome/variables/Variables.html:81
1809 msgid ""
1810 "If you know that the value of your \"variable\" will never change (eg "
1811 "because it contains the screen size or some other constant value), then you "
1812 "should make it a <b>value</b> instead of a variable. Simply change the "
1813 "<code>var</code> keyword with the <code>val</code> one. The compiler can "
1814 "then check your actions and catch your error when you inadvertently modify "
1815 "the value. More interestingly, the compiler can produce faster code in some "
1816 "cases."
1817 msgstr ""
1818
1819 #. type: Content of: <p>
1820 #: src/lessons/welcome/variables/Variables.html:86
1821 msgid ""
1822 "Variables work very similarly for strings, floating point numbers and "
1823 "boolean values."
1824 msgstr ""
1825
1826 #. type: Content of: <pre>
1827 #: src/lessons/welcome/variables/Variables.html:88
1828 #, no-wrap
1829 msgid ""
1830 "char* name = \"Martin Quinson\";\n"
1831 "double height=1.77; <span class=\"comment\">// in meters</span>\n"
1832 "int married=1;<span class=\"comment\">// 1 means \"true\"; \"false\" would "
1833 "be written 0</span>"
1834 msgstr ""
1835
1836 #. type: Content of: <pre>
1837 #: src/lessons/welcome/variables/Variables.html:93
1838 #, no-wrap
1839 msgid ""
1840 "String name = \"Martin Quinson\";\n"
1841 "double height=1.77; <span class=\"comment\">// in meters</span>\n"
1842 "boolean married=true;<span class=\"comment\">// the contrary would be "
1843 "written \"false\"</span>"
1844 msgstr ""
1845
1846 #. type: Content of: <pre>
1847 #: src/lessons/welcome/variables/Variables.html:97
1848 #, no-wrap
1849 msgid ""
1850 "val name:String = \"Martin Quinson\"; <span class=\"comment\">// this cannot "
1851 "be modified (it's a value)</span>\n"
1852 "var height: Double = 1.77; <span class=\"comment\">// in meters</span>\n"
1853 "var married = true; <span class=\"comment\">// the contrary would be written "
1854 "\"false\"</span>\n"
1855 "<span class=\"comment\">// Scala knows that 'true' is a Boolean value, no "
1856 "need to repeat it here</span>"
1857 msgstr ""
1858
1859 #. type: Content of: <pre>
1860 #: src/lessons/welcome/variables/Variables.html:102
1861 #, no-wrap
1862 msgid ""
1863 "firstName = \"Martin\"\n"
1864 "lastName = 'Quinson' <span class=\"comment\"># both single and double quote "
1865 "work here</span>\n"
1866 "motto = \"I never finish anyth' (but I keep trying)\" <span "
1867 "class=\"comment\"># having single quote within double quote is fine</span> "
1868 "\n"
1869 "height=1.77 <span class=\"comment\"># in meters</span>\n"
1870 "married=True <span class=\"comment\"># the contrary would be written "
1871 "\"False\"</span>"
1872 msgstr ""
1873
1874 #. type: Content of: <h3>
1875 #: src/lessons/welcome/variables/Variables.html:108
1876 msgid "Affectations"
1877 msgstr ""
1878
1879 #. type: Content of: <p>
1880 #: src/lessons/welcome/variables/Variables.html:110
1881 msgid ""
1882 "Once your variable is declared, you can <b>affect</b> a new value to it "
1883 "later in the program. That's really easy:"
1884 msgstr ""
1885
1886 #. type: Content of: <pre>
1887 #: src/lessons/welcome/variables/Variables.html:111
1888 #, no-wrap
1889 msgid "x = 3[!java|c];[/!]"
1890 msgstr ""
1891
1892 #. type: Content of: <p>
1893 #: src/lessons/welcome/variables/Variables.html:113
1894 msgid ""
1895 "To the right of the equal symbol, you can put an arithmetic expression "
1896 "containing constants, variables and operations."
1897 msgstr ""
1898
1899 #. type: Content of: <pre>
1900 #: src/lessons/welcome/variables/Variables.html:115
1901 #, no-wrap
1902 msgid ""
1903 "x = 3 + 2[!java|c];[/!]\n"
1904 "x = 3 * x[!java|c];[/!]\n"
1905 "[!java|scala|python]greeting = \"Hello \"+name[!java];[/!] <span "
1906 "class=\"comment\">[!python]#[/!][!scala|java]//[/!] + is (also) the "
1907 "operation to concatenate (ie, to join) strings[/!]</span>"
1908 msgstr ""
1909
1910 #. type: Content of: outside any tag (error?)
1911 #: src/lessons/welcome/variables/Variables.html:120
1912 msgid ""
1913 "It is now time to do more challenging exercises, don't you think? The "
1914 "objective is now to move forward until you find a baggle, pick it up, and "
1915 "then move back to your initial location before dropping the baggle."
1916 msgstr ""
1917
1918 #. type: Content of: <h3>
1919 #: src/lessons/welcome/variables/Variables.html:125
1920 msgid "How to do this?"
1921 msgstr ""
1922
1923 #. type: Content of: <p>
1924 #: src/lessons/welcome/variables/Variables.html:126
1925 msgid ""
1926 "To solve this problem, you have to decompose it in easier sub-parts. For "
1927 "example, you may want to do the following steps:"
1928 msgstr ""
1929
1930 #. type: Content of: <p><ol><li>
1931 #: src/lessons/welcome/variables/Variables.html:129
1932 msgid "Move forward until located over a baggle"
1933 msgstr ""
1934
1935 #. type: Content of: <p><ol><li>
1936 #: src/lessons/welcome/variables/Variables.html:130
1937 msgid "Pickup the baggle"
1938 msgstr ""
1939
1940 #. type: Content of: <p><ol><li>
1941 #: src/lessons/welcome/variables/Variables.html:131
1942 msgid "Move backward of the same amount of steps than done in first step"
1943 msgstr ""
1944
1945 #. type: Content of: <p><ol><li>
1946 #: src/lessons/welcome/variables/Variables.html:132
1947 msgid "Drop back the baggle"
1948 msgstr ""
1949
1950 #. type: Content of: <p>
1951 #: src/lessons/welcome/variables/Variables.html:135
1952 msgid ""
1953 "Naturally, it is impossible to do the right amount of steps backward at step "
1954 "3 if you didn't count the amount of steps done in the first phase. You can "
1955 "use a variable for that, which can be named <code>stepAmount</code>."
1956 msgstr ""
1957
1958 #. type: Content of: <p>
1959 #: src/lessons/welcome/variables/Variables.html:139
1960 msgid ""
1961 "Create an integer variable before phase 1, initialize it to 0, and each time "
1962 "you move one step forward, increment its value by one (<code>stepAmount = "
1963 "stepAmount + 1;</code>[!java|c] or <code>stepAmount++;</code>, both syntaxes "
1964 "being equivalent[/!]). Such variable which takes every values of a given "
1965 "range is often called a <b>stepper</b>."
1966 msgstr ""
1967
1968 #. type: Content of: outside any tag (error?)
1969 #: src/lessons/welcome/variables/Variables.html:145
1970 msgid "[!python|scala]"
1971 msgstr ""
1972
1973 #. type: Content of: <p>
1974 #: src/lessons/welcome/variables/Variables.html:146
1975 msgid ""
1976 "If you know Java or other languages, you will probably try to use the "
1977 "<code>++</code> operator to increment the variable, but it's not allowed in "
1978 "[!thelang]. This is because it would be difficult to define this operator "
1979 "for every data types. For example, what should ++ do when applied to a "
1980 "Complex value or to a String? The problem does not occur in Java as "
1981 "<code>int</code> is not an object but a primitive type. (if you don't know "
1982 "the <code>++</code>, just ignore this paragraph: it does not exist in "
1983 "[!thelang])"
1984 msgstr ""
1985
1986 #. type: Content of: <p>
1987 #: src/lessons/welcome/variables/Variables.html:154
1988 msgid ""
1989 "Then, phase 3 consists in simply creating a new integer variable "
1990 "<code>doneSteps</code> initialized to 0, and do one step backward as long as "
1991 "<code>doneSteps</code> is not equal to <code>stepAmount</code>, incrementing "
1992 "<code>doneSteps</code> each time. The <code>!=</code> operator should be "
1993 "used to test the inequality (whether some values are NOT equal)."
1994 msgstr ""
1995
1996 #. type: Content of: <p>
1997 #: src/lessons/welcome/variables/Variables.html:161
1998 msgid "It's your turn now!"
1999 msgstr ""
2000
2001 #. type: Content of: <h2>
2002 #: src/lessons/welcome/variables/RunFour.html:2
2003 msgid "Run Four bases"
2004 msgstr ""
2005
2006 #. type: Content of: <p>
2007 #: src/lessons/welcome/variables/RunFour.html:4
2008 msgid ""
2009 "Today is a great day for the buggles: the Big Buggles' Race begun. It's a "
2010 "traditional competition in which young buggles prove their value to the "
2011 "tribe. Both force and intelligence is exercised: you have to rush forward, "
2012 "but stop as soon as you reach your fourth baggle. Please help the buggles "
2013 "to move forward while counting the baggles and to determine when to stop."
2014 msgstr ""
2015
2016 #. type: Content of: <h2>
2017 #: src/lessons/welcome/variables/RunHalf.html:2
2018 msgid "The Four Halves run"
2019 msgstr ""
2020
2021 #. type: Content of: <p>
2022 #: src/lessons/welcome/variables/RunHalf.html:4
2023 msgid ""
2024 "Here is the second day of the Big Buggles' Race. As previously, you have to "
2025 "run forward until you reach the right cell to stop on. But this time, you "
2026 "have to reach the cell where the amount of baggles you saw is the double of "
2027 "the orange cells plus 1. In other words, the following condition must "
2028 "become true: <code>2 * baggles = orangeCells + 1</code>."
2029 msgstr ""
2030
2031 #. type: Content of: <p>
2032 #: src/lessons/welcome/variables/RunHalf.html:10
2033 msgid ""
2034 "You can determine whether you are over a orange cell with the "
2035 "<code>isOverOrange()</code> method."
2036 msgstr ""
2037
2038 #. type: Content of: <p>
2039 #: src/lessons/welcome/loopfor/LoopFor.html:4
2040 msgid ""
2041 "While loops are well adapted to situations where you want to achieve an "
2042 "action while a condition stays true, but it is less adapted to achieve a "
2043 "given action a predetermined amount of time. For example, when we wanted to "
2044 "move <code>stepAmount</code> steps backward in a previous exercise, we had "
2045 "to create a new variable, initialize it, and move backward while "
2046 "incrementing this variable until it became equal to <code>stepAmount</code>."
2047 msgstr ""
2048
2049 #. type: Content of: <p>
2050 #: src/lessons/welcome/loopfor/LoopFor.html:11
2051 msgid ""
2052 "In such situations, <code>for</code> loops become handy. Their syntax is the "
2053 "following:"
2054 msgstr ""
2055
2056 #. type: Content of: <pre>
2057 #: src/lessons/welcome/loopfor/LoopFor.html:13
2058 #, no-wrap
2059 msgid ""
2060 "[!java|c]for (<b>initializing</b>; <b>condition</b>; <b>incrementing</b>) "
2061 "{\n"
2062 " <b>action</b>();\n"
2063 "}[/!][!python]for <b>variable</b> in <b>sequence of values</b>:\n"
2064 " <b>action</b>()[/!][!scala] for (<b>variable</b> &lt;- <b>firstValue</b> "
2065 "to <b>lastValue</b>) { \n"
2066 " <b>action</b>();\n"
2067 "}[/!]"
2068 msgstr ""
2069
2070 #. type: Content of: <p>
2071 #: src/lessons/welcome/loopfor/LoopFor.html:20
2072 msgid ""
2073 "For example to repeat the loop body <code>n</code> times, [!python] it is "
2074 "handy to use the instruction <code>range(n)</code> to generate the sequence "
2075 "n integer value from 0 to n-1.[/!] [!java|scala|c] one should write:[/!]"
2076 msgstr ""
2077
2078 #. type: Content of: <pre>
2079 #: src/lessons/welcome/loopfor/LoopFor.html:23
2080 #, no-wrap
2081 msgid ""
2082 "[!java]for (int stepper=0; stepper&lt;n; stepper++) {\n"
2083 " <b>action</b>();\n"
2084 "}[/!][!c]int stepper;\n"
2085 "for (stepper=0; stepper&lt;n; stepper++) {\n"
2086 " <b>action</b>();\n"
2087 "}[/!][!python]for <b>stepper</b> in <b>range(n)</b>:\n"
2088 " <b>action</b>()[/!][!scala] for (<b>stepper</b> &lt;- <b>1</b> to "
2089 "<b>n</b>) { \n"
2090 " <b>action</b>();\n"
2091 "}[/!]"
2092 msgstr ""
2093
2094 #. type: Content of: <p>
2095 #: src/lessons/welcome/loopfor/LoopFor.html:33
2096 msgid ""
2097 "This code is then equivalent to the following one from the computer point of "
2098 "view. From the programmer point of view, one form or the other can make the "
2099 "source code easier to read, depending on the situation. You should chose "
2100 "wisely in each situation whether you want to use a for loop or a while "
2101 "loop. Your uttermost goal should remain to keep your code simple and easy to "
2102 "read, to ensure that your day remain pleasant and productive."
2103 msgstr ""
2104
2105 #. type: Content of: <pre>
2106 #: src/lessons/welcome/loopfor/LoopFor.html:41
2107 #, no-wrap
2108 msgid ""
2109 "[!java|c]int stepper = 0;\n"
2110 "while (stepper &lt; n) {\n"
2111 "&nbsp;&nbsp;&nbsp;&nbsp;<b>action</b>();\n"
2112 "&nbsp;&nbsp;&nbsp;&nbsp;<b>stepper++</b>;\n"
2113 "}[/!][!python]stepper=0\n"
2114 "while stepper &lt; n: \n"
2115 " action()\n"
2116 " stepper = stepper + 1[/!][!scala]\n"
2117 "var stepper = 1\n"
2118 "while (stepper &lt;= n) {\n"
2119 " <b>action</b>()\n"
2120 " stepper = stepper + 1\n"
2121 "}[/!]"
2122 msgstr ""
2123
2124 #. type: Content of: <p>
2125 #: src/lessons/welcome/loopfor/LoopFor.html:55
2126 msgid "In that case, the <code>for</code> loop is easier to read, don't you think?"
2127 msgstr ""
2128
2129 #. type: Content of: <p>
2130 #: src/lessons/welcome/loopfor/LoopFor.html:58
2131 msgid ""
2132 "It is possible to build more advanced <tt>for</tt> loops since any valid "
2133 "instruction can be used as initialization, condition and incrementing "
2134 "instruction. The following example is a bit extreme as there is no need for "
2135 "a loop body to move the buggle forward until it reaches the wall, but it "
2136 "works well: all the work is done in the condition and incrementing "
2137 "instruction."
2138 msgstr ""
2139
2140 #. type: Content of: <pre>
2141 #: src/lessons/welcome/loopfor/LoopFor.html:64
2142 #, no-wrap
2143 msgid ""
2144 "for (; !isFacingWall() ; forward()) { \n"
2145 " <span class=\"comment\">/* nothing in the loop body */</span>\n"
2146 "}\n"
2147 "<span class=\"comment\">/* the buggle now faces a wall */</span>"
2148 msgstr ""
2149
2150 #. type: Content of: <p>
2151 #: src/lessons/welcome/loopfor/LoopFor.html:71
2152 msgid ""
2153 "If you want to nest several loops, you can do it on one line in Scala. This "
2154 "means that the two following chunks are equivalent:"
2155 msgstr ""
2156
2157 #. type: Content of: <pre>
2158 #: src/lessons/welcome/loopfor/LoopFor.html:72
2159 #, no-wrap
2160 msgid ""
2161 "for (stepper1 &lt;- 1 to n) {\n"
2162 " for (stepper2 &lt;- 1 to m) {\n"
2163 " actions()\n"
2164 " }\n"
2165 "}"
2166 msgstr ""
2167
2168 #. type: Content of: <pre>
2169 #: src/lessons/welcome/loopfor/LoopFor.html:77
2170 #, no-wrap
2171 msgid ""
2172 "for (stepper1 &lt;- 1 to n; stepper2 &lt;- 1 to m) { <span "
2173 "class=\"comment\">// Simply separate both loop conditions with a "
2174 "semi-column</span>\n"
2175 " actions()\n"
2176 "}"
2177 msgstr ""
2178
2179 #. type: Content of: <p>
2180 #: src/lessons/welcome/loopfor/LoopFor.html:83
2181 msgid ""
2182 "You now have to redo the same exercise than previously (move forward until "
2183 "being over a baggle, pick it up, move back to your original location, drop "
2184 "the baggle), but using a <code>for</code> loop instead of a "
2185 "<code>while</code> loop to move back to the initial location."
2186 msgstr ""
2187
2188 #. type: Content of: <p>
2189 #: src/lessons/welcome/loopfor/LoopFor.html:88
2190 msgid "Once done, you can proceed to next exercise."
2191 msgstr ""
2192
2193 #. type: Content of: <h2>
2194 #: src/lessons/welcome/loopfor/LoopStairs.html:2
2195 msgid "Stairway to Heaven"
2196 msgstr ""
2197
2198 #. type: Content of: <p>
2199 #: src/lessons/welcome/loopfor/LoopStairs.html:4
2200 msgid ""
2201 "Your buggle feels a bit depressed today, but it's currently facing a magic "
2202 "stair: It leads directly to heaven, and each time you walk on it, joyful "
2203 "colors spur all around."
2204 msgstr ""
2205
2206 #. type: Content of: <p>
2207 #: src/lessons/welcome/loopfor/LoopStairs.html:7
2208 msgid ""
2209 "Your goal is to take this stair, one step after the other. First devise the "
2210 "four instructions you have to give you buggle to take one stair step, and "
2211 "then put them in a loop to take the whole stair."
2212 msgstr ""
2213
2214 #. type: Content of: <p>
2215 #: src/lessons/welcome/loopfor/LoopStairs.html:11
2216 msgid ""
2217 "Before that, walk a bit forward to reach that stair, and ensure that you are "
2218 "in the right situation for your loop content to run properly. And once you "
2219 "reach the heaven, take some steps in your new home. Meanwhile, you just "
2220 "have to walk your way, the colors appear automagically."
2221 msgstr ""
2222
2223 #. type: Content of: <h2>
2224 #: src/lessons/welcome/loopfor/LoopCourse.html:2
2225 msgid "Training Buggle"
2226 msgstr ""
2227
2228 #. type: Content of: <p>
2229 #: src/lessons/welcome/loopfor/LoopCourse.html:4
2230 msgid ""
2231 "Today, your buggle wants to get some serious exercise: It wants to run 'till "
2232 "the track burns! Its super-shoes are just perfect to run like hell, but "
2233 "unfortunately, they can actually damage the track on the long run..."
2234 msgstr ""
2235
2236 #. type: Content of: <p>
2237 #: src/lessons/welcome/loopfor/LoopCourse.html:7
2238 msgid ""
2239 "Your goal is to run the track 10 times, no matter what happens. Even if the "
2240 "track suffers, you <b>really HAVE</b> to take that run. Remember, the track "
2241 "has four sides, that take eight steps each to run along. Now go, and show "
2242 "them what these super shoes can do."
2243 msgstr ""
2244
2245 #. type: Content of: <p>
2246 #: src/lessons/welcome/loopfor/LoopCourse.html:12
2247 msgid ""
2248 "You don't have to do anything particular with regard of the colors: your "
2249 "shoes will do it for you. Just take that run!"
2250 msgstr ""
2251
2252 #. type: Content of: <h2>
2253 #: src/lessons/welcome/loopfor/LoopCourseForest.html:2
2254 msgid "Outdoor Training Buggle"
2255 msgstr ""
2256
2257 #. type: Content of: <p>
2258 #: src/lessons/welcome/loopfor/LoopCourseForest.html:4
2259 msgid ""
2260 "Well, our last training didn't went that well. The track actually burned, "
2261 "and we are now banned from there. This time, our buggle decided to practice "
2262 "outdoor, in the middle of the forest, with its good old shoes instead. The "
2263 "problem is that you have to be careful to not fall into water. The track on "
2264 "which you can run is rather narrow: One side is now 4 steps forward, 2 steps "
2265 "to the left, 4 steps to the right, 2 steps to the right, 4 steps to the "
2266 "left, and you want to run 7 around."
2267 msgstr ""
2268
2269 #. type: Content of: <p>
2270 #: src/lessons/welcome/loopfor/LoopCourseForest.html:10
2271 msgid ""
2272 "Oh crap, running on the grass seems to destroy it too! So just take your 7 "
2273 "loops around the garden, and move along to the next exercise before anyone "
2274 "notices the damage you made..."
2275 msgstr ""
2276
2277 #. type: Content of: <p>
2278 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:4
2279 msgid ""
2280 "Some cells of the world are yellow, but your buggle cannot stand being in "
2281 "such cells. Write the necessary code to move forward until the ground gets "
2282 "white. For that, use the provided method <code>isGroundWhite()</code>."
2283 msgstr ""
2284
2285 #. type: Content of: <p>
2286 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:8
2287 msgid ""
2288 "The trick is that most buggles of this world are currently on this yellow "
2289 "ground that they dislike so much. That is why they are in panic, and every "
2290 "buggle rushes one cell forward, even the buggle that was not on a yellow "
2291 "cell at first. In other worlds, even if the ground is white on the first "
2292 "cell, you still want to move forward to the next cell."
2293 msgstr ""
2294
2295 #. type: Content of: <p>
2296 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:13
2297 msgid "The general idea is to do something like:"
2298 msgstr ""
2299
2300 #. type: Content of: <pre>
2301 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:14
2302 #, no-wrap
2303 msgid "move forward until located in a white cell"
2304 msgstr ""
2305
2306 #. type: Content of: <p>
2307 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:16
2308 msgid ""
2309 "The main difficulty is that we want this loop body to be executed once, even "
2310 "we are already on a white cell. It would be easy to do so by duplicating "
2311 "the loop content before the actual loop, but this would be a bad idea: code "
2312 "duplication is a <b>very</b> bad habit, and you should <b>always</b> avoid "
2313 "it."
2314 msgstr ""
2315
2316 #. type: Content of: <p>
2317 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:20
2318 msgid ""
2319 "Code duplication easily turns code maintenance into a nightmare: reading the "
2320 "code becomes difficult as the reader must ensure that no slight difference "
2321 "exist between the versions. Debugging the code becomes difficult, as bugs "
2322 "have to be fixed in all versions. Actually, every modification of the code "
2323 "becomes difficult. So, really, you should <b>always</b> strive to not "
2324 "duplicate your code if you can avoid. And the good news is that you always "
2325 "can..."
2326 msgstr ""
2327
2328 #. type: Content of: <h3>
2329 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:25
2330 msgid "Executing the loop body at least once"
2331 msgstr ""
2332
2333 #. type: Content of: outside any tag (error?)
2334 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:26
2335 #: src/lessons/welcome/loopdowhile/Poucet2.html:19
2336 #: src/lessons/welcome/array/basics/Array1.html:100
2337 #: src/lessons/turmites/helloturmite/HelloTurmite.html:54
2338 #: src/lessons/maze/pledge/PledgeMaze.html:59
2339 msgid "[!python]"
2340 msgstr ""
2341
2342 #. type: Content of: <p>
2343 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:27
2344 msgid ""
2345 "Some languages have specific constructs for that, but not the Python "
2346 "language. No problem, we can do it on our own! A good way is to have a "
2347 "dedicated variable indicating whether we are taking the loop for the first "
2348 "time or not, as follows."
2349 msgstr ""
2350
2351 #. type: Content of: <pre>
2352 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:31
2353 #, no-wrap
2354 msgid ""
2355 "firstTime = True\n"
2356 "while firstTime or (other conditions):\n"
2357 " firstTime = False\n"
2358 " (loop body)\n"
2359 msgstr ""
2360
2361 #. type: Content of: <p>
2362 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:37
2363 msgid ""
2364 "When <code>firstTime</code> is true, the loop body is executed even if the "
2365 "other conditions would imply the contrary. Once the loop body has been "
2366 "executed once, it is set to false and never impact again the decision to "
2367 "enter the body or not."
2368 msgstr ""
2369
2370 #. type: Content of: <p>
2371 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:43
2372 msgid ""
2373 "In a <tt>while</tt> loop, the condition is evaluated before anything else, "
2374 "and if it's false, the loop body is never evaluated. Sometimes (although not "
2375 "that often), you would prefer the loop body to get evaluated at least once, "
2376 "even if the condition is initially false. For that, a variation of the "
2377 "<tt>while</tt> loop gets used, using the following syntax in [!thelang]. "
2378 "[!java|c]Do not forget the semi-column (;) after the condition, it is "
2379 "mandatory.[/!]"
2380 msgstr ""
2381
2382 #. type: Content of: <p><pre>
2383 #: src/lessons/welcome/loopdowhile/LoopDoWhile.html:51
2384 #, no-wrap
2385 msgid ""
2386 "do {\n"
2387 " <b>action()</b>[!java];[/!]\n"
2388 "} while (<b>condition</b>)[!java];[/!]"
2389 msgstr ""
2390
2391 #. type: Content of: <h2>
2392 #: src/lessons/welcome/loopdowhile/Poucet1.html:2
2393 msgid "Tracks of buggles"
2394 msgstr ""
2395
2396 #. type: Content of: <p>
2397 #: src/lessons/welcome/loopdowhile/Poucet1.html:4
2398 msgid ""
2399 "Your buggle got lost in a strange maze, and you must help it to find the "
2400 "exit that is represented in orange. You cannot simply explain the path to "
2401 "the exit in something like "
2402 "<code>right();forward();forward();forward()</code> because you have to save "
2403 "two buggles at the same time, that are lost in similar but not identical "
2404 "worlds. You can switch to the other world by using the combobox above the "
2405 "world representation (where it's written 'Deep Forest' right now), and "
2406 "selecting the other entry (that should read 'Deeper Forest')."
2407 msgstr ""
2408
2409 #. type: Content of: <p>
2410 #: src/lessons/welcome/loopdowhile/Poucet1.html:10
2411 msgid ""
2412 "The good news is that the path to the exit is written on the ground. As you "
2413 "can see, the world is made of several corridors, with baggles on the "
2414 "ground. After each corridor, you should turn left if the corridor contains "
2415 "three baggels or more, and you have to turn right if there is only 2 baggles "
2416 "or less."
2417 msgstr ""
2418
2419 #. type: Content of: <p>
2420 #: src/lessons/welcome/loopdowhile/Poucet1.html:14
2421 msgid ""
2422 "You should count exactly 5 cells per corridor, from intersection to "
2423 "intersection. Consider in your count the intersection ending the corridor "
2424 "but not the intersection before the corridor."
2425 msgstr ""
2426
2427 #. type: Content of: <p>
2428 #: src/lessons/welcome/loopdowhile/Poucet1.html:18
2429 msgid ""
2430 "So, the general form of your code must be something like \"while I did not "
2431 "find the exit, take the next corridor to decide whether I should turn left "
2432 "or right at the next intersection\". You can determine whether you are on "
2433 "the exit cell (that is orange) with the provided <code>exitReached()</code> "
2434 "method."
2435 msgstr ""
2436
2437 #. type: Content of: <p>
2438 #: src/lessons/welcome/loopdowhile/Poucet1.html:22
2439 msgid ""
2440 "To take one corridor, you simply have to run from one intersection to "
2441 "another while counting the baggles you see on your path. That's easy: there "
2442 "is 5 steps in each corridors so a simple <code>for</code> loop suffices."
2443 msgstr ""
2444
2445 #. type: Attribute 'alt' of: <p><div>
2446 #: src/lessons/welcome/loopdowhile/Poucet1.html:26
2447 msgid "I cannot imagine how to count the baggles I see."
2448 msgstr ""
2449
2450 #. type: Content of: <p><div>
2451 #: src/lessons/welcome/loopdowhile/Poucet1.html:27
2452 msgid ""
2453 "You need a variable that is initialized to 0, and incremented each time you "
2454 "see a baggle on the ground. A variable used this way is often called "
2455 "<i>counter</i>."
2456 msgstr ""
2457
2458 #. type: Content of: <p><div>
2459 #: src/lessons/welcome/loopdowhile/Poucet1.html:29
2460 msgid "Don't forget to reset your counter to 0 at the beginning of each corridor!"
2461 msgstr ""
2462
2463 #. type: Content of: <p>
2464 #: src/lessons/welcome/loopdowhile/Poucet1.html:32
2465 msgid ""
2466 "Oh, and when you reach the exit, don't forget to take an extra step to "
2467 "actually exit the maze!"
2468 msgstr ""
2469
2470 #. type: Content of: <h2>
2471 #: src/lessons/welcome/loopdowhile/Poucet2.html:2
2472 msgid "More buggles tracks"
2473 msgstr ""
2474
2475 #. type: Content of: <p>
2476 #: src/lessons/welcome/loopdowhile/Poucet2.html:4
2477 msgid ""
2478 "Hu oh! Your buggle got lost again in the same kind of maze, but this time, "
2479 "the corridors are not always of the same size. Since there is no way to know "
2480 "the length of the corridor before taking it, a <code>for</code> will not "
2481 "suffice anymore. Instead, you will have to change your inner loop to use a "
2482 "<code>while</code> loop, using the method <code>crossing()</code> that tells "
2483 "whether your buggle currently stands on an intersection."
2484 msgstr ""
2485
2486 #. type: Content of: <p>
2487 #: src/lessons/welcome/loopdowhile/Poucet2.html:10
2488 msgid ""
2489 "The extra complexity is that at the beginning of a corridor, you obviously "
2490 "stand on an intersection, but you still want to move on. [!java|scala|c]For "
2491 "that, the easiest is to use a <code>do / while</code> loop instead of a "
2492 "regular <code>while</code> loop to move until the next intersection.[/!] "
2493 "[!python]For that, use an extra variable indicating whether you already "
2494 "entered the corridor, as follows. This will ensure that you execute the loop "
2495 "body at least once (when <code>firstTime</code> is true) before we actually "
2496 "use the value returned by <code>crossing()</code> to determine to continue "
2497 "or not.[/!]"
2498 msgstr ""
2499
2500 #. type: Content of: <pre>
2501 #: src/lessons/welcome/loopdowhile/Poucet2.html:20
2502 #, no-wrap
2503 msgid ""
2504 "firstTime = True\n"
2505 "while firstTime or not crossing():\n"
2506 " firstTime = False\n"
2507 " (loop body)\n"
2508 msgstr ""
2509
2510 #. type: Content of: <p>
2511 #: src/lessons/welcome/loopdowhile/Poucet2.html:27
2512 msgid "With that new trick, your buggle should exit this maze quite easily."
2513 msgstr ""
2514
2515 #. type: Content of: <h1>
2516 #: src/lessons/welcome/array/basics/Array1.html:2
2517 msgid "[!java|scala]Arrays[/!][!python]Lists[/!] and Knotting"
2518 msgstr ""
2519
2520 #. type: Content of: outside any tag (error?)
2521 #: src/lessons/welcome/array/basics/Array1.html:4
2522 msgid ""
2523 "The goal of this exercise is to reproduce the pattern of the first row in "
2524 "the other rows with a shift of one cell (see the Objective tab for "
2525 "details). The biggest difference between this exercise and the others we had "
2526 "on patterns is that you have to read the pattern (on first row) before "
2527 "reproducing it. You cannot do otherwise because the same code will be "
2528 "executed on three different worlds, each of them having a specific pattern."
2529 msgstr ""
2530
2531 #. type: Content of: <p>
2532 #: src/lessons/welcome/array/basics/Array1.html:12
2533 msgid ""
2534 "One solution is to read the next cell, and go copy it in position before "
2535 "coming back to read the second cell. But since it is forbidden to use the "
2536 "methods to teleport the buggle to a specific position (<code>setPos()</code> "
2537 "and similar), this approach will be a pain to implement."
2538 msgstr ""
2539
2540 #. type: Content of: <p>
2541 #: src/lessons/welcome/array/basics/Array1.html:17
2542 msgid ""
2543 "The simplest is to store the sequence of colors that constitute the whole "
2544 "pattern in an [!java|scala]<b>array</b>[/!][!python]<b>list</b>[/!]. But "
2545 "before we can do so, we should learn a bit what "
2546 "[!java|scala]arrays[/!][!python]lists[/!] are."
2547 msgstr ""
2548
2549 #. type: Content of: <h2>
2550 #: src/lessons/welcome/array/basics/Array1.html:21
2551 msgid "[!java|scala]Arrays[/!][!python]List[/!]"
2552 msgstr ""
2553
2554 #. type: Content of: <p>
2555 #: src/lessons/welcome/array/basics/Array1.html:23
2556 msgid ""
2557 "[!java|scala]An array[/!][!python]A list[/!] is an ordered sequence of "
2558 "variables that go together. It is somehow similar to a shelve where each "
2559 "level can store a separate value. Each variable of the sequence is "
2560 "identified by its position, and can store a specific value. [!java|scala]All "
2561 "cells of the array must store values of the same type because arrays are "
2562 "homogeneous in [!thelang]. It is possible to trick this restriction by using "
2563 "the datatype <code>[!java]Object[/!][!scala]Any[/!]</code> that can contain "
2564 "[!java]almost[/!] any other datatype. [!java]Primitive types such as the "
2565 "ones we saw so far (int, boolean, double, char, etc) cannot be stored in an "
2566 "Object variable, but their objectified counter-part (Integer, Boolean, "
2567 "Double, Char, Boolean, etc) can.[/!] It is however a good practice to make "
2568 "the type of an array as specific as possible, i.e., if you plan to store "
2569 "some integers in your array, make it an array of integers, not of "
2570 "[!java]Object[/!][!scala]Any[/!].[/!] [!python]Lists can even mix values of "
2571 "differing types, such as integer values in some cells and colors in other "
2572 "cells.[/!]"
2573 msgstr ""
2574
2575 #. type: Content of: <p>
2576 #: src/lessons/welcome/array/basics/Array1.html:40
2577 msgid ""
2578 "T is the [!java|scala]array[/!][!python]list[/!]'s name, "
2579 "[!java|python]T[0][/!][!scala]T(0)[/!] is the name of the first cell, "
2580 "[!java|python]T[1][/!][!scala]T(1)[/!] the name of the second cell, "
2581 "[!java|python]T[2][/!][!scala]T(2)[/!] the third one, etc. And yes, the "
2582 "first cell is numbered [!java|python]T[0][/!][!scala]T(0)[/!] while the last "
2583 "one of [!java|scala]an array[/!][!python]a list[/!] of size N is "
2584 "[!java|python]T[N-1][/!][!scala]T(N-1)[/!]. It may seem funny to count "
2585 "starting from 0 and not from 1 as usual, but some historical reasons make it "
2586 "unavoidable here."
2587 msgstr ""
2588
2589 #. type: Content of: <h3>
2590 #: src/lessons/welcome/array/basics/Array1.html:48
2591 msgid "Basic usage"
2592 msgstr ""
2593
2594 #. type: Content of: <p>
2595 #: src/lessons/welcome/array/basics/Array1.html:50
2596 msgid ""
2597 "We can use an integer variable <i>i</i> to access with "
2598 "[!java|python]T[i][/!][!scala]T(i)[/!] to the cells: when the value of "
2599 "<i>i</i> is 0, then [!java|python]T[i][/!][!scala]T(i)[/!] accesses "
2600 "[!java|python]T[0][/!][!scala]T(0)[/!]; when the value of <i>i</i> is 10, "
2601 "then [!java|python]T[i][/!][!scala]T(i)[/!] accesses "
2602 "[!java|python]T[10][/!][!scala]T(10)[/!]. <i>i</i> is said to be the "
2603 "<b>index</b> in T. <code>[!java|python]T[i][/!][!scala]T(i)[/!]</code> can "
2604 "be used just like any variable. We can set a new value:"
2605 msgstr ""
2606
2607 #. type: Content of: <pre>
2608 #: src/lessons/welcome/array/basics/Array1.html:58
2609 #, no-wrap
2610 msgid "[!java|python]T[i][/!][!scala]T(i)[/!] = 78[!java];[/!]"
2611 msgstr ""
2612
2613 #. type: Content of: <p>
2614 #: src/lessons/welcome/array/basics/Array1.html:60
2615 msgid "We can retrieve and use its value:"
2616 msgstr ""
2617
2618 #. type: Content of: <pre>
2619 #: src/lessons/welcome/array/basics/Array1.html:61
2620 #, no-wrap
2621 msgid "x = [!java|python]T[i][/!][!scala]T(i)[/!][!java];[/!]"
2622 msgstr ""
2623
2624 #. type: Content of: <p>
2625 #: src/lessons/welcome/array/basics/Array1.html:63
2626 msgid "We can test this value:"
2627 msgstr ""
2628
2629 #. type: Content of: <pre>
2630 #: src/lessons/welcome/array/basics/Array1.html:64
2631 #, no-wrap
2632 msgid ""
2633 "if ([!java|python]T[i][/!][!scala]T(i)[/!] > 0) "
2634 "[!scala|java]{[/!][!python]:[/!]\n"
2635 " [!java|scala]//[/!][!python]#[/!] instructions...\n"
2636 "[!java|scala]}[/!]"
2637 msgstr ""
2638
2639 #. type: Content of: <p>
2640 #: src/lessons/welcome/array/basics/Array1.html:68
2641 msgid ""
2642 "It is very easy to traverse the whole "
2643 "[!scala|java]array[/!][!python]list[/!], for example to initialize each "
2644 "cells."
2645 msgstr ""
2646
2647 #. type: Content of: <pre>
2648 #: src/lessons/welcome/array/basics/Array1.html:71
2649 #, no-wrap
2650 msgid ""
2651 "[!java]for (int i = 0; i&lt;T.length; i++) {[/!][!python]for i in "
2652 "range(len(T)):[/!][!scala]for (i &lt;- 0 to T.length-1) {[/!]\n"
2653 " [!java|python]T[i][/!][!scala]T(i)[/!] = 3[!java];[/!]\n"
2654 "[!java|scala]}[/!]"
2655 msgstr ""
2656
2657 #. type: Content of: <p>
2658 #: src/lessons/welcome/array/basics/Array1.html:75
2659 msgid ""
2660 "[!java|scala]The notation <code>T.length</code> retrieves the length of the "
2661 "array T,[/!] [!python]The function <code>len()</code> retrieves the length "
2662 "of the list T,[/!] allowing to build a classical for loop easily. "
2663 "[!python]Actually, the <code>len()</code> function is much more generic and "
2664 "can be used to retrieve the length of many objects. Applied to strings for "
2665 "example, it returns the amount of chars in this string.[/!] [!scala]Don't "
2666 "forget to start at <code>0</code> and stop at <code>T.length-1</code> "
2667 "instead of <code>1</code> to <code>T.length</code> however.[/!]"
2668 msgstr ""
2669
2670 #. type: Content of: <p>
2671 #: src/lessons/welcome/array/basics/Array1.html:83
2672 msgid ""
2673 "If you just want to iterate over the values of T without keeping track of "
2674 "their index, you can simply write:"
2675 msgstr ""
2676
2677 #. type: Content of: <pre>
2678 #: src/lessons/welcome/array/basics/Array1.html:84
2679 #, no-wrap
2680 msgid ""
2681 "[!java]for (int i: T) {[/!][!scala]for (i &lt;- T) {[/!][!python]for i in "
2682 "T:[/!]\n"
2683 " action()[!java];[/!]\n"
2684 "[!java|scala]}[/!]"
2685 msgstr ""
2686
2687 #. type: Content of: <p>
2688 #: src/lessons/welcome/array/basics/Array1.html:87
2689 msgid ""
2690 "[!java]This construct is called an <i>extended loop</i> in Java. The "
2691 "variable <i>i</i> takes all values of the set located to the right of the "
2692 "colon (:), one after the other.[/!] [!python|scala]This is actually very "
2693 "similar to the previous construct. Simply, "
2694 "<code>[!python]range(n)[/!][!scala]i to j[/!]</code> returns a set of "
2695 "integers over which the for construct iterates. Actually, [!thelang] offers "
2696 "much more elegant ways to traverse [!python]lists[/!][!scala]arrays[/!] and "
2697 "other data collections, but this should be the topic of a specific set of "
2698 "exercises (that are still to be written in PLM).[/!]"
2699 msgstr ""
2700
2701 #. type: Content of: <h3>
2702 #: src/lessons/welcome/array/basics/Array1.html:98
2703 msgid "Declaring [!python]a list[/!][!java|scala]an array[/!]"
2704 msgstr ""
2705
2706 #. type: Content of: <p>
2707 #: src/lessons/welcome/array/basics/Array1.html:101
2708 msgid ""
2709 "If you know beforehand the content of your list, you can affect these values "
2710 "all together. Just put them between square braces and separated by commas "
2711 "as follows:"
2712 msgstr ""
2713
2714 #. type: Content of: <pre>
2715 #: src/lessons/welcome/array/basics/Array1.html:104
2716 #, no-wrap
2717 msgid ""
2718 "L = [1, 3, 5, 7, 9] \n"
2719 "<span class=\"comment\"># L is now an array of 5 values, all of them being "
2720 "integers</span>"
2721 msgstr ""
2722
2723 #. type: Content of: <p>
2724 #: src/lessons/welcome/array/basics/Array1.html:106
2725 msgid ""
2726 "Otherwise, you probably want to create an empty list and then append each "
2727 "values separately to the list:"
2728 msgstr ""
2729
2730 #. type: Content of: <pre>
2731 #: src/lessons/welcome/array/basics/Array1.html:108
2732 #, no-wrap
2733 msgid ""
2734 "L2 = [] \n"
2735 "<span class=\"comment\"># L2 is now an empty list</span>\n"
2736 "L2.append(1)\n"
2737 "L2.append(3)\n"
2738 "L2.append(5)\n"
2739 "L2.append(7)\n"
2740 "L2.append(9) \n"
2741 "<span class=\"comment\"># Its content is now the same as L previously</span>"
2742 msgstr ""
2743
2744 #. type: Content of: outside any tag (error?)
2745 #: src/lessons/welcome/array/basics/Array1.html:116
2746 #: src/lessons/turmites/helloturmite/HelloTurmite.html:61
2747 msgid "[/!] [!java|scala]"
2748 msgstr ""
2749
2750 #. type: Content of: <p>
2751 #: src/lessons/welcome/array/basics/Array1.html:119
2752 msgid ""
2753 "To declare a variable named <b>T</b> that can store an array of integers, "
2754 "one should write:"
2755 msgstr ""
2756
2757 #. type: Content of: <pre>
2758 #: src/lessons/welcome/array/basics/Array1.html:120
2759 #, no-wrap
2760 msgid "[!java]int[] T;[/!][!scala]var T:Array[Int][/!]"
2761 msgstr ""
2762
2763 #. type: Content of: <p>
2764 #: src/lessons/welcome/array/basics/Array1.html:122
2765 msgid ""
2766 "[!java]<code>int</code> means that the elements of the array are of type "
2767 "integer; <code>[]</code> means that we are speaking of an array and "
2768 "<code>T</code> is the name of the variable. For historical reasons, this "
2769 "can also be written as <code>int T[]</code> (with the [] after the variable "
2770 "name), but this is less readable and should probably be avoided.[/!] "
2771 "[!scala]The <code>[Int]</code> notation specializes the Array type (that is "
2772 "generic), specifying that each cell of this array is an integer. An array of "
2773 "booleans would simply by written <code>Array[Boolean]</code>.[/!]"
2774 msgstr ""
2775
2776 #. type: Content of: <h3>
2777 #: src/lessons/welcome/array/basics/Array1.html:130
2778 msgid "Allocating an array"
2779 msgstr ""
2780
2781 #. type: Content of: <p>
2782 #: src/lessons/welcome/array/basics/Array1.html:132
2783 msgid ""
2784 "Declaring a variable <code>T</code> that stores an array only reserve the "
2785 "<b>name</b> <code>T</code> for later use, but not the memory area to store "
2786 "the cells. The array is not initialized yet: it does not have any "
2787 "value. What would <code>[!java]T[4][/!][!scala]T(4)[/!]</code> mean if we "
2788 "didn't say that the array is 5 cells long?"
2789 msgstr ""
2790
2791 #. type: Content of: <p>
2792 #: src/lessons/welcome/array/basics/Array1.html:137
2793 msgid "First and foremost, we have to give a value to <code>T</code>:"
2794 msgstr ""
2795
2796 #. type: Content of: <pre>
2797 #: src/lessons/welcome/array/basics/Array1.html:138
2798 #, no-wrap
2799 msgid "[!java]T = new int[10];[/!][!scala]var T = new Array[Int](10)[/!]"
2800 msgstr ""
2801
2802 #. type: Content of: <p>
2803 #: src/lessons/welcome/array/basics/Array1.html:140
2804 msgid ""
2805 "<code>new</code> means that we want to create something, and "
2806 "<code>[!java]int[10][/!][!scala]Array[Int](10)[/!]</code> means that it is "
2807 "an array of 10 integer values. In return, an array of 10 integer cells is "
2808 "created in memory, and the <code>T</code> variable <b>references</b> this "
2809 "array."
2810 msgstr ""
2811
2812 #. type: Content of: <p>
2813 #: src/lessons/welcome/array/basics/Array1.html:145
2814 msgid ""
2815 "The size of an array is fixed and cannot be changed after the creation of "
2816 "the array. The size of a <code>T</code> array can be retrieve by consulting "
2817 "the variable <code>T.length</code>."
2818 msgstr ""
2819
2820 #. type: Content of: <p>
2821 #: src/lessons/welcome/array/basics/Array1.html:149
2822 msgid ""
2823 "While allocating, you can specify the size with a variable: "
2824 "<code>[!java]int[] T = new int[i];[/!][!scala]var T = new "
2825 "Array[Int](i);[/!]</code> In this case, the array's size will be set to the "
2826 "value of <code>i</code> <i>when <code>new</code> gets called</i>. The size "
2827 "of the array still cannot be modified: even if the variable <code>i</code> "
2828 "changes afterward, the size remains to the value given when it was "
2829 "allocated. [!java]Also, it is forbidden to write something like <code>int "
2830 "T[10];</code> when declaring the variable. You are required to use the "
2831 "<code>new</code> instruction to allocate it, as in <code>int[] T = new "
2832 "int[10];</code> [/!]"
2833 msgstr ""
2834
2835 #. type: Content of: <h4>
2836 #: src/lessons/welcome/array/basics/Array1.html:157
2837 msgid "Declaration and initialization"
2838 msgstr ""
2839
2840 #. type: Content of: <p>
2841 #: src/lessons/welcome/array/basics/Array1.html:158
2842 msgid ""
2843 "If you know beforehand the content of your array, you can declare, allocate "
2844 "and initialize it in one shoot:"
2845 msgstr ""
2846
2847 #. type: Content of: <pre>
2848 #: src/lessons/welcome/array/basics/Array1.html:159
2849 #, no-wrap
2850 msgid ""
2851 "[!java]int[] T = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };[/!][!scala]var T = "
2852 "Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)[/!]"
2853 msgstr ""
2854
2855 #. type: Content of: <p>
2856 #: src/lessons/welcome/array/basics/Array1.html:161
2857 msgid ""
2858 "To know the size of the array to allocate, the compiler counts the provided "
2859 "values. This code is equivalent to:"
2860 msgstr ""
2861
2862 #. type: Content of: <pre>
2863 #: src/lessons/welcome/array/basics/Array1.html:163
2864 #, no-wrap
2865 msgid ""
2866 "[!java]int[] T = new int[10];\n"
2867 "T[0] = 1;\n"
2868 "T[1] = 2;\n"
2869 "...\n"
2870 "T[9] = 10;[/!][!scala]var T = new Array[Int](10);\n"
2871 "T(0) = 1\n"
2872 "T(1) = 2\n"
2873 "...\n"
2874 "T(9) = 10[/!]"
2875 msgstr ""
2876
2877 #. type: Content of: <p>
2878 #: src/lessons/welcome/array/basics/Array1.html:173
2879 msgid "It is also equivalent to:"
2880 msgstr ""
2881
2882 #. type: Content of: <pre>
2883 #: src/lessons/welcome/array/basics/Array1.html:174
2884 #, no-wrap
2885 msgid ""
2886 "[!java]int[] T = new int[10];\n"
2887 "for (int i=0; i&lt;T.length; i++) {\n"
2888 " T[i] = i+1;\n"
2889 "}[/!][!scala]var T = new Array[Int](10);\n"
2890 "for (i &lt;- 0 to T.length-1) {\n"
2891 " T(i) = i+1\n"
2892 "}[/!]"
2893 msgstr ""
2894
2895 #. type: Content of: <h3>
2896 #: src/lessons/welcome/array/basics/Array1.html:185
2897 msgid "[!python]Lists[/!][!scala|java]Arrays[/!] and method parameters"
2898 msgstr ""
2899
2900 #. type: Content of: <p>
2901 #: src/lessons/welcome/array/basics/Array1.html:186
2902 msgid ""
2903 "It is perfectly OK to pass [!python]a list[/!][!java|scala]an array[/!] to a "
2904 "method as a parameter. This method can then use this parameter as if it "
2905 "were defined locally:"
2906 msgstr ""
2907
2908 #. type: Content of: <pre>
2909 #: src/lessons/welcome/array/basics/Array1.html:188
2910 #, no-wrap
2911 msgid ""
2912 "[!java]boolean has42First(int[] array) {\n"
2913 " return array[0] == 42;\n"
2914 "}[/!][!python]def has42First(list):\n"
2915 " return list[0] == 42[/!][!scala]def has42First(array:Array[Int]):Boolean = "
2916 "{\n"
2917 " return array(0) == 42\n"
2918 "}[/!]"
2919 msgstr ""
2920
2921 #. type: Content of: <p>
2922 #: src/lessons/welcome/array/basics/Array1.html:195
2923 msgid "On the caller side, that also very simple:"
2924 msgstr ""
2925
2926 #. type: Content of: <pre>
2927 #: src/lessons/welcome/array/basics/Array1.html:196
2928 #, no-wrap
2929 msgid ""
2930 "[!java]int[] tab = new int[10];[/!][!scala]var tab = new Array[Int] "
2931 "(10)[/!][!python]tab = [1, 3, 5, 7, 9][/!]\n"
2932 "[!java|scala]<span class=\"comment\">// Values initialization "
2933 "omitted</span>\n"
2934 "[/!]if (has42First(tab))[!java|scala] {[/!][!python]:[/!]\n"
2935 " <span class=\"comment\">[!java|scala]//[/!][!python]#[/!] do "
2936 "something</span>\n"
2937 "[!java|scala]}[/!]"
2938 msgstr ""
2939
2940 #. type: Content of: outside any tag (error?)
2941 #: src/lessons/welcome/array/basics/Array1.html:202
2942 #: src/lessons/turmites/langton/Langton.html:21
2943 msgid "[!java]"
2944 msgstr ""
2945
2946 #. type: Content of: <p>
2947 #: src/lessons/welcome/array/basics/Array1.html:203
2948 msgid ""
2949 "If you want to allocate and initialize the array in one shoot, that's a bit "
2950 "more complicated as the compiler has to know the type of the parameter you "
2951 "are creating. For that, use the following (ugly) construct:"
2952 msgstr ""
2953
2954 #. type: Content of: <pre>
2955 #: src/lessons/welcome/array/basics/Array1.html:206
2956 #, no-wrap
2957 msgid ""
2958 "if (has42First( new int[] {1, 3, 5, 7, 9} ) {\n"
2959 " <span class=\"comment\">// do something</span>\n"
2960 "}"
2961 msgstr ""
2962
2963 #. type: Content of: <p>
2964 #: src/lessons/welcome/array/basics/Array1.html:211
2965 msgid ""
2966 "Methods can also return [!java|scala]arrays[/!][!python]lists[/!] as result "
2967 "without any complication. Here is a method that returns [!java|scala]an "
2968 "array[/!][!python]a list[/!] of the requested size, filled with 42s."
2969 msgstr ""
2970
2971 #. type: Content of: <pre>
2972 #: src/lessons/welcome/array/basics/Array1.html:214
2973 #, no-wrap
2974 msgid ""
2975 "[!java]int[] fill42(int size) {\n"
2976 " int[] res = new int[size];\n"
2977 " for (int i=0; i&lt;size; i++) \n"
2978 " res[i] = 42;\n"
2979 " return res;\n"
2980 "}[/!][!scala]def fill42(size:Int):Array[Int] = {\n"
2981 " var res = new Array[int] (size)\n"
2982 " for (i &lt;- 0 to size -1) {\n"
2983 " res(i) = 42;\n"
2984 " }\n"
2985 " return res;\n"
2986 "}[/!][!python]def fill42(size):\n"
2987 " res = []\n"
2988 " for i in range(size):\n"
2989 " res.append(42)\n"
2990 " return res[/!]"
2991 msgstr ""
2992
2993 #. type: Content of: <h3>
2994 #: src/lessons/welcome/array/basics/Array1.html:231
2995 #: src/lessons/recursion/lego/square/FourSquare.html:48
2996 #: src/lessons/recursion/hanoi/HanoiBoard.html:21
2997 msgid "Goal of this exercise"
2998 msgstr ""
2999
3000 #. type: Content of: <p>
3001 #: src/lessons/welcome/array/basics/Array1.html:233
3002 msgid "At least! After this long explanation, we can come back to the exercise."
3003 msgstr ""
3004
3005 #. type: Content of: <p>
3006 #: src/lessons/welcome/array/basics/Array1.html:234
3007 msgid ""
3008 "Your mission is rather simple actually. Your code should save the color "
3009 "pattern observed on the first row into [!java|scala]an array[/!][!python]a "
3010 "list[/!]. [!python]The easiest is to create an empty list, and then "
3011 "<code>append()</code> the colors one after the others as you read them (with "
3012 "<code>getGroundColor()</code>).[/!] [!java|scala]For that, you should "
3013 "declare and allocate an array of <code>Color</code>. Beware, there is "
3014 "several worlds, of differing size; use <code>getWorldHeight()</code> to "
3015 "retrieve the size of the current world. Once the array allocated, fill it "
3016 "by reading the ground color in each locations (with "
3017 "<code>getGroundColor()</code>).[/!]"
3018 msgstr ""
3019
3020 #. type: Content of: <p>
3021 #: src/lessons/welcome/array/basics/Array1.html:242
3022 msgid ""
3023 "Once you managed to read and save the pattern on the first row, you have to "
3024 "reapply the pattern on every rows, for example by executing "
3025 "<code>getWorldHeight()</code> times a method written specifically for this."
3026 msgstr ""
3027
3028 #. type: Content of: <h1>
3029 #: src/lessons/welcome/array/basics/Array2.html:2
3030 msgid "[!java|scala]Arrays[/!][!python]Lists[/!], Knotting and Modulos"
3031 msgstr ""
3032
3033 #. type: Content of: <p>
3034 #: src/lessons/welcome/array/basics/Array2.html:4
3035 msgid ""
3036 "This exercise is similar to the previous one: you have to reproduce the "
3037 "color pattern of the first cell into the other ones."
3038 msgstr ""
3039
3040 #. type: Content of: <p>
3041 #: src/lessons/welcome/array/basics/Array2.html:7
3042 msgid ""
3043 "The first difference is that the world is bordered of walls: you thus have "
3044 "to slightly modify your trajectory to ensure that the buggle does not crash "
3045 "into a wall. The simpler for that is to handle the first cell out of the "
3046 "<code>for</code> loop and do only <code>getWorldHeight()-1</code> steps in "
3047 "the loop."
3048 msgstr ""
3049
3050 #. type: Content of: <p>
3051 #: src/lessons/welcome/array/basics/Array2.html:13
3052 msgid ""
3053 "The other difference is that the offset to apply between columns is not "
3054 "fixed, but written on the first cell of each column. To get the info as an "
3055 "integer, we can use:"
3056 msgstr ""
3057
3058 #. type: Content of: <pre>
3059 #: src/lessons/welcome/array/basics/Array2.html:17
3060 #, no-wrap
3061 msgid ""
3062 "[!java]int offset = Integer.parseInt(readMessage())[/!][!python]offset = "
3063 "int( readMessage() )[/!][!scala]val offset = readMessage().toInt[/!]"
3064 msgstr ""
3065
3066 #. type: Content of: <p>
3067 #: src/lessons/welcome/array/basics/Array2.html:19
3068 msgid ""
3069 "<code>readMessage()</code> gets the message on the ground as a "
3070 "[!java|scala]String[/!][!python]string[/!], while "
3071 "<code>[!java]Integer.parseInt(str)[/!][!scala]str.toInt[/!][!python]int(str)[/!]</code> "
3072 "transforms the string <code>str</code> into an integer by <i>reading</i> it."
3073 msgstr ""
3074
3075 #. type: Content of: <p>
3076 #: src/lessons/welcome/array/basics/Array2.html:23
3077 msgid ""
3078 "Then, to pick the right color, the easier is to use the <code>%</code> "
3079 "(modulo) operator. For example, <code>(i + 5) % size</code> allows to "
3080 "retrieve the <code>i</code>th cell of an array of size <code>size</code> "
3081 "with an offset of <code>5</code>."
3082 msgstr ""
3083
3084 #. type: Content of: <p>
3085 #: src/lessons/welcome/array/basics/Array2.html:28
3086 msgid "You're up."
3087 msgstr ""
3088
3089 #. type: Content of: <h1>
3090 #: src/lessons/welcome/array/search/IndexOfValue.html:2
3091 msgid "Searching for a given value"
3092 msgstr ""
3093
3094 #. type: Content of: <p>
3095 #: src/lessons/welcome/array/search/IndexOfValue.html:4
3096 msgid ""
3097 "The goal of this exercise is to search the cell of a given value, and return "
3098 "its position."
3099 msgstr ""
3100
3101 #. type: Content of: <p>
3102 #: src/lessons/welcome/array/search/IndexOfValue.html:6
3103 msgid ""
3104 "To that extend, you should fill the method <code>indexOf()</code>, which "
3105 "parameters are the array to explore, and the value to search. If the value "
3106 "<code>lookingFor</code> is not in the array <code>tab</code>, the method "
3107 "should return -1."
3108 msgstr ""
3109
3110 #. type: Content of: <p>
3111 #: src/lessons/welcome/array/search/IndexOfValue.html:10
3112 msgid ""
3113 "The idea of the algorithm is to sweep over the whole array, checking the "
3114 "value of each cell. If it's the searched value, you should return the index "
3115 "of the cell currently checked."
3116 msgstr ""
3117
3118 #. type: Content of: <p>
3119 #: src/lessons/welcome/array/search/IndexOfValue.html:14
3120 msgid ""
3121 "Remember that indices begin at 0 and not at 1. So, if there is 3 cells, "
3122 "their indices will be 0, 1 and 2. There would not be any cell numbered 3."
3123 msgstr ""
3124
3125 #. type: Content of: <p>
3126 #: src/lessons/welcome/array/search/IndexOfValue.html:17
3127 msgid ""
3128 "Remember also that the amount of cells in an array can be retrieved using "
3129 "the <code>length</code> attribute. So, if your array is called "
3130 "<code>tab</code>, its size can be retrieved as <code>tab.length</code>. "
3131 "Note that there is no () after <code>length</code>. An attribute is a sort "
3132 "of variable embedded in another object (here, the array)."
3133 msgstr ""
3134
3135 #. type: Content of: <p>
3136 #: src/lessons/welcome/array/search/IndexOfValue.html:22
3137 msgid "So, the last value of an array is given by <code>tab[tab.length - 1]</code>."
3138 msgstr ""
3139
3140 #. type: Content of: <p>
3141 #: src/lessons/welcome/array/search/IndexOfValue.html:24
3142 msgid ""
3143 "Remember also that the amount of cells in an array can be retrieved with the "
3144 "<code>len()</code> function. So, if your array is called <code>tab</code>, "
3145 "its size can be retrieved as <code>len(tab)</code>."
3146 msgstr ""
3147
3148 #. type: Content of: <p>
3149 #: src/lessons/welcome/array/search/IndexOfValue.html:28
3150 msgid "So, the last value of an array is given by <code>tab[ len(tab) - 1]</code>."
3151 msgstr ""
3152
3153 #. type: Content of: <h1>
3154 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:2
3155 msgid "Index of the maximum value"
3156 msgstr ""
3157
3158 #. type: Content of: <p>
3159 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:4
3160 msgid ""
3161 "In this exercise, you must compute the index of the tab cell containing the "
3162 "biggest value."
3163 msgstr ""
3164
3165 #. type: Content of: <p>
3166 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:6
3167 msgid ""
3168 "For that, fill the <code>indexOfMaximum()</code> method. Its parameter is "
3169 "the array to explore. Should the array contain the searched value several "
3170 "times, you should return the index of the first occurrence."
3171 msgstr ""
3172
3173 #. type: Content of: <p>
3174 #: src/lessons/welcome/array/search/IndexOfMaxValue.html:10
3175 msgid ""
3176 "To solve this exercise, you should sweep over the whole array. For each "
3177 "value, if it's bigger than the biggest value you saw so far, you must save "
3178 "this new champion and its position. You will thus need 2 extra variables; "
3179 "the initial value of the champion could be the value of the first cell."
3180 msgstr ""
3181
3182 #. type: Content of: <h1>
3183 #: src/lessons/welcome/array/search/AverageValue.html:2
3184 msgid "Average value"
3185 msgstr ""
3186
3187 #. type: Content of: <p>
3188 #: src/lessons/welcome/array/search/AverageValue.html:5
3189 msgid ""
3190 "The objective of this exercise is to compute the average value of the "
3191 "integer values stored in an array."
3192 msgstr ""
3193
3194 #. type: Content of: <p>
3195 #: src/lessons/welcome/array/search/AverageValue.html:7
3196 msgid ""
3197 "You have to fill the body of the method <code>average()</code> which takes "
3198 "as parameter the array of integers of which it computes and returns the "
3199 "average value. Please note that this method must return an integer."
3200 msgstr ""
3201
3202 #. type: Content of: <p>
3203 #: src/lessons/welcome/array/search/AverageValue.html:9
3204 msgid ""
3205 "To compute the average value of an integer, it is necessary to traverse the "
3206 "whole array and to compute the sum of all its values (so you will need a "
3207 "variable to store this temporary result), then you have to divide this sum "
3208 "by the size of the array."
3209 msgstr ""
3210
3211 #. type: Content of: <p>
3212 #: src/lessons/welcome/array/search/AverageValue.html:11
3213 msgid ""
3214 "In Java, you can get the size of an array <code>myarray</code> by consulting "
3215 "its <code>length</code> attribute (in other words, "
3216 "<code>myarray.length</code>). Notice that there is no parenthesis after "
3217 "<code>length</code>."
3218 msgstr ""
3219
3220 #. type: Content of: <p>
3221 #: src/lessons/welcome/array/search/AverageValue.html:16
3222 msgid ""
3223 "In python, retrieving the size of an array <code>myarray</code> is as easy "
3224 "as calling <code>len(myarray)</code>."
3225 msgstr ""
3226
3227 #. type: Content of: <h1>
3228 #: src/lessons/welcome/array/search/MaxValue.html:2
3229 msgid "Maximal value"
3230 msgstr ""
3231
3232 #. type: Content of: <p>
3233 #: src/lessons/welcome/array/search/MaxValue.html:4
3234 msgid ""
3235 "In this exercise, you must compute the maximal value contained in an array. "
3236 "For that, fill the <code>maximum()</code> method, which parameter is the "
3237 "array to explore."
3238 msgstr ""
3239
3240 #. type: Content of: <p>
3241 #: src/lessons/welcome/array/search/MaxValue.html:8
3242 msgid ""
3243 "To compute this value, sweep over the whole parameter. For each value, if "
3244 "it's bigger than the biggest value you saw so far, you must save this value "
3245 "somewhere to remember it afterward. You thus need an extra variable, which "
3246 "can be initialized to the value of the first array cell."
3247 msgstr ""
3248
3249 #. type: Content of: <h1>
3250 #: src/lessons/welcome/array/search/OccurrenceOfValue.html:2
3251 msgid "Occurrence of a value"
3252 msgstr ""
3253
3254 #. type: Content of: <p>
3255 #: src/lessons/welcome/array/search/OccurrenceOfValue.html:4
3256 msgid ""
3257 "In this exercise, you must compute the amount of occurrences of a given "
3258 "value in an array (that is, the amount of time that this value appears in "
3259 "the array). For that, fill the <code>occurrences()</code> method, which "
3260 "returns the number of occurrence of <code>lookingFor</code> in "
3261 "<code>tab</code>."
3262 msgstr ""
3263
3264 #. type: Content of: <p>
3265 #: src/lessons/welcome/array/search/OccurrenceOfValue.html:9
3266 msgid ""
3267 "To compute this value, simply sweep over the array counting for the amount "
3268 "of cells containing the searched value. You thus need an extra variable for "
3269 "that."
3270 msgstr ""
3271
3272 #. type: Content of: <h1>
3273 #: src/lessons/welcome/array/search/Extrema.html:2
3274 msgid "Maxima and Minima"
3275 msgstr ""
3276
3277 #. type: Content of: outside any tag (error?)
3278 #: src/lessons/welcome/array/search/Extrema.html:4
3279 msgid ""
3280 "In this exercise, you must return the difference between the maxima (i.e., "
3281 "the largest value of the array) and the minima (i.e., its smallest "
3282 "value). The returned value is then a positive number. Beware, you can only "
3283 "do one traversal of the array to gather all informations that you need."
3284 msgstr ""
3285
3286 #. type: Content of: <h1>
3287 #: src/lessons/welcome/array/search/SecondMaxValue.html:2
3288 msgid "Second Biggest Value"
3289 msgstr ""
3290
3291 #. type: Content of: <p>
3292 #: src/lessons/welcome/array/search/SecondMaxValue.html:4
3293 msgid ""
3294 "In this exercise, you must compute the second maximal value contained in an "
3295 "array, i.e. the value that becomes the maximum if you remove every instance "
3296 "of the current maximum from the array."
3297 msgstr ""
3298
3299 #. type: Content of: <p>
3300 #: src/lessons/welcome/array/search/SecondMaxValue.html:7
3301 msgid ""
3302 "As usual, you should gather the information in only one traversal of the "
3303 "array. You can assume that the second biggest value actual exists (there is "
3304 "at least two distinct values in the array), and that all values in the array "
3305 "are greater than [!python] -100000000.[/!] "
3306 "[!java|scala]<code>Integer.MIN_VALUE</code> (which is the smallest "
3307 "representable integer existing in [!thelang]).[/!]"
3308 msgstr ""
3309
3310 #. type: Content of: <h1>
3311 #: src/lessons/welcome/array/array123/Array123.html:2
3312 msgid "Array123"
3313 msgstr ""
3314
3315 #. type: Content of: outside any tag (error?)
3316 #: src/lessons/welcome/array/array123/Array123.html:3
3317 msgid ""
3318 "Given an array of integers, return true if .. 1, 2, 3, .. appears in the "
3319 "array somewhere."
3320 msgstr ""
3321
3322 #. type: Content of: <p>
3323 #: src/lessons/welcome/array/array123/Array123.html:5
3324 #: src/lessons/welcome/array/array667/Array667.html:8
3325 #: src/lessons/welcome/array/arraycount9/ArrayCount9.html:5
3326 #: src/lessons/welcome/array/arrayfront9/ArrayFront9.html:5
3327 #: src/lessons/welcome/array/notriples/NoTriples.html:8
3328 #: src/lessons/welcome/array/has271/Has271.html:10
3329 #: src/lessons/welcome/bat/bool1/Close10.html:8
3330 #: src/lessons/welcome/bat/bool1/Diff21.html:6
3331 #: src/lessons/welcome/bat/bool1/HasTeen.html:7
3332 #: src/lessons/welcome/bat/bool1/IcyHot.html:6
3333 #: src/lessons/welcome/bat/bool1/In1020.html:6
3334 #: src/lessons/welcome/bat/bool1/In3050.html:6
3335 #: src/lessons/welcome/bat/bool1/LoneTeen.html:7
3336 #: src/lessons/welcome/bat/bool1/Main.html:12
3337 #: src/lessons/welcome/bat/bool1/Makes10.html:6
3338 #: src/lessons/welcome/bat/bool1/Max1020.html:8
3339 #: src/lessons/welcome/bat/bool1/MonkeyTrouble.html:8
3340 #: src/lessons/welcome/bat/bool1/NearHundred.html:8
3341 #: src/lessons/welcome/bat/bool1/ParotTrouble.html:9
3342 #: src/lessons/welcome/bat/bool1/PosNeg.html:6
3343 #: src/lessons/welcome/bat/bool1/SleepIn.html:8
3344 #: src/lessons/welcome/bat/bool1/SumDouble.html:6
3345 #: src/lessons/welcome/bat/bool2/AlarmClock.html:12
3346 #: src/lessons/welcome/bat/bool2/AnswerCell.html:9
3347 #: src/lessons/welcome/bat/bool2/BlueTicket.html:11
3348 #: src/lessons/welcome/bat/bool2/CaughtSpeeding.html:12
3349 #: src/lessons/welcome/bat/bool2/CigarParty.html:10
3350 #: src/lessons/welcome/bat/bool2/DateFashion.html:13
3351 #: src/lessons/welcome/bat/bool2/GreenTicket.html:10
3352 #: src/lessons/welcome/bat/bool2/In1To10.html:9
3353 #: src/lessons/welcome/bat/bool2/InOrderEqual.html:10
3354 #: src/lessons/welcome/bat/bool2/InOrder.html:9
3355 #: src/lessons/welcome/bat/bool2/LastDigit2.html:9
3356 #: src/lessons/welcome/bat/bool2/LessBy10.html:6
3357 #: src/lessons/welcome/bat/bool2/Main.html:7
3358 #: src/lessons/welcome/bat/bool2/MaxMod5.html:10
3359 #: src/lessons/welcome/bat/bool2/NearTen.html:9
3360 #: src/lessons/welcome/bat/bool2/RedTicket.html:10
3361 #: src/lessons/welcome/bat/bool2/SortaSum.html:8
3362 #: src/lessons/welcome/bat/bool2/SquirrelPlay.html:11
3363 #: src/lessons/welcome/bat/bool2/TeaParty.html:12
3364 #: src/lessons/welcome/bat/bool2/TeenSum.html:9
3365 #: src/lessons/welcome/bat/bool2/TwoAsOne.html:6
3366 #: src/lessons/welcome/bat/bool2/WithoutDoubles.html:9
3367 #: src/lessons/bat/string1/Main.html:10 src/lessons/bat/string1/AltPairs.html:5
3368 #: src/lessons/bat/string1/FrontTimes.html:8
3369 #: src/lessons/bat/string1/Last2.html:9
3370 #: src/lessons/bat/string1/StringBits.html:5
3371 #: src/lessons/bat/string1/StringMatch.html:9
3372 #: src/lessons/bat/string1/StringSplosion.html:5
3373 #: src/lessons/bat/string1/StringTimes.html:5
3374 #: src/lessons/bat/string1/StringX.html:7
3375 #: src/lessons/bat/string1/StringYak.html:8
3376 msgid ""
3377 "This exercise was converted to PLM from the excellent exercising site "
3378 "http://codingbat.com/"
3379 msgstr ""
3380
3381 #. type: Content of: <h1>
3382 #: src/lessons/welcome/array/array667/Array667.html:2
3383 msgid "Array667"
3384 msgstr ""
3385
3386 #. type: Content of: outside any tag (error?)
3387 #: src/lessons/welcome/array/array667/Array667.html:3
3388 msgid ""
3389 "Given an array of integers, return the number of times that two 6's are next "
3390 "to each other in the array. Also count instances where the second \"6\" is "
3391 "actually a 7."
3392 msgstr ""
3393
3394 #. type: Content of: <h1>
3395 #: src/lessons/welcome/array/arraycount9/ArrayCount9.html:2
3396 msgid "ArrayCount9"
3397 msgstr ""
3398
3399 #. type: Content of: outside any tag (error?)
3400 #: src/lessons/welcome/array/arraycount9/ArrayCount9.html:3
3401 msgid "Given an array of integers, return the number of 9's in the array."
3402 msgstr ""
3403
3404 #. type: Content of: <h1>
3405 #: src/lessons/welcome/array/arrayfront9/ArrayFront9.html:2
3406 msgid "ArrayFront9"
3407 msgstr ""
3408
3409 #. type: Content of: outside any tag (error?)
3410 #: src/lessons/welcome/array/arrayfront9/ArrayFront9.html:3
3411 msgid ""
3412 "Given an array of integers, return true if one of the first 4 elements in "
3413 "the array is a 9. The array length may be less than 4."
3414 msgstr ""
3415
3416 #. type: Content of: <h1>
3417 #: src/lessons/welcome/array/notriples/NoTriples.html:2
3418 msgid "NoTriples"
3419 msgstr ""
3420
3421 #. type: Content of: outside any tag (error?)
3422 #: src/lessons/welcome/array/notriples/NoTriples.html:3
3423 msgid ""
3424 "Given an array of integers, we'll say that a triple is a value appearing 3 "
3425 "times in a row in the array. Return true if the array does not contain any "
3426 "triples."
3427 msgstr ""
3428
3429 #. type: Content of: <h1>
3430 #: src/lessons/welcome/array/has271/Has271.html:2
3431 msgid "Has271"
3432 msgstr ""
3433
3434 #. type: Content of: <p>
3435 #: src/lessons/welcome/array/has271/Has271.html:3
3436 msgid ""
3437 "Given an array of integers, return true if it contains a 2, 7, 1 pattern -- "
3438 "a value, followed by the value plus 5, followed by the initial value minus "
3439 "1. So, 2,7,1 is such a pattern because 7 is 5+2 and 1 is 2-1. 3,8,2 is also "
3440 "such a pattern."
3441 msgstr ""
3442
3443 #. type: Content of: <p>
3444 #: src/lessons/welcome/array/has271/Has271.html:7
3445 msgid ""
3446 "Additionally the 271 counts even if the \"1\" differs by 2 or less from the "
3447 "correct value."
3448 msgstr ""
3449
3450 #. type: Content of: <h1>
3451 #: src/lessons/welcome/array/golomb/Golomb.html:2
3452 msgid "Golomb sequence"
3453 msgstr ""
3454
3455 #. type: Content of: outside any tag (error?)
3456 #: src/lessons/welcome/array/golomb/Golomb.html:4
3457 msgid ""
3458 "The Golomb sequence is a non-decreasing integer sequence where a(n) is the "
3459 "number of times that n occurs in the sequence, with a(1) = 1."
3460 msgstr ""
3461
3462 #. type: Content of: <p>
3463 #: src/lessons/welcome/array/golomb/Golomb.html:7
3464 msgid ""
3465 "Since a(1)=1, it means that 1 occurs only once in the sequence, so a(2) must "
3466 "be different. Since the sequence is non-decreasing, a(2) must be greater "
3467 "than 1. Since a(2)>1, the digit 2 must appear more than one time in the "
3468 "sequence. So a(2)=2."
3469 msgstr ""
3470
3471 #. type: Content of: <p>
3472 #: src/lessons/welcome/array/golomb/Golomb.html:12
3473 msgid ""
3474 "Since a(2)=2, there is two 2 in the sequence, so we know the value of "
3475 "a(3). And so on for the other values of the sequence."
3476 msgstr ""
3477
3478 #. type: Content of: <p>
3479 #: src/lessons/welcome/array/golomb/Golomb.html:15
3480 msgid "Write a function that computes the Nth element of the sequence."
3481 msgstr ""
3482
3483 #. type: Content of: <h1>
3484 #: src/lessons/welcome/array/island/Island.html:2
3485 msgid "Buggles' Island"
3486 msgstr ""
3487
3488 #. type: Content of: outside any tag (error?)
3489 #: src/lessons/welcome/array/island/Island.html:4
3490 msgid ""
3491 "You just received the traveling notes of your old aunt who traveled accross "
3492 "the country of the Buggles' Islands. She wrote down the altitude every "
3493 "kilometer during her trip, resulting in a sequence of numbers as follows."
3494 msgstr ""
3495
3496 #. type: Content of: <pre>
3497 #: src/lessons/welcome/array/island/Island.html:9
3498 #, no-wrap
3499 msgid "0 0 1 1 2 2 1 1 0 1 2 2 1 1 0"
3500 msgstr ""
3501
3502 #. type: Content of: <p>
3503 #: src/lessons/welcome/array/island/Island.html:11
3504 msgid "Here is a cut of the islands on that path:"
3505 msgstr ""
3506
3507 #. type: Content of: <pre>
3508 #: src/lessons/welcome/array/island/Island.html:14
3509 #, no-wrap
3510 msgid ""
3511 " /***\\ /*\\ &lt;-- 2 meters above the see level\n"
3512 " /***********\\ /*******\\ &lt;-- 1 meter above the see level\n"
3513 "*************************** &lt;-- see level\n"
3514 "| | | | | | | | | | | | | |\n"
3515 "0 0 1 1 2 2 1 1 0 1 2 1 1 0 &lt;-- altitude on each point\n"
3516 msgstr ""
3517
3518 #. type: Content of: <p>
3519 #: src/lessons/welcome/array/island/Island.html:21
3520 msgid "This example is constituted of four levels of island:"
3521 msgstr ""
3522
3523 #. type: Content of: <ul><li>
3524 #: src/lessons/welcome/array/island/Island.html:24
3525 msgid "1 1 2 2 1 1 (the island on the left)"
3526 msgstr ""
3527
3528 #. type: Content of: <ul><li>
3529 #: src/lessons/welcome/array/island/Island.html:25
3530 msgid "2 2 (the mountain topping the left island)"
3531 msgstr ""
3532
3533 #. type: Content of: <ul><li>
3534 #: src/lessons/welcome/array/island/Island.html:26
3535 msgid "1 2 1 1 (the right island)"
3536 msgstr ""
3537
3538 #. type: Content of: <ul><li>
3539 #: src/lessons/welcome/array/island/Island.html:27
3540 msgid "2 (the mountain on the right)"
3541 msgstr ""
3542
3543 #. type: Content of: <p>
3544 #: src/lessons/welcome/array/island/Island.html:30
3545 msgid "This can also be visualized this way:"
3546 msgstr ""
3547
3548 #. type: Content of: <pre>
3549 #: src/lessons/welcome/array/island/Island.html:32
3550 #, no-wrap
3551 msgid "0 0(1 1(2 2)1 1)0(1(2)1 1)0"
3552 msgstr ""
3553
3554 #. type: Content of: <p>
3555 #: src/lessons/welcome/array/island/Island.html:34
3556 msgid ""
3557 "Could you write a little program to compute the amount of levels in a given "
3558 "sequence of altitudes? Actually, there is an iterative and a recursive "
3559 "solution to that problem."
3560 msgstr ""
3561
3562 #. type: Content of: <p>
3563 #: src/lessons/welcome/methods/basics/Methods.html:5
3564 msgid ""
3565 "We will now write our own methods. It somehow comes down to extending the "
3566 "buggle vocabulary by teaching it new tricks."
3567 msgstr ""
3568
3569 #. type: Content of: <p>
3570 #: src/lessons/welcome/methods/basics/Methods.html:8
3571 msgid ""
3572 "For example, we saw in a previous exercise how to ask the buggle to go get "
3573 "the baggle in front of it, and bring it back. If there is several baggles on "
3574 "the board, and if we want to bring all of them on the bottom line, you have "
3575 "to repeat this code several times, or include it in a loop. In any case, you "
3576 "should avoid to duplicate your code to keep it pleasant to read and easily "
3577 "understandable. It would be better if the buggle could obey an "
3578 "<code>goAndGet()</code> order just like it understands a "
3579 "<code>[!c]stepForward()[/!][!scala|java|python]forward()[/!]</code> one."
3580 msgstr ""
3581
3582 #. type: Content of: <h3>
3583 #: src/lessons/welcome/methods/basics/Methods.html:16
3584 msgid "Defining methods"
3585 msgstr ""
3586
3587 #. type: Content of: <p>
3588 #: src/lessons/welcome/methods/basics/Methods.html:18
3589 msgid ""
3590 "The [!thelang] syntax to write a simple method called <code>goAndGet</code> "
3591 "is the following:"
3592 msgstr ""
3593
3594 #. type: Content of: <pre>
3595 #: src/lessons/welcome/methods/basics/Methods.html:20
3596 #, no-wrap
3597 msgid ""
3598 "[!java|c]void goAndGet() {[/!][!python]def goAndGet():[/!][!scala]def "
3599 "goAndGet() {[/!]\n"
3600 " actions()[!java|c];[/!]\n"
3601 " to()[!java|c];[/!]\n"
3602 " do()[!java|c];[/!]\n"
3603 "[!java|scala|c]}[/!]"
3604 msgstr ""
3605
3606 #. type: Content of: <p>
3607 #: src/lessons/welcome/methods/basics/Methods.html:26
3608 msgid ""
3609 "The method body [!java|scala|c](between curly braces)[/!][!python](the "
3610 "indented block)[/!] will be executed when we call the method later on (that "
3611 "is, when we write <code>goAndGet()</code> somewhere in our code). This "
3612 "method body can contain as many instructions as you want, and any "
3613 "construction we saw so far (for, while, if, etc). [!java|c]The "
3614 "<code>void</code> keyword means that this method does not return any "
3615 "result. For example, the <code>isOverBaggle()</code> method does return a "
3616 "result, which is a [!c]int[/!][!java]boolean[/!] indicating whether or not "
3617 "the buggle is located over a baggle. We will soon learn to define such "
3618 "methods too. For now, just write <code>void</code> at this location.[/!]"
3619 msgstr ""
3620
3621 #. type: Content of: <h3>
3622 #: src/lessons/welcome/methods/basics/Methods.html:39
3623 msgid "Documenting methods"
3624 msgstr ""
3625
3626 #. type: Content of: <p>
3627 #: src/lessons/welcome/methods/basics/Methods.html:41
3628 msgid ""
3629 "You should strive to document your code to keep it readable. When you write "
3630 "it, its purpose and limitations are clear to you, but most of the time, this "
3631 "does not last for long. You will soon forget about the details of every "
3632 "specific method, and this day you will be happy to read its "
3633 "documentation. In the following example, we use the specific formalism of "
3634 "[!java]javadoc[/!][!scala]scaladoc[/!][!python]pydoc[/!], a program that "
3635 "extracts the documentation of [!thelang] source code to produce html "
3636 "pages. The main advantage is that it allows to keep the documentation near "
3637 "to the code. So, when you change your code, you have less chances to forget "
3638 "to update the documentation."
3639 msgstr ""
3640
3641 #. type: Content of: <p>
3642 #: src/lessons/welcome/methods/basics/Methods.html:50
3643 msgid ""
3644 "[!java|scala][!java]javadoc[/!][!scala]scaladoc[/!] comments begin with the "
3645 "<code>/**</code> marker (with two asterisks). They must be placed right "
3646 "before the method they document for the tool to find them.[/!] "
3647 "[!python]pydoc comments should be placed at the beginning of the method body "
3648 "so that the tool finds them. They should be placed between "
3649 "<code>\"\"\"</code>, which mark multi-line strings in python.[/!] The first "
3650 "line should be a brief description of what this method does while any "
3651 "subsequent lines should provide any important details about the method."
3652 msgstr ""
3653
3654 #. type: Content of: <pre>
3655 #: src/lessons/welcome/methods/basics/Methods.html:59
3656 #, no-wrap
3657 msgid ""
3658 "[!java|scala]/**\n"
3659 " * Go, retrieves the baggle in front of the buggle, and brings it back \n"
3660 " *\n"
3661 " * Does not check for walls, so be careful to not call it when walls are "
3662 "present.\n"
3663 " */[/!]\n"
3664 "[!java]void goAndGet() {[/!]\n"
3665 "[!scala]def goAndGet() {[/!]\n"
3666 "[!python]def goAndGet():\n"
3667 " \"\"\"Go, retrieves the baggle in front of the buggle, and brings it "
3668 "back.\n"
3669 "\n"
3670 " Does not check for walls, so be careful to not call it when walls are "
3671 "present.\"\"\"[/!]\n"
3672 " actions()[!java];[/!]\n"
3673 " to()[!java];[/!]\n"
3674 " do()[!java];[/!]\n"
3675 "[!java|scala]}[/!]"
3676 msgstr ""
3677
3678 #. type: Content of: <h3>
3679 #: src/lessons/welcome/methods/basics/Methods.html:75
3680 msgid "Naming conventions"
3681 msgstr ""
3682
3683 #. type: Content of: <p>
3684 #: src/lessons/welcome/methods/basics/Methods.html:76
3685 msgid ""
3686 "Most programming language forbid the use of spaces in method and variable "
3687 "identifiers (=their names). Accented letters are sometimes allowed (as in "
3688 "[!thelang]), but they can lead to portability issues between operating "
3689 "systems and should thus be avoided when possible."
3690 msgstr ""
3691
3692 #. type: Content of: <p>
3693 #: src/lessons/welcome/methods/basics/Methods.html:80
3694 msgid ""
3695 "Across all programming languages, there is two main conventions to name "
3696 "variables and methods. The first one, consists in concatenating all words "
3697 "with only the first letter of each word in upper case. \"go and get\" "
3698 "becomes goAndGet(). It is called CamelCase because identifiers written this "
3699 "way graphically remind of a camel back. The other convention, called "
3700 "snake_case, is to write every words in lower case, separated with "
3701 "underscores symbols (_). \"go and get\" becomes go_and_get()."
3702 msgstr ""
3703
3704 #. type: Content of: <p>
3705 #: src/lessons/welcome/methods/basics/Methods.html:87
3706 msgid ""
3707 "Which convention to use is the topic of heated discussion across developers, "
3708 "but each programming language has its own habits. In Python, Perl and the C "
3709 "language, the snake_case is often used for methods and variables. Java and "
3710 "Scala prefer the lowerCamelCase (the very first letter is lower case) for "
3711 "that."
3712 msgstr ""
3713
3714 #. type: Content of: <p>
3715 #: src/lessons/welcome/methods/basics/Methods.html:91
3716 msgid ""
3717 "The CamelCase convention is used everywhere in PLM because this program is "
3718 "written in Java itself, so we kept our habits when adding new languages. But "
3719 "the fact that the Python bindings of PLM use the CamelCase instead of the "
3720 "snake_case is considered as a bug that we will fix in further releases."
3721 msgstr ""
3722
3723 #. type: Content of: <p>
3724 #: src/lessons/welcome/methods/basics/Methods.html:97
3725 msgid ""
3726 "The goal of this exercise is to write a method called "
3727 "<code>goAndGet()</code> which does the same than in a previous exercises "
3728 "(move forward until over a baggle, pick it up, move back to initial "
3729 "position, drop baggle)."
3730 msgstr ""
3731
3732 #. type: Content of: <p>
3733 #: src/lessons/welcome/methods/basics/Methods.html:101
3734 msgid ""
3735 "This exercise is a bit different because you will not write all of the code "
3736 "executed by the buggle. Instead, you should only write one method that get "
3737 "called automagically added when you click on <b>Start</b>. Your buggle calls "
3738 "your <code>goAndGet()</code> method on each row, until the baggle is "
3739 "found. [!python|scala]The code for that is already provided under the "
3740 "<code>goAndGet()</code> method, but you probably don't want to change "
3741 "it.[/!] [!java]You don't need to write the code calling "
3742 "<code>goAndGet()</code> yourself. It's automagically there already, even if "
3743 "you cannot see it.[/!]"
3744 msgstr ""
3745
3746 #. type: Content of: <p>
3747 #: src/lessons/welcome/methods/basics/Methods.html:110
3748 msgid ""
3749 "But for that to work, you have to actually write this "
3750 "<code>goAndGet()</code> method now."
3751 msgstr ""
3752
3753 #. type: Content of: outside any tag (error?)
3754 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:4
3755 msgid ""
3756 "We now would like to teach the buggle to build a doghouse. The naive "
3757 "approach consists in directly writing the needed code as follows. This "
3758 "works because the buggle of this exercise leaves a red path as it moves."
3759 msgstr ""
3760
3761 #. type: Content of: <pre>
3762 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:8
3763 #, no-wrap
3764 msgid ""
3765 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3766 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3767 "left()[!java|c];[/!]\n"
3768 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3769 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3770 "left()[!java|c];[/!]\n"
3771 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3772 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3773 "left()[!java|c];[/!]\n"
3774 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3775 "[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]\n"
3776 "left()[!java|c];[/!]"
3777 msgstr ""
3778
3779 #. type: Content of: <p>
3780 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:21
3781 msgid ""
3782 "It becomes harder when we want to draw two doghouses: we have to rewrite the "
3783 "same code twice, which is not really handy. When the code becomes a bit long "
3784 "as this one, it becomes easier to see why we insist since a while on the "
3785 "pure evilness that code duplication represents. Indeed, if you realize that "
3786 "an error sneaked into a code that you copied at several locations, you will "
3787 "have to fix it several times. And mind your back if you forget one of these "
3788 "locations."
3789 msgstr ""
3790
3791 #. type: Content of: <p>
3792 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:27
3793 msgid ""
3794 "There is even a name to this good principle in programming: DRY/SPOT, which "
3795 "means \"Don't Repeat Yourself / Single Point Of Truth\". The latter part "
3796 "means that each information must be written in only one location of your "
3797 "program to avoid the differing locations to get out of synch when you modify "
3798 "your code."
3799 msgstr ""
3800
3801 #. type: Content of: <p>
3802 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:32
3803 msgid ""
3804 "So, let's apply this good principle and <b>factorize our code</b>, ie to "
3805 "write it only once, for example in a method. You should even to go further "
3806 "by factorizing the method body with a <code>for</code> loop, as seen "
3807 "previously. If you do it correctly (what you should), you can use the "
3808 "method <code>left()</code> only once."
3809 msgstr ""
3810
3811 #. type: Content of: <p>
3812 #: src/lessons/welcome/methods/basics/MethodsDogHouse.html:39
3813 msgid ""
3814 "The goal of this exercise is to write a method called <code>dogHouse</code> "
3815 "achieving the same result than the code above, but with a for loop to keep "
3816 "it short. The buggle will call your creation to create several dog houses "
3817 "around its world."
3818 msgstr ""
3819
3820 #. type: Content of: outside any tag (error?)
3821 #: src/lessons/welcome/methods/picture/PictureMono1.html:4
3822 #: src/lessons/welcome/methods/picture/MethodsPicture.html:4
3823 msgid ""
3824 "In this exercise, we will reproduce the geometric drawing that you can see "
3825 "in the \"Objective\" tab."
3826 msgstr ""
3827
3828 #. type: Content of: <p>
3829 #: src/lessons/welcome/methods/picture/PictureMono1.html:7
3830 #: src/lessons/welcome/methods/picture/MethodsPicture.html:7
3831 msgid ""
3832 "Your goal (here and in any well written program) is to write the simplest "
3833 "possible code. For that, you have to decompose your work in sub-steps, and "
3834 "write a specific method for each sub-step."
3835 msgstr ""
3836
3837 #. type: Content of: <p>
3838 #: src/lessons/welcome/methods/picture/PictureMono1.html:11
3839 msgid ""
3840 "If you observe carefully the picture to draw, it is constituted of four "
3841 "parts depicting a sort of V. A possible decomposition is to write a method "
3842 "in charge of drawing a V from the current position. Its prototype can be: "
3843 "<code>[!java|c]void [/!]makeV()</code>"
3844 msgstr ""
3845
3846 #. type: Content of: <p>
3847 #: src/lessons/welcome/methods/picture/PictureMono1.html:16
3848 msgid ""
3849 "In this method, you should use the methods <code>brushUp()</code> and "
3850 "<code>brushDown()</code> to mark the ground (you may want to factorize this "
3851 "in another method). It may be wise to write the <code>makeV()</code> so that "
3852 "it places directly the buggle in position for the next V."
3853 msgstr ""
3854
3855 #. type: Content of: <p>
3856 #: src/lessons/welcome/methods/picture/PictureMono1.html:21
3857 msgid ""
3858 "Your turn. Your code should not be longer than 4 lines (not counting "
3859 "<code>makeV</code>)..."
3860 msgstr ""
3861
3862 #. type: Content of: outside any tag (error?)
3863 #: src/lessons/welcome/methods/picture/PictureMono2.html:4
3864 msgid ""
3865 "We will now reproduce an even bigger geometrical drawing. Once again, you "
3866 "can see the model by clicking on the \"Objective\" tab."
3867 msgstr ""
3868
3869 #. type: Content of: <p>
3870 #: src/lessons/welcome/methods/picture/PictureMono2.html:7
3871 msgid ""
3872 "You can naturally reuse all the code you typed in previous exercise (select "
3873 "the other exercise, do Ctrl-C, come back to the code of this exercise, do "
3874 "Ctrl-V)."
3875 msgstr ""
3876
3877 #. type: Content of: <p>
3878 #: src/lessons/welcome/methods/picture/PictureMono2.html:11
3879 msgid ""
3880 "But you want to keep your code as simple as possible. For that, define new "
3881 "methods to deal simply with the repetitions in the pattern. For example, a "
3882 "method <code>makePattern()</code> achieving the pattern of previous example "
3883 "seems to be a good idea (but this may not be enough)."
3884 msgstr ""
3885
3886 #. type: Content of: <p>
3887 #: src/lessons/welcome/methods/picture/PictureMono2.html:16
3888 msgid ""
3889 "Why don't you give it a shot? The main code method shouldn't take more than "
3890 "2 lines (included in a for loop)"
3891 msgstr ""
3892
3893 #. type: Content of: outside any tag (error?)
3894 #: src/lessons/welcome/methods/picture/PictureMono3.html:4
3895 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:4
3896 msgid ""
3897 "As you can imagine, you have to reproduce the geometric drawing depicted in "
3898 "the \"Objectives\" tab. As you can see, it is even bigger than the previous "
3899 "one."
3900 msgstr ""
3901
3902 #. type: Content of: <p>
3903 #: src/lessons/welcome/methods/picture/PictureMono3.html:8
3904 msgid ""
3905 "You thus have to declare even more methods to use the repetitions of the "
3906 "pattern and factorize your code. Your turn..."
3907 msgstr ""
3908
3909 #. type: Content of: <h1>
3910 #: src/lessons/welcome/methods/returning/MethodsReturning.html:2
3911 #: src/lessons/lightbot/Board06Func.html:2
3912 msgid "Functions"
3913 msgstr ""
3914
3915 #. type: Content of: <p>
3916 #: src/lessons/welcome/methods/returning/MethodsReturning.html:4
3917 msgid ""
3918 "Quite often, you want to write a method that compute some value and returns "
3919 "it. Methods returning results are called <b>functions</b>. Writing a "
3920 "function is not really harder than writing a simple method. [!java|c]You "
3921 "simply have to specify the data type of expected results before the function "
3922 "name (where we previously had <code>void</code>).[/!] [!scala]You simply "
3923 "have to add a colon (:) after the parenthesis and write the type of data "
3924 "that your function will return, and add an equal sign (=). This syntax is "
3925 "actually rather close to defining a variable, with its type, that is "
3926 "actually a function.[/!] You can use the <code>return</code> instruction "
3927 "anywhere in your function body to specify that the computation is done (the "
3928 "function is not further executed), and that the result is the value "
3929 "following the <code>return</code> keyword."
3930 msgstr ""
3931
3932 #. type: Content of: <pre>
3933 #: src/lessons/welcome/methods/returning/MethodsReturning.html:14
3934 #, no-wrap
3935 msgid ""
3936 "[!java|c]double pi() {[/!][!scala]def pi(): Double = {[/!][!python]def "
3937 "pi():[/!]\n"
3938 " return 3.14159[!java|c];[/!]\n"
3939 "[!java|scala|c]}[/!]"
3940 msgstr ""
3941
3942 #. type: Content of: <p>
3943 #: src/lessons/welcome/methods/returning/MethodsReturning.html:18
3944 msgid ""
3945 "Actually, you can also use that <code>return</code> keyword in methods that "
3946 "do not return any result, to interupt the computation. Of course, you should "
3947 "not provide any value to return in that case."
3948 msgstr ""
3949
3950 #. type: Content of: <p>
3951 #: src/lessons/welcome/methods/returning/MethodsReturning.html:21
3952 msgid ""
3953 "It is possible to have several <code>return</code> instructions in several "
3954 "branches of a conditional. In fact, it is forbidden to have any execution "
3955 "path of your body without any <code>return</code>, or to write some code "
3956 "after the <code>return</code> instruction. Indeed, if the machine reaches "
3957 "the end of the function without finding any <code>return</code>, it cannot "
3958 "know what actual value to give back to the function caller. Moreover, "
3959 "<code>return</code> interrupts immediately the function execution (why "
3960 "bother looking further when you know the function result?). So, if there is "
3961 "some code after a <code>return</code>, it must be an error and the compiler "
3962 "warns you."
3963 msgstr ""
3964
3965 #. type: Content of: <pre>
3966 #: src/lessons/welcome/methods/returning/MethodsReturning.html:32
3967 #, no-wrap
3968 msgid ""
3969 "[!java|scala|c][!java]boolean [/!][!c]int [/!][!scala]def "
3970 "[/!]isFrontFree()[!scala]:Boolean =[/!] {\n"
3971 " if (isFacingWall() == [!java|scala]true[/!][!c]1[/!]) {\n"
3972 " return [!java|scala]false[/!][!c]0[/!];\n"
3973 " <span class=\"comment\">/* no code allowed here */</span>\n"
3974 " } else {\n"
3975 " return [!java|scala]true[/!][!c]1[/!];\n"
3976 " <span class=\"comment\">/* here neither */</span>\n"
3977 " }\n"
3978 " <span class=\"comment\">/* even here, forget it */</span>\n"
3979 "}[/!][!python]def isFrontFree():\n"
3980 " if isFacingWall() == True:\n"
3981 " return False\n"
3982 " <span class=\"comment\"># no code allowed here</span>\n"
3983 " else\n"
3984 " return True\n"
3985 " <span class=\"comment\"># here neither</span>\n"
3986 "<span class=\"comment\"># even here, forget it</span>[/!]"
3987 msgstr ""
3988
3989 #. type: Content of: outside any tag (error?)
3990 #: src/lessons/welcome/methods/returning/MethodsReturning.html:50
3991 msgid ""
3992 "You will once again write a function that the buggle will use. Its name must "
3993 "be <code>haveBaggle</code>, and it returns a boolean value indicating "
3994 "whether the row in front of the buggle contains a baggle or not. The buggle "
3995 "will use it to search the first row containing a baggle, and stop here."
3996 msgstr ""
3997
3998 #. type: Content of: <p>
3999 #: src/lessons/welcome/methods/returning/MethodsReturning.html:55
4000 msgid ""
4001 "The easier for this function is to use a boolean variable called "
4002 "<code>seenBaggle</code> indicating whether or not we saw a baggle so "
4003 "far. Its initial value is "
4004 "'[!python]False[/!][!scala|java]false[/!][!c]0[/!]'."
4005 msgstr ""
4006
4007 #. type: Content of: <p>
4008 #: src/lessons/welcome/methods/returning/MethodsReturning.html:59
4009 msgid ""
4010 "Then, move 6 steps forward (the world contains 7 cells and we already are on "
4011 "one of them). For each cell, if it contains a baggle, we store true in "
4012 "<code>sawBaggle</code> (and we don't do anything but moving forward if not)."
4013 msgstr ""
4014
4015 #. type: Content of: <p>
4016 #: src/lessons/welcome/methods/returning/MethodsReturning.html:63
4017 msgid ""
4018 "At the end, we move back by 6 steps, and we return the value of "
4019 "<code>seenBaggle</code> to the caller."
4020 msgstr ""
4021
4022 #. type: Content of: <p>
4023 #: src/lessons/welcome/methods/returning/MethodsReturning.html:66
4024 msgid ""
4025 "Note that the used buggle provides some hidden code that will call your "
4026 "<code>haveBaggle</code> function on each column, moving automatically "
4027 "between columns. It is thus very important that your <code>haveBaggle</code> "
4028 "function have no side effect: the position (and orientation) at the end of "
4029 "your code must be the one observed at the beginning of this code. It will "
4030 "move in between to seek for the baggle, but come back to the column start."
4031 msgstr ""
4032
4033 #. type: Content of: <p>
4034 #: src/lessons/welcome/methods/returning/MethodsReturning.html:73
4035 msgid ""
4036 "Also, this exercise is a bit different since there is two initial worlds, "
4037 "each with a specific objective. Your code must work for each of "
4038 "them. Observe that the world selection scrolling menu (right below the speed "
4039 "slider) allows to switch the observed world."
4040 msgstr ""
4041
4042 #. type: Content of: <p>
4043 #: src/lessons/welcome/methods/returning/MethodsReturning.html:78
4044 msgid "When your function <code>haveBaggle</code> works, proceed to next exercise."
4045 msgstr ""
4046
4047 #. type: Content of: <p>
4048 #: src/lessons/welcome/methods/args/MethodsArgs.html:4
4049 msgid ""
4050 "Don't you get tired of writing again and again the code to move by a fixed "
4051 "amount of steps? On the other hand, writing <tt>forward2()</tt>, "
4052 "<tt>forward3()</tt>, <tt>forward4()</tt>, as well as <tt>backward2()</tt>, "
4053 "<tt>backward3()</tt>, <tt>backward4()</tt>, and so on does not really help, "
4054 "to say the less."
4055 msgstr ""
4056
4057 #. type: Content of: <p>
4058 #: src/lessons/welcome/methods/args/MethodsArgs.html:10
4059 msgid ""
4060 "Luckily, it is possible to pass <b>parameters</b> to your methods. You have "
4061 "to specify their type and name between the parenthesis after the method "
4062 "name. Then, you can use them in the method body as if it were variables "
4063 "defined in there, and which initial value is what the caller specified."
4064 msgstr ""
4065
4066 #. type: Content of: <pre>
4067 #: src/lessons/welcome/methods/args/MethodsArgs.html:15
4068 #, no-wrap
4069 msgid ""
4070 "[!java|c]double [/!]divideByTwo([!java|c]double [/!]x[!scala]: "
4071 "Double[/!])[!scala]: Double =[/!] [!java|scala|c]{[/!][!python]:[/!]\n"
4072 " return x / 2[!java|c];[/!]\n"
4073 "[!scala|java|c]}[/!]"
4074 msgstr ""
4075
4076 #. type: Content of: <p>
4077 #: src/lessons/welcome/methods/args/MethodsArgs.html:19
4078 msgid ""
4079 "As caller, you have to specify the initial value of this \"variables\" "
4080 "between the call's parenthesis."
4081 msgstr ""
4082
4083 #. type: Content of: <pre>
4084 #: src/lessons/welcome/methods/args/MethodsArgs.html:21
4085 #, no-wrap
4086 msgid "[!java|c]double [/!][!scala]val [/!]result = divideByTwo(3.14)[!java|c];[/!]"
4087 msgstr ""
4088
4089 #. type: Content of: <p>
4090 #: src/lessons/welcome/methods/args/MethodsArgs.html:23
4091 msgid ""
4092 "If you want several parameters, you need to separate them with comas (,) "
4093 "both in the declaration and calls."
4094 msgstr ""
4095
4096 #. type: Content of: <pre>
4097 #: src/lessons/welcome/methods/args/MethodsArgs.html:26
4098 #, no-wrap
4099 msgid ""
4100 "[!java|c]double divide(double x, double y) {[/!]\n"
4101 "[!scala]def divide(x:Double, y:Double): Double = {[/!]\n"
4102 "[!python]def divide(x, y):[/!]\n"
4103 " return x / y[!java|c];[/!]\n"
4104 "[!java|scala|c]}[/!]"
4105 msgstr ""
4106
4107 #. type: Content of: <pre>
4108 #: src/lessons/welcome/methods/args/MethodsArgs.html:31
4109 #, no-wrap
4110 msgid ""
4111 "[!java|c]double res = divide(3.14 , 1.5);[/!]\n"
4112 "[!scala]val res = divide(3.14 , 1.5)[/!]\n"
4113 "[!python]res = divide(3.14 , 1.5)[/!]"
4114 msgstr ""
4115
4116 #. type: Content of: outside any tag (error?)
4117 #: src/lessons/welcome/methods/args/MethodsArgs.html:35
4118 #: src/lessons/welcome/methods/picture/MethodsPicture.html:35
4119 msgid "[!java|scala]"
4120 msgstr ""
4121
4122 #. type: Content of: <p>
4123 #: src/lessons/welcome/methods/args/MethodsArgs.html:36
4124 msgid ""
4125 "In [!thelang], you can declare several methods of the same name as long as "
4126 "they don't have the same <b>signature</b>, that is, the same amount of "
4127 "parameters and the same parameters' types."
4128 msgstr ""
4129
4130 #. type: Content of: <pre>
4131 #: src/lessons/welcome/methods/args/MethodsArgs.html:40
4132 #, no-wrap
4133 msgid ""
4134 "[!java]double max(double x, double y)[/!][!scala]def max(x:Double, "
4135 "y:Double): Double =[/!] {\n"
4136 " if (x > y) {\n"
4137 " return x;\n"
4138 " }\n"
4139 " return y;\n"
4140 "}[!java]int max(int x, int y)[/!][!scala]def max(x:Int, y:Int): Int =[/!] "
4141 "{\n"
4142 " if (x > y) {\n"
4143 " return x;\n"
4144 " }\n"
4145 " return y;\n"
4146 "}\n"
4147 "[!java]int max(int x, int y; int z)[/!][!scala]def max(x:Int, y:Int, z:Int): "
4148 "Int =[/!] {\n"
4149 " if (x > y && x > z) {\n"
4150 " return x;\n"
4151 " }\n"
4152 " if (y > z) {\n"
4153 " return y;\n"
4154 " }\n"
4155 " return z;\n"
4156 "}"
4157 msgstr ""
4158
4159 #. type: Content of: <p>
4160 #: src/lessons/welcome/methods/args/MethodsArgs.html:61
4161 msgid ""
4162 "Observe that we omitted the <tt>else</tt> branches of each <tt>if</tt>. It "
4163 "works anyway because a <tt>return</tt> interrupts the method execution. If "
4164 "we arrive to the last line of "
4165 "<code>[!java]max(int,int)[/!][!scala]max(Int,Int):Int[/!]</code>, we know "
4166 "that <code>x&lt;=y</code> because otherwise, the <tt>return</tt> of line 2 "
4167 "would have stopped the execution."
4168 msgstr ""
4169
4170 #. type: Content of: <p>
4171 #: src/lessons/welcome/methods/args/MethodsArgs.html:71
4172 msgid ""
4173 "This time, you have to write a <code> [!java|c]move(int "
4174 "stepCount,[!java]boolean[/!][!c]int[/!] forward)[/!] [!scala]move(stepCount: "
4175 "Int,forward: Boolean)[/!] [!python]move(stepCount,forward)[/!] </code> "
4176 "method which moves forward by <code>stepCount</code> steps if "
4177 "<code>forward</code> is true, and moves back of that amount of steps if the "
4178 "boolean is false."
4179 msgstr ""
4180
4181 #. type: Content of: <p>
4182 #: src/lessons/welcome/methods/args/MethodsArgs.html:79
4183 msgid ""
4184 "This time, there is only one world but seven buggles, all sharing the same "
4185 "code. This code should not be really problematic for you to write, "
4186 "actually."
4187 msgstr ""
4188
4189 #. type: Content of: <h2>
4190 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:2
4191 msgid "Flower Pot"
4192 msgstr ""
4193
4194 #. type: Content of: <p>
4195 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:4
4196 msgid ""
4197 "Your buggle decided to flower a bit the pot it lives in. You have to help it "
4198 "reproducing the drawing of its dreams (check the \"Objective\" tab to see "
4199 "it)."
4200 msgstr ""
4201
4202 #. type: Content of: <p>
4203 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:7
4204 msgid ""
4205 "For that, you have to write a <code>growFlowers()</code> method that does "
4206 "not take any parameter and does not return any result. You could probably "
4207 "make it without defining this method, but this is part of the assignment."
4208 msgstr ""
4209
4210 #. type: Content of: <p>
4211 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:11
4212 msgid ""
4213 "Also, you should try to decompose this complex drawing in sub-steps so that "
4214 "your code remains short and easy to read. A method to draw one flower of the "
4215 "color passed in parameter sounds like a good start, but it is probably not "
4216 "enough."
4217 msgstr ""
4218
4219 #. type: Content of: <p>
4220 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:15
4221 msgid ""
4222 "For your information, this drawing uses five colors that are listed below. "
4223 "[!java|scala|c]The data type of these constants is <code>Color</code>, that "
4224 "naturally describes a particular color.[/!]"
4225 msgstr ""
4226
4227 #. type: Content of: <ul><li>
4228 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:20
4229 msgid "<code>[!scala|java|python]Color.[/!]RED</code>"
4230 msgstr ""
4231
4232 #. type: Content of: <ul><li>
4233 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:21
4234 msgid "<code>[!scala|java|python]Color.[/!]PINK</code>"
4235 msgstr ""
4236
4237 #. type: Content of: <ul><li>
4238 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:22
4239 msgid "<code>[!scala|java|python]Color.[/!]CYAN</code>"
4240 msgstr ""
4241
4242 #. type: Content of: <ul><li>
4243 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:23
4244 msgid "<code>[!scala|java|python]Color.[/!]ORANGE</code>"
4245 msgstr ""
4246
4247 #. type: Content of: <ul><li>
4248 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:24
4249 msgid "<code>[!scala|java|python]Color.[/!]GREEN</code>"
4250 msgstr ""
4251
4252 #. type: Content of: <ul><li>
4253 #: src/lessons/welcome/methods/flowerpot/FlowerPot.html:25
4254 msgid "<code>[!scala|java|python]Color.[/!]YELLOW</code>"
4255 msgstr ""
4256
4257 #. type: Content of: <h2>
4258 #: src/lessons/welcome/methods/flowerpot/FlowerCase.html:2
4259 msgid "Flower Display Case"
4260 msgstr ""
4261
4262 #. type: Content of: <p>
4263 #: src/lessons/welcome/methods/flowerpot/FlowerCase.html:4
4264 msgid ""
4265 "Whao! That's not a little pot anymore! That's a huge large flower display "
4266 "case! Your buggle can't help but starts flowering this gorgeous place. You "
4267 "should help it to prevent that it bumps into a wall..."
4268 msgstr ""
4269
4270 #. type: Content of: <p>
4271 #: src/lessons/welcome/methods/flowerpot/FlowerCase.html:8
4272 msgid "PS: the newly used color is <code>Color.BLUE</code>."
4273 msgstr ""
4274
4275 #. type: Content of: <h2>
4276 #: src/lessons/welcome/methods/picture/MethodsPicture.html:2
4277 msgid "Colorful drawing"
4278 msgstr ""
4279
4280 #. type: Content of: <p>
4281 #: src/lessons/welcome/methods/picture/MethodsPicture.html:11
4282 msgid ""
4283 "If you observe carefully the picture to draw, it is constituted of four "
4284 "parts depicting a sort of V using a different color. A possible "
4285 "decomposition is to write a method in charge of drawing a V of the specified "
4286 "color from the current position. Its prototype can be:"
4287 msgstr ""
4288
4289 #. type: Content of: <pre>
4290 #: src/lessons/welcome/methods/picture/MethodsPicture.html:15
4291 #, no-wrap
4292 msgid ""
4293 "[!java|c]void [/!]makeV([!java|c]Color [/!]c[!scala]: Color[/!])[!python] "
4294 "<span class=\"comment\"># parameter c is of type Color</span>[/!]"
4295 msgstr ""
4296
4297 #. type: Content of: <p>
4298 #: src/lessons/welcome/methods/picture/MethodsPicture.html:17
4299 msgid ""
4300 "The <code>Color</code> data type naturally describes a particular "
4301 "color. Your code should probably call <code>makeV</code> with the following "
4302 "arguments (a different color for each call):"
4303 msgstr ""
4304
4305 #. type: Content of: <ul><li>
4306 #: src/lessons/welcome/methods/picture/MethodsPicture.html:21
4307 msgid "[!java|scala|python]Color.[/!]YELLOW"
4308 msgstr ""
4309
4310 #. type: Content of: <ul><li>
4311 #: src/lessons/welcome/methods/picture/MethodsPicture.html:22
4312 msgid "[!java|scala|python]Color.[/!]RED"
4313 msgstr ""
4314
4315 #. type: Content of: <ul><li>
4316 #: src/lessons/welcome/methods/picture/MethodsPicture.html:23
4317 msgid "[!java|scala|python]Color.[/!]BLUE"
4318 msgstr ""
4319
4320 #. type: Content of: <ul><li>
4321 #: src/lessons/welcome/methods/picture/MethodsPicture.html:24
4322 msgid "[!java|scala|python]Color.[/!]GREEN"
4323 msgstr ""
4324
4325 #. type: Content of: <p>
4326 #: src/lessons/welcome/methods/picture/MethodsPicture.html:27
4327 msgid ""
4328 "In <code>makeV()</code>, you should use the <code>setBrushColor()</code> "
4329 "method (predefined in the buggle) to change the color of the buggle's brush, "
4330 "as well as <code>brushUp()</code> and <code>brushDown()</code> to change the "
4331 "brush position."
4332 msgstr ""
4333
4334 #. type: Content of: <p>
4335 #: src/lessons/welcome/methods/picture/MethodsPicture.html:32
4336 msgid ""
4337 "It may be wise to write the <code>makeV()</code> so that it places directly "
4338 "the buggle in position for the next V."
4339 msgstr ""
4340
4341 #. type: Content of: <p>
4342 #: src/lessons/welcome/methods/picture/MethodsPicture.html:36
4343 msgid ""
4344 "Your turn now. I'm sure you can imagine the other methods you need to keep "
4345 "your code simple and pleasant to read. Complete the method "
4346 "<code>run()</code> that should be called automatically (once). [!java]the "
4347 "<code>public</code> keyword means more or less that anybody can call this "
4348 "method, which is good because the PLM infrastructure calls it directly.[/!]"
4349 msgstr ""
4350
4351 #. type: Content of: <h2>
4352 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:2
4353 msgid "Larger colorful drawing"
4354 msgstr ""
4355
4356 #. type: Content of: <p>
4357 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:8
4358 msgid ""
4359 "You thus have to declare even more methods to use the repetitions of the "
4360 "pattern and factorize your code. Another solution is to <i>parametrize</i> "
4361 "your functions to reuse the code you wrote previously by changing the size."
4362 msgstr ""
4363
4364 #. type: Content of: <p>
4365 #: src/lessons/welcome/methods/picture/MethodsPictureLarge.html:13
4366 #: src/lessons/welcome/traversal/Snake.html:40
4367 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:50
4368 #: src/lessons/welcome/traversal/line/TraversalByLine.html:11
4369 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:11
4370 #: src/lessons/welcome/traversal/zigzag/TraversalZigZag.html:7
4371 msgid "Your turn..."
4372 msgstr ""
4373
4374 #. type: Content of: <h2>
4375 #: src/lessons/welcome/methods/picture/PatternPicture.html:2
4376 msgid "Another Colorful Pattern"
4377 msgstr ""
4378
4379 #. type: Content of: outside any tag (error?)
4380 #: src/lessons/welcome/methods/picture/PatternPicture.html:4
4381 msgid ""
4382 "Here is yet another exercise where you have to reproduce the pattern "
4383 "provided in the \"Objective\" tab."
4384 msgstr ""
4385
4386 #. type: Content of: <p>
4387 #: src/lessons/welcome/methods/picture/PatternPicture.html:7
4388 msgid ""
4389 "This one is a bit more difficult than the one seen previously. Look for "
4390 "repeating patterns, even if the color changes, and write a method drawing "
4391 "each of them."
4392 msgstr ""
4393
4394 #. type: Content of: <p>
4395 #: src/lessons/welcome/methods/picture/PatternPicture.html:11
4396 #: src/lessons/lander/lvl1_lander_101/Lander101.html:42
4397 msgid "Good luck!"
4398 msgstr ""
4399
4400 #. type: Content of: <p>
4401 #: src/lessons/welcome/methods/slug/SlugHunting.html:4
4402 msgid ""
4403 "Now that your <code>isFacingTrail()</code> method is working, it's time to "
4404 "write the code to organize the hunting party. Copy/paste your code from the "
4405 "previous exercise, and complete the <code>hunt()</code> method."
4406 msgstr ""
4407
4408 #. type: Content of: <p>
4409 #: src/lessons/welcome/methods/slug/SlugHunting.html:8
4410 msgid ""
4411 "Following a track is not very difficult: move forward as long as you have "
4412 "the track in front of you. If there is not track in front of you anymore, "
4413 "check whether the rest of the track is on your left or on your right, and "
4414 "follow it further."
4415 msgstr ""
4416
4417 #. type: Content of: <p>
4418 #: src/lessons/welcome/methods/slug/SlugHunting.html:12
4419 msgid ""
4420 "To ensure that you don't mix the track you come from with the one in front "
4421 "of you, the easier is to erase the track when you follow it. Use the method "
4422 "<code>brushDown()</code> to put your brush down and mark the ground, and "
4423 "<code>brushUp()</code> to move it up again."
4424 msgstr ""
4425
4426 #. type: Content of: <p>
4427 #: src/lessons/welcome/methods/slug/SlugHunting.html:16
4428 msgid ""
4429 "Finally, do not forget to capture your prey once you found it (using "
4430 "<code>pickupBaggle()</code>)."
4431 msgstr ""
4432
4433 #. type: Content of: outside any tag (error?)
4434 #: src/lessons/welcome/methods/slug/SlugHunting.html:20
4435 msgid ""
4436 "<a name=\"Objectives\"> Complete the <code>hunt()</code> method. You "
4437 "probably want to copy over the <code>isFacingTrail()</code> method that you "
4438 "wrote in previous exercise. </a>"
4439 msgstr ""
4440
4441 #. type: Content of: <p>
4442 #: src/lessons/welcome/methods/slug/SlugTracking.html:4
4443 msgid ""
4444 "Your buggle is super happy! It just found the green dribbling trail, "
4445 "certainly left by a big yummy slug. At its end, the buggle is certain to "
4446 "entertain itself with this appetizing slug (represented as a baggle)."
4447 msgstr ""
4448
4449 #. type: Content of: <p>
4450 #: src/lessons/welcome/methods/slug/SlugTracking.html:8
4451 msgid ""
4452 "To reach that goal, you had to write a method <tt>isFacingTrail</tt> that "
4453 "will be called automatically by the buggle on each step. Your method should "
4454 "return [!python]True[/!][!java|scala]true[/!] if facing a green cell, or "
4455 "[!python]False[/!][!java|scala]false[/!] if not. Of course, if we are facing "
4456 "a wall, it should return false without bumping into it. You should make sure "
4457 "that this method has no <b>side effect</b>, i.e. that it does not change the "
4458 "state of the calling buggle nor of its world."
4459 msgstr ""
4460
4461 #. type: Content of: <p>
4462 #: src/lessons/welcome/methods/slug/SlugTracking.html:14
4463 msgid ""
4464 "Your tool to that end is the <code>getGroundColor()</code> that returns the "
4465 "color of the current cell. Just go to the cell you want to test and run that "
4466 "function. [!java]You cannot test whether this color is equal to "
4467 "<code>Color.green</code> with an <code>==</code> sign but instead you have "
4468 "to write something like "
4469 "<code>getGroundColor().equals(Color.green)</code>. This is because green is "
4470 "an <i>object</i> in Java, and <code>.equals()</code> is the way to go to "
4471 "test equality between Java objects.[/!] [!python|scala|c]So you just have to "
4472 "test whether the returned color is equal to the value "
4473 "<code>[!scala|python]Color.green[/!][!c]GREEN[/!]</code>, that represents "
4474 "the green color.[/!]"
4475 msgstr ""
4476
4477 #. type: Content of: <p>
4478 #: src/lessons/welcome/methods/slug/SlugTracking.html:25
4479 msgid ""
4480 "Complete the <code>isFacingTrail()</code> method (which gets called "
4481 "automatically)."
4482 msgstr ""
4483
4484 #. type: Content of: <h2>
4485 #: src/lessons/welcome/methods/slug/SlugSnail.html:2
4486 msgid "Slugs and Snails"
4487 msgstr ""
4488
4489 #. type: Content of: <p>
4490 #: src/lessons/welcome/methods/slug/SlugSnail.html:4
4491 msgid ""
4492 "Yuhu! This time, your buggle found the tracks of much more preys! In the "
4493 "first world, that's a yummy Kitty Slug (leaving a pink trail) while on the "
4494 "second world, that's a big fat snail that awaits your buggle at the end of "
4495 "the orange trail."
4496 msgstr ""
4497
4498 #. type: Content of: <p>
4499 #: src/lessons/welcome/methods/slug/SlugSnail.html:8
4500 msgid ""
4501 "You have to copy/paste your code again, and change it so that your methods "
4502 "take the color of the trail to follow as a parameter. Beside of this, your "
4503 "code should work as earlier."
4504 msgstr ""
4505
4506 #. type: Content of: <p>
4507 #: src/lessons/welcome/methods/slug/SlugSnail.html:11
4508 msgid ""
4509 "Don't get lost on false leads! <code>The hunt()</code> method was given a "
4510 "parameter to tell you which color to follow (and it is not the same in all "
4511 "worlds). Add a parameter to your <code>isFacingTrail()</code> method to only "
4512 "follow the requested color, as the other colors lead to dead ends..."
4513 msgstr ""
4514
4515 #. type: Content of: <h2>
4516 #: src/lessons/welcome/bdr/BDR.html:2
4517 msgid "Buggle Dance Revolution (BDR)"
4518 msgstr ""
4519
4520 #. type: Content of: <p>
4521 #: src/lessons/welcome/bdr/BDR.html:4
4522 msgid ""
4523 "After these races, it's time to party! For that, we will teach the buggles "
4524 "to play Dance Revolution, this game beloved of some students: The player has "
4525 "to move the feet on the carpet according to the instructions presented on "
4526 "the screen, and following the music. But before that, we have some details "
4527 "to study first."
4528 msgstr ""
4529
4530 #. type: Content of: outside any tag (error?)
4531 #: src/lessons/welcome/bdr/BDR.html:9 src/lessons/welcome/bdr/BDR2.html:4
4532 #: src/lessons/recursion/lego/square/FourSquare.html:28
4533 msgid "[!java|scala|c]"
4534 msgstr ""
4535
4536 #. type: Content of: <h3>
4537 #: src/lessons/welcome/bdr/BDR.html:10
4538 msgid "Conditionals without curly braces"
4539 msgstr ""
4540
4541 #. type: Content of: <p>
4542 #: src/lessons/welcome/bdr/BDR.html:12
4543 msgid ""
4544 "There is one detail we omitted about the conditional syntax: if a branch "
4545 "contains only one instruction, then the curly braces become optional. So, "
4546 "the two chunk of code are equivalent:"
4547 msgstr ""
4548
4549 #. type: Content of: <pre>
4550 #: src/lessons/welcome/bdr/BDR.html:16
4551 #, no-wrap
4552 msgid ""
4553 "if (<b>condition</b>) {\n"
4554 " <b>whatToDoIfTheConditionIsTrue();</b>\n"
4555 "} else {\n"
4556 " <b>whatToDoElse();</b>\n"
4557 "}"
4558 msgstr ""
4559
4560 #. type: Content of: <pre>
4561 #: src/lessons/welcome/bdr/BDR.html:21
4562 #, no-wrap
4563 msgid ""
4564 "if (<b>condition</b>) \n"
4565 " <b>whatToDoIfTheConditionIsTrue();</b>\n"
4566 "else\n"
4567 " <b>whatToDoElse();</b>"
4568 msgstr ""
4569
4570 #. type: Content of: <p>
4571 #: src/lessons/welcome/bdr/BDR.html:26
4572 msgid ""
4573 "Actually, you can do the same for loops body that are reduced to one "
4574 "instruction only. But beware, this becomes dangerous if you chain the "
4575 "<tt>if</tt> instructions like this:"
4576 msgstr ""
4577
4578 #. type: Content of: <pre>
4579 #: src/lessons/welcome/bdr/BDR.html:28
4580 #, no-wrap
4581 msgid ""
4582 "if (isOverBaggle()) \n"
4583 " if (x == 5)\n"
4584 " left();\n"
4585 "else // Do not write it this way, it's misleading!\n"
4586 " right(); \n"
4587 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
4588 msgstr ""
4589
4590 #. type: Content of: <p>
4591 #: src/lessons/welcome/bdr/BDR.html:35
4592 msgid ""
4593 "You think that <code>right()</code> refers to the first <code>if</code> and "
4594 "get executed when <code>isOverBaggle()</code> returns false, but in fact, it "
4595 "refers to the second one <code>if</code> and will be executed when "
4596 "<code>isOverBaggle()</code> returns true and <code>x != 5</code>. Yes, "
4597 "despite the indentation, the buggle understands the previous code as "
4598 "follows:"
4599 msgstr ""
4600
4601 #. type: Content of: <pre>
4602 #: src/lessons/welcome/bdr/BDR.html:42
4603 #, no-wrap
4604 msgid ""
4605 "if (isOverBaggle()) \n"
4606 " if (x == 5)\n"
4607 " left();\n"
4608 " else\n"
4609 " right();\n"
4610 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
4611 msgstr ""
4612
4613 #. type: Content of: <p>
4614 #: src/lessons/welcome/bdr/BDR.html:49
4615 msgid ""
4616 "In [!thelang] the computer connects a <tt>else</tt> branch to the closest "
4617 "<tt>if</tt>. If you find it ambiguous, you should add more braces than "
4618 "strictly necessary. Computers don't even look at the indentation in "
4619 "[!thelang]. The previous code could even be written as follows and lead to "
4620 "the same result."
4621 msgstr ""
4622
4623 #. type: Content of: <pre>
4624 #: src/lessons/welcome/bdr/BDR.html:55
4625 #, no-wrap
4626 msgid ""
4627 "if (isOverBaggle()) if (x == 5) left(); else right(); "
4628 "[!c]stepForward();[/!][!java|scala]forward();[/!]"
4629 msgstr ""
4630
4631 #. type: Content of: <p>
4632 #: src/lessons/welcome/bdr/BDR.html:57
4633 msgid ""
4634 "But for humans, <b>you really want to indent your code correctly "
4635 "correctly</b>. For example if you want a professor to review or even grade "
4636 "your code, if you want to reuse your own code later, or even if you need to "
4637 "debug it. That is right: you need to write readable code for your own "
4638 "comfort."
4639 msgstr ""
4640
4641 #. type: Content of: <h3>
4642 #: src/lessons/welcome/bdr/BDR.html:63
4643 msgid "Chaining conditionals"
4644 msgstr ""
4645
4646 #. type: Content of: <p>
4647 #: src/lessons/welcome/bdr/BDR.html:65
4648 msgid "You sometimes want to ask the buggle something similar to:"
4649 msgstr ""
4650
4651 #. type: Content of: <pre>
4652 #: src/lessons/welcome/bdr/BDR.html:66
4653 #, no-wrap
4654 msgid ""
4655 "if it's raining, take an umbrella;\n"
4656 "if not, and if it's a hot day, take a bottle of water;\n"
4657 "if not and if it's July 4th, take an American flag"
4658 msgstr ""
4659
4660 #. type: Content of: <p>
4661 #: src/lessons/welcome/bdr/BDR.html:70
4662 msgid ""
4663 "The trap is that we want at most one of these actions to be taken. That is "
4664 "to say, if it's raining a very hot July 4th, we don't want the buggle to get "
4665 "outside with an umbrella, some water and a flag, but simply with an "
4666 "umbrella. The following code is thus WRONG."
4667 msgstr ""
4668
4669 #. type: Content of: <pre>
4670 #: src/lessons/welcome/bdr/BDR.html:75
4671 #, no-wrap
4672 msgid ""
4673 "[!scala|c|java]if (rainy())\n"
4674 " takeUmbrella();\n"
4675 "if (hot())\n"
4676 " takeWater();\n"
4677 "if (todayIsJuly4th())\n"
4678 " takeFlag();[/!][!python]if rainy():\n"
4679 " takeUmbrella()\n"
4680 "if hot():\n"
4681 " takeWater()\n"
4682 "if todayIsJuly4th():\n"
4683 " takeFlag()[/!]"
4684 msgstr ""
4685
4686 #. type: Content of: <p>
4687 #: src/lessons/welcome/bdr/BDR.html:88
4688 msgid ""
4689 "Indeed, since the conditions are evaluated one after the other, there is a "
4690 "risk that you go to the July 4th march on a rainy day. Instead, we should "
4691 "use something like this to ensure that once we found a true condition, we "
4692 "won't evaluate the next ones."
4693 msgstr ""
4694
4695 #. type: Content of: <pre>
4696 #: src/lessons/welcome/bdr/BDR.html:93
4697 #, no-wrap
4698 msgid ""
4699 "[!java|scala|c]if (rainy()) {\n"
4700 " takeUmbrella();\n"
4701 "} else {\n"
4702 " if (hotDay()) {\n"
4703 " takeWater();\n"
4704 " } else {\n"
4705 " if (todayIsJuly4th()) {\n"
4706 " takeFlag();\n"
4707 " }\n"
4708 " }\n"
4709 "}[/!][!python]if rainy():\n"
4710 " takeUmbrella()\n"
4711 "else:\n"
4712 " if hotDay():\n"
4713 " takeWater()\n"
4714 " else:\n"
4715 " if todayIsJuly4th():\n"
4716 " takeFlag()[/!]"
4717 msgstr ""
4718
4719 #. type: Content of: <p>
4720 #: src/lessons/welcome/bdr/BDR.html:113
4721 msgid ""
4722 "Unfortunately, such a cascade of conditionals is quite difficult to read. It "
4723 "is better to [!java|scala|c]omit the curly braces for the <tt>else</tt> "
4724 "statements. Some languages even introduce a specific construct for these "
4725 "<tt>else if</tt>, but not [!thelang].[/!] [!python]change the sub-blocks "
4726 "using the <code>elif</code> keyword to mark explicitly these \"else if\" "
4727 "branches.[/!]"
4728 msgstr ""
4729
4730 #. type: Content of: <pre>
4731 #: src/lessons/welcome/bdr/BDR.html:120
4732 #, no-wrap
4733 msgid ""
4734 "[!c|java|scala]if (rainy()) { \n"
4735 " takeUmbrella();\n"
4736 "} else if (hotDay()) {\n"
4737 " takeWater();\n"
4738 "} else if (todayIsJuly4th()) {\n"
4739 " takeFlag();\n"
4740 "}[/!][!python]if rainy():\n"
4741 " takeUmbrella()\n"
4742 "elif hotDay():\n"
4743 " takeWater()\n"
4744 "elif todayIsJuly4th():\n"
4745 " takeFlag()[/!]"
4746 msgstr ""
4747
4748 #. type: Content of: <h3>
4749 #: src/lessons/welcome/bdr/BDR.html:133
4750 msgid "Graffiti in the Buggle World"
4751 msgstr ""
4752
4753 #. type: Content of: <p>
4754 #: src/lessons/welcome/bdr/BDR.html:135
4755 msgid ""
4756 "Buggles can tag graffitis on the ground of their world. For that, they use "
4757 "the four following methods:"
4758 msgstr ""
4759
4760 #. type: Content of: <ul><li>
4761 #: src/lessons/welcome/bdr/BDR.html:139
4762 msgid ""
4763 "<code>[!c]int[/!][!java]boolean[/!] "
4764 "isOverMessage()[!scala]:Boolean[/!]</code>: returns "
4765 "<code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> if and only if "
4766 "there is a message on the ground."
4767 msgstr ""
4768
4769 #. type: Content of: <ul><li>
4770 #: src/lessons/welcome/bdr/BDR.html:142
4771 msgid ""
4772 "<code>[!c]char*[/!][!java]String[/!] readMessage()[!scala]: "
4773 "String[/!]</code>: returns the message written on the ground (or an empty "
4774 "string if nothing is written)."
4775 msgstr ""
4776
4777 #. type: Content of: <ul><li>
4778 #: src/lessons/welcome/bdr/BDR.html:144
4779 msgid ""
4780 "<code>[!java|c]void[/!] writeMessage([!c]char*[/!][!java]String "
4781 "[/!]msg[!scala]: String[/!])</code>: writes the specified message down on "
4782 "the ground. If there is already a message on the ground, the new content is "
4783 "added at the end of the existing message."
4784 msgstr ""
4785
4786 #. type: Content of: <ul><li>
4787 #: src/lessons/welcome/bdr/BDR.html:147
4788 msgid ""
4789 "<code>[!java|c]void [/!]clearMessage()</code>: clears what is written on the "
4790 "ground."
4791 msgstr ""
4792
4793 #. type: Content of: outside any tag (error?)
4794 #: src/lessons/welcome/bdr/BDR.html:151
4795 msgid ""
4796 "The goal is then to organize a BDR game between the buggles by teaching them "
4797 "to move according to the instructions written on the ground. These "
4798 "instructions are messages written on the ground, with the following "
4799 "signification:"
4800 msgstr ""
4801
4802 #. type: Content of: <table><tr><td>
4803 #: src/lessons/welcome/bdr/BDR.html:157 src/lessons/welcome/bdr/BDR2.html:139
4804 msgid "Message"
4805 msgstr ""
4806
4807 #. type: Content of: <table><tr><td>
4808 #: src/lessons/welcome/bdr/BDR.html:158 src/lessons/welcome/bdr/BDR2.html:140
4809 msgid "What to do"
4810 msgstr ""
4811
4812 #. type: Content of: <table><tr><td>
4813 #: src/lessons/welcome/bdr/BDR.html:159
4814 msgid "Mnemonic"
4815 msgstr ""
4816
4817 #. type: Content of: <table><tr><td>
4818 #: src/lessons/welcome/bdr/BDR.html:161 src/lessons/welcome/bdr/BDR2.html:142
4819 msgid "[!java|c]'R'[/!][!scala|python]\"R\"[/!]"
4820 msgstr ""
4821
4822 #. type: Content of: <table><tr><td>
4823 #: src/lessons/welcome/bdr/BDR.html:161 src/lessons/welcome/bdr/BDR2.html:142
4824 msgid "Turn right and move one step forward"
4825 msgstr ""
4826
4827 #. type: Content of: <table><tr><td>
4828 #: src/lessons/welcome/bdr/BDR.html:161
4829 msgid "Right"
4830 msgstr ""
4831
4832 #. type: Content of: <table><tr><td>
4833 #: src/lessons/welcome/bdr/BDR.html:162 src/lessons/welcome/bdr/BDR2.html:143
4834 msgid "[!java|c]'L'[/!][!scala|python]\"L\"[/!]"
4835 msgstr ""
4836
4837 #. type: Content of: <table><tr><td>
4838 #: src/lessons/welcome/bdr/BDR.html:162 src/lessons/welcome/bdr/BDR2.html:143
4839 msgid "Turn left and move one step forward"
4840 msgstr ""
4841
4842 #. type: Content of: <table><tr><td>
4843 #: src/lessons/welcome/bdr/BDR.html:162
4844 msgid "Left"
4845 msgstr ""
4846
4847 #. type: Content of: <table><tr><td>
4848 #: src/lessons/welcome/bdr/BDR.html:163 src/lessons/welcome/bdr/BDR2.html:144
4849 msgid "[!java|c]'I'[/!][!scala|python]\"I\"[/!]"
4850 msgstr ""
4851
4852 #. type: Content of: <table><tr><td>
4853 #: src/lessons/welcome/bdr/BDR.html:163
4854 msgid "Turn back (U-turn) and move one step forward"
4855 msgstr ""
4856
4857 #. type: Content of: <table><tr><td>
4858 #: src/lessons/welcome/bdr/BDR.html:163
4859 msgid "Inverse"
4860 msgstr ""
4861
4862 #. type: Content of: <table><tr><td>
4863 #: src/lessons/welcome/bdr/BDR.html:165 src/lessons/welcome/bdr/BDR2.html:146
4864 msgid "[!java|c]'A'[/!][!scala|python]\"A\"[/!]"
4865 msgstr ""
4866
4867 #. type: Content of: <table><tr><td>
4868 #: src/lessons/welcome/bdr/BDR.html:165 src/lessons/welcome/bdr/BDR2.html:146
4869 msgid "Move one step forward"
4870 msgstr ""
4871
4872 #. type: Content of: <table><tr><td>
4873 #: src/lessons/welcome/bdr/BDR.html:165
4874 msgid "First letter of the alphabet"
4875 msgstr ""
4876
4877 #. type: Content of: <table><tr><td>
4878 #: src/lessons/welcome/bdr/BDR.html:166 src/lessons/welcome/bdr/BDR2.html:147
4879 msgid "[!java|c]'B'[/!][!scala|python]\"B\"[/!]"
4880 msgstr ""
4881
4882 #. type: Content of: <table><tr><td>
4883 #: src/lessons/welcome/bdr/BDR.html:166 src/lessons/welcome/bdr/BDR2.html:147
4884 msgid "Move two steps forward"
4885 msgstr ""
4886
4887 #. type: Content of: <table><tr><td>
4888 #: src/lessons/welcome/bdr/BDR.html:166
4889 msgid "Second letter of the alphabet"
4890 msgstr ""
4891
4892 #. type: Content of: <table><tr><td>
4893 #: src/lessons/welcome/bdr/BDR.html:167 src/lessons/welcome/bdr/BDR2.html:148
4894 msgid "[!java|c]'C'[/!][!scala|python]\"C\"[/!]"
4895 msgstr ""
4896
4897 #. type: Content of: <table><tr><td>
4898 #: src/lessons/welcome/bdr/BDR.html:167 src/lessons/welcome/bdr/BDR2.html:148
4899 msgid "Move three steps forward"
4900 msgstr ""
4901
4902 #. type: Content of: <table><tr><td>
4903 #: src/lessons/welcome/bdr/BDR.html:167
4904 msgid "Third letter of the alphabet"
4905 msgstr ""
4906
4907 #. type: Content of: <table><tr><td>
4908 #: src/lessons/welcome/bdr/BDR.html:169 src/lessons/welcome/bdr/BDR2.html:153
4909 msgid "[!java|c]'Z'[/!][!scala|python]\"Z\"[/!]"
4910 msgstr ""
4911
4912 #. type: Content of: <table><tr><td>
4913 #: src/lessons/welcome/bdr/BDR.html:169 src/lessons/welcome/bdr/BDR2.html:153
4914 msgid "Move one step backward"
4915 msgstr ""
4916
4917 #. type: Content of: <table><tr><td>
4918 #: src/lessons/welcome/bdr/BDR.html:169
4919 msgid "One letter before the end of the alphabet"
4920 msgstr ""
4921
4922 #. type: Content of: <table><tr><td>
4923 #: src/lessons/welcome/bdr/BDR.html:170 src/lessons/welcome/bdr/BDR2.html:154
4924 msgid "[!java|c]'Y'[/!][!scala|python]\"Y\"[/!]"
4925 msgstr ""
4926
4927 #. type: Content of: <table><tr><td>
4928 #: src/lessons/welcome/bdr/BDR.html:170 src/lessons/welcome/bdr/BDR2.html:154
4929 msgid "Move two steps backward"
4930 msgstr ""
4931
4932 #. type: Content of: <table><tr><td>
4933 #: src/lessons/welcome/bdr/BDR.html:170
4934 msgid "Two letters before the end of the alphabet"
4935 msgstr ""
4936
4937 #. type: Content of: <table><tr><td>
4938 #: src/lessons/welcome/bdr/BDR.html:171 src/lessons/welcome/bdr/BDR2.html:155
4939 msgid "[!java|c]'X'[/!][!scala|python]\"X\"[/!]"
4940 msgstr ""
4941
4942 #. type: Content of: <table><tr><td>
4943 #: src/lessons/welcome/bdr/BDR.html:171 src/lessons/welcome/bdr/BDR2.html:155
4944 msgid "Move three steps backward"
4945 msgstr ""
4946
4947 #. type: Content of: <table><tr><td>
4948 #: src/lessons/welcome/bdr/BDR.html:171
4949 msgid "Three letters before the end of the alphabet"
4950 msgstr ""
4951
4952 #. type: Content of: <table><tr><td>
4953 #: src/lessons/welcome/bdr/BDR.html:172 src/lessons/welcome/bdr/BDR2.html:159
4954 msgid "<i>(anything else)</i>"
4955 msgstr ""
4956
4957 #. type: Content of: <table><tr><td>
4958 #: src/lessons/welcome/bdr/BDR.html:172 src/lessons/welcome/bdr/BDR2.html:159
4959 msgid "Stop dancing."
4960 msgstr ""
4961
4962 #. type: Content of: <h3>
4963 #: src/lessons/welcome/bdr/BDR.html:175
4964 msgid "Indications"
4965 msgstr ""
4966
4967 #. type: Content of: outside any tag (error?)
4968 #: src/lessons/welcome/bdr/BDR.html:177
4969 msgid ""
4970 "This exercise may seem a bit complex at the first glance, but it comes down "
4971 "to summarizing the information of the table in a sequence of conditionals."
4972 msgstr ""
4973
4974 #. type: Content of: <p>
4975 #: src/lessons/welcome/bdr/BDR.html:180
4976 msgid ""
4977 "You have to keep dancing as long as there is some dancing steps to do, i.e., "
4978 "as long as we are in a cell which content is described in the table. The "
4979 "easier for that is to use a boolean variable (<code>finished</code>) as "
4980 "termination condition to a <code>while</code> loop. It should be "
4981 "initialized to "
4982 "<code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code>, and switched "
4983 "to <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> as soon as "
4984 "the buggle find a cell with a value not described in the table. Thus, the "
4985 "loop will stop and the program will terminate."
4986 msgstr ""
4987
4988 #. type: Content of: <p>
4989 #: src/lessons/welcome/bdr/BDR.html:190
4990 msgid ""
4991 "Another subtlety is that detecting if strings are equals is a bit annoying "
4992 "in [!thelang]. So, we use the <code>char getIndication[!c]Bdr[/!]()</code> "
4993 "instead of <code>[!java]String[/!][!c]char*[/!] readMessage()</code>. This "
4994 "method, only known by the buggles of this exercise, returns the first char "
4995 "of the message written on the ground (or ' ' -- the space char -- if nothing "
4996 "is written down). It enables to work with chars instead of strings, that is "
4997 "much simpler in [!thelang]."
4998 msgstr ""
4999
5000 #. type: Content of: <h3>
5001 #: src/lessons/welcome/bdr/BDR.html:198
5002 msgid "Tips and Hints"
5003 msgstr ""
5004
5005 #. type: Content of: outside any tag (error?)
5006 #: src/lessons/welcome/bdr/BDR.html:200
5007 msgid ""
5008 "If you fail to understand why the buggle does not execute the expected "
5009 "steps, try adding <code>brushDown()</code> in your method. This asks the "
5010 "buggle to put down a brush leaving a trail when it moves. It should help you "
5011 "understanding its trajectory, but do not forget to remove this call when you "
5012 "want to test whether your code is a valid solution to the exercise: you are "
5013 "asked to let the buggle dance, not to vandalize the dance floor."
5014 msgstr ""
5015
5016 #. type: Content of: <p>
5017 #: src/lessons/welcome/bdr/BDR.html:207
5018 msgid "When your program finally works, move on to the next exercise."
5019 msgstr ""
5020
5021 #. type: Content of: <h2>
5022 #: src/lessons/welcome/bdr/BDR2.html:2
5023 msgid "Buggle Dance Revolution 2 (BDR2)"
5024 msgstr ""
5025
5026 #. type: Content of: <p>
5027 #: src/lessons/welcome/bdr/BDR2.html:5
5028 msgid ""
5029 "BDR is cool, but it's a bit chaotic. First, the buggles giggle in any "
5030 "directions, and then the code you had to write to let them move is rather "
5031 "difficult to read. Here is a new BDR world where the buggle will dance a "
5032 "gentle circle. We will benefit this tranquillity to clean up a bit our code "
5033 "thanks to the new constructs we will introduce."
5034 msgstr ""
5035
5036 #. type: Content of: <h3>
5037 #: src/lessons/welcome/bdr/BDR2.html:11
5038 msgid "[!java|c]<code>switch</code> conditionals[/!][!scala]Pattern matching[/!]"
5039 msgstr ""
5040
5041 #. type: Content of: <p>
5042 #: src/lessons/welcome/bdr/BDR2.html:13
5043 msgid ""
5044 "The hardest part of previous code is certainly the conditional "
5045 "cascading. Somewhere in your code, you certainly had something similar to:"
5046 msgstr ""
5047
5048 #. type: Content of: <pre>
5049 #: src/lessons/welcome/bdr/BDR2.html:16
5050 #, no-wrap
5051 msgid ""
5052 "if ([!java|c]getIndication() == 'R'[/!][!scala]readMessage() == \"R\"[/!]) "
5053 "{\n"
5054 " right();\n"
5055 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
5056 "} else if ([!java|c]getIndication() == 'L'[/!][!scala]readMessage() == "
5057 "\"L\"[/!]) {\n"
5058 " left();\n"
5059 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
5060 "} else if ([!java|c]getIndication() == 'I'[/!][!scala]readMessage() == "
5061 "\"I\"[/!]) {\n"
5062 " back();\n"
5063 " [!c]stepForward()[/!][!java|scala]forward()[/!];\n"
5064 "<span class=\"comment\">/* other else if */</span>\n"
5065 "} else {\n"
5066 " finished = [!c]1[/!][!java|scala]true[/!];\n"
5067 "}\n"
5068 msgstr ""
5069
5070 #. type: Content of: <p>
5071 #: src/lessons/welcome/bdr/BDR2.html:31
5072 msgid ""
5073 "When you review this code, it may not be clear at the first glance that it "
5074 "is simply a choice with 4 branches depending on the value of "
5075 "[!java|c]getIndication()[/!][!scala]readMessage()[/!]. To improve this, we "
5076 "will use a [!java|c]<code>switch</code> construct, which Java syntax is the "
5077 "following:[/!] [!scala] pattern matching, which is a very powerful construct "
5078 "that greatly generalizes the <code>if</code>. It is arguably one of the "
5079 "major advantages of Scala when compared to languages such as Java or "
5080 "python. It is not new either, as other languages such as OCaml or Haskell "
5081 "offer this feature since long, but still. It's really cool![/!]"
5082 msgstr ""
5083
5084 #. type: Content of: outside any tag (error?)
5085 #: src/lessons/welcome/bdr/BDR2.html:40
5086 msgid "[/!] [!java|c]"
5087 msgstr ""
5088
5089 #. type: Content of: <pre>
5090 #: src/lessons/welcome/bdr/BDR2.html:44
5091 #, no-wrap
5092 msgid ""
5093 "switch (<b>expression</b>) {\n"
5094 " case <b>firstValue</b>: \n"
5095 " <b>whatToDoIfExpressionEqualsFirstValue();</b>\n"
5096 " break;\n"
5097 " case <b>secondValue</b>: \n"
5098 " <b>whatToDoIfExpressionEqualsSecondValue();</b>\n"
5099 " break;\n"
5100 " case <b>thirdValue</b>: \n"
5101 " <b>whatToDoIfExpressionEqualsThirdValue();</b>\n"
5102 " break;\n"
5103 " /* as much similar cases as you want */\n"
5104 " default: \n"
5105 " <b>whatToDoIfExpressionDoesNotEqualsAnySeenValues();</b>\n"
5106 "}"
5107 msgstr ""
5108
5109 #. type: Content of: <p>
5110 #: src/lessons/welcome/bdr/BDR2.html:59
5111 msgid ""
5112 "Observe that each branch of a <tt>switch</tt> must be ended by a "
5113 "<code>break</code>. If you forget this, the machine keeps going and execute "
5114 "the next branch in the list after the branch it jumped to. There is even "
5115 "some <b>rare</b> cases where this behavior reveals helpful."
5116 msgstr ""
5117
5118 #. type: Content of: <p>
5119 #: src/lessons/welcome/bdr/BDR2.html:64
5120 msgid ""
5121 "It is then possible to rewrite previous BDR code in a cleaner way using the "
5122 "<tt>switch</tt> construct:"
5123 msgstr ""
5124
5125 #. type: Content of: <pre>
5126 #: src/lessons/welcome/bdr/BDR2.html:67
5127 #, no-wrap
5128 msgid ""
5129 "switch (getIndication()) {\n"
5130 " case 'R':\n"
5131 " right(); \n"
5132 " [!c]stepForward()[/!][!java]forward()[/!]; \n"
5133 " break;\n"
5134 " case 'L':\n"
5135 " left();\n"
5136 " [!c]stepForward()[/!][!java]forward()[/!]; \n"
5137 " break;\n"
5138 " case 'I':\n"
5139 " back();\n"
5140 " [!c]stepForward()[/!][!java]forward()[/!];\n"
5141 " break;\n"
5142 " default: \n"
5143 " return;\n"
5144 "}"
5145 msgstr ""
5146
5147 #. type: Content of: <pre>
5148 #: src/lessons/welcome/bdr/BDR2.html:85
5149 #, no-wrap
5150 msgid ""
5151 "<i>expression</i> <b>match</b> {\n"
5152 " <b>case</b> <i>possible value</i> <b>=></b> instructions\n"
5153 " <b>case</b> <i>other value</i> <b>=></b> other instructions\n"
5154 " <b>case</b> <i>another value</i> <b>=></b> yet another instructions\n"
5155 " <b>case _ =></b> default instructions\n"
5156 "}\n"
5157 msgstr ""
5158
5159 #. type: Content of: <p>
5160 #: src/lessons/welcome/bdr/BDR2.html:92
5161 msgid ""
5162 "The expression provided before the keyword <code>match</code>, and then the "
5163 "branches are evaluated one after the other until we find one which value "
5164 "provided between <code>case</code> and <code>=&gt</code> is equal to the "
5165 "expression's value. The <code>_</code> symbol acts as a wildcard, so the "
5166 "<code>_</code> branch <i>always</i> matches. Here is an example where a "
5167 "variable <code>name</code> is matched."
5168 msgstr ""
5169
5170 #. type: Content of: <pre>
5171 #: src/lessons/welcome/bdr/BDR2.html:97
5172 #, no-wrap
5173 msgid ""
5174 "name match {\n"
5175 " case \"Martin\" => println(\"Hello Martin, how are you?\")\n"
5176 " case \"Gerald\" => println(\"Hey Gerald! How are you doing?\")\n"
5177 " case _ => println(\"Welcome stranger.\")\n"
5178 "}"
5179 msgstr ""
5180
5181 #. type: Content of: <p>
5182 #: src/lessons/welcome/bdr/BDR2.html:103
5183 msgid ""
5184 "It is possible to have more than one instruction per branch, and merge "
5185 "branches when the values are separated by a | symbol."
5186 msgstr ""
5187
5188 #. type: Content of: <pre>
5189 #: src/lessons/welcome/bdr/BDR2.html:105
5190 #, no-wrap
5191 msgid ""
5192 "name match {\n"
5193 " case \"Martin\" | \"Gerald\" => println(\"Hello \"+name+\", how are "
5194 "you?\"); openTheDoor()\n"
5195 " case _ => println(\"Hello stranger. Please do "
5196 "not pass.\"); lockTheDoor()\n"
5197 "}"
5198 msgstr ""
5199
5200 #. type: Content of: <p>
5201 #: src/lessons/welcome/bdr/BDR2.html:110
5202 msgid ""
5203 "You can even add guards to your branches. These are extra conditions that "
5204 "must be respected for the branch to get applied. This is handy if you want "
5205 "match on value ranges, as follows."
5206 msgstr ""
5207
5208 #. type: Content of: <pre>
5209 #: src/lessons/welcome/bdr/BDR2.html:112
5210 #, no-wrap
5211 msgid ""
5212 "age match {\n"
5213 " case i if i&lt;10 => println(\"Hey kid!\")\n"
5214 " case i if i&lt;20 => println(\"Hey dude!\")\n"
5215 " case i if i&lt;30 => println(\"Hello young man\")\n"
5216 " case _ => println(\"Hello Sir\")\n"
5217 "}"
5218 msgstr ""
5219
5220 #. type: Content of: <p>
5221 #: src/lessons/welcome/bdr/BDR2.html:118
5222 msgid ""
5223 "Note that there is no need to check whether the value is higher than 10 on "
5224 "the second line because the first matching branch is used. So, if the second "
5225 "branch gets evaluated, then the first one did not match."
5226 msgstr ""
5227
5228 #. type: Content of: <p>
5229 #: src/lessons/welcome/bdr/BDR2.html:121
5230 msgid "Finally, it is possible also to match several variables in one shoot!"
5231 msgstr ""
5232
5233 #. type: Content of: <pre>
5234 #: src/lessons/welcome/bdr/BDR2.html:122
5235 #, no-wrap
5236 msgid ""
5237 "(x,y) match {\n"
5238 " case (0,0) => println(\"that's the origin\")\n"
5239 " case (_,0) => println(\"On the ordinate\")\n"
5240 " case (0,_) => println(\"On the abscissa\")\n"
5241 " case (_,_) => println(\"Some random point\")\n"
5242 "}"
5243 msgstr ""
5244
5245 #. type: Content of: <p>
5246 #: src/lessons/welcome/bdr/BDR2.html:129
5247 msgid ""
5248 "I told you that scala's pattern matching is very powerful! I actually love "
5249 "this feature!"
5250 msgstr ""
5251
5252 #. type: Content of: <p>
5253 #: src/lessons/welcome/bdr/BDR2.html:133
5254 msgid ""
5255 "[!java|scala|c]Apply the improvement we just saw to rewrite your buggle code "
5256 "with the following dance steps. [/!] [!python]Let's teach a new dance step "
5257 "to the buggles. It is slightly more complex but actually better "
5258 "looking. Beside of that, that's the same old story.[/!] Note that we can now "
5259 "move up to 6 cells in one dance step."
5260 msgstr ""
5261
5262 #. type: Content of: <table><tr><td>
5263 #: src/lessons/welcome/bdr/BDR2.html:144
5264 msgid "Turn back and move one step forward"
5265 msgstr ""
5266
5267 #. type: Content of: <table><tr><td>
5268 #: src/lessons/welcome/bdr/BDR2.html:149
5269 msgid "[!java|c]'D'[/!][!scala|python]\"D\"[/!]"
5270 msgstr ""
5271
5272 #. type: Content of: <table><tr><td>
5273 #: src/lessons/welcome/bdr/BDR2.html:149
5274 msgid "Move four cells forward"
5275 msgstr ""
5276
5277 #. type: Content of: <table><tr><td>
5278 #: src/lessons/welcome/bdr/BDR2.html:150
5279 msgid "[!java|c]'E'[/!][!scala|python]\"E\"[/!]"
5280 msgstr ""
5281
5282 #. type: Content of: <table><tr><td>
5283 #: src/lessons/welcome/bdr/BDR2.html:150
5284 msgid "Move five cells forward"
5285 msgstr ""
5286
5287 #. type: Content of: <table><tr><td>
5288 #: src/lessons/welcome/bdr/BDR2.html:151
5289 msgid "[!java|c]'F'[/!][!scala|python]\"F\"[/!]"
5290 msgstr ""
5291
5292 #. type: Content of: <table><tr><td>
5293 #: src/lessons/welcome/bdr/BDR2.html:151
5294 msgid "Move six cells forward"
5295 msgstr ""
5296
5297 #. type: Content of: <table><tr><td>
5298 #: src/lessons/welcome/bdr/BDR2.html:156
5299 msgid "[!java|c]'W'[/!][!scala|python]\"W\"[/!]"
5300 msgstr ""
5301
5302 #. type: Content of: <table><tr><td>
5303 #: src/lessons/welcome/bdr/BDR2.html:156
5304 msgid "Move four cells backward"
5305 msgstr ""
5306
5307 #. type: Content of: <table><tr><td>
5308 #: src/lessons/welcome/bdr/BDR2.html:157
5309 msgid "[!java|c]'V'[/!][!scala|python]\"V\"[/!]"
5310 msgstr ""
5311
5312 #. type: Content of: <table><tr><td>
5313 #: src/lessons/welcome/bdr/BDR2.html:157
5314 msgid "Move five cells backward"
5315 msgstr ""
5316
5317 #. type: Content of: <table><tr><td>
5318 #: src/lessons/welcome/bdr/BDR2.html:158
5319 msgid "[!java|c]'U'[/!][!scala|python]\"U\"[/!]"
5320 msgstr ""
5321
5322 #. type: Content of: <table><tr><td>
5323 #: src/lessons/welcome/bdr/BDR2.html:158
5324 msgid "Move six cells backward"
5325 msgstr ""
5326
5327 #. type: Content of: <p>
5328 #: src/lessons/welcome/bdr/BDR2.html:163
5329 msgid "When you program works again, proceed to next exercise."
5330 msgstr ""
5331
5332 #. type: Content of: <p>
5333 #: src/lessons/welcome/traversal/Snake.html:4
5334 msgid ""
5335 "We will now teach the buggle to explore its world. Its initial position is "
5336 "the bottom left corner, and it should visit any cells up to the top "
5337 "(coloring the ground on its path. The main loop of your code is something "
5338 "like:"
5339 msgstr ""
5340
5341 #. type: Content of: <pre>
5342 #: src/lessons/welcome/traversal/Snake.html:8
5343 #, no-wrap
5344 msgid ""
5345 " move brush down\n"
5346 " while we did not reach the final position\n"
5347 " move like a snake\n"
5348 msgstr ""
5349
5350 #. type: Content of: <p>
5351 #: src/lessons/welcome/traversal/Snake.html:13
5352 msgid ""
5353 "We thus have to write two specific methods: The first one returns a boolean "
5354 "indicating whether we are on a final position while the second moves one "
5355 "snake step forward."
5356 msgstr ""
5357
5358 #. type: Content of: <p>
5359 #: src/lessons/welcome/traversal/Snake.html:17
5360 msgid "We reached the final position if and only if both conditions are true:"
5361 msgstr ""
5362
5363 #. type: Content of: <ul><li>
5364 #: src/lessons/welcome/traversal/Snake.html:19
5365 msgid "We are facing a wall"
5366 msgstr ""
5367
5368 #. type: Content of: <ul><li>
5369 #: src/lessons/welcome/traversal/Snake.html:20
5370 msgid ""
5371 "There is a wall on the north of the buggle. So, if the buggle is facing "
5372 "east, you should check whether there is a wall on the left, and if the "
5373 "buggle is facing west, you should check on the right side."
5374 msgstr ""
5375
5376 #. type: Content of: <ul><li>
5377 #: src/lessons/welcome/traversal/Snake.html:23
5378 msgid ""
5379 "We can get the current heading of the buggle using the "
5380 "<code>getDirection()</code>, and we know whether it looks east using "
5381 "<code>getDirection() == [!scala|python|java]Direction.[/!]EAST</code> (WEST "
5382 "for west)."
5383 msgstr ""
5384
5385 #. type: Content of: <ul><li>
5386 #: src/lessons/welcome/traversal/Snake.html:26
5387 msgid ""
5388 "To check, nothing magical: you have to turn the buggle and check whether it "
5389 "is facing a wall afterward."
5390 msgstr ""
5391
5392 #. type: Content of: <p>
5393 #: src/lessons/welcome/traversal/Snake.html:29
5394 msgid ""
5395 "Then, a snake step can be achieved by moving one step forward if we are not "
5396 "facing a wall, and moving to the upper line else (i.e., if you look to the "
5397 "west facing a wall, you have to turn right, forward and turn right)."
5398 msgstr ""
5399
5400 #. type: Content of: <p>
5401 #: src/lessons/welcome/traversal/Snake.html:33
5402 msgid ""
5403 "Hint: the main loop of your code must continue while the testing function "
5404 "returns false. There is two ways of writing it:"
5405 msgstr ""
5406
5407 #. type: Content of: <pre>
5408 #: src/lessons/welcome/traversal/Snake.html:35
5409 #, no-wrap
5410 msgid ""
5411 "while (testingFunction() == [!c]0) {[/!][!java|scala]false) "
5412 "{[/!][!python]False):[/!]"
5413 msgstr ""
5414
5415 #. type: Content of: <p>
5416 #: src/lessons/welcome/traversal/Snake.html:36
5417 msgid ""
5418 "[!python]You may prefer to write it as:[/!] [!java|scala|c]Since the "
5419 "exclamation mark (!) denotes the boolean negation in [!thelang], you may "
5420 "write it as:[/!]"
5421 msgstr ""
5422
5423 #. type: Content of: <pre>
5424 #: src/lessons/welcome/traversal/Snake.html:38
5425 #, no-wrap
5426 msgid ""
5427 "while ([!java|scala|c]![/!][!python]not "
5428 "[/!]testingFunction())[!java|scala|c] {[/!][!python]:[/!]"
5429 msgstr ""
5430
5431 #. type: Content of: <p>
5432 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:4
5433 msgid ""
5434 "The goal of this serie of exercises is to let the buggle traverse its "
5435 "world. It must number the cells it walks on to show its traversal order."
5436 msgstr ""
5437
5438 #. type: Content of: <p>
5439 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:7
5440 msgid "The main loop of your code should be something like:"
5441 msgstr ""
5442
5443 #. type: Content of: <pre>
5444 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:9
5445 #, no-wrap
5446 msgid ""
5447 " while we are not on the final position\n"
5448 " go to the next position\n"
5449 " label the cell with its number\n"
5450 msgstr ""
5451
5452 #. type: Content of: <p>
5453 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:14
5454 msgid ""
5455 "In contrary to the exercises we saw so far, we won't use the "
5456 "<code>forward()</code>, <code>backward()</code> and similar "
5457 "methods. Instead, we will compute the coordinate of the next buggle position "
5458 "and use the <code>setPos(x, y)</code> method to <i>teleport</i> the buggle "
5459 "directly to this position. For example, <code>setPos(3, 5)</code> teleports "
5460 "the buggle to the cell where x=3 and y=5."
5461 msgstr ""
5462
5463 #. type: Content of: <p>
5464 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:21
5465 msgid ""
5466 "Your first task is thus to write a boolean function indicating whether the "
5467 "buggle reached the final position or not, ie if it reached the bottom right "
5468 "corner of the world. For this, you can use <code>getWorldWidth()</code> and "
5469 "<code>getWorldHeight()</code> which return respectively the world's width "
5470 "and height. Your test is about comparing the buggle's current position (that "
5471 "you can access with <code>getX()</code> and <code>getY()</code>) to the "
5472 "world dimensions."
5473 msgstr ""
5474
5475 #. type: Content of: <p>
5476 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:28
5477 msgid ""
5478 "Beware, the first line and column are numbered 0 and not 1, and the point "
5479 "(0,0) is on the top left corner. This may seem surprising, but it is very "
5480 "often so in Computer Science."
5481 msgstr ""
5482
5483 #. type: Content of: <p>
5484 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:32
5485 msgid ""
5486 "Then, you have to write the code to reach the next position. In this "
5487 "exercise, you have to traverse the world row after row. So, if you are at "
5488 "the bottom of a row, you have to move to the top of next row. Else, you have "
5489 "to move to the cell below."
5490 msgstr ""
5491
5492 #. type: Content of: <p>
5493 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:37
5494 msgid ""
5495 "At this point, you can launch your program to check that the buggle "
5496 "correctly traverse the world in the expected order, and that it stops when "
5497 "it has to. Use the <b>stop</b> button if the buggle does not stop correctly."
5498 msgstr ""
5499
5500 #. type: Content of: <p>
5501 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:41
5502 msgid ""
5503 "It is now time to write down the cell numbers. For that, you will need a "
5504 "counter initialiser to zero at the beginning of your code, and incremented "
5505 "by one at each step (for example with <code>counter += 1;</code>). Then, "
5506 "you have to use <code>writeMessage()</code> to write the value on the "
5507 "ground."
5508 msgstr ""
5509
5510 #. type: Content of: <p>
5511 #: src/lessons/welcome/traversal/column/TraversalByColumn.html:47
5512 msgid ""
5513 "You probably need to write the first [!java|scala|c]or last [/!]value out of "
5514 "the main loop [!java|scala|c], depending on whether you prefer to use a "
5515 "<code>while</code> or a <code>do/while</code> one[/!]."
5516 msgstr ""
5517
5518 #. type: Content of: outside any tag (error?)
5519 #: src/lessons/welcome/traversal/line/TraversalByLine.html:4
5520 msgid ""
5521 "You once again have to let the buggle traverse the world numbering the cells "
5522 "on its way, but the goal of this exercise is to write a line traversal. Most "
5523 "of the code you wrote for previous exercise remains usable here. Simply, the "
5524 "method computing the coordinates of the next buggle position has to be "
5525 "correctly updated: if you are at the right of a line, you have to go to the "
5526 "beginning of the next one. If not, you have to go to the right cell."
5527 msgstr ""
5528
5529 #. type: Content of: <p>
5530 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:4
5531 msgid ""
5532 "This time, you are asked to traverse the world one diagonal after the "
5533 "other. Have a look at the objective world for more details on the requested "
5534 "traversal order."
5535 msgstr ""
5536
5537 #. type: Content of: <p>
5538 #: src/lessons/welcome/traversal/diagonal/TraversalDiagonal.html:8
5539 msgid ""
5540 "You may find useful to use an integer variable <code>diag</code> storing the "
5541 "number of the diagonal you are traversing."
5542 msgstr ""
5543
5544 #. type: Content of: outside any tag (error?)
5545 #: src/lessons/welcome/traversal/zigzag/TraversalZigZag.html:4
5546 msgid ""
5547 "This time, you have to zigzag on the way up. Have a look at the objective "
5548 "world for more details on the requested traversal order."
5549 msgstr ""
5550
5551 #. type: Content of: <h2>
5552 #: src/lessons/welcome/summative/Moria.html:2
5553 msgid "Lost in the Moria"
5554 msgstr ""
5555
5556 #. type: Content of: <p>
5557 #: src/lessons/welcome/summative/Moria.html:4
5558 msgid ""
5559 "You buggles got stuck in the mines of Moria! Some rocks are blocking the "
5560 "exit, and you will have to clear your way to the exit. Well of course these "
5561 "are only baggles and you could simply walk away, but it will be easier to "
5562 "program the buggles so that they move those \"rocks\" than convincing them "
5563 "to walk away without solving the problem. Dwarfs are sometimes really "
5564 "stubborns..."
5565 msgstr ""
5566
5567 #. type: Content of: <p>
5568 #: src/lessons/welcome/summative/Moria.html:11
5569 msgid ""
5570 "So, you have to find the first baggle blocking the exit (simply walk to the "
5571 "east until you are over a baggle), take it and move it back to the other "
5572 "side of the tunnel (walk to the west while you are not over a baggle, and "
5573 "then move back one step to the east and drop your baggle), and iterate until "
5574 "you find the exit (that is, the wall to the east side). Afterward, move out "
5575 "as in the objective world. That's only a few more steps away."
5576 msgstr ""
5577
5578 #. type: Content of: <p>
5579 #: src/lessons/welcome/summative/Moria.html:18
5580 msgid ""
5581 "To make things worse, you have to write a program that works for every "
5582 "buggle, even if writing a specific program for each of them would be "
5583 "easier. It seems that using <code>while</code> loops is the only solution to "
5584 "move the buggles correctly."
5585 msgstr ""
5586
5587 #. type: Content of: <p>
5588 #: src/lessons/welcome/summative/Moria.html:23
5589 msgid ""
5590 "Once you manage to escape this trap, you can move forward to the next "
5591 "exercise. This exercise is a bit more complex, so you can also leave it for "
5592 "now and come back later if you don't get it right now."
5593 msgstr ""
5594
5595 #. type: Content of: <h3>
5596 #: src/lessons/turmites/Main.html:2 src/lessons/turmites/short_desc.html:2
5597 msgid "The turmites"
5598 msgstr ""
5599
5600 #. type: Content of: <p>
5601 #: src/lessons/turmites/Main.html:4
5602 msgid ""
5603 "This set of activities lets you play with Langton's ants, that are 2D turing "
5604 "machines. They constitute very simple application problems, achievable by "
5605 "beginners, and open the door to an amazing world."
5606 msgstr ""
5607
5608 #. type: Content of: <p>
5609 #: src/lessons/turmites/Main.html:8
5610 msgid ""
5611 "This mechanism were invented in 1986 by Chris Langton, and later generalized "
5612 "in several ways (as we shall see in the next exercises). It was proven that "
5613 "Turmites and Turing machines are of equal power: An ant's trajectory can be "
5614 "used to compute any boolean circuit, and thus that an ant is capable of "
5615 "universal computation. Put simply, any possible computation can be achieved "
5616 "using a turmite as a computing device. Yet another subject of fascination..."
5617 msgstr ""
5618
5619 #. type: Content of: <p>
5620 #: src/lessons/turmites/Main.html:14
5621 msgid ""
5622 "Multicolor Langton's ants were discovered in 1995 by Propp et Al. Another "
5623 "funny fact is that the ants which name is a list of consecutive pair of "
5624 "identical letters (LL and RR) produce symmetric patterns. This fact was even "
5625 "formally proved."
5626 msgstr ""
5627
5628 #. type: Content of: <p>
5629 #: src/lessons/turmites/Main.html:19
5630 msgid ""
5631 "Check the corresponding wikipedia web page, of which this exercise is "
5632 "inspired, for further details."
5633 msgstr ""
5634
5635 #. type: Content of: <h3>
5636 #: src/lessons/turmites/Main.html:22 src/lessons/sort/basic/Main.html:15
5637 #: src/lessons/sort/dutchflag/Main.html:9 src/lessons/sort/pancake/Main.html:30
5638 #: src/lessons/sort/baseball/Main.html:28 src/lessons/turtleart/Main.html:12
5639 msgid "What can I do to improve this PLM universe?"
5640 msgstr ""
5641
5642 #. type: Content of: <p>
5643 #: src/lessons/turmites/Main.html:24 src/lessons/sort/basic/Main.html:17
5644 #: src/lessons/sort/dutchflag/Main.html:11
5645 #: src/lessons/sort/pancake/Main.html:32 src/lessons/sort/baseball/Main.html:30
5646 #: src/lessons/turtleart/Main.html:14 src/lessons/recursion/cons/Main.html:7
5647 msgid ""
5648 "As usual, there are several things that could be done in the code of this "
5649 "universe to improve it:"
5650 msgstr ""
5651
5652 #. type: Content of: <ul><li>
5653 #: src/lessons/turmites/Main.html:26
5654 msgid ""
5655 "We are probably missing some good exercises. The turmite creator exercise is "
5656 "a bit harsh: we could introduce the patterns in a more friendly manner."
5657 msgstr ""
5658
5659 #. type: Content of: <ul><li>
5660 #: src/lessons/turmites/Main.html:28
5661 msgid "We may want to write an exercise on the busy beaver, maybe?"
5662 msgstr ""
5663
5664 #. type: Content of: <p>
5665 #: src/lessons/turmites/short_desc.html:3
5666 msgid "Discover the Langton's ants, that are 2D turing machines."
5667 msgstr ""
5668
5669 #. type: Content of: <p>
5670 #: src/lessons/turmites/short_desc.html:5
5671 msgid ""
5672 "These activities are very simple application problems, achievable by "
5673 "beginners, and open the door to an amazing world."
5674 msgstr ""
5675
5676 #. type: Content of: <h2>
5677 #: src/lessons/turmites/langton/Langton.html:2
5678 msgid "Langton's ant"
5679 msgstr ""
5680
5681 #. type: Content of: <p>
5682 #: src/lessons/turmites/langton/Langton.html:4
5683 msgid ""
5684 "In this exercise, you will turn your buggle into a <i>Langton's "
5685 "ant</i>. These artificial little animals are very interesting because they "
5686 "are given simple rules that depend only on their local environment, and "
5687 "after a period of apparent chaotic behavior, a general pattern "
5688 "<i>emerges</i>."
5689 msgstr ""
5690
5691 #. type: Content of: <p>
5692 #: src/lessons/turmites/langton/Langton.html:9
5693 msgid ""
5694 "The rules are absolutely trivial: to compute what the next step should be, "
5695 "you should check the current color of the ground (using "
5696 "<code>getGroundColor()</code>). If it's white, change it to black, turn "
5697 "right and move forward by one cell. If the ground is currently black, change "
5698 "it to white, turn left and move forward by one cell."
5699 msgstr ""
5700
5701 #. type: Content of: <p>
5702 #: src/lessons/turmites/langton/Langton.html:15
5703 msgid ""
5704 "It's hard to come up with simpler rules isn't it? Well, let's go and code it "
5705 "now. You have to complete the <code>step()</code> method, which encodes the "
5706 "behavior of the ant at each step. You will probably use the "
5707 "<code>getGroundColor()</code> method to retrieve the color of the cell on "
5708 "which the ant is currently. Colors of interest are simply named "
5709 "<code>Color.black</code> and <code>Color.white</code>."
5710 msgstr ""
5711
5712 #. type: Content of: <p>
5713 #: src/lessons/turmites/langton/Langton.html:22
5714 msgid ""
5715 "To compare colors, you cannot use the equal signs (==), because these things "
5716 "are not scalar values but objects. Instead, you need to write something like "
5717 "the following:"
5718 msgstr ""
5719
5720 #. type: Content of: <pre>
5721 #: src/lessons/turmites/langton/Langton.html:25
5722 #, no-wrap
5723 msgid ""
5724 "Color c /* = some initialization */;\n"
5725 "if (c.equals(Color.black)) {\n"
5726 " /* that's equal */\n"
5727 "} else {\n"
5728 " /* that was not equal */\n"
5729 "}\n"
5730 msgstr ""
5731
5732 #. type: Content of: <p>
5733 #: src/lessons/turmites/langton/Langton.html:34
5734 msgid ""
5735 "Changing the ground color is not difficult, but a bit long: you have to "
5736 "change the brush color of your buggle, set the brush down (to mark the "
5737 "current cell -- with <code>brushDown()</code>), and set the brush back up "
5738 "(with <code>brushUp()</code>) to avoid further issues when the buggle will "
5739 "move. You are naturally free of organizing your code the way you want, but "
5740 "you may want to write a <code>setGroundColor(color)</code> method to "
5741 "factorize things a bit."
5742 msgstr ""
5743
5744 #. type: Content of: <p>
5745 #: src/lessons/turmites/langton/Langton.html:41
5746 msgid ""
5747 "As you can see from the execution of this exercise, the interest in this "
5748 "algorithm is that after about 10000 steps of relative chaotic behavior, the "
5749 "ant start building a regular pattern. This emergence of a regular pattern "
5750 "from the chaos is rather fascinating, isn't it? Move on to the next exercise "
5751 "to see more of them."
5752 msgstr ""
5753
5754 #. type: Content of: <h2>
5755 #: src/lessons/turmites/langtoncolors/LangtonColors.html:2
5756 msgid "Multicolor Langton's ant"
5757 msgstr ""
5758
5759 #. type: Content of: <p>
5760 #: src/lessons/turmites/langtoncolors/LangtonColors.html:4
5761 msgid ""
5762 "There is several ways to extend the concept of Langton's ant. In this "
5763 "exercise, we explore first one, using more than two colors. It remains very "
5764 "similar to the base case: the behavior at each step still depends on the "
5765 "ground color, but you have more than 2 possibilities. It allows to have more "
5766 "than one kind of ant, depending on what you decide to do for each color. For "
5767 "example, the ant LRL takes 3 colors. It turns left on the first color, right "
5768 "on the second one and left on the third color. According to this definition, "
5769 "the basic ant is a RL (since it turns right on white cells and left on black "
5770 "ones)."
5771 msgstr ""
5772
5773 #. type: Content of: <p>
5774 #: src/lessons/turmites/langtoncolors/LangtonColors.html:13
5775 msgid ""
5776 "Some of these ants draw fascinating patterns (switch the world to see them): "
5777 "LLRR build a symmetric figure resembling loosely to a ball, LRRRRRLLR draws "
5778 "a square, LLRRRLRLRLLR draws a convoluted regular pattern after a period of "
5779 "seemingly chaotic behavior, and RRLLLRLLLRRR seems to fill a hour glass..."
5780 msgstr ""
5781
5782 #. type: Content of: <p>
5783 #: src/lessons/turmites/langtoncolors/LangtonColors.html:18
5784 msgid ""
5785 "Changing your buggle into a generic Langton's ant is not very complicated, "
5786 "although it is not completely trivial. As previously, you have to write a "
5787 "<code>step</code> function. But this time, it receives two arrays as "
5788 "parameters. The first one defines the rules to follow depending on the "
5789 "ground color while the second one gives the sequence of colors to use. For "
5790 "example, the basic ant would have [!java]<code>{'R', 'L'}</code> and "
5791 "<code>{Color.white, Color.black}</code>[/!] [!python]<code>['R', 'L']</code> "
5792 "and <code>[Color.white, Color.black]</code>[/!] [!scala]<code>Array('R', "
5793 "'L')</code> and <code>Array(Color.white, Color.black)</code>[/!] as "
5794 "arguments."
5795 msgstr ""
5796
5797 #. type: Content of: <p>
5798 #: src/lessons/turmites/langtoncolors/LangtonColors.html:29
5799 msgid "At each step, you thus have to apply the following pseudo-code:"
5800 msgstr ""
5801
5802 #. type: Content of: <ul><li>
5803 #: src/lessons/turmites/langtoncolors/LangtonColors.html:31
5804 msgid "Find the position of the ground color in the color sequence;"
5805 msgstr ""
5806
5807 #. type: Content of: <ul><li>
5808 #: src/lessons/turmites/langtoncolors/LangtonColors.html:32
5809 msgid ""
5810 "Turn left or right depending on the content of the rule array at that "
5811 "position;"
5812 msgstr ""
5813
5814 #. type: Content of: <ul><li>
5815 #: src/lessons/turmites/langtoncolors/LangtonColors.html:33
5816 msgid ""
5817 "Mark the current ground with the next color in the sequence (the last color "
5818 "being followed by the first one);"
5819 msgstr ""
5820
5821 #. type: Content of: <ul><li>
5822 #: src/lessons/turmites/langtoncolors/LangtonColors.html:34
5823 msgid "Move forward by one step."
5824 msgstr ""
5825
5826 #. type: Content of: <p>
5827 #: src/lessons/turmites/langtoncolors/LangtonColors.html:37
5828 #: src/lessons/turmites/helloturmite/HelloTurmite.html:67
5829 msgid "You now should have enough information to succeed."
5830 msgstr ""
5831
5832 #. type: Content of: <h2>
5833 #: src/lessons/turmites/helloturmite/HelloTurmite.html:2
5834 msgid "Turmites"
5835 msgstr ""
5836
5837 #. type: Content of: <p>
5838 #: src/lessons/turmites/helloturmite/HelloTurmite.html:4
5839 msgid ""
5840 "This exercise explores a new way to extend the concept of Langton's "
5841 "ant. Now, the behavior of the ant not only depends on the color on the "
5842 "ground, but also on its internal state (represented by an integer "
5843 "value). The idea of changing the ant into such an automata naturally comes "
5844 "from the Turing machine concept. This explains the name of these new "
5845 "animals, which is a portemanteau of <i>Turing</i> and <i>Termite</i> (if you "
5846 "don't know what a Turing machine is, you should run to wikipedia, because it "
5847 "is simply impossible to be a real computer scientist before that)."
5848 msgstr ""
5849
5850 #. type: Content of: <p>
5851 #: src/lessons/turmites/helloturmite/HelloTurmite.html:13
5852 msgid ""
5853 "Once again, you just have to write the <code>step()</code> method, in charge "
5854 "of doing one turmite's step. Once again, you should first find the rank of "
5855 "the current's cell ground color in the color sequence. But this time, the "
5856 "<code>rule</code> data depends both on the current color and the current "
5857 "state. <code>rule</code> actually contains 3 information in each situation: "
5858 "the color to write, the move to do, and the next state value. For example, "
5859 "[!java|python]rule[1][0][/!][!scala]rule(1)(0)[/!] contains the informations "
5860 "to use when <code>state==1</code> and <code>color==0</code>. In other "
5861 "worlds, you can retrieve the information relative to your current situation "
5862 "by using "
5863 "<code>[!java|python]rule[state][currentColor][/!][!scala]rule(state)(currentColor)[/!]</code>."
5864 msgstr ""
5865
5866 #. type: Content of: <p>
5867 #: src/lessons/turmites/helloturmite/HelloTurmite.html:25
5868 msgid ""
5869 "Each such information set contains 3 values. The first one is the rank of "
5870 "the color to write on the ground. The second is the move to do, with the "
5871 "following notation: 0=stop, 1=noturn, 2=left, 4=u-turn, 8=right. Note that "
5872 "if the command is stop, you shouldn't even move forward on that step (but "
5873 "you shouldn't stop your program either: the next steps can do something else "
5874 "in a future state). Finally, the third integer is the next "
5875 "<code>state</code> value to go into after this iteration."
5876 msgstr ""
5877
5878 #. type: Content of: <p>
5879 #: src/lessons/turmites/helloturmite/HelloTurmite.html:32
5880 msgid ""
5881 "Since these arbitrary notations are somehow difficult to remember, you "
5882 "should define a set of constants that you should use instead of the direct "
5883 "numerical values. Their names could be NOTURN, LEFT, RIGHT and so on. "
5884 "[!scala]Just declare them using the keyword <code>val</code> instead of "
5885 "<code>var</code>. You should always use <code>val</code> instead of "
5886 "<code>var</code> when possible anyway.[/!] [!java]The modifiers <code>final "
5887 "static</code> before their type is the way to mark variables as constant in "
5888 "Java. You should write for example <code>static final int NOTURN=1;</code> "
5889 "Sorry for the complexity of this notation. [/!] [!python]By convention, such "
5890 "constant variables are written in upper case in python. Technically, you "
5891 "can still modify them, but that would be a very bad idea.[/!] You should "
5892 "write them out of any method so that they are globally visible."
5893 msgstr ""
5894
5895 #. type: Content of: <p>
5896 #: src/lessons/turmites/helloturmite/HelloTurmite.html:44
5897 msgid ""
5898 "Using such constants greatly help making the code easier to read. Compare "
5899 "the next two code chunks:"
5900 msgstr ""
5901
5902 #. type: Content of: <pre>
5903 #: src/lessons/turmites/helloturmite/HelloTurmite.html:46
5904 #, no-wrap
5905 msgid ""
5906 "[!java]if (rule[state][currentColor][NEXT_MOVE] == LEFT) {[/!][!python]if "
5907 "rule[state][currentColor][NEXT_MOVE] == LEFT:[/!][!scala]if "
5908 "(rule(state)(currentColor)(NEXT_MOVE) == LEFT) {[/!]\n"
5909 " left()[!java];[/!]\n"
5910 "[!java|scala]}[/!]"
5911 msgstr ""
5912
5913 #. type: Content of: <p>
5914 #: src/lessons/turmites/helloturmite/HelloTurmite.html:49
5915 msgid "This is much more easier to read (although longer) than the following:"
5916 msgstr ""
5917
5918 #. type: Content of: <pre>
5919 #: src/lessons/turmites/helloturmite/HelloTurmite.html:50
5920 #, no-wrap
5921 msgid ""
5922 "[!java]if (rule[i][j][1] == 2) {[/!][!python]if rule[i][j][1] == "
5923 "2:[/!][!scala]if (rule(i)(j)(1) == 2) {[/!]\n"
5924 " left()[!java];[/!]\n"
5925 "[!java|scala]}[/!]"
5926 msgstr ""
5927
5928 #. type: Content of: <p>
5929 #: src/lessons/turmites/helloturmite/HelloTurmite.html:54
5930 msgid ""
5931 "Finally, you probably want to write a <code>elif</code> branch for the "
5932 "<code>STOP</code> condition too. Having a <code>else</code> branch "
5933 "displaying an error message such as \"unknown case\" is a good practice: it "
5934 "makes your assumptions about your code more explicit, and you will get an "
5935 "error message if they fall short. When doing so, the next problem is that "
5936 "you have nothing to do in the <code>STOP</code> case, but python do not "
5937 "allows you to write empty <code>elif</code> branches. You should use the "
5938 "<code>pass</code> instruction as a placeholder: it says python that you have "
5939 "a branch here, and that it does not contain anything."
5940 msgstr ""
5941
5942 #. type: Content of: <p>
5943 #: src/lessons/turmites/helloturmite/HelloTurmite.html:63
5944 msgid ""
5945 "You should probably use a [!java]switch case[/!][!scala]pattern matching[/!] "
5946 "construct to keep your code readable. If you can't remember what it is, "
5947 "check <a href=\"plm://lessons.welcome/bdr.BDR2\">this exercise</a>."
5948 msgstr ""
5949
5950 #. type: Content of: <h2>
5951 #: src/lessons/turmites/helloturmite/HelloTurmite.html:69
5952 msgid "Bibliographical notes"
5953 msgstr ""
5954
5955 #. type: Content of: <p>
5956 #: src/lessons/turmites/helloturmite/HelloTurmite.html:70
5957 msgid ""
5958 "According to wikipedia, turmites were invented independently by the end of "
5959 "the eighties. It has been shown that turmites in general are exactly "
5960 "equivalent in power to one-dimensional Turing machines with an infinite "
5961 "tape, as either can simulate the other. This means that absolutely any "
5962 "program that you can think of could theoretically be computed on this "
5963 "device..."
5964 msgstr ""
5965
5966 #. type: Content of: <h2>
5967 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:2
5968 msgid "Creating Turmites"
5969 msgstr ""
5970
5971 #. type: Content of: <p>
5972 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:4
5973 msgid ""
5974 "This exercise allows you to build your own turmites. To pass the exercise, "
5975 "you should simply write a <code>init()</code> method which initializes the "
5976 "<code>rule</code> to use the following transitions table (from wikipedia), "
5977 "set the buggle initial position at (8;33), and ask for 8342 steps."
5978 msgstr ""
5979
5980 #. type: Content of: <table><tr><th>
5981 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:11
5982 msgid "Current color"
5983 msgstr ""
5984
5985 #. type: Content of: <table><tr><td>
5986 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:14
5987 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:29
5988 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:32
5989 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:40
5990 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:42
5991 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:43
5992 msgid "0"
5993 msgstr ""
5994
5995 #. type: Content of: <table><tr><td>
5996 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:15
5997 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:30
5998 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:33
5999 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:35
6000 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:38
6001 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:45
6002 msgid "1"
6003 msgstr ""
6004
6005 #. type: Content of: <table><tr><th>
6006 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:19
6007 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:22
6008 msgid "Write color"
6009 msgstr ""
6010
6011 #. type: Content of: <table><tr><th>
6012 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:20
6013 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:23
6014 msgid "Turn"
6015 msgstr ""
6016
6017 #. type: Content of: <table><tr><th>
6018 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:21
6019 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:24
6020 msgid "Next state"
6021 msgstr ""
6022
6023 #. type: Content of: <table><tr><th>
6024 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:27
6025 msgid "Current state"
6026 msgstr ""
6027
6028 #. type: Content of: <table><tr><td>
6029 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:31
6030 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:34
6031 msgid "R"
6032 msgstr ""
6033
6034 #. type: Content of: <table><tr><td>
6035 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:41
6036 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:44
6037 msgid "N"
6038 msgstr ""
6039
6040 #. type: Content of: <p>
6041 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:49
6042 msgid ""
6043 "where the direction to turn is one of <b>L</b> (90° left), <b>R</b> (90° "
6044 "right), <b>N</b> (no turn) and <b>U</b> (180° U-turn)."
6045 msgstr ""
6046
6047 #. type: Content of: <h2>
6048 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:51
6049 msgid "Going further"
6050 msgstr ""
6051
6052 #. type: Content of: <p>
6053 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:52
6054 msgid ""
6055 "This exercise is naturally an excuse to let you experiment with your own "
6056 "turmites. Feel free to change the transition table and the amount of steps "
6057 "to experiment by yourself. To that extend, you may find the Ed Pegg Jr's "
6058 "library useful. If you find new interesting patterns, send them per email so "
6059 "that we can integrate them to this list!"
6060 msgstr ""
6061
6062 #. type: Content of: <p>
6063 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:58
6064 msgid ""
6065 "In addition, wikipedia is desperately missing some good looking colorful "
6066 "turmites: only black and white ones are depicted. You should consider "
6067 "submitting your creations directly to the free encyclopedia."
6068 msgstr ""
6069
6070 #. type: Content of: <p>
6071 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:63
6072 msgid ""
6073 "Here are some 2-color turmites, extracted from "
6074 "http://demonstrations.wolfram.com/Turmites/ [!python|scala]They are not "
6075 "written using the [!thelang] syntax, but converting them should be easy.[/!]"
6076 msgstr ""
6077
6078 #. type: Content of: <pre>
6079 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:67
6080 #, no-wrap
6081 msgid ""
6082 "{{{1, RIGHT , 0}, {0, LEFT , 0}}} # 1: Langton's ant\n"
6083 "{{{1, RIGHT , 0}, {0, NOTURN, 0}}} # 2: binary counter\n"
6084 "{{{0, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 3: "
6085 "(filled triangle)\n"
6086 "{{{0, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {0, NOTURN, 1}}} # 4: "
6087 "spiral in a box\n"
6088 "{{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 5: "
6089 "stripe-filled spiral\n"
6090 "{{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {1, NOTURN, 0}}} # 6: "
6091 "stepped pyramid\n"
6092 "{{{0, RIGHT , 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {1, LEFT , 0}}} # 7: "
6093 "contoured island\n"
6094 "{{{0, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {0, RIGHT , 1}}} # 8: "
6095 "woven placemat\n"
6096 "{{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {1, LEFT , 0}}} # 9: "
6097 "snowflake-ish\n"
6098 "{{{1, LEFT , 0}, {0, NOTURN, 1}}, {{0, LEFT , 0}, {0, LEFT , 1}}} # 10: "
6099 "slow city builder\n"
6100 "{{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 0}, {0, LEFT , 1}}} # 11: "
6101 "framed computer art\n"
6102 "{{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 1}, {1, LEFT , 0}}} # 12: "
6103 "balloon bursting (makes a spreading highway)\n"
6104 "{{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 13: "
6105 "makes a horizontal highway\n"
6106 "{{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 1}, {1, RIGHT , 0}}} # 14: "
6107 "makes a 45 degree highway\n"
6108 "{{{1, LEFT , 1}, {0, LEFT , 1}}, {{1, RIGHT , 1}, {0, LEFT , 0}}} # 15: "
6109 "makes a 45 degree highway\n"
6110 "{{{1, LEFT , 1}, {0, NOTURN, 0}}, {{1, NOTURN, 0}, {1, RIGHT , 0}}} # 16: "
6111 "spiral in a filled box\n"
6112 "{{{1, LEFT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 17: "
6113 "glaciers\n"
6114 "{{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 18: "
6115 "golden rectangle!\n"
6116 "{{{1, LEFT , 1}, {1, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 19: "
6117 "fizzy spill\n"
6118 "{{{1, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 20: "
6119 "nested cabinets\n"
6120 "{{{1, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {1, NOTURN, 1}}} # 21: "
6121 "(cross)\n"
6122 "{{{1, NOTURN, 1}, {0, NOTURN, 0}}, {{0, RIGHT , 0}, {1, LEFT , 0}}} # 22: "
6123 "saw-tipped growth\n"
6124 "{{{1, NOTURN, 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 23: "
6125 "curves in blocks growth\n"
6126 "{{{1, NOTURN, 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 24: "
6127 "textured growth\n"
6128 "{{{1, NOTURN, 1}, {0, RIGHT , 1}}, {{1, LEFT , 0}, {1, RIGHT , 0}}} # 25: "
6129 "(diamond growth)\n"
6130 "{{{1, NOTURN, 1}, {1, LEFT , 0}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 26: "
6131 "coiled rope\n"
6132 "{{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, NOTURN, 1}}} # 27: "
6133 "(growth)\n"
6134 "{{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, RIGHT , 1}}} # 28: "
6135 "(square spiral)\n"
6136 "{{{1, RIGHT , 0}, {1, RIGHT , 1}}, {{0, NOTURN, 0}, {0, NOTURN, 1}}} # 29: "
6137 "loopy growth with holes\n"
6138 "{{{1, RIGHT , 1}, {0, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 30: "
6139 "Lanton's Ant drawn with squares\n"
6140 "{{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 1}, {1, LEFT , 0}}} # 31: "
6141 "growth with curves and blocks\n"
6142 "{{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, NOTURN, 0}, {1, RIGHT , 1}}} # 32: "
6143 "distracted spiral builder\n"
6144 "{{{1, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 33: "
6145 "cauliflower stalk (45 deg highway)\n"
6146 "{{{1, RIGHT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, RIGHT , 0}}} # 34: "
6147 "worm trails (eventually turns cyclic!)\n"
6148 "{{{1, RIGHT , 1}, {1, NOTURN, 0}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 35: "
6149 "eventually makes a two-way highway!\n"
6150 "{{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, NOTURN, 0}, {0, NOTURN, 0}}} # 36: "
6151 "almost symmetric mould bloom\n"
6152 "{{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, RIGHT , 0}, {1, NOTURN, 1}}} # 37: "
6153 "makes a 1 in 2 gradient highway\n"
6154 "{{{1, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 38: "
6155 "immediately makes a 1 in 3 highway\n"
6156 "{{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{0, LEFT , 2}, {0, LEFT , 0}}, {{1, "
6157 "RIGHT , 2}, {1, LEFT , 0}}} # 39: squares and diagonals growth\n"
6158 "{{{1, LEFT , 1}, {0, NOTURN, 0}}, {{0, RIGHT , 2}, {1, LEFT , 0}}, {{1, "
6159 "RIGHT , 1}, {1, NOTURN, 0}}} # 40: streak at approx. an 8.1 in 1 gradient\n"
6160 "{{{1, LEFT , 1}, {0, NOTURN, 2}}, {{0, RIGHT , 2}, {1, NOTURN, 1}}, {{1, "
6161 "RIGHT , 1}, {1, NOTURN, 0}}} # 41: streak at approx. a 1.14 in 1 gradient\n"
6162 "{{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 2}}, {{0, "
6163 "LEFT , 1}, {1, NOTURN, 1}}} # 42: maze-like growth\n"
6164 "{{{1, LEFT , 2}, {0, RIGHT , 0}}, {{1, LEFT , 0}, {0, RIGHT , 0}}, {{0, "
6165 "LEFT , 0}, {0, LEFT , 1}}} # 43: growth by cornices \n"
6166 "{{{1, RIGHT , 0}, {0, RIGHT , 2}}, {{0, LEFT , 0}, {0, RIGHT , 0}}, {{0, "
6167 "NOTURN, 1}, {1, LEFT , 0}}} # 44: makes a 1 in 7 highway\n"
6168 "{{{1, RIGHT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 2}, {0, NOTURN, 0}}, {{1, "
6169 "LEFT , 0}, {0, LEFT , 0}}} # 45: makes a 4 in 1 highway\n"
6170 msgstr ""
6171
6172 #. type: Content of: <p>
6173 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:114
6174 msgid ""
6175 "Langton's ants may not share the expressiveness power of the turmites, but "
6176 "they remain fascinating too. You can experiment with them using the "
6177 "initLangton() method, provided in your template, that allows to build a "
6178 "Turmite transition table from a Langton's ant name. Tiny changes in the ant "
6179 "may result huge changes. For example, \"RRL\" does not seem to lead to any "
6180 "constructed pattern, even after a million steps, but \"RLL\" starts building "
6181 "a very simple highway pattern after less than 100 steps!"
6182 msgstr ""
6183
6184 #. type: Content of: <p>
6185 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:121
6186 msgid ""
6187 "Quite a lot of Langton's ants build highways: RL, of course, but also "
6188 "RLRLRLLRLR (about 2500 steps). The chaotic behavior of ants before the "
6189 "highway can be very short (as with RLL that only need 100 steps to converge) "
6190 "or very long, as with LLLLLLRRLRRR which seems chaotic for more than 500,000 "
6191 "steps before build the highway or even RRLLLRRRLRRR which needs 1170000 to "
6192 "start converging. Some are narrow, and others are very large, such as "
6193 "RRLRLLRLRR (200,000 steps). This ant is also notable since it is somehow "
6194 "squarish even before the highway start where most others do not show "
6195 "anything notable before their highway."
6196 msgstr ""
6197
6198 #. type: Content of: <p><p><p>
6199 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:129
6200 msgid ""
6201 "Some ants fill solid sectors, such as RRLLLRLLLRRR (16,000 steps), "
6202 "RRLLLRLLLRRR (30,000 steps), RRLLLRRRRRLR (125,000 steps) or RRLRLLRRRRRR "
6203 "(20,000 steps). Some even fill the whole space (RRLRR after 3000 "
6204 "steps). Some of my personal favorite ones are the ones where the ant seem to "
6205 "be bouncing within a box that gets bigger on each bump, such as LRRRRRLLR "
6206 "(30,000 steps). LRRRRLLLRRR is even more impressing since the bounces within "
6207 "the box are regular and since it converges more rapidly to its stable "
6208 "behavior (15,000 steps are enough)."
6209 msgstr ""
6210
6211 #. type: Content of: <p><p><p>
6212 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:136
6213 msgid ""
6214 "Finally, some ants are just build artistic patterns. You should check this "
6215 "video for some beautiful ones: "
6216 "http://www.youtube.com/watch?v=1X-gtr4pEBU. If you want to convert them into "
6217 "your code, you have to shift them by one: For example, the one depicted at "
6218 "3:42 is not RRLRLRLLRL, but RLRLRLLRLR (the first visible move should be "
6219 "read as last one)."
6220 msgstr ""
6221
6222 #. type: Content of: <p><p><p>
6223 #: src/lessons/turmites/turmitecreator/TurmiteCreator.html:141
6224 msgid ""
6225 "As you can see by exploring the above set of turmites, they are usually not "
6226 "as colorful as the ants, but this may be because very few colors suffice to "
6227 "exhibit complex behaviors. For example, there is a specific class of "
6228 "turmites called <i>busy beavers</i> which are turmites that write a lot of "
6229 "things before stopping (busy beavers are usually classical turing machines, "
6230 "but the idea fits perfectly to turmites too). There is a sort of "
6231 "international competition where people strive to find the turmite that "
6232 "covers the biggest area before stopping. The web page is here: "
6233 "http://code.google.com/p/ruletablerepository/wiki/TwoDimensionalTuringMachines"
6234 msgstr ""
6235
6236 #. type: Content of: <h1>
6237 #: src/lessons/turmites/universe/TurmiteWorld.html:2
6238 msgid "Turmite universe"
6239 msgstr ""
6240
6241 #. type: Content of: <p>
6242 #: src/lessons/turmites/universe/TurmiteWorld.html:4
6243 msgid ""
6244 "This universe is very similar to the buggle one, but you will probably not "
6245 "use all buggles methods. So, this page only recap the buggle methods that "
6246 "you will use."
6247 msgstr ""
6248
6249 #. type: Content of: <table><tr><td>
6250 #: src/lessons/turmites/universe/TurmiteWorld.html:12
6251 msgid ""
6252 "[!java|c]void [/!][!c]stepForward()[/!][!java|python|scala]forward()[/!] or "
6253 "[!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])"
6254 msgstr ""
6255
6256 #. type: Content of: <table><tr><td>
6257 #: src/lessons/turmites/universe/TurmiteWorld.html:13
6258 msgid ""
6259 "[!java|c]void [/!][!c]stepBackward()[/!][!java|python|scala]backward()[/!] "
6260 "or [!java|c]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])"
6261 msgstr ""
6262
6263 #. type: Content of: <h1>
6264 #: src/plm/universe/sort/SortingWorld.html:2
6265 msgid "Sorting World"
6266 msgstr ""
6267
6268 #. type: Content of: outside any tag (error?)
6269 #: src/plm/universe/sort/SortingWorld.html:3
6270 msgid ""
6271 "This world provides tools to experiment with the sorting algorithms. It can "
6272 "be used in two different ways: the first one is naturally to write the "
6273 "required sorting algorithms. But it is also possible to simply use the demo "
6274 "mode of each exercise to observe the behavior of sorting algorithms. It "
6275 "helps understanding the differences between each of them."
6276 msgstr ""
6277
6278 #. type: Content of: <h2>
6279 #: src/plm/universe/sort/SortingWorld.html:9
6280 msgid "Methods available to sorting algorithms"
6281 msgstr ""
6282
6283 #. type: Content of: <table><tr><td>
6284 #: src/plm/universe/sort/SortingWorld.html:11
6285 msgid "<b>Method</b>"
6286 msgstr ""
6287
6288 #. type: Content of: <table><tr><td>
6289 #: src/plm/universe/sort/SortingWorld.html:11
6290 msgid "<b>Action</b>"
6291 msgstr ""
6292
6293 #. type: Content of: <table><tr><td>
6294 #: src/plm/universe/sort/SortingWorld.html:11
6295 msgid "<b>Cost</b>"
6296 msgstr ""
6297
6298 #. type: Content of: <table><tr><td>
6299 #: src/plm/universe/sort/SortingWorld.html:12
6300 msgid "[!java|c]int [/!]getValueCount() [!scala]:Int[/!]"
6301 msgstr ""
6302
6303 #. type: Content of: <table><tr><td>
6304 #: src/plm/universe/sort/SortingWorld.html:13
6305 msgid "Returns the amount of values in the array"
6306 msgstr ""
6307
6308 #. type: Content of: <table><tr><td>
6309 #: src/plm/universe/sort/SortingWorld.html:13
6310 #: src/plm/universe/sort/SortingWorld.html:31
6311 msgid "none"
6312 msgstr ""
6313
6314 #. type: Content of: <table><tr><td>
6315 #: src/plm/universe/sort/SortingWorld.html:15
6316 msgid ""
6317 "[!java]boolean [/!][!c]int [/!]isSmaller([!java|c]int [/!]i[!scala]:Int[/!], "
6318 "[!java|c]int [/!]j[!scala]:Int[/!]) [!scala]:Boolean[/!]"
6319 msgstr ""
6320
6321 #. type: Content of: <table><tr><td>
6322 #: src/plm/universe/sort/SortingWorld.html:16
6323 msgid ""
6324 "Returns true if the content of cell i is strictly smaller than the one of "
6325 "cell j"
6326 msgstr ""
6327
6328 #. type: Content of: <table><tr><td>
6329 #: src/plm/universe/sort/SortingWorld.html:16
6330 msgid "two reads"
6331 msgstr ""
6332
6333 #. type: Content of: <table><tr><td>
6334 #: src/plm/universe/sort/SortingWorld.html:17
6335 msgid ""
6336 "[!java]boolean [/!][!c]int [/!]isSmallerThan([!java|c]int "
6337 "[/!]i[!scala]:Int[/!], [!java|c]int [/!]value[!scala]:Int[/!])[!scala] "
6338 ":Boolean[/!]"
6339 msgstr ""
6340
6341 #. type: Content of: <table><tr><td>
6342 #: src/plm/universe/sort/SortingWorld.html:18
6343 msgid ""
6344 "Returns true if the content of cell i is strictly smaller than the "
6345 "<code>value</code>"
6346 msgstr ""
6347
6348 #. type: Content of: <table><tr><td>
6349 #: src/plm/universe/sort/SortingWorld.html:18
6350 #: src/plm/universe/sort/SortingWorld.html:26
6351 msgid "one read"
6352 msgstr ""
6353
6354 #. type: Content of: <table><tr><td>
6355 #: src/plm/universe/sort/SortingWorld.html:20
6356 msgid ""
6357 "[!java|c]void [/!]swap([!java|c]int [/!]i[!scala]:Int[/!], [!java|c]int "
6358 "[/!]j[!scala]:Int[/!])"
6359 msgstr ""
6360
6361 #. type: Content of: <table><tr><td>
6362 #: src/plm/universe/sort/SortingWorld.html:21
6363 msgid "Swaps the content of cell i and the one of cell j"
6364 msgstr ""
6365
6366 #. type: Content of: <table><tr><td>
6367 #: src/plm/universe/sort/SortingWorld.html:21
6368 msgid "two reads, two writes"
6369 msgstr ""
6370
6371 #. type: Content of: <table><tr><td>
6372 #: src/plm/universe/sort/SortingWorld.html:22
6373 msgid ""
6374 "[!java|c]void [/!]copy([!java|c]int [/!]from[!scala]:Int[/!], [!java|c]int "
6375 "[/!]to[!scala]:Int[/!])"
6376 msgstr ""
6377
6378 #. type: Content of: <table><tr><td>
6379 #: src/plm/universe/sort/SortingWorld.html:23
6380 msgid "Copy the content of cell 'from' into the cell 'to'"
6381 msgstr ""
6382
6383 #. type: Content of: <table><tr><td>
6384 #: src/plm/universe/sort/SortingWorld.html:23
6385 msgid "one read, one write"
6386 msgstr ""
6387
6388 #. type: Content of: <table><tr><td>
6389 #: src/plm/universe/sort/SortingWorld.html:25
6390 msgid "[!java|c]int [/!]getValue([!java|c]int [/!]idx[!scala]:Int[/!])"
6391 msgstr ""
6392
6393 #. type: Content of: <table><tr><td>
6394 #: src/plm/universe/sort/SortingWorld.html:26
6395 msgid "Returns the value of cell idx"
6396 msgstr ""
6397
6398 #. type: Content of: <table><tr><td>
6399 #: src/plm/universe/sort/SortingWorld.html:27
6400 msgid ""
6401 "[!java|c]void [/!]setValue([!java|c]int [/!]idx[!scala]:Int[/!], "
6402 "[!java|c]int [/!]value[!scala]:Int[/!])"
6403 msgstr ""
6404
6405 #. type: Content of: <table><tr><td>
6406 #: src/plm/universe/sort/SortingWorld.html:28
6407 msgid "Sets cell 'idx' to the <code>value</code>"
6408 msgstr ""
6409
6410 #. type: Content of: <table><tr><td>
6411 #: src/plm/universe/sort/SortingWorld.html:28
6412 msgid "one write"
6413 msgstr ""
6414
6415 #. type: Content of: <table><tr><td>
6416 #: src/plm/universe/sort/SortingWorld.html:30
6417 msgid "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
6418 msgstr ""
6419
6420 #. type: Content of: outside any tag (error?)
6421 #: src/plm/universe/sort/SortingWorld.html:31
6422 #: src/lessons/sort/pancake/universe/PancakeWorld.html:22
6423 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:28
6424 msgid "Returns whether the current world is selected in the graphical interface."
6425 msgstr ""
6426
6427 #. type: Content of: <h2>
6428 #: src/plm/universe/sort/SortingWorld.html:35
6429 msgid "History view"
6430 msgstr ""
6431
6432 #. type: Content of: <p>
6433 #: src/plm/universe/sort/SortingWorld.html:36
6434 msgid ""
6435 "It is not enough to sort the array to pass the exercises. Your solution must "
6436 "strictly follow the expected behavior of each exercise. This is enforced by "
6437 "checking that your algorithm needs the same amount of read and write "
6438 "operations to sort the array. When they don't match, understanding the "
6439 "difference between your code and the expected solution can reveal very "
6440 "difficult."
6441 msgstr ""
6442
6443 #. type: Content of: <p>
6444 #: src/plm/universe/sort/SortingWorld.html:43
6445 msgid ""
6446 "To help in this process, it is possible to graphically explore the history "
6447 "of your sorting algorithm. Switch to the Objective view and use the "
6448 "contextual menu (right click) to switch from the view of the current state "
6449 "to the view of its history."
6450 msgstr ""
6451
6452 #. type: Content of: <p>
6453 #: src/plm/universe/sort/SortingWorld.html:48
6454 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:19
6455 msgid ""
6456 "The history view is a bit hairly at the first glance, but actually rather "
6457 "simple: The time flows from left to right on this graph, and each row is a "
6458 "cell of your array. The curved lines that go navigate between rows represent "
6459 "a given data value. When two lines cross, this means that two values were "
6460 "swapped at this time stamp; A line fork represent a value copy; When a value "
6461 "is magenta and followed by an interrogation mark (?), it was read using "
6462 "getValue(); If the value is red and followed with an exclamation point (!), "
6463 "it was written using setValue()."
6464 msgstr ""
6465
6466 #. type: Content of: <p>
6467 #: src/plm/universe/sort/SortingWorld.html:57
6468 msgid ""
6469 "This view, inspired from Aldo Cortesi, reveals very helpful understand the "
6470 "inner behavior of sorting algorithms."
6471 msgstr ""
6472
6473 #. type: Content of: <h3>
6474 #: src/lessons/sort/basic/Main.html:2 src/lessons/sort/basic/short_desc.html:2
6475 msgid "Sorting Algorithms"
6476 msgstr ""
6477
6478 #. type: Content of: outside any tag (error?)
6479 #: src/lessons/sort/basic/Main.html:4
6480 msgid ""
6481 "This lesson allows to experiment with some classical sorting algorithms (and "
6482 "some less common variant of them). The goal is two fold: you can first "
6483 "better understand the idea of these algorithms by writing them yourself. But "
6484 "even if you don't code the algorithms, you can use the demo mode to organize "
6485 "\"races\" between these algorithms to experiment in practice what the "
6486 "different asymptotical complexity mean."
6487 msgstr ""
6488
6489 #. type: Content of: <p>
6490 #: src/lessons/sort/basic/Main.html:11
6491 msgid ""
6492 "More exercises are planned for the future, on recursive sorting algorithms "
6493 "(such as QuickSort and MergeSort) or using other microworlds to apply these "
6494 "algorithms to other contexts."
6495 msgstr ""
6496
6497 #. type: Content of: <ul><li>
6498 #: src/lessons/sort/basic/Main.html:19
6499 msgid ""
6500 "Other graphical representations could be proposed, such as the ones "
6501 "presented at <a href=\"http://sorting.at/\">http://sorting.at/</a>."
6502 msgstr ""
6503
6504 #. type: Content of: <p>
6505 #: src/lessons/sort/basic/short_desc.html:4
6506 msgid ""
6507 "This lesson allows to experiment with some classical sorting algorithms (and "
6508 "some less common variant of them :)"
6509 msgstr ""
6510
6511 #. type: Content of: <p>
6512 #: src/lessons/sort/basic/short_desc.html:7
6513 #: src/lessons/recursion/lego/short_desc.html:6
6514 #: src/lessons/maze/short_desc.html:6
6515 msgid "You are supposed to master the bases of programming to take this lesson."
6516 msgstr ""
6517
6518 #. type: Content of: <h1>
6519 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:2
6520 msgid "BubbleSort"
6521 msgstr ""
6522
6523 #. type: Content of: <p>
6524 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:4
6525 msgid ""
6526 "Welcome to the sorting universe. It allows you to experiment with the "
6527 "existing sorting algorithms. The list of buildins that you can use in your "
6528 "algorithms is available in the world reference documentation "
6529 "(\"Help\"-&gt;\"About this world\")."
6530 msgstr ""
6531
6532 #. type: Content of: <p>
6533 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:8
6534 msgid ""
6535 "It is not enough to sort the array to pass the exercises. Your solution must "
6536 "strictly follow the expected behavior of each exercise. This is enforced by "
6537 "checking that your algorithm needs the same amount of read and write "
6538 "operations to sort the array."
6539 msgstr ""
6540
6541 #. type: Content of: <p>
6542 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:13
6543 msgid ""
6544 "When your algorithm diverges from the expectation, understanding the "
6545 "difference between your code and the expected solution can reveal very "
6546 "difficult. To help in this process, it is posible to graphically explore the "
6547 "history of your sorting algorithm. Switch to the Objective view and use the "
6548 "contextual menu (right click) to switch from the the view of the current "
6549 "state to the view of its history."
6550 msgstr ""
6551
6552 #. type: Content of: <h2>
6553 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:28
6554 msgid "First attempt at BubbleSort"
6555 msgstr ""
6556
6557 #. type: Content of: <p>
6558 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:30
6559 msgid ""
6560 "This first sorting algorithm is the most simple one: Bubble sort consists in "
6561 "progressively moving up the smaller elements of the array, as if they were "
6562 "air bubbles moving up to the surface of a liquid. The algorithm traverse the "
6563 "array, and compare any pair of adjacent elements. If two adjacent elements "
6564 "are wrongly sorted, they are swapped. Once the array was completely "
6565 "traversed, the operation starts again from the beginning. When no elements "
6566 "were sorted after a full traversal, it means that the array is completely "
6567 "sorted: the algorithm can stop. Bubble sort is studied because of its "
6568 "simplicity, but it is almost never used in practice because of its bad "
6569 "performance (O(n^2) on average)."
6570 msgstr ""
6571
6572 #. type: Attribute 'alt' of: <div>
6573 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:40
6574 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:12
6575 msgid "Show Tip (Pseudo-code)"
6576 msgstr ""
6577
6578 #. type: Content of: <div><p>
6579 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:41
6580 msgid "The pseudo-code of the BubbleSort algorithm is the following:"
6581 msgstr ""
6582
6583 #. type: Content of: <div><pre>
6584 #: src/lessons/sort/basic/bubble/AlgBubbleSort1.html:42
6585 #, no-wrap
6586 msgid ""
6587 "do: \n"
6588 " For each i in [0,len-2]\n"
6589 " If cells i and i+1 must be swapped, do it\n"
6590 "while we swapped something during last traversal\n"
6591 msgstr ""
6592
6593 #. type: Content of: <h1>
6594 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:2
6595 msgid "BubbleSort (take 2)"
6596 msgstr ""
6597
6598 #. type: Content of: <p>
6599 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:4
6600 msgid ""
6601 "If you look carefully at the behavior of BubbleSort, a first easy "
6602 "optimization appears: after one traversal, the last element of the array "
6603 "must be the biggest of all since the traversal moved it up like a bubble to "
6604 "its position. More generally, after N traversal, we know that the N last "
6605 "elements of the array are already sorted. It is thus not necessary to "
6606 "compare them again during the subsequent traversals. For now, we will have "
6607 "as many traversal as there is in the array."
6608 msgstr ""
6609
6610 #. type: Content of: <div><p>
6611 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:13
6612 msgid "The pseudo-code of the BubbleSort2 algorithm is the following:"
6613 msgstr ""
6614
6615 #. type: Content of: <div><pre>
6616 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:14
6617 #, no-wrap
6618 msgid ""
6619 "For all i in [len-2,0] (traversing from biggest to smallest)\n"
6620 " For all j in [0, i]\n"
6621 " If cells j and j+1 must be swapped, do it\n"
6622 msgstr ""
6623
6624 #. type: Content of: <p>
6625 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:20
6626 msgid ""
6627 "When we run this algorithm, it is quite disappointing to see that it runs "
6628 "approximately at the same speed than the basic version of BubbleSort. This "
6629 "is a graphical effect only since only value changes are graphically "
6630 "represented. Since this variation avoids some useless comparisons, it does "
6631 "exactly the same amount of swaps that the basic version. It is thus quite "
6632 "logical that the graphical interface draws this version at the same pace "
6633 "than the base version. But the statistics on the amount of reads show that "
6634 "we saved about the fourth of the amount of reads, which is not bad."
6635 msgstr ""
6636
6637 #. type: Content of: <p>
6638 #: src/lessons/sort/basic/bubble/AlgBubbleSort2.html:29
6639 msgid ""
6640 "From the asymptotic complexity point of view, there is absolutely no "
6641 "difference: this variation is still in O(n^2) on average (our gain is only "
6642 "on the constant term, ignored when computing the asymptotic complexity)."
6643 msgstr ""
6644
6645 #. type: Content of: <h1>
6646 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:2
6647 msgid "BubbleSort (take 3)"
6648 msgstr ""
6649
6650 #. type: Content of: <p>
6651 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:4
6652 msgid ""
6653 "Let's now reintroduce the little optimization we removed at previous step: "
6654 "if a traversal does not swap any element, it means that the array is already "
6655 "sorted. In that case, we want to stop the whole sorting process."
6656 msgstr ""
6657
6658 #. type: Content of: <p>
6659 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:9
6660 msgid ""
6661 "[!java|python|c]For that, simply use the <code>break</code> keyword, which "
6662 "breaks the current loop. Beware, if you have several nested loops, this "
6663 "will apply to the internal one.[/!] [!scala]For that, simply quit the "
6664 "current function by calling <code>return</code> with no associated "
6665 "value.[/!]"
6666 msgstr ""
6667
6668 #. type: Attribute 'alt' of: <div>
6669 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:14
6670 msgid "If you want, this tip shows the pseudo-code."
6671 msgstr ""
6672
6673 #. type: Content of: <div><pre>
6674 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:16
6675 #, no-wrap
6676 msgid ""
6677 "For all i in [len-2,0] (traversing from biggest to smallest)\n"
6678 " For all j in [0, i]\n"
6679 " If cells j and j+1 must be swapped, do it\n"
6680 " If traversal on j did not swap anything, break the for loop\n"
6681 msgstr ""
6682
6683 #. type: Content of: <p>
6684 #: src/lessons/sort/basic/bubble/AlgBubbleSort3.html:23
6685 msgid ""
6686 "This optimization is even more disappointing: it only provide a gain of a "
6687 "few percents on the amount of reads over BubbleSort2."
6688 msgstr ""
6689
6690 #. type: Content of: <h1>
6691 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:2
6692 msgid "CocktailSort"
6693 msgstr ""
6694
6695 #. type: Content of: <p>
6696 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:4
6697 msgid ""
6698 "To improve further the BubbleSort algorithm, we need to look closer its "
6699 "behavior. One can notice that big elements are moved very quickly in "
6700 "position while small ones move very slowly to their destination. They are "
6701 "thus traditionally referred to as \"rabbits\" and \"turtles\" respectively "
6702 "for big fast values and small slow ones."
6703 msgstr ""
6704
6705 #. type: Content of: <p>
6706 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:10
6707 msgid ""
6708 "To help the turtles moving faster, the cocktail sort traverse alternatively "
6709 "the array from right to left and from left to right. Here is the "
6710 "pseudo-code:"
6711 msgstr ""
6712
6713 #. type: Content of: <pre>
6714 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:15
6715 #, no-wrap
6716 msgid ""
6717 "Do\n"
6718 " For all i in [0,len-2], do:\n"
6719 " if i and i+1 must be swapped, do it\n"
6720 " For all i in [len-2,0] (downward), do:\n"
6721 " if i and i+1 must be swapped, do it\n"
6722 "while at least one of the traversal swapped an element\n"
6723 msgstr ""
6724
6725 #. type: Content of: <p>
6726 #: src/lessons/sort/basic/cocktail/AlgCocktailSort1.html:23
6727 msgid ""
6728 "One can see that cocktail sort achieves exactly the same amount of swaps "
6729 "than the bubble sort, but improves slightly on read amount. It is however "
6730 "still worse than BubbleSort2 to that extend."
6731 msgstr ""
6732
6733 #. type: Content of: <h1>
6734 #: src/lessons/sort/basic/cocktail/AlgCocktailSort2.html:2
6735 msgid "CocktailSort (take 2)"
6736 msgstr ""
6737
6738 #. type: Content of: <p>
6739 #: src/lessons/sort/basic/cocktail/AlgCocktailSort2.html:4
6740 msgid ""
6741 "We will now apply to CocktailSort the same optimization than BubbleSort2 did "
6742 "to BubbleSort. We must remember the limits of the array part not being "
6743 "sorted yet, and traverse it alternatively from left to right and from right "
6744 "to left:"
6745 msgstr ""
6746
6747 #. type: Content of: <pre>
6748 #: src/lessons/sort/basic/cocktail/AlgCocktailSort2.html:9
6749 #, no-wrap
6750 msgid ""
6751 "beg=0; end=len-2\n"
6752 "do\n"
6753 " For all Pour i in [beg,end], do:\n"
6754 " If cells i and i+1 must be swapped, do it \n"
6755 " end -= 1 (this means end = end - 1)\n"
6756 " For all Pour i in [beg,end] (downwards), do:\n"
6757 " If cells i and i+1 must be swapped, do it \n"
6758 " beg += 1 (this means beg = beg + 1)\n"
6759 "while at least one of the traversal swapped an element\n"
6760 msgstr ""
6761
6762 #. type: Content of: <h1>
6763 #: src/lessons/sort/basic/cocktail/AlgCocktailSort3.html:2
6764 msgid "CocktailSort (take 3)"
6765 msgstr ""
6766
6767 #. type: Content of: <p>
6768 #: src/lessons/sort/basic/cocktail/AlgCocktailSort3.html:4
6769 msgid ""
6770 "Even if the asymptotic complexity of CocktailSort2 is the same than the one "
6771 "of BubbleSort, it seem to perform better in practice. It is even possible to "
6772 "improve a bit further by stopping it if the first traversal didn't found "
6773 "anything to swap, without achieving the downwards traversal. Likewise, we "
6774 "can stop if the upward traversal found something to swap, but not the "
6775 "downwards one."
6776 msgstr ""
6777
6778 #. type: Content of: <h1>
6779 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:2
6780 msgid "InsertionSort"
6781 msgstr ""
6782
6783 #. type: Content of: <p>
6784 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:5
6785 msgid ""
6786 "This sorting algorithm is quite simple to understand and write, even if it "
6787 "is not as efficient as possible. Its asymptotic complexity is in O(n2), but "
6788 "it is more efficient in practice (linear in best case, ie when the array is "
6789 "already sorted, and N2/4 on average)."
6790 msgstr ""
6791
6792 #. type: Content of: <p>
6793 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:10
6794 msgid ""
6795 "The idea is to traverse all elements of the array, and to insert each of "
6796 "them into its proper position in the already sorted part of the array. When "
6797 "we look at an element x, the situation is the following: any elements to the "
6798 "left of the array are already sorted, and we have to insert x at its "
6799 "position in the array."
6800 msgstr ""
6801
6802 #. type: Content of: <p>
6803 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:18
6804 msgid "Once this is done, the situation is the following:"
6805 msgstr ""
6806
6807 #. type: Content of: <p>
6808 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:22
6809 msgid "The pseudo-code of this algorithm is thus the following:"
6810 msgstr ""
6811
6812 #. type: Content of: <pre>
6813 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:23
6814 #, no-wrap
6815 msgid ""
6816 "For each i in [1,len-1]\n"
6817 " store the value of i in a variable v\n"
6818 " copy the cell i-1 into i if i-1 contains a value bigger than v\n"
6819 " copy the cell i-2 into i-1 if i-2 contains a value bigger than v\n"
6820 " copy the cell i-3 into i-2 if i-3 contains a value bigger than v\n"
6821 " copy the cell i-4 into i-3 if i-4 contains a value bigger than v\n"
6822 " ...\n"
6823 " copy v into the last cell copied above\n"
6824 msgstr ""
6825
6826 #. type: Content of: <p>
6827 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:33
6828 msgid ""
6829 "Naturally, you should use a loop to write the big permutation within the "
6830 "given loop. Writing it this way would be really ... counter-productive."
6831 msgstr ""
6832
6833 #. type: Content of: <p>
6834 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:36
6835 msgid ""
6836 "If you've always wondered what computer science researchers do nowadays, "
6837 "here is part of the answer: They improve fundamental algorithms so that "
6838 "others can write efficient programs."
6839 msgstr ""
6840
6841 #. type: Content of: <h2>
6842 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:40
6843 msgid "Other variation of insertion sort"
6844 msgstr ""
6845
6846 #. type: Content of: <p>
6847 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:42
6848 msgid ""
6849 "TreeSort builds a binary search tree to sort them. It leads to a O(n log(n)) "
6850 "on average, but O(n^2) in worst cases. We won't study this algorithm here "
6851 "since understanding its behavior requires to know what a binary tree is, "
6852 "what is beyond our present goals."
6853 msgstr ""
6854
6855 #. type: Content of: <p>
6856 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:47
6857 msgid ""
6858 "There is other variations over the insertion sort, such as PatienceSort "
6859 "which builds piles of values and sort each pile afterward. This algorithm "
6860 "presents a 0(n log(n)) timing worst case and a 0(n) space "
6861 "complexity. LibrarySort (proposed in 2004) also trades a bit space in "
6862 "exchange for time since it provide a time complexity of O(n log(n)) but "
6863 "needs to store some more data."
6864 msgstr ""
6865
6866 #. type: Content of: <p>
6867 #: src/lessons/sort/basic/insertion/AlgInsertionSort.html:54
6868 msgid ""
6869 "Wikipedia provides a detailled description of all these algorithms we cannot "
6870 "present here because of time constraints."
6871 msgstr ""
6872
6873 #. type: Content of: <h2>
6874 #: src/lessons/sort/basic/shell/AlgShellSort.html:2
6875 msgid "ShellSort"
6876 msgstr ""
6877
6878 #. type: Content of: outside any tag (error?)
6879 #: src/lessons/sort/basic/shell/AlgShellSort.html:4
6880 msgid ""
6881 "This algorithm is named after its author, Donald Shell, who published it in "
6882 "1959. It can be seen as an application of the CombSort idea (let elements "
6883 "having a long path to travel take shortcuts) to the insertion sort (CombSort "
6884 "is a variation of BubbleSort). Instead of comparing adjacent values during "
6885 "the insertion sort, it compares values separated by a bigger gap. The bigger "
6886 "the gap, the faster the elements are moved to their final destination, but "
6887 "also the less precise is this move. It is thus mandatory to apply the "
6888 "algorithm with a serie of decreasing gaps. At the last step, when the gap is "
6889 "one, InsertionSort is used, but onto an array which is almost already sorted "
6890 "by previous steps."
6891 msgstr ""
6892
6893 #. type: Content of: <p>
6894 #: src/lessons/sort/basic/shell/AlgShellSort.html:15
6895 msgid ""
6896 "Donald Shell propose <code>len/2</code> as initial value of the gap, and "
6897 "then to divide it by 2 at each step. The pseudo-code is thus the following:"
6898 msgstr ""
6899
6900 #. type: Content of: <p><pre>
6901 #: src/lessons/sort/basic/shell/AlgShellSort.html:18
6902 #, no-wrap
6903 msgid ""
6904 "gap=len/2\n"
6905 "while gap>0:\n"
6906 " apply InsertionSort, comparing i-gap and i, then i-2gap and i-gap, then "
6907 "i-3gap and i-2gap, etc.\n"
6908 msgstr ""
6909
6910 #. type: Content of: <p><p>
6911 #: src/lessons/sort/basic/shell/AlgShellSort.html:23
6912 msgid ""
6913 "Just like in CombSort, the sequence of values taken by the gap is crucial "
6914 "for Shell sort performance. In some rare pathological cases, the sequence we "
6915 "used above can lead to a O(n^2) performance. Other sequences were proposed: "
6916 "the Hibbard's increments of 2k − 1 lead to a complexity of O(n^(3/2)) in "
6917 "worst cases. Pratt's increments 2^i3^j lead to a O(nlog(n)log(n) performance "
6918 "in worst cases. The existance of a sequence leading to a O(n log(n)) was "
6919 "precluded by Poonen, Plaxton, and Suel. Thanks to this performance, "
6920 "ShellSort is a valid candidate for array of several hundred thousands when "
6921 "correctly implemented."
6922 msgstr ""
6923
6924 #. type: Content of: <p><p>
6925 #: src/lessons/sort/basic/shell/AlgShellSort.html:33
6926 msgid ""
6927 "In our case, the array are ways too small to benefit of these "
6928 "optimizations. If you ever need to do so, take as initial gap the biggest "
6929 "value of the targeted serie still smaller than the array size, and then use "
6930 "decreasing values of the serie."
6931 msgstr ""
6932
6933 #. type: Content of: <p><p>
6934 #: src/lessons/sort/basic/shell/AlgShellSort.html:38
6935 msgid ""
6936 "Interestingly enough, determining the best gap sequence for shell sort turns "
6937 "into a research issue of our century in computer science. For example, an "
6938 "article of 2001 introduces the following sequence, which seems to be optimal "
6939 "in practice for arrays of size up to 10^5: {1, 4, 10, 23, 57, 132, 301, 701, "
6940 "1750} (Marcin Ciura, Best Increments for the Average Case of Shellsort, 13th "
6941 "International Symposium on Fundamentals of Computation Theory, LNCS 2001; "
6942 "Vol. 2138)."
6943 msgstr ""
6944
6945 #. type: Content of: <h1>
6946 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:2
6947 msgid "Selection Sort"
6948 msgstr ""
6949
6950 #. type: Content of: outside any tag (error?)
6951 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:4
6952 msgid ""
6953 "In this exercise we will implement another classical algorithm: selection "
6954 "sort."
6955 msgstr ""
6956
6957 #. type: Content of: <p>
6958 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:7
6959 msgid ""
6960 "The idea is simply to select for each cell of the array the smallest value "
6961 "from the part not already sorted. Thus for the first cell, it takes the "
6962 "smallest value over the whole array. For the second one, it takes the second "
6963 "smallest value, which is the smallest value from the cell not already "
6964 "sorted. You of course don't have to sort the last cell of the array, that is "
6965 "already sorted when you consider it."
6966 msgstr ""
6967
6968 #. type: Content of: <p><p>
6969 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:14
6970 msgid ""
6971 "More generally, for the cell N, it looks the cell M in [N;len] containing "
6972 "the smallest possible value of the interval. Then, it swaps the content of "
6973 "cell N with the one of cell M."
6974 msgstr ""
6975
6976 #. type: Content of: <p><p><h2>
6977 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:18
6978 msgid "Existing variations"
6979 msgstr ""
6980
6981 #. type: Content of: <p><p>
6982 #: src/lessons/sort/basic/selection/AlgSelectionSort.html:19
6983 msgid ""
6984 "Another classical algorithm which idea is based on the selection of good "
6985 "elements is HeapSort, but it uses a heap data structure which we did not see "
6986 "yet. Simply remember that HeapSort provides a O(n log n) performance in "
6987 "worst case, which is why it is a very interesting algorithm in practice."
6988 msgstr ""
6989
6990 #. type: Content of: <h1>
6991 #: src/lessons/sort/basic/comb/AlgCombSort.html:2
6992 msgid "CombSort"
6993 msgstr ""
6994
6995 #. type: Content of: <p>
6996 #: src/lessons/sort/basic/comb/AlgCombSort.html:4
6997 msgid ""
6998 "We saw that CocktailSort improve a bit for turtles (i.e. small values near "
6999 "to the end of the array), but it is still possible to achieve "
7000 "better. ComboSort comes down to providing them a short cut: instead of "
7001 "comparing adjacent values, we compare values separated by a gap bigger than "
7002 "1. That way, turtles will traverse <i>gap</i> cells at each "
7003 "traversal. Naturally, we have to apply the algorithm with decreasing gaps, "
7004 "and finish with <i>gap=1</i> to ensure that the array is correctly sorted "
7005 "afterward. Choosing the right gap and how to decrease it is a difficult "
7006 "question, but in practice, dividing it by 1.3 after each traversal leads to "
7007 "good performance. Here is the corresponding pseudo-code:"
7008 msgstr ""
7009
7010 #. type: Content of: <pre>
7011 #: src/lessons/sort/basic/comb/AlgCombSort.html:16
7012 #, no-wrap
7013 msgid ""
7014 "gap = len;\n"
7015 "do\n"
7016 " if gap>1 then\n"
7017 " gap = gap / 1.3\n"
7018 " i = O\n"
7019 " while i+gap &lt; len do:\n"
7020 " if i and i+gap must be swapped, do it\n"
7021 " increase i by one\n"
7022 "while the gap is bigger than 1 or the last traversal swapped at least one "
7023 "pair\n"
7024 msgstr ""
7025
7026 #. type: Content of: outside any tag (error?)
7027 #: src/lessons/sort/basic/comb/AlgCombSort.html:27
7028 #: src/lessons/maze/island/IslandMaze.html:67
7029 #: src/lessons/welcome/bat/bool1/Max1020.html:6
7030 msgid "[!scala]"
7031 msgstr ""
7032
7033 #. type: Content of: <p>
7034 #: src/lessons/sort/basic/comb/AlgCombSort.html:27
7035 msgid ""
7036 "One tricky part is that we want to divide gap, that is an integer (of type "
7037 "Int), by 1.3, that is a Double. The type system of scala won't let us do "
7038 "this, because such discrepancy usually denotes a programmer error. As this "
7039 "is not an error this time, we have to convert gap to Double for the time of "
7040 "the operation, and then convert the result back to Int to store it into "
7041 "gap. This should be written this way:"
7042 msgstr ""
7043
7044 #. type: Content of: <pre>
7045 #: src/lessons/sort/basic/comb/AlgCombSort.html:31
7046 #, no-wrap
7047 msgid "gap = (gap.asInstanceOf[Double] / 1.3).asInstanceOf[Int]"
7048 msgstr ""
7049
7050 #. type: Content of: <p>
7051 #: src/lessons/sort/basic/comb/AlgCombSort.html:32
7052 msgid ""
7053 "This is rather verbose, but actually, this notation is not very complex. And "
7054 "remember that the type checker is your friend. It's picky and sometimes "
7055 "annoying (as on this one), but it often catches weird bugs that would have "
7056 "been a pain to debug if not catch by the type checker. And since the Scala's "
7057 "authors are pragmatic, the previous expression can be simplified:"
7058 msgstr ""
7059
7060 #. type: Content of: <pre>
7061 #: src/lessons/sort/basic/comb/AlgCombSort.html:36
7062 #, no-wrap
7063 msgid "gap = (gap.toDouble / 1.3).toInt"
7064 msgstr ""
7065
7066 #. type: Content of: <p>
7067 #: src/lessons/sort/basic/comb/AlgCombSort.html:37
7068 msgid ""
7069 "<code>toDouble</code> and <code>toInt</code> are just shortcuts for the "
7070 "corresponding expressions <code>asInstanceOf[Double]</code> and "
7071 "<code>asInstanceOf[Int]</code>. It's not very generic, but it's very handy."
7072 msgstr ""
7073
7074 #. type: Content of: <p>
7075 #: src/lessons/sort/basic/comb/AlgCombSort.html:41
7076 msgid ""
7077 "This algorithm was invented by Wlodek Dobosiewicz in 1980, and later "
7078 "rediscovered and popularized by Stephen Lacey and Richard Box, who described "
7079 "it in Byte Magazine in April 1991."
7080 msgstr ""
7081
7082 #. type: Content of: <h1>
7083 #: src/lessons/sort/basic/comb/AlgCombSort11.html:2
7084 msgid "CombSort11"
7085 msgstr ""
7086
7087 #. type: Content of: <p>
7088 #: src/lessons/sort/basic/comb/AlgCombSort11.html:4
7089 msgid ""
7090 "The authors of this algorithm observed that the performance is increased if "
7091 "we make sure that the last values of the gap are (11, 8, 6, 4, 3, 2, 1) "
7092 "rather than (9, 6, 4, 3, 2, 1) or (10, 7, 5, 3, 2, 1). Rework the code of "
7093 "CombSort to ensure just after the gap update that if it is 9 or 10, we "
7094 "should use 11 instead."
7095 msgstr ""
7096
7097 #. type: Content of: <h1>
7098 #: src/lessons/sort/basic/gnome/AlgGnomeSort.html:2
7099 msgid "GnomeSort"
7100 msgstr ""
7101
7102 #. type: Content of: <p>
7103 #: src/lessons/sort/basic/gnome/AlgGnomeSort.html:4
7104 msgid ""
7105 "The Gnome sort is similar to insertion sort, but the elements are moved in "
7106 "position by a serie of swaps just like in bubble sort. It is named after the "
7107 "supposed behavior of garden gnomes when they sort flower pots. Here is a "
7108 "description of the algorithm by its author:"
7109 msgstr ""
7110
7111 #. type: Content of: <p>
7112 #: src/lessons/sort/basic/gnome/AlgGnomeSort.html:9
7113 msgid ""
7114 "Gnome Sort is based on the technique used by the standard Dutch Garden Gnome "
7115 "(Du.: tuinkabouter). Here is how a garden gnome sorts a line of flower "
7116 "pots. Basically, he looks at the flower pot next to him and the one "
7117 "immediately after ; if they are in the right order he steps one pot forward, "
7118 "otherwise he swaps them and steps one pot backwards. Boundary conditions: if "
7119 "there is no previous pot, he steps forwards; if there is no pot next to him, "
7120 "he is done. <i>—Dick Grune</i>"
7121 msgstr ""
7122
7123 #. type: Content of: <h1>
7124 #: src/lessons/sort/dutchflag/Main.html:2
7125 #: src/lessons/sort/dutchflag/short_desc.html:2
7126 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:2
7127 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:2
7128 msgid "The Dutch Flag Problem"
7129 msgstr ""
7130
7131 #. type: Content of: <p>
7132 #: src/lessons/sort/dutchflag/Main.html:4
7133 msgid ""
7134 "This problem was first proposed by E.W Dijkstra in 1976 (in the chapter 14 "
7135 "of his book \"A Discipline of Programming\"). It is a very classical "
7136 "variation of the sorting algorithms since then. It is sometimes useful in "
7137 "real life, but it became famous for its pedagogical properties: its "
7138 "complexity is not trivial, but not complex either. It can easily be "
7139 "formally proven, but it's not absolutely trivial either."
7140 msgstr ""
7141
7142 #. type: Content of: <ul><li>
7143 #: src/lessons/sort/dutchflag/Main.html:13
7144 msgid "A temporal view could be welcomed."
7145 msgstr ""
7146
7147 #. type: Content of: <ul><li>
7148 #: src/lessons/sort/dutchflag/Main.html:14
7149 msgid ""
7150 "Other exercises, for example with 2 colors only or with more than 3 colors, "
7151 "could generalize the proposed approach."
7152 msgstr ""
7153
7154 #. type: Content of: <ul><li>
7155 #: src/lessons/sort/dutchflag/Main.html:15
7156 msgid "This problem could be solved recursively."
7157 msgstr ""
7158
7159 #. type: Content of: <p>
7160 #: src/lessons/sort/dutchflag/short_desc.html:4
7161 msgid ""
7162 "This is a classical sorting problem, constituting a variation over the "
7163 "insertion sort."
7164 msgstr ""
7165
7166 #. type: Content of: <p>
7167 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:4
7168 msgid ""
7169 "Your work is to sort all the colors of the Dutch flag, and the only provided "
7170 "primitive is to exchange two given lines. In addition, you should not "
7171 "create any additional variables (but a few indices)."
7172 msgstr ""
7173
7174 #. type: Content of: <p>
7175 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:7
7176 msgid ""
7177 "If you think carefully, this can be done in linear time, where you sort a "
7178 "line at each iteration of the loop. You may want to check again the <a "
7179 "href=\"plm://lessons.sort.basic/insertion.AlgInsertionSort\">insertion "
7180 "sort</a>, of which the Dutch Flag sort is a variation. The main difference "
7181 "is that you have 3 insertion points, not only one..."
7182 msgstr ""
7183
7184 #. type: Attribute 'alt' of: <div>
7185 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:11
7186 msgid "I need an hint to start"
7187 msgstr ""
7188
7189 #. type: Content of: <div>
7190 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:12
7191 msgid "Do a traversal over your data, saving 3 indices:"
7192 msgstr ""
7193
7194 #. type: Content of: <div><ul><li>
7195 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:14
7196 msgid ""
7197 "<code>afterBlue</code> is initialized to 0. Make sure that every cell below "
7198 "<code>afterBlue</code> is filled with blue elements."
7199 msgstr ""
7200
7201 #. type: Content of: <div><ul><li>
7202 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:15
7203 msgid ""
7204 "<code>whiteRed</code> is initialized to size-1. Make sure that every cell "
7205 "after <code>whiteRed</code> is filled with red elements."
7206 msgstr ""
7207
7208 #. type: Content of: <div><ul><li>
7209 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:16
7210 msgid ""
7211 "<code>beforeWhite</code> is initialized to size-1. Make sure that every cell "
7212 "after <code>beforeWhite</code> and before <code>whiteRed</code> is filled "
7213 "with white elements."
7214 msgstr ""
7215
7216 #. type: Content of: <div>
7217 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:18
7218 msgid ""
7219 "Note that the unsorted cells are always between <code>afterBlue</code> and "
7220 "<code>beforeWhite</code>."
7221 msgstr ""
7222
7223 #. type: Content of: <div>
7224 #: src/lessons/sort/dutchflag/DutchFlagAlgo.html:20
7225 msgid ""
7226 "At each step of your traversal, check the color of the cell at "
7227 "<code>afterBlue</code> and do the required exchanges. The loop ending "
7228 "condition is when <code>afterBlue</code> becomes larger than "
7229 "<code>beforeWhite</code>."
7230 msgstr ""
7231
7232 #. type: Content of: <h2>
7233 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:4
7234 msgid "Provided values"
7235 msgstr ""
7236
7237 #. type: Content of: <p>
7238 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:6
7239 msgid ""
7240 "The colors are represented through the following constants: BLUE, WHITE and "
7241 "RED. You can use them directly in your code."
7242 msgstr ""
7243
7244 #. type: Content of: <h2>
7245 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:9
7246 #: src/lessons/lander/universe/DelegatingLanderWorld.html:8
7247 msgid "Provided functions"
7248 msgstr ""
7249
7250 #. type: Content of: <p>
7251 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:11
7252 msgid "This world is very simple, with only 5 provided functions."
7253 msgstr ""
7254
7255 #. type: Content of: <pre>
7256 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:13
7257 #, no-wrap
7258 msgid ""
7259 "[!java|c]void [/!]swap([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int "
7260 "[/!]y[!scala]:Int[/!])"
7261 msgstr ""
7262
7263 #. type: Content of: outside any tag (error?)
7264 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:14
7265 msgid "Swap the lines number <code>x</code> and <code>y</code>."
7266 msgstr ""
7267
7268 #. type: Content of: <pre>
7269 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:16
7270 #, no-wrap
7271 msgid "[!java|c]int [/!]getSize() [!scala]:Int[/!]"
7272 msgstr ""
7273
7274 #. type: Content of: outside any tag (error?)
7275 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:17
7276 msgid "Returns the amount of lines on this flag."
7277 msgstr ""
7278
7279 #. type: Content of: <pre>
7280 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:19
7281 #, no-wrap
7282 msgid ""
7283 "[!java|c]int [/!]getColor([!java|c]int [/!]line[!scala]:Int[/!]) "
7284 "[!scala]:Int[/!]"
7285 msgstr ""
7286
7287 #. type: Content of: outside any tag (error?)
7288 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:20
7289 msgid "Returns the color of the given line."
7290 msgstr ""
7291
7292 #. type: Content of: <pre>
7293 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:22
7294 #: src/lessons/sort/baseball/universe/BaseballWorld.html:31
7295 #, no-wrap
7296 msgid "[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]"
7297 msgstr ""
7298
7299 #. type: Content of: outside any tag (error?)
7300 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:23
7301 msgid "Returns whether the flag is sorted."
7302 msgstr ""
7303
7304 #. type: Content of: <pre>
7305 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:25
7306 #: src/lessons/sort/baseball/universe/BaseballWorld.html:37
7307 #, no-wrap
7308 msgid "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
7309 msgstr ""
7310
7311 #. type: Content of: outside any tag (error?)
7312 #: src/lessons/sort/dutchflag/universe/DutchFlagWorld.html:26
7313 #: src/lessons/sort/baseball/universe/BaseballWorld.html:38
7314 msgid "Returns whether the current world is selected in the interface."
7315 msgstr ""
7316
7317 #. type: Content of: <h1>
7318 #: src/lessons/sort/pancake/universe/PancakeWorld.html:2
7319 msgid "PancakeWorld"
7320 msgstr ""
7321
7322 #. type: Content of: <p>
7323 #: src/lessons/sort/pancake/universe/PancakeWorld.html:4
7324 msgid "This universe is very simple, with only five functions provided."
7325 msgstr ""
7326
7327 #. type: Content of: <pre>
7328 #: src/lessons/sort/pancake/universe/PancakeWorld.html:6
7329 #, no-wrap
7330 msgid "[!java|c]int [/!]getStackSize() [!scala]:Int[/!]"
7331 msgstr ""
7332
7333 #. type: Content of: outside any tag (error?)
7334 #: src/lessons/sort/pancake/universe/PancakeWorld.html:7
7335 msgid "Returns the size of the stack, that is the amount of pancakes it contains."
7336 msgstr ""
7337
7338 #. type: Content of: <pre>
7339 #: src/lessons/sort/pancake/universe/PancakeWorld.html:9
7340 #, no-wrap
7341 msgid ""
7342 "[!java|c]int [/!]getPancakeRadius([!java|c]int [/!]rank[!scala]:Int[/!]) "
7343 "[!scala]:Int[/!]"
7344 msgstr ""
7345
7346 #. type: Content of: outside any tag (error?)
7347 #: src/lessons/sort/pancake/universe/PancakeWorld.html:10
7348 msgid ""
7349 "Returns the radius of the pancake passed as argument, with the rank of the "
7350 "top-most pancake being 0."
7351 msgstr ""
7352
7353 #. type: Content of: <pre>
7354 #: src/lessons/sort/pancake/universe/PancakeWorld.html:12
7355 #, no-wrap
7356 msgid ""
7357 "[!java]boolean [/!][!c]int [/!]isPancakeUpsideDown([!java|c]int "
7358 "[/!]rank[!scala]:Int[/!]) [!scala]:Boolean[/!]"
7359 msgstr ""
7360
7361 #. type: Content of: outside any tag (error?)
7362 #: src/lessons/sort/pancake/universe/PancakeWorld.html:13
7363 msgid ""
7364 "Returns whether the pancake passed as argument upside-down, that is, if its "
7365 "burned side is on top. As usual, the top-most pancake is of rank 0."
7366 msgstr ""
7367
7368 #. type: Content of: <pre>
7369 #: src/lessons/sort/pancake/universe/PancakeWorld.html:15
7370 #, no-wrap
7371 msgid "[!java|c]void [/!]flip([!java|c]int [/!]amount[!scala]:Int[/!])"
7372 msgstr ""
7373
7374 #. type: Content of: outside any tag (error?)
7375 #: src/lessons/sort/pancake/universe/PancakeWorld.html:16
7376 msgid ""
7377 "Flips the <code>amount</code> first pancakes composing the stack, from the "
7378 "top of it."
7379 msgstr ""
7380
7381 #. type: Content of: <pre>
7382 #: src/lessons/sort/pancake/universe/PancakeWorld.html:18
7383 #, no-wrap
7384 msgid "[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]"
7385 msgstr ""
7386
7387 #. type: Content of: outside any tag (error?)
7388 #: src/lessons/sort/pancake/universe/PancakeWorld.html:19
7389 msgid "Returns whether the pancake stack is correctly sorted."
7390 msgstr ""
7391
7392 #. type: Content of: <pre>
7393 #: src/lessons/sort/pancake/universe/PancakeWorld.html:21
7394 #, no-wrap
7395 msgid "[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]"
7396 msgstr ""
7397
7398 #. type: Content of: <h1>
7399 #: src/lessons/sort/pancake/Main.html:2
7400 #: src/lessons/sort/pancake/BasicPancake.html:2
7401 msgid "Pancake Sorting"
7402 msgstr ""
7403
7404 #. type: Content of: <p>
7405 #: src/lessons/sort/pancake/Main.html:4
7406 msgid ""
7407 "This activity is inspired by a problem first introduced in 1975 by Harry "
7408 "Dweighter in the American Mathematical Monthly. The question is not only to "
7409 "sort the pancakes, but to determine <code>f(n)</code> the <i>minimal</i> "
7410 "amount of flips mandated to sort any stack of size <code>n</code>."
7411 msgstr ""
7412
7413 #. type: Content of: <p>
7414 #: src/lessons/sort/pancake/Main.html:8
7415 msgid ""
7416 "This problem is now famous because Bill Gates authored (with "
7417 "C. Papadimitriou) his only scientific publication in 1979 on this topic, "
7418 "providing a faster algorithm and proving that <code>17n/16 ≤ f(n) ≤ "
7419 "(5n+5)/3</code>. This was the only publication of Bill Gates before he "
7420 "invented Windows and became rich."
7421 msgstr ""
7422
7423 #. type: Content of: <p>
7424 #: src/lessons/sort/pancake/Main.html:12
7425 msgid ""
7426 "Then, David X. Cohen, the inventor of the Futurama comics with many "
7427 "mathematical references, introduced the variant with burnt pancakes and "
7428 "studied its complexity with Manuel Blum in 1993."
7429 msgstr ""
7430
7431 #. type: Content of: <p>
7432 #: src/lessons/sort/pancake/Main.html:15
7433 msgid ""
7434 "An article of 2011 (by L. Bulteau, G. Fertin and I. Rusu) proved that "
7435 "determining the minimal amount of flips to sort the stack is a NP-complete "
7436 "problem. Naturally, the stack sorting problem is not NP-complete since it "
7437 "can be solved in 2n-3 steps with the naive algorithm and (5n+5)/3 steps with "
7438 "the Gates algorithm. That's determining the minimal amount of steps that is "
7439 "NP."
7440 msgstr ""
7441
7442 #. type: Content of: <p>
7443 #: src/lessons/sort/pancake/Main.html:20
7444 msgid "Further information can be found on the wikipedia page, as usual."
7445 msgstr ""
7446
7447 #. type: Content of: <p>
7448 #: src/lessons/sort/pancake/Main.html:23
7449 msgid ""
7450 "This activity is also integrated to CSIRL (my repository of <i>free</i> "
7451 "unplugged activities to introduce computer science, available at "
7452 "http://www.loria.fr/~quinson/Mediation/SMN/), and it may be interesting to "
7453 "run the unplugged activities before implementing these algorithms in PLM."
7454 msgstr ""
7455
7456 #. type: Content of: <ul><li>
7457 #: src/lessons/sort/pancake/Main.html:34
7458 msgid "A temporal view similar to the sorting universe could be helpful"
7459 msgstr ""
7460
7461 #. type: Content of: <ul><li>
7462 #: src/lessons/sort/pancake/Main.html:35
7463 msgid ""
7464 "Other exercises, for example on the Roti sorting, with a pile of Roti that "
7465 "have to touch the grill on each face (see "
7466 "http://en.wikipedia.org/wiki/Pancake_sorting#The_identical_pancake_stack)."
7467 msgstr ""
7468
7469 #. type: Content of: <h3>
7470 #: src/lessons/sort/pancake/short_desc.html:2
7471 msgid "The pancake problem"
7472 msgstr ""
7473
7474 #. type: Content of: <p>
7475 #: src/lessons/sort/pancake/short_desc.html:4
7476 msgid "Help the poor psychorigid pancakes' chef to sort its pancake stack!"
7477 msgstr ""
7478
7479 #. type: Content of: <p>
7480 #: src/lessons/sort/pancake/short_desc.html:6
7481 msgid ""
7482 "This funny problem leads to algorithms that are somewhat more challenging to "
7483 "implement. You are supposed to master the bases of programming and some "
7484 "sorting algorithms to take this lesson."
7485 msgstr ""
7486
7487 #. type: Content of: <p>
7488 #: src/lessons/sort/pancake/BasicPancake.html:4
7489 msgid ""
7490 "The pancake sorting problem is a simple puzzle where you have a set of "
7491 "pancakes, each of differing size. The chef cooking the pancake is a bit "
7492 "psychorigid: he hates when the pancakes are not correctly sorted on the "
7493 "plate. He loves when they are correctly ordered, with the small ones over "
7494 "the larger ones. As every pancake maker, he masters the pancake flipping "
7495 "with his spatula. He can flip the pancake on top of the stack, or even "
7496 "several pancakes at once. The thing is that he has only one plate and the "
7497 "table is too dirty to place pancakes on it, even temporary. The only allowed "
7498 "operation is to flip some pancakes that are on top of the stack."
7499 msgstr ""
7500
7501 #. type: Content of: <p>
7502 #: src/lessons/sort/pancake/BasicPancake.html:13
7503 msgid ""
7504 "Your work is to help this poor guy sorting his stack by flipping the "
7505 "pancakes. Each pancake is defined by its radius and rank within the stack, "
7506 "with the top-most pancake is at rank 0, and the one below at rank 1."
7507 msgstr ""
7508
7509 #. type: Content of: <p>
7510 #: src/lessons/sort/pancake/BasicPancake.html:17
7511 msgid ""
7512 "Note that you can play physically with pieces of paper or wood at first to "
7513 "get the grasp on this problem. This is even one of the activities that I use "
7514 "in my CS-IRL (computer science in real life) project to introduce the "
7515 "concept of algorithm to absolute beginners that wonder about our "
7516 "science. More information at http://www.loria.fr/~quinson/Mediation/SMN/ (in "
7517 "French)."
7518 msgstr ""
7519
7520 #. type: Attribute 'alt' of: <p><div>
7521 #: src/lessons/sort/pancake/BasicPancake.html:23
7522 #: src/lessons/sort/pancake/BubblePancake.html:10
7523 msgid "I don't get it. I need some help."
7524 msgstr ""
7525
7526 #. type: Content of: <p><div>
7527 #: src/lessons/sort/pancake/BasicPancake.html:24
7528 msgid ""
7529 "You should try to first move the largest pancake to the bottom, and then the "
7530 "largest but one pancake on top of it, and then the one just smaller on top, "
7531 "and so on."
7532 msgstr ""
7533
7534 #. type: Attribute 'alt' of: <p><p><div>
7535 #: src/lessons/sort/pancake/BasicPancake.html:28
7536 #: src/lessons/sort/pancake/BubblePancake.html:13
7537 msgid "The first tip was not enough. I need another one."
7538 msgstr ""
7539
7540 #. type: Content of: <p><div>
7541 #: src/lessons/sort/pancake/BasicPancake.html:29
7542 msgid "So first, you need to move the largest pancake at the bottom of the stack."
7543 msgstr ""
7544
7545 #. type: Content of: <p><div>
7546 #: src/lessons/sort/pancake/BasicPancake.html:30
7547 msgid ""
7548 "Can you imagine a situation in which you can easily bring this damn large "
7549 "pancake to the bottom?"
7550 msgstr ""
7551
7552 #. type: Content of: <p><div>
7553 #: src/lessons/sort/pancake/BasicPancake.html:31
7554 msgid "How could you reach this situation from the current one?"
7555 msgstr ""
7556
7557 #. type: Content of: <h1>
7558 #: src/lessons/sort/pancake/BubblePancake.html:2
7559 msgid "Bubble Pancakes"
7560 msgstr ""
7561
7562 #. type: Content of: <p>
7563 #: src/lessons/sort/pancake/BubblePancake.html:4
7564 msgid ""
7565 "This problem is similar to the previous: you have to sort the pancakes, the "
7566 "smallest at the top and the biggest at the bottom, except you can only flip "
7567 "them to sort."
7568 msgstr ""
7569
7570 #. type: Content of: <p>
7571 #: src/lessons/sort/pancake/BubblePancake.html:6
7572 msgid ""
7573 "The purpose here is to sort them using the bubble algorithm, where one "
7574 "pancake is moved to the bottom until it encounters a bigger one. In "
7575 "graphical representations, it looks like a bubble takes the element and move "
7576 "them through the pile. This is where its name comes from."
7577 msgstr ""
7578
7579 #. type: Content of: <p>
7580 #: src/lessons/sort/pancake/BubblePancake.html:8
7581 msgid ""
7582 "Now, using pancakes makes it a little more difficult to write, because you "
7583 "have to find a way to swap only two pancakes at a time."
7584 msgstr ""
7585
7586 #. type: Content of: <p><div>
7587 #: src/lessons/sort/pancake/BubblePancake.html:11
7588 msgid ""
7589 "The bubble algorithm consists in browsing the whole pile from top to bottom, "
7590 "and making a comparision between two pancakes. Each time the top pancake is "
7591 "bigger than the one below, you have to swap them, then compare the bigger "
7592 "pancake you just swapped with one below, and so on. You have to browse "
7593 "through the entire pile until no swap has occurred, in which case the pile "
7594 "is sorted."
7595 msgstr ""
7596
7597 #. type: Content of: <p><p><div>
7598 #: src/lessons/sort/pancake/BubblePancake.html:14
7599 msgid ""
7600 "If you don't understand the basic bubble sorting algorithm, you should try "
7601 "the exercises within the “Sorting algorithms” lesson. If you do, but can't "
7602 "figure a way to swap only two pancakes at a time, think of a situation where "
7603 "only two pancakes are swapped at a time, and find a way to reach that "
7604 "situation."
7605 msgstr ""
7606
7607 #. type: Content of: <h1>
7608 #: src/lessons/sort/pancake/BurnedPancake.html:2
7609 msgid "Burned Pancakes"
7610 msgstr ""
7611
7612 #. type: Content of: <p>
7613 #: src/lessons/sort/pancake/BurnedPancake.html:4
7614 msgid ""
7615 "Hard blow for the chef! The pancakes got burnt on one side! There is no way "
7616 "he can deliver a stack of pancakes with visibly burnt pancakes! You've got "
7617 "to help him ensuring that no pancake is upside-down while sorting his stack."
7618 msgstr ""
7619
7620 #. type: Content of: <h1>
7621 #: src/lessons/sort/pancake/GatesPancake.html:2
7622 msgid "Faster Pancake Sorting"
7623 msgstr ""
7624
7625 #. type: Content of: <p>
7626 #: src/lessons/sort/pancake/GatesPancake.html:4
7627 msgid ""
7628 "Unlike others sorting problem, the expensive operation is not the comparison "
7629 "of values, but the flipping of pancakes. In this exercise, we will explore "
7630 "another algorithm that attempt to reduce the amount of stack flipping. The "
7631 "funny side is that this algorithm was first introduced by Bill Gates, before "
7632 "invented Windows."
7633 msgstr ""
7634
7635 #. type: Content of: <p>
7636 #: src/lessons/sort/pancake/GatesPancake.html:9
7637 msgid ""
7638 "The basic idea is to grow sequences of sorted pancakes, not necessarily "
7639 "starting from the bottom. We say that a sequence of ordered pancakes "
7640 "constitute a <b>block</b> while a pancake that is not part of a block is "
7641 "said to be <b>free</b>. The algorithm then considers the topmost pancake (of "
7642 "radius <code>t</code>) and search for the <code>t+1</code> or "
7643 "<code>t-1</code> pancakes (the considered neighbor is noted "
7644 "<code>t+o</code>). Eight cases may happen:"
7645 msgstr ""
7646
7647 #. type: Content of: <ul><li>
7648 #: src/lessons/sort/pancake/GatesPancake.html:16
7649 msgid ""
7650 "<b>Case a</b>: Both <code>t</code> and <code>t+o</code> are free. They are "
7651 "then merged in one flip."
7652 msgstr ""
7653
7654 #. type: Content of: <ul><li>
7655 #: src/lessons/sort/pancake/GatesPancake.html:20
7656 msgid ""
7657 "<b>Case b</b>: <code>t</code> is free, and <code>t+o</code> is the first of "
7658 "a block. They are merged in one flip."
7659 msgstr ""
7660
7661 #. type: Content of: <ul><li>
7662 #: src/lessons/sort/pancake/GatesPancake.html:25
7663 msgid ""
7664 "<b>Case c</b>: <code>t</code> is free but both <code>t-1</code> and "
7665 "<code>t+1</code> are the last elements of blocks. Both blocks and "
7666 "<code>t</code> are merged all together in 4 flips. Beware, if either "
7667 "<code>t-1</code> or <code>t+1</code> does not exist (because <code>t</code> "
7668 "is 0 or max), only two flips are mandated."
7669 msgstr ""
7670
7671 #. type: Content of: <ul><li>
7672 #: src/lessons/sort/pancake/GatesPancake.html:33
7673 msgid ""
7674 "<b>Case d</b>: <code>t</code> is in a block but <code>t+o</code> is "
7675 "free. They are merged in one flip."
7676 msgstr ""
7677
7678 #. type: Content of: <ul><li>
7679 #: src/lessons/sort/pancake/GatesPancake.html:38
7680 msgid ""
7681 "<b>Case e</b>: <code>t</code> is in a block and <code>t+o</code> is the "
7682 "first element of a block. They are merged in one flip."
7683 msgstr ""
7684
7685 #. type: Content of: <ul><li>
7686 #: src/lessons/sort/pancake/GatesPancake.html:42
7687 msgid ""
7688 "<b>Case f</b>: <code>t</code> is in a block and <code>t+o</code> is the last "
7689 "element of another block. They are merged in 3 flips as follows."
7690 msgstr ""
7691
7692 #. type: Content of: <ul><li>
7693 #: src/lessons/sort/pancake/GatesPancake.html:46
7694 msgid ""
7695 "<b>Case g</b>: <code>t</code> is in a block of length k+1 (the last element "
7696 "is <code>t+ko</code>), <code>t+(k+1)o</code> is either free or the last "
7697 "element of another block. Both blocks are merged in 2 flips:"
7698 msgstr ""
7699
7700 #. type: Content of: <ul><li>
7701 #: src/lessons/sort/pancake/GatesPancake.html:49
7702 msgid ""
7703 "<b>Case h</b>: <code>t</code> is in a block of length k+1 (the last element "
7704 "is <code>t+ko</code>), <code>t+(k+1)o</code> is the first element of another "
7705 "block (the difference with case g is that <code>t+(k+1)o</code> is now the "
7706 "<i>first</i> element of its block). Both blocks are merged in 2 flips:"
7707 msgstr ""
7708
7709 #. type: Content of: <ul><li>
7710 #: src/lessons/sort/pancake/GatesPancake.html:55
7711 msgid ""
7712 "<b>Case i</b>: <code>t</code> is in a block of length <code>n</code> (this "
7713 "block contains all pancakes). If <code>t</code> is not 1, the whole stack "
7714 "is fliped. The algorithm then stops."
7715 msgstr ""
7716
7717 #. type: Content of: <p>
7718 #: src/lessons/sort/pancake/GatesPancake.html:58
7719 msgid ""
7720 "Each iteration increases the size of the blocks, so the algorithm eventually "
7721 "halts in all cases. A finer analysis would show that it takes at most "
7722 "<code>(5n+5)/3</code> steps to sort the stack. That's better than the naïve "
7723 "algorithm, that requires 2n-3 steps."
7724 msgstr ""
7725
7726 #. type: Content of: <h2>
7727 #: src/lessons/sort/pancake/GatesPancake.html:61
7728 msgid "Your turn"
7729 msgstr ""
7730
7731 #. type: Content of: <p>
7732 #: src/lessons/sort/pancake/GatesPancake.html:62
7733 msgid ""
7734 "You now have almost enough information to implement this algorithm on your "
7735 "own. We just have to remove the last remaining ambiguities to ensure that "
7736 "you implement exactly the same algorithm that the correction. If several "
7737 "cases apply to your situation, then you should use the first given one. For "
7738 "example, if both cases a and b apply (e.g., with <code>t-1</code> on case "
7739 "<b>a</b> and <code>t+1</code> on case <b>b</b>), then you should apply the "
7740 "flips of case <b>a</b>. If a given case applies for both <code>t+1</code> "
7741 "and <code>t-1</code>, then you should apply it to <code>t+1</code>."
7742 msgstr ""
7743
7744 #. type: Content of: <p>
7745 #: src/lessons/sort/pancake/GatesPancake.html:68
7746 msgid ""
7747 "Note that it is somehow harder than the other exercises we did so far, so "
7748 "don't be surprised if you need more time to achieve this. But do not give "
7749 "up hope, you can do it!"
7750 msgstr ""
7751
7752 #. type: Attribute 'alt' of: <p><div>
7753 #: src/lessons/sort/pancake/GatesPancake.html:71
7754 msgid "Well, I need some help to start."
7755 msgstr ""
7756
7757 #. type: Content of: <p><div>
7758 #: src/lessons/sort/pancake/GatesPancake.html:72
7759 msgid ""
7760 "First write some helper functions such as <code>isFirst()</code> or "
7761 "<code>isFree()</code>. This will simplify your main algorithm afterward, "
7762 "that can be written very similarly to the explication above with a bunch of "
7763 "if conditions. Factorizing code this way often helps making your code more "
7764 "readable."
7765 msgstr ""
7766
7767 #. type: Attribute 'alt' of: <p><div>
7768 #: src/lessons/sort/pancake/GatesPancake.html:79
7769 msgid "My code keeps failing and I don't know how to debug it."
7770 msgstr ""
7771
7772 #. type: Content of: <p><div>
7773 #: src/lessons/sort/pancake/GatesPancake.html:80
7774 msgid ""
7775 "To debug one world after the other and avoid that the messages of all worlds "
7776 "get intermixed, you can write your debug function only if the method "
7777 "<code>isSelected()</code> returns true. It will be so only for the entity "
7778 "that is currently selected in the graphical interface, that is probably the "
7779 "world you are currently debugging. This will help breaking the difficulty in "
7780 "parts by debugging the situation one after the other."
7781 msgstr ""
7782
7783 #. type: Content of: <p><div>
7784 #: src/lessons/sort/pancake/GatesPancake.html:86
7785 msgid ""
7786 "In particular, it may help to print textually the state of the world each "
7787 "time you enter the main loop."
7788 msgstr ""
7789
7790 #. type: Content of: <h1>
7791 #: src/lessons/sort/pancake/CohenPancake.html:2
7792 msgid "Faster Burned Pancake Sorting"
7793 msgstr ""
7794
7795 #. type: Content of: <p>
7796 #: src/lessons/sort/pancake/CohenPancake.html:4
7797 msgid ""
7798 "The Gates' algorithm that we saw in the previous exercise quickly sort a "
7799 "stack of unburned pancakes by increasing the size of the blocks of sorted "
7800 "pancakes. This is much faster that the naive algorithm which moves at each "
7801 "step the largest pancake to the bottom of still unsorted pancakes. Gates' "
7802 "algorithm manages to sort a stack of <i>n</i> pancakes in less than <i>(5n + "
7803 "5)/3</i> steps in the worst case, while the naive algorithm requires at most "
7804 "<i>2n</i> steps. Gates is thus about one third faster in the worst case."
7805 msgstr ""
7806
7807 #. type: Content of: <p>
7808 #: src/lessons/sort/pancake/CohenPancake.html:11
7809 msgid ""
7810 "In this exercise, we will explore an adaptation of the same idea to burnt "
7811 "pancakes. This was first published by David X. Cohen and Manuel Blum. David "
7812 "Cohen co-founded a few years later the Futurama TV show full of mathematical "
7813 "jokes. Definitively, interesting people studied that little pancake "
7814 "problem..."
7815 msgstr ""
7816
7817 #. type: Content of: <p>
7818 #: src/lessons/sort/pancake/CohenPancake.html:16
7819 msgid ""
7820 "The Cohen's algorithm is slightly easier than the Gates' one since it "
7821 "distinguishes less cases:"
7822 msgstr ""
7823
7824 #. type: Content of: <p>
7825 #: src/lessons/sort/pancake/CohenPancake.html:18
7826 msgid ""
7827 "<b>Case 1:</b> At least one pancake is rightside up in the stack. Let "
7828 "<i>p</i> be the largest such pancake. Note that <i>p + 1</i> must therefore "
7829 "be upside down, unless <i>p = n</i> (in which case there is no <i>p + 1</i> "
7830 "pancake)."
7831 msgstr ""
7832
7833 #. type: Content of: <ul><li>
7834 #: src/lessons/sort/pancake/CohenPancake.html:22
7835 msgid "<b>Case 1.a:</b> <i>p+1</i> is lower in the stack than <i>p</i>."
7836 msgstr ""
7837
7838 #. type: Content of: <ul><li>
7839 #: src/lessons/sort/pancake/CohenPancake.html:23
7840 msgid "<b>Case 1.b:</b> <i>p+1</i> is higher in the stack than <i>p</i>."
7841 msgstr ""
7842
7843 #. type: Content of: <ul><li>
7844 #: src/lessons/sort/pancake/CohenPancake.html:24
7845 msgid ""
7846 "<b>Case 1.c:</b> There is no <i>p+1</i> because <i>p</i> is the largest "
7847 "pancake in stack, that is because <i>p = n</i>. If pancake <i>p</i> is "
7848 "already in position, there is nothing to do. If not, you can move it to the "
7849 "bottom of the stack in 2 flips:"
7850 msgstr ""
7851
7852 #. type: Content of: <ul><li>
7853 #: src/lessons/sort/pancake/CohenPancake.html:28
7854 msgid ""
7855 "<b>The trick is that the pancake <i>p</i> should never be considered "
7856 "again.</b> Otherwise, you will consider that pancake again and again since "
7857 "it's rightside up, and since that's the largest pancake. To leave that "
7858 "pancake alone, you should keep track of the stack size that is still to be "
7859 "sorted. Any traversal of the stack must then only consider these pancakes, "
7860 "leaving alone the ones that are already in position at the bottom of the "
7861 "stack."
7862 msgstr ""
7863
7864 #. type: Content of: <p>
7865 #: src/lessons/sort/pancake/CohenPancake.html:36
7866 msgid ""
7867 "<b>Case 2:</b> All pancakes are downside. Again, we distinguish two "
7868 "sub-cases."
7869 msgstr ""
7870
7871 #. type: Content of: <ul><li>
7872 #: src/lessons/sort/pancake/CohenPancake.html:39
7873 msgid ""
7874 "<b>Case 2.a:</b> There is at least one <i>p</i> for which <i>p+1</i> is "
7875 "higher than <i>p</i> (if there is several such <i>p</i>, take the largest "
7876 "one)."
7877 msgstr ""
7878
7879 #. type: Content of: <ul><li>
7880 #: src/lessons/sort/pancake/CohenPancake.html:43
7881 msgid ""
7882 "<b>Case 2.b:</b> Any pancake <i>p</i> is lower than pancake <i>p+1</i>. In "
7883 "that case, we must have that setting:"
7884 msgstr ""
7885
7886 #. type: Content of: <p>
7887 #: src/lessons/sort/pancake/CohenPancake.html:48
7888 msgid ""
7889 "As you can see, we achieve one join in 2 flips in the cases 1 or 2.a. Since "
7890 "we need to achieve n joins to sort the stack, we can sort the stack in "
7891 "<i>2n</i> steps if case 2.b does not occurs."
7892 msgstr ""
7893
7894 #. type: Content of: <p>
7895 #: src/lessons/sort/pancake/CohenPancake.html:51
7896 msgid ""
7897 "That case 2.b requires a very different handling as it is obviously not "
7898 "possible to achieve a join in only 2 flips. But fortunately, we can "
7899 "leverage the very specific setting of the stack in that case to provide the "
7900 "following algorithm. It sorts a stack in that exact configuration after "
7901 "exactly <i>2n</i> steps."
7902 msgstr ""
7903
7904 #. type: Content of: <pre>
7905 #: src/lessons/sort/pancake/CohenPancake.html:56
7906 #, no-wrap
7907 msgid ""
7908 "Repeat n times\n"
7909 " Flip the whole stack of n pancakes\n"
7910 " Flip the top (n-1) pancakes\n"
7911 msgstr ""
7912
7913 #. type: Content of: <p>
7914 #: src/lessons/sort/pancake/CohenPancake.html:61
7915 msgid ""
7916 "It may sound somehow magic, but it actually works, as depicted on an example "
7917 "below."
7918 msgstr ""
7919
7920 #. type: Content of: <p>
7921 #: src/lessons/sort/pancake/CohenPancake.html:65
7922 msgid ""
7923 "So, all in all, the Cohen algorithm manages to sort the stack of burnt "
7924 "pancakes in <i>2n</i> steps in all cases. Quite a win over the naive "
7925 "algorithm for burnt pancakes that requires <i>3n</i> steps."
7926 msgstr ""
7927
7928 #. type: Attribute 'alt' of: <p><div>
7929 #: src/lessons/sort/pancake/CohenPancake.html:68
7930 msgid "I cannot get it right."
7931 msgstr ""
7932
7933 #. type: Content of: <p><div>
7934 #: src/lessons/sort/pancake/CohenPancake.html:69
7935 msgid ""
7936 "Don't worry. This exercise is very difficult, so it's ok if it does not work "
7937 "right away for you. Add some relevant logging to your code to understand "
7938 "where it stop performing correctly. Make sure to use the method "
7939 "<code>isSelected()</code> so that your logs only appears in the currently "
7940 "displayed world. In particular, it may help to print textually the state of "
7941 "the world each time you enter the main loop."
7942 msgstr ""
7943
7944 #. type: Content of: <h1>
7945 #: src/lessons/sort/baseball/Main.html:2
7946 msgid "The Rainbow Baseball Game"
7947 msgstr ""
7948
7949 #. type: Content of: <p>
7950 #: src/lessons/sort/baseball/Main.html:4
7951 msgid ""
7952 "This activity is inspired from the orange game, from the \"Computer Science "
7953 "Unplugged\" activities repository. It was however heavily since then, first "
7954 "for the CSIRL (my repository of <i>free</i> unplugged activities to "
7955 "introduce computer science, available at "
7956 "http://www.loria.fr/~quinson/Mediation/SMN/) and now for PLM."
7957 msgstr ""
7958
7959 #. type: Content of: <p>
7960 #: src/lessons/sort/baseball/Main.html:8
7961 msgid ""
7962 "In the literature, the generalized form of this problem is known as the "
7963 "pebble motion problem (the bases can be connected by any kind of graph, and "
7964 "the affinity of pebbles with bases may be different). Another variant of "
7965 "this problem is the well known 15-puzzle, with one player per base, and a "
7966 "two dimensional square grid. Much more information about these problems can "
7967 "be found on wikipedia, as usual."
7968 msgstr ""
7969
7970 #. type: Content of: <h3>
7971 #: src/lessons/sort/baseball/Main.html:13
7972 msgid ""
7973 "How do you know that the naive algorithm won't loop on that initial "
7974 "situation?"
7975 msgstr ""
7976
7977 #. type: Content of: <p>
7978 #: src/lessons/sort/baseball/Main.html:15
7979 msgid ""
7980 "Well, we simply tested all possible situations to see when this algorithm "
7981 "loops and when it finds the correct solution. We found that it works for all "
7982 "situations where no player is at home (there is 84 such situations for 4 "
7983 "bases, once you take the symmetries into account). It obviously works for "
7984 "some situations that do not respect this criteria (such as all situations it "
7985 "encounters from one of those 84 boards to the final state), but that's "
7986 "another story. Having such a criteria allows us to generate pseudo-random "
7987 "initial situations for the first exercise for which the algorithm we propose "
7988 "is guarenteed to work."
7989 msgstr ""
7990
7991 #. type: Content of: <p>
7992 #: src/lessons/sort/baseball/Main.html:22
7993 msgid ""
7994 "We also explored bigger instances of the problem, and unfortunately, we have "
7995 "no such criteria for them. With 5 bases, the algorithm wrongly loops for 24 "
7996 "of the 1824 possible boards where no player is home (that's 1.31%). With 6 "
7997 "bases, it fails on 1251 of the 58860 such boards (2.12%). With 7 bases, it "
7998 "fails for 84444 out of 2633940 (that's 3.2%). I am still looking for a "
7999 "criteria ensuring that the algorithm won't loop. If you discover one, please "
8000 "report it. Ideally, it would be simple to enforce manually so that we can "
8001 "use it during our unplugged activities."
8002 msgstr ""
8003
8004 #. type: Content of: <ul><li>
8005 #: src/lessons/sort/baseball/Main.html:32
8006 msgid ""
8007 "Other graphical representations could be proposed, such as a linear one (for "
8008 "the existing exercises) or other ones (such as a grid or a tree, if an "
8009 "exercise on this kind of graph proves interesting)."
8010 msgstr ""
8011
8012 #. type: Content of: <ul><li>
8013 #: src/lessons/sort/baseball/Main.html:34
8014 msgid ""
8015 "Other exercises on other algorithms on this variant, or on other variants "
8016 "such as the 15-puzzle."
8017 msgstr ""
8018
8019 #. type: Content of: <h3>
8020 #: src/lessons/sort/baseball/short_desc.html:2
8021 msgid "Rainbow baseball"
8022 msgstr ""
8023
8024 #. type: Content of: <p>
8025 #: src/lessons/sort/baseball/short_desc.html:4
8026 msgid ""
8027 "This is another funny variation on the sorting problem, adapting the main "
8028 "sorting algorithms on an unusual context."
8029 msgstr ""
8030
8031 #. type: Content of: <h1>
8032 #: src/lessons/sort/baseball/universe/BaseballWorld.html:2
8033 msgid "Rainbow Baseball"
8034 msgstr ""
8035
8036 #. type: Content of: <p>
8037 #: src/lessons/sort/baseball/universe/BaseballWorld.html:3
8038 msgid ""
8039 "The colors are represented by integers, between <code>0</code> and "
8040 "<code>amount of bases -1</code>. The hole is represented by the special "
8041 "value <code>-1</code>. The color of each base is its rank. So base "
8042 "<code>1</code> is of color <code>1</code>. In the graphical interface, the "
8043 "base <code>0</code> is the dark blue one while the base <code>1</code> is "
8044 "the fuscia one."
8045 msgstr ""
8046
8047 #. type: Content of: <p>
8048 #: src/lessons/sort/baseball/universe/BaseballWorld.html:9
8049 msgid ""
8050 "Once every players on the field are in their home base, the hole should be "
8051 "in the last base, that is of rank <code>getBasesAmount()-1</code>."
8052 msgstr ""
8053
8054 #. type: Content of: <h2>
8055 #: src/lessons/sort/baseball/universe/BaseballWorld.html:12
8056 msgid "Functions to retrieve the world's dimensions"
8057 msgstr ""
8058
8059 #. type: Content of: <pre>
8060 #: src/lessons/sort/baseball/universe/BaseballWorld.html:14
8061 #, no-wrap
8062 msgid "[!java|c]int [/!]getBasesAmount() [!scala]:Int[/!]"
8063 msgstr ""
8064
8065 #. type: Content of: outside any tag (error?)
8066 #: src/lessons/sort/baseball/universe/BaseballWorld.html:15
8067 msgid "Returns the amount of bases on this field."
8068 msgstr ""
8069
8070 #. type: Content of: <pre>
8071 #: src/lessons/sort/baseball/universe/BaseballWorld.html:17
8072 #, no-wrap
8073 msgid "[!java|c]int [/!]getPositionsAmount() [!scala]:Int[/!]"
8074 msgstr ""
8075
8076 #. type: Content of: outside any tag (error?)
8077 #: src/lessons/sort/baseball/universe/BaseballWorld.html:18
8078 msgid "Returns the amount of player's positions per base on this field."
8079 msgstr ""
8080
8081 #. type: Content of: <h2>
8082 #: src/lessons/sort/baseball/universe/BaseballWorld.html:20
8083 msgid "Functions to retrieve the world's state"
8084 msgstr ""
8085
8086 #. type: Content of: <pre>
8087 #: src/lessons/sort/baseball/universe/BaseballWorld.html:22
8088 #, no-wrap
8089 msgid "[!java|c]int [/!]getHoleBase() [!scala]:Int[/!]"
8090 msgstr ""
8091
8092 #. type: Content of: outside any tag (error?)
8093 #: src/lessons/sort/baseball/universe/BaseballWorld.html:23
8094 msgid "Returns the base in which the hole is located."
8095 msgstr ""
8096
8097 #. type: Content of: <pre>
8098 #: src/lessons/sort/baseball/universe/BaseballWorld.html:25
8099 #, no-wrap
8100 msgid "[!java|c]int [/!]getHolePosition() [!scala]:Int[/!]"
8101 msgstr ""
8102
8103 #. type: Content of: outside any tag (error?)
8104 #: src/lessons/sort/baseball/universe/BaseballWorld.html:26
8105 msgid "Returns the hole position within its base"
8106 msgstr ""
8107
8108 #. type: Content of: <pre>
8109 #: src/lessons/sort/baseball/universe/BaseballWorld.html:28
8110 #, no-wrap
8111 msgid ""
8112 "[!java|c]int [/!]getPlayerColor([!java|c]int [/!]base[!scala]:Int[/!], "
8113 "[!java|c]int [/!]position[!scala]:Int[/!]) [!scala]:Int[/!]"
8114 msgstr ""
8115
8116 #. type: Content of: outside any tag (error?)
8117 #: src/lessons/sort/baseball/universe/BaseballWorld.html:29
8118 msgid "Returns the color of the player at a given location."
8119 msgstr ""
8120
8121 #. type: Content of: outside any tag (error?)
8122 #: src/lessons/sort/baseball/universe/BaseballWorld.html:32
8123 msgid "Returns whether all players of the field are at home."
8124 msgstr ""
8125
8126 #. type: Content of: <pre>
8127 #: src/lessons/sort/baseball/universe/BaseballWorld.html:34
8128 #, no-wrap
8129 msgid ""
8130 "[!java]boolean [/!][!c]int [/!]isBaseSorted([!java|c]int [/!]base) "
8131 "[!scala]:Boolean[/!]"
8132 msgstr ""
8133
8134 #. type: Content of: outside any tag (error?)
8135 #: src/lessons/sort/baseball/universe/BaseballWorld.html:35
8136 msgid "Returns whether all players of a given base are at home."
8137 msgstr ""
8138
8139 #. type: Content of: <h2>
8140 #: src/lessons/sort/baseball/universe/BaseballWorld.html:39
8141 msgid "Functions to change the world"
8142 msgstr ""
8143
8144 #. type: Content of: <pre>
8145 #: src/lessons/sort/baseball/universe/BaseballWorld.html:41
8146 #, no-wrap
8147 msgid ""
8148 "[!java|c]void [/!]move([!java|c]int [/!]base[!scala]:Int[/!], [!java|c]int "
8149 "[/!]position[!scala]:Int[/!])"
8150 msgstr ""
8151
8152 #. type: Content of: outside any tag (error?)
8153 #: src/lessons/sort/baseball/universe/BaseballWorld.html:42
8154 msgid ""
8155 "Moves a given player into the hole. This throws an IllegalArgumentException "
8156 "if the specified player is not near the hole (at most one base away)."
8157 msgstr ""
8158
8159 #. type: Content of: <h1>
8160 #: src/lessons/sort/baseball/NaiveBaseball.html:2
8161 msgid "Naive Rainbow Baseball"
8162 msgstr ""
8163
8164 #. type: Content of: <p>
8165 #: src/lessons/sort/baseball/NaiveBaseball.html:4
8166 msgid ""
8167 "Today, the buggles decided to play a baseball game, but they are rather out "
8168 "of luck, actually. First, kinda forgot the rules, and ... well ... they "
8169 "cannot find the ball and bats again. So they decided to \"adapt a bit\" the "
8170 "rules. As the are no ball, the buggles can only running around the field, "
8171 "what they do happily: for a while, all attending buggle run at full speed in "
8172 "all directions around the field."
8173 msgstr ""
8174
8175 #. type: Content of: <p>
8176 #: src/lessons/sort/baseball/NaiveBaseball.html:10
8177 msgid ""
8178 "But after a few collisions, they decide to invent new rules to organize a "
8179 "bit the game: They make one team per base and two players per team. One of "
8180 "the teams has only one player so that its base has an empty location. Then, "
8181 "the players are dispatched randomly around the bases, and the game for them "
8182 "is to reach their home base. The whole game stops when all players are "
8183 "home. There is no winning team: either all players win, or they all "
8184 "lose. Actually, this game is very different from the original baseball. The "
8185 "only rule that remains is that you can only run around the field, from one "
8186 "base to the next one, without crossing middle of the field."
8187 msgstr ""
8188
8189 #. type: Content of: <p>
8190 #: src/lessons/sort/baseball/NaiveBaseball.html:18
8191 msgid ""
8192 "Now, they are asking you to help them deciding who and when should move so "
8193 "that each player returns to its base. Only one buggle can move at each "
8194 "round, from its position to the empty spot. The maximal distance that a "
8195 "buggle can cover in one round is of one base."
8196 msgstr ""
8197
8198 #. type: Content of: <p>
8199 #: src/lessons/sort/baseball/NaiveBaseball.html:22
8200 msgid ""
8201 "So, at each round, the empty spot is on one base (say <code>B</code>), and "
8202 "you should decide which buggle enters that empty spot. There is four "
8203 "candidates (two from base <code>B-1</code> and two from base "
8204 "<code>B+1</code>). Actually, there is a fifth candidate since the buggle "
8205 "that is on the same base than the empty spot can change its position, but "
8206 "that's not really helping."
8207 msgstr ""
8208
8209 #. type: Content of: <h3>
8210 #: src/lessons/sort/baseball/NaiveBaseball.html:27
8211 msgid "The Naïve algorithm"
8212 msgstr ""
8213
8214 #. type: Content of: <p>
8215 #: src/lessons/sort/baseball/NaiveBaseball.html:29
8216 msgid ""
8217 "In this exercise, we will first explore a very simple algorithm. To decide "
8218 "which of the four candidate buggles should enter the empty spot, we first "
8219 "restrict ourselves and decide that buggles can only turn clockwise. Then, "
8220 "from the two remaining candidates, we pick the one that has the largest "
8221 "distance to cover to reach its base (turning clockwise). Click on the demo "
8222 "button: this works rather well in practice."
8223 msgstr ""
8224
8225 #. type: Content of: <p>
8226 #: src/lessons/sort/baseball/NaiveBaseball.html:35
8227 msgid ""
8228 "It's hard to find a simpler algorithm for this problem: While it's not "
8229 "sorted, search for the base containing the candidate buggles: if the hole is "
8230 "in base <code>B</code>, it's the base <code>B+1</code>, modulo the amount of "
8231 "bases. Then, compute the distance that each buggle of that base still has to "
8232 "run to reach its base (0 if it's already home). Once you found the buggle "
8233 "that should enter the empty spot, just use the <code>move</code> method on "
8234 "it, and iterate."
8235 msgstr ""
8236
8237 #. type: Content of: <p>
8238 #: src/lessons/sort/baseball/NaiveBaseball.html:41
8239 msgid ""
8240 "The main difficulty should be to get the few equations right: determining "
8241 "the base next to the hole should be easy, but determining the distance that "
8242 "a player has to cover may reveal a bit more challenging. Don't hesitate to "
8243 "draw pictures on a paper to cover all possible cases. It should not be that "
8244 "difficult either: there is not that many cases after all."
8245 msgstr ""
8246
8247 #. type: Content of: <h1>
8248 #: src/lessons/sort/baseball/SelectBaseball.html:2
8249 msgid "Selection Baseball"
8250 msgstr ""
8251
8252 #. type: Content of: <p>
8253 #: src/lessons/sort/baseball/SelectBaseball.html:4
8254 msgid ""
8255 "The previous algorithm is very pleasant: it's rather simple and rather fast "
8256 "to implement, but unfortunately, it is also rather wrong! In some cases, it "
8257 "never stops, which is obviously bad. If you don't believe it, just copy "
8258 "paste your previous code, and hit the run button. The first world of this "
8259 "exercise is one of these unfortunate situations that drives our previous "
8260 "algorithm crazy."
8261 msgstr ""
8262
8263 #. type: Content of: <p>
8264 #: src/lessons/sort/baseball/SelectBaseball.html:10
8265 msgid ""
8266 "So we have to find another algorithm, preferably one that works in all "
8267 "cases."
8268 msgstr ""
8269
8270 #. type: Content of: <p>
8271 #: src/lessons/sort/baseball/SelectBaseball.html:12
8272 msgid ""
8273 "For that, the best solution is to start from a well known algorithm instead "
8274 "of trying to invent a new one from scratch as we just did. When you think a "
8275 "bit about this problem, this can is very similar to a sorting problem: Just "
8276 "make sure that the players are sorted by their colors and you're set. And "
8277 "while we are at it, let's generalize the game to allow more that 4 bases."
8278 msgstr ""
8279
8280 #. type: Content of: <p>
8281 #: src/lessons/sort/baseball/SelectBaseball.html:18
8282 msgid ""
8283 "Let's adapt the selection sort to our situation. The big lines of the "
8284 "algorithm is then \"for each base, select the players that should occupy "
8285 "this base and make sure that they come to their position\". This way, we "
8286 "will grow an sorted area where all players are already sorted (and never "
8287 "changed) while the unsorted area shrinks."
8288 msgstr ""
8289
8290 #. type: Content of: <p>
8291 #: src/lessons/sort/baseball/SelectBaseball.html:24
8292 msgid ""
8293 "Selecting the player should be no problem; Do not hesitate to define some "
8294 "methods such as <code>findPlayer()</code> or "
8295 "<code>findPlayerBase()</code>. This will ensure that your code remains "
8296 "understandable."
8297 msgstr ""
8298
8299 #. type: Content of: <p>
8300 #: src/lessons/sort/baseball/SelectBaseball.html:28
8301 msgid ""
8302 "The most problematic aspect is to move the selected players into "
8303 "position. For that, you have to move the hole to the position where the "
8304 "player is, and then move both the player and the hole to the base that is "
8305 "next to the player's goal (probably in a loop), and finally put the player "
8306 "in the right position of its target base."
8307 msgstr ""
8308
8309 #. type: Content of: <p>
8310 #: src/lessons/sort/baseball/SelectBaseball.html:33
8311 msgid ""
8312 "As often in programming, the devil is in the details: there is a bunch of "
8313 "corner cases that you should detect and deal with correctly, such as the "
8314 "cases where the player is already in the base (but not in the position that "
8315 "you would like), or when the hole is on the right of the player (probably "
8316 "when you sort the first base). But you will find and hunt these while "
8317 "debugging your code."
8318 msgstr ""
8319
8320 #. type: Content of: <h1>
8321 #: src/lessons/sort/baseball/InsertBaseball.html:2
8322 msgid "Insertion Baseball"
8323 msgstr ""
8324
8325 #. type: Content of: <p>
8326 #: src/lessons/sort/baseball/InsertBaseball.html:4
8327 msgid ""
8328 "The good point of adapting the selection sort to the baseball problem is "
8329 "that we know that it works (provided that our adaptation is correct). That's "
8330 "much better than the first naive algorithm, that was unable to converge to "
8331 "the solution in some situations. But actually, the selection sort is not "
8332 "perfect either as it requires a lot of swaps: we have to bring the hole to "
8333 "the selected player and then both the player and hole in position, and "
8334 "more. We can do better."
8335 msgstr ""
8336
8337 #. type: Content of: <p>
8338 #: src/lessons/sort/baseball/InsertBaseball.html:10
8339 msgid ""
8340 "For example, each player can run quite a long way from its initial position "
8341 "to its target solution. Instead, it may be more interesting to split the "
8342 "field in two parts: one on the left where all players are sorted relatively "
8343 "to each others, and one on the right where the players are still at their "
8344 "initial positions. Then, at each iteration, we take the player at the border "
8345 "between the sorted and unsorted areas (that is, the left-most player of the "
8346 "unsorted area) and move it to the left (within the sorted area) until it "
8347 "reaches its position (that is, until the position where it's bigger that its "
8348 "left neighbor). This would at least reduce the travel of players to the "
8349 "sorted area as we use the first one on the border."
8350 msgstr ""
8351
8352 #. type: Content of: <p>
8353 #: src/lessons/sort/baseball/InsertBaseball.html:19
8354 msgid ""
8355 "Actually, that's exactly what an insertion sort would do: maintain a sorted "
8356 "area on the left, and put iteratively the player on the border to its "
8357 "position within the sorted area. This is good, as we know that our algorithm "
8358 "is not inherently flawed since we adapt a well known one."
8359 msgstr ""
8360
8361 #. type: Content of: <p>
8362 #: src/lessons/sort/baseball/InsertBaseball.html:23
8363 msgid ""
8364 "The easiest to adapt the insertion sort to the baseball problem is to "
8365 "consider all positions as adjacent and forget about bases. For that, we "
8366 "define the methods <code>getColor[!c]Insert[/!](pos)</code>, "
8367 "<code>move[!c]Insert[/!](pos)</code> and "
8368 "<code>getHole[!c]Insert[/!]()</code> that all use a unique integer to "
8369 "designate a given position. These functions simply convert between the way "
8370 "to specify a position and then call the usual functions to interact with the "
8371 "world. If you have an <code>index</code> and want to convert it into a "
8372 "<code>base,pos</code>, then <code>base=index/2</code> and "
8373 "<code>pos=index%2</code>. To compute the reverse, "
8374 "<code>index=base*2+pos</code> (this works because "
8375 "<code>getPositionsAmount()</code> always returns 2)."
8376 msgstr ""
8377
8378 #. type: Content of: <p>
8379 #: src/lessons/sort/baseball/InsertBaseball.html:32
8380 msgid ""
8381 "For the algorithm itself, you should first move the hole to the position "
8382 "1. The position 0 is considered to be the sorted area (of size 1 for now) "
8383 "while the area above 2 is the unsorted area. Then comes an iteration to "
8384 "sort each element of the unsorted area. Since this iteration is a bit "
8385 "complex, you should think of its loop invariant, that is, the condition that "
8386 "is true before and after the loop and which explains that the loop fulfills "
8387 "its goal. Here, the loop invariant is twofold: First, the hole is between "
8388 "the sorted area and the unsorted area, and then, the every elements of the "
8389 "sorted area are ... well sorted relatively to their neighbors."
8390 msgstr ""
8391
8392 #. type: Content of: <p>
8393 #: src/lessons/sort/baseball/InsertBaseball.html:40
8394 msgid ""
8395 "Then, the loop body to sort an element should first descend the hole and the "
8396 "elements within the sorted area until the element is larger than the element "
8397 "before in the sorted area (2 moves per position to travel), and then move "
8398 "the hole back to its position between the sorted and unsorted areas (1 move "
8399 "per position)."
8400 msgstr ""
8401
8402 #. type: Content of: <p>
8403 #: src/lessons/sort/baseball/InsertBaseball.html:44
8404 msgid ""
8405 "Once you insert the last element within the sorted area, your whole set is "
8406 "sorted and you're done. I preserve the surprise of the border cases that "
8407 "will require some little adjustments to your algorithm to make it work "
8408 "properly :)"
8409 msgstr ""
8410
8411 #. type: Content of: <h1>
8412 #: src/lessons/sort/baseball/BubbleBaseball.html:2
8413 msgid "Bubble Baseball"
8414 msgstr ""
8415
8416 #. type: Content of: <p>
8417 #: src/lessons/sort/baseball/BubbleBaseball.html:4
8418 msgid ""
8419 "Crap, we adapted the insertion sort because our selection sort required too "
8420 "much moves to get the selected players to their position, but the insertion "
8421 "sort requires an inordinate amount of changes to get the border elements to "
8422 "their position within the sorted area without mixing the already sorted "
8423 "elements. At the end of the day, our selection variant was more efficient "
8424 "with at most <code>3*amountOfBase</code> moves to sort one element (1 to get "
8425 "the hole alongside with the player, and 2 to get the hole+player in "
8426 "position) while our insertion variant requires at most "
8427 "<code>3*amountOfPlayers</code> to sort one element (2 to descend the hole "
8428 "and player in position, 1 to get the hole back to its position). That's "
8429 "twice as bad as there is two players per base. It may be possible to improve "
8430 "the insertion sort by moving by more than one element when descending, but "
8431 "it seems uneasy (at least, while not mixing the already sorted elements) and "
8432 "it would probably only ensure that our insertion variant becomes as "
8433 "efficient as our selection variant, not dramatically better."
8434 msgstr ""
8435
8436 #. type: Content of: <p>
8437 #: src/lessons/sort/baseball/BubbleBaseball.html:16
8438 msgid ""
8439 "If we cannot make the sort faster, we can make it easier. If you think about "
8440 "it, it seems rather natural to adapt the bubble sort to this problem: the "
8441 "hole becomes the bubble that moves up and down, sorting a bit the array "
8442 "during each traversal. The big lines are simply: \"while it's not sorted, "
8443 "move the hole down to base 0 (moving the biggest player of each base at each "
8444 "step) and then back to the maximal base (moving the smallest player of each "
8445 "base)\". After a while, <code>isSorted()</code> will return true and your "
8446 "algorithm will stop."
8447 msgstr ""
8448
8449 #. type: Content of: <p>
8450 #: src/lessons/sort/baseball/BubbleBaseball.html:22
8451 msgid ""
8452 "This is so easy that we introduce another variant of the problem, with more "
8453 "than two players per base. But actually, that shouldn't block you very "
8454 "long, should it?"
8455 msgstr ""
8456
8457 #. type: Content of: <p>
8458 #: src/lessons/sort/baseball/BubbleBaseball.html:25
8459 msgid ""
8460 "Surprisingly, the bubble sort variant requires ways less moves than the "
8461 "other variants. This is astonishing because usually, the bubble sort "
8462 "performs much worse than the others sorts, but it comes from the very good "
8463 "match between its big lines and the baseball universe. It actually happens "
8464 "rather often that a pleasantly written algorithm performs very decently. But "
8465 "this is not an universal rule either, as demonstrated by the naive algorithm "
8466 "of the first exercise, that was nice, simple and wrong ;)"
8467 msgstr ""
8468
8469 #. type: Content of: <h1>
8470 #: src/plm/universe/turtles/TurtleWorld.html:2
8471 msgid "The universe of turtles"
8472 msgstr ""
8473
8474 #. type: Content of: <p>
8475 #: src/plm/universe/turtles/TurtleWorld.html:4
8476 msgid "This is an adaptation of LOGO for the Programmer's Learning Machine."
8477 msgstr ""
8478
8479 #. type: Content of: <p>
8480 #: src/plm/universe/turtles/TurtleWorld.html:6
8481 msgid ""
8482 "It is directly inspired from the work of the mathematician Seymour Papert in "
8483 "the 60's. Inspired from the swiss psycholog Jean Piaget, he came up with a "
8484 "learning method called LOGO to teach programming to young childs. The world "
8485 "is full of turtles which leave a painting where they go and which respond to "
8486 "simple orders."
8487 msgstr ""
8488
8489 #. type: Content of: <h2>
8490 #: src/plm/universe/turtles/TurtleWorld.html:12
8491 msgid "Functions to move the turtle"
8492 msgstr ""
8493
8494 #. type: Content of: <pre>
8495 #: src/plm/universe/turtles/TurtleWorld.html:14
8496 #, no-wrap
8497 msgid ""
8498 "[!java|c]void [/!]forward([!java|c]double [/!]steps[!scala]:Double[/!])\n"
8499 "[!java|c]void [/!]backward([!java|c]double [/!]steps[!scala]:Double[/!])"
8500 msgstr ""
8501
8502 #. type: Content of: outside any tag (error?)
8503 #: src/plm/universe/turtles/TurtleWorld.html:16
8504 msgid "Moves forward or backward of the requested amount of steps."
8505 msgstr ""
8506
8507 #. type: Content of: <pre>
8508 #: src/plm/universe/turtles/TurtleWorld.html:18
8509 #, no-wrap
8510 msgid ""
8511 "[!java|c]void [/!]right([!java|c]double [/!]angle[!scala]:Double[/!])\n"
8512 "[!java|c]void [/!]left([!java|c]double [/!]angle[!scala]:Double[/!])"
8513 msgstr ""
8514
8515 #. type: Content of: outside any tag (error?)
8516 #: src/plm/universe/turtles/TurtleWorld.html:20
8517 msgid "Turns left or right of the given angle (in degrees)."
8518 msgstr ""
8519
8520 #. type: Content of: <pre>
8521 #: src/plm/universe/turtles/TurtleWorld.html:22
8522 #: src/lessons/lander/universe/DelegatingLanderWorld.html:10
8523 #, no-wrap
8524 msgid ""
8525 "[!java|c]double [/!]getX()[!scala]:Double[/!]\n"
8526 "[!java|c]double [/!]getY()[!scala]:Double[/!]"
8527 msgstr ""
8528
8529 #. type: Content of: outside any tag (error?)
8530 #: src/plm/universe/turtles/TurtleWorld.html:24
8531 msgid ""
8532 "Returns the current position of the turtle. Note that the point (0,0) is on "
8533 "the top left corner, as it is often the case in Computer Science."
8534 msgstr ""
8535
8536 #. type: Content of: <pre>
8537 #: src/plm/universe/turtles/TurtleWorld.html:27
8538 #, no-wrap
8539 msgid ""
8540 "[!java|c]void [/!]setX([!java|c]double [/!]x[!scala]:Double[/!])\n"
8541 "[!java|c]void [/!]setY([!java|c]double [/!]y[!scala]:Double[/!])\n"
8542 "[!java|c]void [/!]setPos([!java|c]double [/!]x[!scala]:Double[/!], "
8543 "[!java|c]double [/!]y[!scala]:Double[/!])"
8544 msgstr ""
8545
8546 #. type: Content of: outside any tag (error?)
8547 #: src/plm/universe/turtles/TurtleWorld.html:30
8548 msgid "Teleports the turtle to a new position (without leaving any trace)."
8549 msgstr ""
8550
8551 #. type: Content of: <pre>
8552 #: src/plm/universe/turtles/TurtleWorld.html:32
8553 #, no-wrap
8554 msgid ""
8555 "[!java|c]void [/!]moveTo([!java|c]double [/!]x[!scala]:Double[/!], "
8556 "[!java|c]double [/!]y[!scala]:Double[/!])"
8557 msgstr ""
8558
8559 #. type: Content of: outside any tag (error?)
8560 #: src/plm/universe/turtles/TurtleWorld.html:33
8561 msgid "Moves the turtle to a new position."
8562 msgstr ""
8563
8564 #. type: Content of: <pre>
8565 #: src/plm/universe/turtles/TurtleWorld.html:35
8566 #, no-wrap
8567 msgid "[!java|c]void [/!]circle([!java|c]double [/!]radius[!scala]:Double[/!])"
8568 msgstr ""
8569
8570 #. type: Content of: outside any tag (error?)
8571 #: src/plm/universe/turtles/TurtleWorld.html:36
8572 msgid "Draw a circle of the specified radius centered on the turtle."
8573 msgstr ""
8574
8575 #. type: Content of: <pre>
8576 #: src/plm/universe/turtles/TurtleWorld.html:38
8577 #, no-wrap
8578 msgid "[!java|c]void [/!]hide()"
8579 msgstr ""
8580
8581 #. type: Content of: outside any tag (error?)
8582 #: src/plm/universe/turtles/TurtleWorld.html:39
8583 msgid "Hides the turtle."
8584 msgstr ""
8585
8586 #. type: Content of: <pre>
8587 #: src/plm/universe/turtles/TurtleWorld.html:41
8588 #, no-wrap
8589 msgid "[!java|c]void [/!]show()"
8590 msgstr ""
8591
8592 #. type: Content of: outside any tag (error?)
8593 #: src/plm/universe/turtles/TurtleWorld.html:42
8594 msgid "Shows the turtle back."
8595 msgstr ""
8596
8597 #. type: Content of: <pre>
8598 #: src/plm/universe/turtles/TurtleWorld.html:44
8599 #, no-wrap
8600 msgid "[!java]boolean [/!][!c]int [/!]isVisible()[!scala]:Boolean[/!]"
8601 msgstr ""
8602
8603 #. type: Content of: outside any tag (error?)
8604 #: src/plm/universe/turtles/TurtleWorld.html:45
8605 msgid "Returns whether the turtle is currently visible."
8606 msgstr ""
8607
8608 #. type: Content of: <pre>
8609 #: src/plm/universe/turtles/TurtleWorld.html:47
8610 #, no-wrap
8611 msgid "[!java|c]void [/!]clear()"
8612 msgstr ""
8613
8614 #. type: Content of: outside any tag (error?)
8615 #: src/plm/universe/turtles/TurtleWorld.html:48
8616 msgid "Removes any trail on the sheet."
8617 msgstr ""
8618
8619 #. type: Content of: <pre>
8620 #: src/plm/universe/turtles/TurtleWorld.html:50
8621 #, no-wrap
8622 msgid "[!java|c]double [/!]getHeading()[!scala]:Double[/!]"
8623 msgstr ""
8624
8625 #. type: Content of: outside any tag (error?)
8626 #: src/plm/universe/turtles/TurtleWorld.html:51
8627 msgid "Returns the current heading of the turtle (in degrees)."
8628 msgstr ""
8629
8630 #. type: Content of: <pre>
8631 #: src/plm/universe/turtles/TurtleWorld.html:53
8632 #, no-wrap
8633 msgid "[!java|c]void [/!]setHeading([!java|c]double [/!]angle[!scala]:Double[/!])"
8634 msgstr ""
8635
8636 #. type: Content of: outside any tag (error?)
8637 #: src/plm/universe/turtles/TurtleWorld.html:54
8638 msgid "Sets a new heading to the turtle (in degrees)."
8639 msgstr ""
8640
8641 #. type: Content of: <h2>
8642 #: src/plm/universe/turtles/TurtleWorld.html:56
8643 msgid "Functions about the pen"
8644 msgstr ""
8645
8646 #. type: Content of: <pre>
8647 #: src/plm/universe/turtles/TurtleWorld.html:58
8648 #, no-wrap
8649 msgid "[!java|c]void [/!]penUp()"
8650 msgstr ""
8651
8652 #. type: Content of: outside any tag (error?)
8653 #: src/plm/universe/turtles/TurtleWorld.html:59
8654 msgid ""
8655 "Moves the pen up (turtles have pens, not brushes as buggles). The turtle "
8656 "will not leave any trace during its subsequent moves."
8657 msgstr ""
8658
8659 #. type: Content of: <pre>
8660 #: src/plm/universe/turtles/TurtleWorld.html:62
8661 #, no-wrap
8662 msgid "[!java|c]void [/!]penDown()"
8663 msgstr ""
8664
8665 #. type: Content of: outside any tag (error?)
8666 #: src/plm/universe/turtles/TurtleWorld.html:63
8667 msgid ""
8668 "Moves the pen down. The turtle will leave a trace during its subsequent "
8669 "moves."
8670 msgstr ""
8671
8672 #. type: Content of: <pre>
8673 #: src/plm/universe/turtles/TurtleWorld.html:65
8674 #, no-wrap
8675 msgid "[!java]boolean [/!][!c]int [/!]isPenDown()[!scala]:Boolean[/!]"
8676 msgstr ""
8677
8678 #. type: Content of: outside any tag (error?)
8679 #: src/plm/universe/turtles/TurtleWorld.html:66
8680 msgid "Returns the current pen position as a boolean."
8681 msgstr ""
8682
8683 #. type: Content of: <pre>
8684 #: src/plm/universe/turtles/TurtleWorld.html:68
8685 #, no-wrap
8686 msgid "[!java|c]Color [/!]getColor()[!scala]:Color[/!]"
8687 msgstr ""
8688
8689 #. type: Content of: outside any tag (error?)
8690 #: src/plm/universe/turtles/TurtleWorld.html:69
8691 msgid "Returns the current pen color."
8692 msgstr ""
8693
8694 #. type: Content of: <pre>
8695 #: src/plm/universe/turtles/TurtleWorld.html:71
8696 #, no-wrap
8697 msgid "[!java|c]void [/!]setColor([!java|c]Color [/!]color[!scala]:Color[/!])"
8698 msgstr ""
8699
8700 #. type: Content of: outside any tag (error?)
8701 #: src/plm/universe/turtles/TurtleWorld.html:72
8702 msgid "Changes the pen color."
8703 msgstr ""
8704
8705 #. type: Content of: <h2>
8706 #: src/plm/universe/turtles/TurtleWorld.html:74
8707 msgid "Other functions"
8708 msgstr ""
8709
8710 #. type: Content of: outside any tag (error?)
8711 #: src/plm/universe/turtles/TurtleWorld.html:77
8712 msgid "Returns whether the current turtle is selected in the graphical interface."
8713 msgstr ""
8714
8715 #. type: Content of: <h3>
8716 #: src/lessons/turtleart/Main.html:2 src/lessons/turtleart/short_desc.html:2
8717 msgid "Turtle Art"
8718 msgstr ""
8719
8720 #. type: Content of: <p>
8721 #: src/lessons/turtleart/Main.html:4
8722 msgid ""
8723 "Since its inception in the 60's, the LOGO turtle fascinates by its ability "
8724 "to draw nice figures on computer. This lesson allows you to explore some of "
8725 "the classical figures, and draw your own."
8726 msgstr ""
8727
8728 #. type: Content of: <p>
8729 #: src/lessons/turtleart/Main.html:7
8730 msgid ""
8731 "The language's syntax is absolutely not presented, but if you know a bit of "
8732 "it or if someone tells you, you can take these exercises even if you are an "
8733 "absolute beginner in programming."
8734 msgstr ""
8735
8736 #. type: Content of: <p>
8737 #: src/lessons/turtleart/Main.html:10
8738 msgid ""
8739 "Please send us your best contributions so that they get added to this "
8740 "gallery to inspire the next ones."
8741 msgstr ""
8742
8743 #. type: Content of: <ul><li>
8744 #: src/lessons/turtleart/Main.html:16
8745 msgid ""
8746 "Other exercises should be added. A whole lot of exercises are available from "
8747 "<a "
8748 "href=\"http://neoparaiso.com/logo/#sect4\">http://neoparaiso.com/logo/#sect4</a> "
8749 "or from <a "
8750 "href=\"http://billkerr2.blogspot.fr/2009/08/40-maths-shapes-challenges.html.\">http://billkerr2.blogspot.fr/2009/08/40-maths-shapes-challenges.html</a>."
8751 msgstr ""
8752
8753 #. type: Content of: <ul><li>
8754 #: src/lessons/turtleart/Main.html:19
8755 msgid ""
8756 "Missing: the built-ins arc() and arcTo(), that draw an arc, either w/o "
8757 "moving or by moving to the end of the arc."
8758 msgstr ""
8759
8760 #. type: Content of: <p>
8761 #: src/lessons/turtleart/short_desc.html:3
8762 msgid ""
8763 "Draw beautiful figures with the Logo turtle, and learn programming while "
8764 "playing."
8765 msgstr ""
8766
8767 #. type: Content of: <p>
8768 #: src/lessons/turtleart/short_desc.html:6
8769 msgid ""
8770 "You should know the basic syntax of the programming language you will "
8771 "choose, but no exhaustive programming practice is required to take this "
8772 "lesson."
8773 msgstr ""
8774
8775 #. type: Content of: <h1>
8776 #: src/lessons/recursion/cons/universe/ConsWorld.html:2
8777 msgid "ConsWorld"
8778 msgstr ""
8779
8780 #. type: Content of: <p>
8781 #: src/lessons/recursion/cons/universe/ConsWorld.html:4
8782 msgid ""
8783 "This world allows you to experiment with the recursive lists, as they were "
8784 "first introduced in Lisp. It is very similar to the BatWorld, but you are "
8785 "supposed to write recursive functions working on [!python|java]recursive "
8786 "strings. Since [!thelang] does not provide such a construct natively, the "
8787 "ConsWorld defines recursive lists of type <code>RecList</code>.[/!] "
8788 "[!scala]lists of integers (<code>List[Int]</code>).[/!]"
8789 msgstr ""
8790
8791 #. type: Content of: <p>
8792 #: src/lessons/recursion/cons/universe/ConsWorld.html:12
8793 msgid ""
8794 "Any given such list is either the empty list (noted "
8795 "<code>[!scala]Nil[/!][!java]null[/!][!python]None[/!]</code>), or an integer "
8796 "followed by a list. If a list is not empty, you can retrieve its first "
8797 "integer with <code>list.head</code> and the list containing its other "
8798 "parameters with <code>list.tail</code>. Of course, the empty list has no "
8799 "head nor the tail, so trying to access these elements will result in an "
8800 "(unpleasant) error message."
8801 msgstr ""
8802
8803 #. type: Content of: <p>
8804 #: src/lessons/recursion/cons/universe/ConsWorld.html:20
8805 msgid ""
8806 "To build your own list, you need to concatenate a head and a tail as "
8807 "follows: [!java|python]<code>cons(head, tail)</code>[/!] "
8808 "[!scala]<code>head::tail</code> Note that <code>::</code> is a generic "
8809 "operator in Scala to build lists.[/!]"
8810 msgstr ""
8811
8812 #. type: Content of: <p>
8813 #: src/lessons/recursion/cons/universe/ConsWorld.html:26
8814 msgid ""
8815 "So, in summary, you can solve every exercises of this lesson with the "
8816 "following constructs."
8817 msgstr ""
8818
8819 #. type: Content of: <ul><li>
8820 #: src/lessons/recursion/cons/universe/ConsWorld.html:30
8821 msgid "<b>The empty list:</b>"
8822 msgstr ""
8823
8824 #. type: Content of: <ul><li><pre>
8825 #: src/lessons/recursion/cons/universe/ConsWorld.html:30
8826 #, no-wrap
8827 msgid "[!java]null[/!][!scala]Nil[/!][!python]None[/!]"
8828 msgstr ""
8829
8830 #. type: Content of: <ul><li>
8831 #: src/lessons/recursion/cons/universe/ConsWorld.html:31
8832 msgid "<b>Get the first element of <code>l</code></b>"
8833 msgstr ""
8834
8835 #. type: Content of: <ul><li><pre>
8836 #: src/lessons/recursion/cons/universe/ConsWorld.html:31
8837 #, no-wrap
8838 msgid "l.head"
8839 msgstr ""
8840
8841 #. type: Content of: <ul><li>
8842 #: src/lessons/recursion/cons/universe/ConsWorld.html:32
8843 msgid "<b>Get the rest of the list</b>, when the first element is removed:"
8844 msgstr ""
8845
8846 #. type: Content of: <ul><li><pre>
8847 #: src/lessons/recursion/cons/universe/ConsWorld.html:32
8848 #, no-wrap
8849 msgid "l.tail"
8850 msgstr ""
8851
8852 #. type: Content of: <ul><li>
8853 #: src/lessons/recursion/cons/universe/ConsWorld.html:33
8854 msgid ""
8855 "<b>Build a list</b> from a <code>value</code> and a <code>list</code>: "
8856 "[!java|python]"
8857 msgstr ""
8858
8859 #. type: Content of: <ul><li><pre>
8860 #: src/lessons/recursion/cons/universe/ConsWorld.html:34
8861 #, no-wrap
8862 msgid "cons(value, list)"
8863 msgstr ""
8864
8865 #. type: Content of: <ul><li><pre>
8866 #: src/lessons/recursion/cons/universe/ConsWorld.html:35
8867 #, no-wrap
8868 msgid "value::list"
8869 msgstr ""
8870
8871 #. type: Content of: <h1>
8872 #: src/lessons/recursion/cons/Main.html:2
8873 msgid "Recursive Lists"
8874 msgstr ""
8875
8876 #. type: Content of: <p>
8877 #: src/lessons/recursion/cons/Main.html:3
8878 msgid ""
8879 "This lesson contains a bunch of classical exercises on recursive lists. It "
8880 "is certainly not the most pleasant lesson to do, but I think that it is the "
8881 "easiest of the PLM lessons dealing with recursion."
8882 msgstr ""
8883
8884 #. type: Content of: <ul><li>
8885 #: src/lessons/recursion/cons/Main.html:10
8886 msgid ""
8887 "New exercises could be proposed, such as "
8888 "http://webloria.loria.fr/~quinson/Teaching/TOP/02-td-recursivite-enonce.pdf "
8889 "If you know some others, please report them as an issue."
8890 msgstr ""
8891
8892 #. type: Content of: <ul><li>
8893 #: src/lessons/recursion/cons/Main.html:13
8894 msgid ""
8895 "It would be interesting to check the asymptotic complexity of the student's "
8896 "code, but that does not sound easy to do. In Python and Java (where we "
8897 "provide a hand-made RecList class), we could count the amount of cons per "
8898 "exercise, but it won't be easy to relate this to the right BatTest. For "
8899 "Scala, it sounds even more difficult as we use the classical :: operators of "
8900 "the language. That will be difficult to override to add a counting "
8901 "mechanism. Another solution would be to ensure that the call stack does not "
8902 "pass a given threshold, but that sounds very difficult too. Any idea is "
8903 "welcome."
8904 msgstr ""
8905
8906 #. type: Content of: <h1>
8907 #: src/lessons/recursion/cons/Length.html:2
8908 msgid "Length"
8909 msgstr ""
8910
8911 #. type: Content of: outside any tag (error?)
8912 #: src/lessons/recursion/cons/Length.html:3
8913 msgid ""
8914 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return its "
8915 "length[!scala] (without using its <code>size</code> method, of course)[/!]. "
8916 "[!java|python]"
8917 msgstr ""
8918
8919 #. type: Content of: <p>
8920 #: src/lessons/recursion/cons/Length.html:5
8921 msgid ""
8922 "[!python]Be careful, you are not supposed to use the Python lists, but the "
8923 "specific type defined in this exercise. [/!] Please refer to the world's "
8924 "documentation for more information about recursive lists."
8925 msgstr ""
8926
8927 #. type: Content of: <p>
8928 #: src/lessons/recursion/cons/Length.html:10
8929 #: src/lessons/recursion/cons/IsMember.html:7
8930 #: src/lessons/recursion/cons/Occurrence.html:7
8931 #: src/lessons/recursion/cons/Last.html:6 src/lessons/recursion/cons/Min.html:6
8932 #: src/lessons/recursion/cons/Increasing.html:6
8933 #: src/lessons/recursion/cons/ButLast.html:6
8934 #: src/lessons/recursion/cons/PlusOne.html:5
8935 #: src/lessons/recursion/cons/Remove.html:9
8936 #: src/lessons/recursion/cons/ButNfirst.html:6
8937 msgid "Your solution should be linear in time."
8938 msgstr ""
8939
8940 #. type: Content of: <h1>
8941 #: src/lessons/recursion/cons/IsMember.html:2
8942 msgid "IsMember"
8943 msgstr ""
8944
8945 #. type: Content of: outside any tag (error?)
8946 #: src/lessons/recursion/cons/IsMember.html:3
8947 msgid ""
8948 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an "
8949 "integer, return true if the given integer is one of the elements of the "
8950 "list, or false if it cannot be found."
8951 msgstr ""
8952
8953 #. type: Content of: <h1>
8954 #: src/lessons/recursion/cons/Occurrence.html:2
8955 msgid "Occurrences"
8956 msgstr ""
8957
8958 #. type: Content of: outside any tag (error?)
8959 #: src/lessons/recursion/cons/Occurrence.html:3
8960 msgid ""
8961 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an "
8962 "integer, return the amount of occurrences of the given integer in the "
8963 "list. If the integer is not a member of the list, the function should thus "
8964 "return 0."
8965 msgstr ""
8966
8967 #. type: Content of: <h1>
8968 #: src/lessons/recursion/cons/Last.html:2
8969 msgid "Last"
8970 msgstr ""
8971
8972 #. type: Content of: outside any tag (error?)
8973 #: src/lessons/recursion/cons/Last.html:3
8974 msgid ""
8975 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return its "
8976 "last element. You can assume that the list is not empty."
8977 msgstr ""
8978
8979 #. type: Content of: <h1>
8980 #: src/lessons/recursion/cons/Min.html:2
8981 msgid "Min"
8982 msgstr ""
8983
8984 #. type: Content of: outside any tag (error?)
8985 #: src/lessons/recursion/cons/Min.html:3
8986 msgid ""
8987 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return the "
8988 "smallest of its values. You will probably need an extra function, even if "
8989 "you can assume that the list is not empty."
8990 msgstr ""
8991
8992 #. type: Content of: <h1>
8993 #: src/lessons/recursion/cons/Increasing.html:2
8994 msgid "Increasing"
8995 msgstr ""
8996
8997 #. type: Content of: outside any tag (error?)
8998 #: src/lessons/recursion/cons/Increasing.html:3
8999 msgid ""
9000 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return "
9001 "whether its elements form an increasing sequence (i.e., if the elements are "
9002 "sorted from the smallest to the largest one)."
9003 msgstr ""
9004
9005 #. type: Content of: <h1>
9006 #: src/lessons/recursion/cons/ButLast.html:2
9007 msgid "But Last"
9008 msgstr ""
9009
9010 #. type: Content of: outside any tag (error?)
9011 #: src/lessons/recursion/cons/ButLast.html:3
9012 msgid ""
9013 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return the "
9014 "list containing every elements but the last one. You can assume that the "
9015 "list is not empty."
9016 msgstr ""
9017
9018 #. type: Content of: <h1>
9019 #: src/lessons/recursion/cons/PlusOne.html:2
9020 msgid "PlusOne"
9021 msgstr ""
9022
9023 #. type: Content of: outside any tag (error?)
9024 #: src/lessons/recursion/cons/PlusOne.html:3
9025 msgid ""
9026 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return a new "
9027 "list containing all elements of your parameter incremented by one."
9028 msgstr ""
9029
9030 #. type: Content of: <h1>
9031 #: src/lessons/recursion/cons/Remove.html:2
9032 msgid "Remove"
9033 msgstr ""
9034
9035 #. type: Content of: outside any tag (error?)
9036 #: src/lessons/recursion/cons/Remove.html:4
9037 msgid ""
9038 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] "
9039 "<code>L</code>and an integer, return a new list containing all elements of "
9040 "<code>L</code> that are not equal to the value received as parameter."
9041 msgstr ""
9042
9043 #. type: Content of: <h1>
9044 #: src/lessons/recursion/cons/Nth.html:2
9045 msgid "Nth"
9046 msgstr ""
9047
9048 #. type: Content of: outside any tag (error?)
9049 #: src/lessons/recursion/cons/Nth.html:3
9050 msgid ""
9051 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
9052 "<code>N</code>, return the <code>N</code>th element of the list."
9053 msgstr ""
9054
9055 #. type: Content of: <p>
9056 #: src/lessons/recursion/cons/Nth.html:6
9057 #: src/lessons/recursion/cons/Nfirst.html:7
9058 msgid ""
9059 "You can assume that the list is long enough, i.e. that there is at least "
9060 "<code>N</code> elements. Your solution should be linear in time."
9061 msgstr ""
9062
9063 #. type: Content of: <h1>
9064 #: src/lessons/recursion/cons/Nfirst.html:2
9065 msgid "Nfirst"
9066 msgstr ""
9067
9068 #. type: Content of: outside any tag (error?)
9069 #: src/lessons/recursion/cons/Nfirst.html:3
9070 msgid ""
9071 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
9072 "<code>N</code>, return the list constituted of the first <code>N</code> "
9073 "elements. You can assume that the list is long enough, i.e. that there is at "
9074 "least <code>N</code> elements."
9075 msgstr ""
9076
9077 #. type: Content of: <h1>
9078 #: src/lessons/recursion/cons/Nlast.html:2
9079 msgid "Nlast"
9080 msgstr ""
9081
9082 #. type: Content of: outside any tag (error?)
9083 #: src/lessons/recursion/cons/Nlast.html:3
9084 msgid ""
9085 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
9086 "<code>N</code>, return the list with only the <code>N</code> last elements."
9087 msgstr ""
9088
9089 #. type: Content of: <p>
9090 #: src/lessons/recursion/cons/Nlast.html:6
9091 #: src/lessons/recursion/cons/ButNlast.html:6
9092 #: src/lessons/recursion/cons/Concat.html:6
9093 msgid ""
9094 "Your solution should be linear in time, but you will probably need to define "
9095 "several functions to achieve that complexity."
9096 msgstr ""
9097
9098 #. type: Attribute 'alt' of: <div>
9099 #: src/lessons/recursion/cons/Nlast.html:8
9100 #: src/lessons/recursion/cons/ButNlast.html:8
9101 #: src/lessons/recursion/cons/Reverse.html:8
9102 #: src/lessons/recursion/cons/Concat.html:8
9103 msgid "I cannot do it in linear time"
9104 msgstr ""
9105
9106 #. type: Content of: <div>
9107 #: src/lessons/recursion/cons/Nlast.html:9
9108 #: src/lessons/recursion/cons/ButNlast.html:9
9109 msgid ""
9110 "The trick is to compute only once (and beforehand) how many elements you "
9111 "should keep."
9112 msgstr ""
9113
9114 #. type: Content of: <h1>
9115 #: src/lessons/recursion/cons/ButNfirst.html:2
9116 msgid "But Nfirst"
9117 msgstr ""
9118
9119 #. type: Content of: outside any tag (error?)
9120 #: src/lessons/recursion/cons/ButNfirst.html:3
9121 msgid ""
9122 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
9123 "<code>N</code>, return the list without the <code>N</code> first elements."
9124 msgstr ""
9125
9126 #. type: Content of: <h1>
9127 #: src/lessons/recursion/cons/ButNlast.html:2
9128 msgid "But Nlast"
9129 msgstr ""
9130
9131 #. type: Content of: outside any tag (error?)
9132 #: src/lessons/recursion/cons/ButNlast.html:3
9133 msgid ""
9134 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer "
9135 "<code>N</code>, return the list without the <code>N</code> last elements."
9136 msgstr ""
9137
9138 #. type: Content of: <h1>
9139 #: src/lessons/recursion/cons/Reverse.html:2
9140 msgid "Reverse"
9141 msgstr ""
9142
9143 #. type: Content of: outside any tag (error?)
9144 #: src/lessons/recursion/cons/Reverse.html:3
9145 msgid ""
9146 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return a new "
9147 "list with all elements in reverse order."
9148 msgstr ""
9149
9150 #. type: Content of: <p>
9151 #: src/lessons/recursion/cons/Reverse.html:5
9152 msgid ""
9153 "This function is very important and you should not pass that challenge. "
9154 "Your solution should be linear in time, with the help of helper functions."
9155 msgstr ""
9156
9157 #. type: Content of: <div>
9158 #: src/lessons/recursion/cons/Reverse.html:9
9159 msgid ""
9160 "You need an helper function in which the result is accumulated (built) at "
9161 "each step."
9162 msgstr ""
9163
9164 #. type: Content of: <h1>
9165 #: src/lessons/recursion/cons/Concat.html:2
9166 msgid "Concat"
9167 msgstr ""
9168
9169 #. type: Content of: outside any tag (error?)
9170 #: src/lessons/recursion/cons/Concat.html:3
9171 msgid ""
9172 "Given two [!scala]List[Int][/!][!java|python]recursive list[/!] "
9173 "<code>l1</code> and <code>l2</code>, return a new list with all elements of "
9174 "<code>l1</code> followed by the elements of <code>l2</code>."
9175 msgstr ""
9176
9177 #. type: Content of: <div>
9178 #: src/lessons/recursion/cons/Concat.html:9
9179 msgid ""
9180 "You need to modify <code>l1</code> beforehand so that the computations at "
9181 "each step of the recursion are in constant time."
9182 msgstr ""
9183
9184 #. type: Content of: <h1>
9185 #: src/lessons/recursion/cons/AllDifferent.html:2
9186 msgid "All Different"
9187 msgstr ""
9188
9189 #. type: Content of: outside any tag (error?)
9190 #: src/lessons/recursion/cons/AllDifferent.html:3
9191 msgid ""
9192 "Given a [!scala]List[Int][/!][!java|python]recursive list[/!], return true "
9193 "if any two elements of the list are different (ie, if no element appears "
9194 "more than once in the list)."
9195 msgstr ""
9196
9197 #. type: Content of: <p>
9198 #: src/lessons/recursion/cons/AllDifferent.html:6
9199 msgid ""
9200 "The simplest solution is in O(n²), meaning that it runs in quadratic time. "
9201 "You will probably have to define one extra function for that. Another much "
9202 "more complex solution runs in O(n log(n))."
9203 msgstr ""
9204
9205 #. type: Content of: <h1>
9206 #: src/lessons/recursion/lego/Main.html:2
9207 msgid "Recursive algorithms"
9208 msgstr ""
9209
9210 #. type: Content of: outside any tag (error?)
9211 #: src/lessons/recursion/lego/Main.html:3
9212 msgid "This lesson allows to experiment with recursive algorithms."
9213 msgstr ""
9214
9215 #. type: Content of: <p>
9216 #: src/lessons/recursion/lego/Main.html:5
9217 msgid ""
9218 "If you need more recursive algorithms, an exercise on recursive sorting "
9219 "algorithms (in particular QuickSort and MergeSort) is planned in the future "
9220 "within the sorting lesson."
9221 msgstr ""
9222
9223 #. type: Content of: <h3>
9224 #: src/lessons/recursion/lego/Main.html:9
9225 msgid "What can I do to improve this lesson?"
9226 msgstr ""
9227
9228 #. type: Content of: <p>
9229 #: src/lessons/recursion/lego/Main.html:11
9230 msgid ""
9231 "As usual, there are several things that could be done in this lesson to "
9232 "improve it further:"
9233 msgstr ""
9234
9235 #. type: Content of: <ul><li>
9236 #: src/lessons/recursion/lego/Main.html:13
9237 msgid ""
9238 "The Sierpinski triangle can be drawn using a simpler L-system. See "
9239 "http://jpvallon.free.fr/recursivite.html"
9240 msgstr ""
9241
9242 #. type: Content of: <ul><li>
9243 #: src/lessons/recursion/lego/Main.html:14
9244 msgid ""
9245 "The arrowhead curve is also interesting: "
9246 "http://www.mathcurve.com/fractals/sierpinski/sierpinskitriangle.shtml"
9247 msgstr ""
9248
9249 #. type: Content of: <ul><li>
9250 #: src/lessons/recursion/lego/Main.html:15
9251 msgid ""
9252 "The dragon curve could be explained as a L-system: "
9253 "http://ecademy.agnesscott.edu/~lriddle/ifs/heighway/heighway.htm"
9254 msgstr ""
9255
9256 #. type: Content of: <ul><li>
9257 #: src/lessons/recursion/lego/Main.html:16
9258 msgid ""
9259 "The dragon2 curve is called the twin dragon: "
9260 "http://ecademy.agnesscott.edu/~lriddle/ifs/heighway/twindragon.htm"
9261 msgstr ""
9262
9263 #. type: Content of: <ul><li>
9264 #: src/lessons/recursion/lego/Main.html:17
9265 msgid ""
9266 "The space filling curves could be added (Peano, Hildebert, etc). See: "
9267 "http://teachout1.net/village/fill.html"
9268 msgstr ""
9269
9270 #. type: Content of: <ul><li>
9271 #: src/lessons/recursion/lego/Main.html:19
9272 msgid ""
9273 "We could do another exercise on embeeded polygons: "
9274 "http://www.inrialpes.fr/helix/people/genoud/ENSJAVA/tds/sujets/dessinsReccursifs/actionsrecursives.html"
9275 msgstr ""
9276
9277 #. type: Content of: <h3>
9278 #: src/lessons/recursion/lego/short_desc.html:2
9279 msgid "Bases of recursion"
9280 msgstr ""
9281
9282 #. type: Content of: <p>
9283 #: src/lessons/recursion/lego/short_desc.html:3
9284 msgid ""
9285 "Discover the recursive way of thinking by drawing trees and other figures "
9286 "with the Logo turtle."
9287 msgstr ""
9288
9289 #. type: Content of: <h2>
9290 #: src/lessons/recursion/lego/square/FourSquare.html:2
9291 msgid "The small cousines of Buggles"
9292 msgstr ""
9293
9294 #. type: Content of: <p>
9295 #: src/lessons/recursion/lego/square/FourSquare.html:4
9296 msgid ""
9297 "Today, we will meet the small cousines of the buggles: the turtles. In fact, "
9298 "turtles are much olders than the buggles. They were invented in the 70's by "
9299 "a scientific from MIT called Seymour Papert to help teaching programming, "
9300 "and the buggles are a variation on the idea invented by Lyn Turbak from "
9301 "Wellesley College later."
9302 msgstr ""
9303
9304 #. type: Content of: <p>
9305 #: src/lessons/recursion/lego/square/FourSquare.html:10
9306 msgid ""
9307 "Turtles are thus a bit like buggles, but smaller. Just like buggles, you can "
9308 "order them to move forward, to turn, to move backward, etc. Just like "
9309 "buggles, they leave a line on their path when they move (but the line is "
9310 "much smaller)."
9311 msgstr ""
9312
9313 #. type: Content of: <p>
9314 #: src/lessons/recursion/lego/square/FourSquare.html:15
9315 msgid ""
9316 "The main difference is that where buggles can only move of right angles, "
9317 "turtles can move of any arbitrary angles specified by a real number (a "
9318 "double). This gives them much more liberty in their movings. The buggles can "
9319 "do several other tricks, like reading and writting messages, picking or "
9320 "dropping objects, and there is sometimes walls in their worlds (but all this "
9321 "is completely above the capacities of turtles)."
9322 msgstr ""
9323
9324 #. type: Content of: <p>
9325 #: src/lessons/recursion/lego/square/FourSquare.html:22
9326 msgid ""
9327 "From a practical point of view, most of the methods you knew about buggles "
9328 "still work with turtles, with some minor adaptations. In particular, the "
9329 "<code>forward()</code> method takes the amount of steps to do not as an "
9330 "integer, but as a [!python]point number[/!][!java|scala|c]double[/!] (see "
9331 "\"About this world\" for more details)."
9332 msgstr ""
9333
9334 #. type: Content of: <h3>
9335 #: src/lessons/recursion/lego/square/FourSquare.html:29
9336 msgid "Doubles? But what is it?"
9337 msgstr ""
9338
9339 #. type: Content of: outside any tag (error?)
9340 #: src/lessons/recursion/lego/square/FourSquare.html:30
9341 msgid "It's simply a point number. Example:"
9342 msgstr ""
9343
9344 #. type: Content of: <pre>
9345 #: src/lessons/recursion/lego/square/FourSquare.html:32
9346 #, no-wrap
9347 msgid ""
9348 "double x = 3.72;\n"
9349 "x + 1.234 // Value = 4.954\n"
9350 "x + 2. // Value = 5.72 (2. means 2.0)\n"
9351 "x + 2 // [!java|c]Value = 5.72 (2 automatically converted to "
9352 "2.0)[/!][!scala]Type error (+ operator don't mix Double and Int); manual "
9353 "conversion mandatory[/!]\n"
9354 "x * 2. // Value = 7.44 \n"
9355 "x / 2. // Value = 1.86 \n"
9356 "[!java|c](int) x[/!][!scala]x.asInstanceOf[Int][/!] // Value = 1 (“casting "
9357 "to int”, converted to integer by truncating)\n"
9358 "Math.round(x) // Value = 2 (1.86 rounded to nearest integer)\n"
9359 "Math.floor(x) // Value = 1 (1.86 rounded toward minus infinity)\n"
9360 "Math.floor(-5.12) // Value = -6 (rounded toward minus infinity)\n"
9361 "Math.ceiling(x) // Value = 2 (1.86 rounded toward plus infinity)\n"
9362 "Math.ceiling(-5.12) // Value = -5 (rounded toward plus infinity)\n"
9363 "[!java|c](double) 17[/!][!scala]17.asInstanceOf[Double][/!] // Value = 17.0 "
9364 "(“casted to double”, converted to double)\n"
9365 msgstr ""
9366
9367 #. type: Content of: <p>
9368 #: src/lessons/recursion/lego/square/FourSquare.html:49
9369 msgid ""
9370 "Even if this is the first exercise on the recursivity lesson, the code you "
9371 "have to write is not recursive. The goal is to get familiar with the turtle "
9372 "world before getting on serious matter."
9373 msgstr ""
9374
9375 #. type: Content of: <p>
9376 #: src/lessons/recursion/lego/square/FourSquare.html:53
9377 msgid ""
9378 "You must reproduce a simple geometrical painting constituted of four 100 "
9379 "steps long squares (see the objective world for more details). It is "
9380 "obviously a good idea to write a method to draw a square, and then use it in "
9381 "your code."
9382 msgstr ""
9383
9384 #. type: Content of: <h2>
9385 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:2
9386 msgid "Fractal of polygons"
9387 msgstr ""
9388
9389 #. type: Content of: outside any tag (error?)
9390 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:4
9391 msgid ""
9392 "The fractal we will now draw is formed of a polygon, with little polygons on "
9393 "each corner. The prototype of the method drawing it is the following:"
9394 msgstr ""
9395
9396 #. type: Content of: <pre>
9397 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:6
9398 #, no-wrap
9399 msgid ""
9400 "[!java|c]void [/!]polygonFractal ([!java|c]int [/!]levels[!scala]:Int[/!], "
9401 "[!java|c]int [/!]sides[!scala]:Int[/!], [!java|c]double "
9402 "[/!]length[!scala]:Double[/!], [!java|c]double "
9403 "[/!]shrink[!scala]:Double[/!])"
9404 msgstr ""
9405
9406 #. type: Content of: <p>
9407 #: src/lessons/recursion/lego/polygonfractal/PolygonFractal.html:8
9408 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:26
9409 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:45
9410 msgid ""
9411 "Have a look at each world's objective view to understand how to write the "
9412 "function."
9413 msgstr ""
9414
9415 #. type: Content of: <h2>
9416 #: src/lessons/recursion/lego/koch/Koch.html:2
9417 msgid "Snow flake"
9418 msgstr ""
9419
9420 #. type: Content of: outside any tag (error?)
9421 #: src/lessons/recursion/lego/koch/Koch.html:4
9422 msgid ""
9423 "We will now draw snow flakes using the Koch fractal. A fractal is a "
9424 "geometric pattern repeated at every scale."
9425 msgstr ""
9426
9427 #. type: Content of: <p>
9428 #: src/lessons/recursion/lego/koch/Koch.html:7
9429 msgid ""
9430 "The general form is a triangle, with each side given by several recursive "
9431 "calls. Your work is only to write the code of the <code>snowSide</code> "
9432 "method so that it draws one side of the triangle. To make it easier, each "
9433 "sides are represented in a specific color. Just draw the red things (without "
9434 "changing your pen color), and the other colors will be drawn automatically."
9435 msgstr ""
9436
9437 #. type: Content of: <p>
9438 #: src/lessons/recursion/lego/koch/Koch.html:13
9439 msgid ""
9440 "Observe the drawing in each world's objective to understand the pattern's "
9441 "logic, and then reproduce it. At level 0, the Koch curve is just a straight "
9442 "line. At level 1, the curve is divided in three thirds, and the middle part "
9443 "is replaced by the two sides of an equilateral triangle of the same length "
9444 "as the segment being removed. At level 2, the process is repeated, whith "
9445 "each segments split in three parts and the middle part being replaced by the "
9446 "two sides of an equilateral triangle."
9447 msgstr ""
9448
9449 #. type: Content of: <p>
9450 #: src/lessons/recursion/lego/koch/Koch.html:20
9451 msgid "The pseudo-code of the general case is the following:"
9452 msgstr ""
9453
9454 #. type: Content of: <pre>
9455 #: src/lessons/recursion/lego/koch/Koch.html:22
9456 #, no-wrap
9457 msgid ""
9458 " Draw recursively a smaller segment\n"
9459 " Turn 60 degrees to the left\n"
9460 " Draw recursively a smaller segment \n"
9461 " Turn 120 degrees to the right\n"
9462 " Draw recursively a smaller segment\n"
9463 " Turn 60 degrees to the left\n"
9464 " Draw recursively a smaller segment\n"
9465 msgstr ""
9466
9467 #. type: Content of: <p>
9468 #: src/lessons/recursion/lego/koch/Koch.html:30
9469 msgid ""
9470 "As you can see, the function forward() is not called from the recursive "
9471 "case, only in the base case when there is no recursive call."
9472 msgstr ""
9473
9474 #. type: Attribute 'alt' of: <p><div>
9475 #: src/lessons/recursion/lego/koch/Koch.html:34
9476 msgid "Too much letters. Please picture it."
9477 msgstr ""
9478
9479 #. type: Content of: <p><div><p>
9480 #: src/lessons/recursion/lego/koch/Koch.html:35
9481 #: src/lessons/recursion/lego/koch/SquareKoch.html:9
9482 msgid "Here are the results of the first levels of recursion."
9483 msgstr ""
9484
9485 #. type: Content of: <p>
9486 #: src/lessons/recursion/lego/koch/Koch.html:39
9487 msgid ""
9488 "You must write the <code>snowSide()</code> method, which is recursive but "
9489 "<b>do not call snowFlake from snowSide</b>, or you will get very strange and "
9490 "unexpected behaviors."
9491 msgstr ""
9492
9493 #. type: Content of: <h2>
9494 #: src/lessons/recursion/lego/koch/SquareKoch.html:2
9495 msgid "Snow square"
9496 msgstr ""
9497
9498 #. type: Content of: <p>
9499 #: src/lessons/recursion/lego/koch/SquareKoch.html:4
9500 msgid ""
9501 "This exercise is a variation over the snow flake that we saw previously. "
9502 "The main difference is that we are growing little squares instead of "
9503 "triangles on the sides of the figure."
9504 msgstr ""
9505
9506 #. type: Attribute 'alt' of: <p><div>
9507 #: src/lessons/recursion/lego/koch/SquareKoch.html:8
9508 msgid "I don't see it, sorry. Please picture it."
9509 msgstr ""
9510
9511 #. type: Content of: <p>
9512 #: src/lessons/recursion/lego/koch/SquareKoch.html:14
9513 msgid ""
9514 "As previously, your <code>squareSide</code> function should only draw one "
9515 "side of the figure, and the template will call it for all sides "
9516 "automatically (with one color per side)."
9517 msgstr ""
9518
9519 #. type: Content of: <h2>
9520 #: src/lessons/recursion/lego/koch/PentaKoch.html:2
9521 msgid "Snow pentagon"
9522 msgstr ""
9523
9524 #. type: Content of: <p>
9525 #: src/lessons/recursion/lego/koch/PentaKoch.html:4
9526 msgid ""
9527 "Here comes yet another variation of the Koch curve. This time, we grow "
9528 "little pentagons (ie, polygons with five sides each). I'm sure you get it "
9529 "now."
9530 msgstr ""
9531
9532 #. type: Content of: <p>
9533 #: src/lessons/recursion/lego/koch/PentaKoch.html:7
9534 msgid ""
9535 "Another difference with earlier is that the length is not divided by three "
9536 "at each step anymore, but multiplied by 0.4. The curve looks better this way "
9537 ":)"
9538 msgstr ""
9539
9540 #. type: Content of: <p>
9541 #: src/lessons/recursion/lego/koch/PentaKoch.html:10
9542 msgid ""
9543 "We draw only one side in this exercise so your code will be called only once "
9544 "this time."
9545 msgstr ""
9546
9547 #. type: Content of: <h2>
9548 #: src/lessons/recursion/lego/koch/HexaKoch.html:2
9549 msgid "Snow hexagon"
9550 msgstr ""
9551
9552 #. type: Content of: <p>
9553 #: src/lessons/recursion/lego/koch/HexaKoch.html:4
9554 msgid ""
9555 "This time, we will draw the curve that is known as the (6, 0.14)-Koch "
9556 "curve. This means that you have to grow 6-sided polygons on the segments, "
9557 "and that the length should be multiplied by 0.14 at each recursion level."
9558 msgstr ""
9559
9560 #. type: Content of: <p>
9561 #: src/lessons/recursion/lego/koch/HexaKoch.html:8
9562 msgid ""
9563 "For the record, the original Koch curve is the (3, 1/3)-Koch curve, the Snow "
9564 "square would be (4,1/3)-Koch curve while the Snow pentagon is also called "
9565 "the (5, 0.4)-Koch curve. If you want, you can switch to the creative mode in "
9566 "the menu and explore freely other Koch curves. Just change the initial call "
9567 "to hexaKoch to what you want."
9568 msgstr ""
9569
9570 #. type: Content of: <p>
9571 #: src/lessons/recursion/lego/koch/HexaKoch.html:13
9572 msgid ""
9573 "For further reference, please see <a "
9574 "href=\"http://ecademy.agnesscott.edu/~lriddle/ifs/kcurve/kcurve.htm\">http://ecademy.agnesscott.edu/~lriddle/ifs/kcurve/kcurve.htm</a>."
9575 msgstr ""
9576
9577 #. type: Content of: <h2>
9578 #: src/lessons/recursion/lego/koch/Crab.html:2
9579 msgid "Fractal Crab"
9580 msgstr ""
9581
9582 #. type: Content of: <p>
9583 #: src/lessons/recursion/lego/koch/Crab.html:4
9584 msgid ""
9585 "The Crab curve is not exactly a Koch curve, but that's still a fractal and "
9586 "it's built rather similarly. This time, we grow square triangle on the side "
9587 "of the figure: the angle is 45 degrees, and the length is divided by "
9588 "[!java|scala]Math.sqrt(2)[/!][!python]math.sqrt(2)[/!][!c]sqrt(2);[/!] at "
9589 "each step."
9590 msgstr ""
9591
9592 #. type: Content of: <p>
9593 #: src/lessons/recursion/lego/koch/Crab.html:8
9594 msgid ""
9595 "Check the figures produced by the first steps of recursion to understand the "
9596 "pattern."
9597 msgstr ""
9598
9599 #. type: Content of: <h3>
9600 #: src/lessons/recursion/lego/koch/Crab.html:10
9601 msgid "Bibliographical note"
9602 msgstr ""
9603
9604 #. type: Content of: <p>
9605 #: src/lessons/recursion/lego/koch/Crab.html:11
9606 msgid ""
9607 "This curve, also called the Lévy C curve was invented in 1938 by the French "
9608 "mathematician Paul Lévy. As usual, the wikipedia page is very instructive, "
9609 "and the page provide very good additions: <a "
9610 "href=\"http://www.mathcurve.com/fractals/c/c.shtml\">http://www.mathcurve.com/fractals/c/c.shtml</a>."
9611 msgstr ""
9612
9613 #. type: Content of: <h2>
9614 #: src/lessons/recursion/lego/tree/Tree.html:2
9615 msgid "Trees"
9616 msgstr ""
9617
9618 #. type: Content of: <p>
9619 #: src/lessons/recursion/lego/tree/Tree.html:4
9620 msgid ""
9621 "We will now draw trees. For that, we will write a method using double "
9622 "recursion following this prototype"
9623 msgstr ""
9624
9625 #. type: Content of: <pre>
9626 #: src/lessons/recursion/lego/tree/Tree.html:6
9627 #, no-wrap
9628 msgid ""
9629 "[!java|c]void [/!]tree([!java|c]int [/!]steps[!scala]:Int[/!], "
9630 "[!java|c]double [/!]length[!scala]:Double[/!], [!java|c]double "
9631 "[/!]angle[!scala]:Double[/!], [!java|c]double [/!]shrink[!scala]:Double[/!])"
9632 msgstr ""
9633
9634 #. type: Content of: <p>
9635 #: src/lessons/recursion/lego/tree/Tree.html:8
9636 msgid ""
9637 "To draw a tree of four levels, you have to draw a trunk of the given length, "
9638 "turn right of the given angle, draw a tree of level 3, turn left twice of "
9639 "the given angle, draw another tree of level 3, and come back to your initial "
9640 "location. Don't forget to come back to the initial location!"
9641 msgstr ""
9642
9643 #. type: Content of: <p><p><p>
9644 #: src/lessons/recursion/lego/tree/Tree.html:13
9645 msgid ""
9646 "If a tree's trunk is of length 'len', the trunk of the next level tree will "
9647 "be of length 'len*shrink'."
9648 msgstr ""
9649
9650 #. type: Content of: <p><p><p><p><p>
9651 #: src/lessons/recursion/lego/tree/Tree.html:16
9652 msgid ""
9653 "At the end, here is the pseudo-code of the general case (you should add the "
9654 "base case yourself):"
9655 msgstr ""
9656
9657 #. type: Content of: <p><p><p><p><pre>
9658 #: src/lessons/recursion/lego/tree/Tree.html:18
9659 #, no-wrap
9660 msgid ""
9661 " Move forward of the desired length\n"
9662 " Draw (recursively) the right subtree\n"
9663 " Draw (recursively) the left subtree\n"
9664 " Move back to your initial position\n"
9665 msgstr ""
9666
9667 #. type: Content of: <p><p><p><p><p>
9668 #: src/lessons/recursion/lego/tree/Tree.html:23
9669 msgid ""
9670 "Don't forget to add the base case to your code, or your buggle will enter an "
9671 "infinite loop. Then, drawing the right subtree comes down to turn right and "
9672 "then draw the subtree."
9673 msgstr ""
9674
9675 #. type: Content of: <p><p><p><p><p>
9676 #: src/lessons/recursion/lego/tree/Tree.html:26
9677 msgid ""
9678 "As you can see, each recursion level is represented by a distinctive "
9679 "color. For that, you have to call the <code>current(step)</code>, passing "
9680 "the current recursion level as a parameter. This will pick the right color "
9681 "for you. Don't erase your great colors when you move back to your initial "
9682 "location."
9683 msgstr ""
9684
9685 #. type: Content of: <p><p><p><p><p>
9686 #: src/lessons/recursion/lego/tree/Tree.html:30
9687 msgid ""
9688 "If you get your function wrong, this can easily become hairly to debug as "
9689 "your errors will appear at each level of the recursion, completely changing "
9690 "the drawing. For debugging purpose, you can use the <code>subtree()</code> "
9691 "that will draw a correct subtree. This function is then very similar to the "
9692 "one you are trying to write. The only difference is that "
9693 "<code>subtree()</code> only draws in black. So, you can use it instead of a "
9694 "recursive call to debug your code, but you have to change for a proper "
9695 "recursive call to your own code (once it works) to get the colors right, "
9696 "and pass the exercise."
9697 msgstr ""
9698
9699 #. type: Content of: <h2>
9700 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:2
9701 msgid "Sierpinski's Triangle"
9702 msgstr ""
9703
9704 #. type: Content of: <p>
9705 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:4
9706 msgid ""
9707 "The fractal we will now draw is formed of a big triangle inside which "
9708 "several smaller triangles are embedded. The prototype of the function to "
9709 "draw it is the following:"
9710 msgstr ""
9711
9712 #. type: Content of: <pre>
9713 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:7
9714 #, no-wrap
9715 msgid ""
9716 "[!java|c]void [/!]sierpinski([!java|c]int [/!]level[!scala]:Int[/!], "
9717 "[!java|c]double [/!]length[!scala]:Double[/!])"
9718 msgstr ""
9719
9720 #. type: Content of: <p>
9721 #: src/lessons/recursion/lego/sierpinski/Sierpinski.html:9
9722 msgid ""
9723 "Have a look at each world's objective view to understand how to write the "
9724 "function. To draw one side of the triangle, draw a smaller recursive "
9725 "triangle (halve the length) and move forward by the requested length. "
9726 "Globally, you have to draw 3 such sides and turn by 120 between each side."
9727 msgstr ""
9728
9729 #. type: Content of: <h2>
9730 #: src/lessons/recursion/lego/spiral/Spiral.html:2
9731 msgid "Spirals"
9732 msgstr ""
9733
9734 #. type: Content of: outside any tag (error?)
9735 #: src/lessons/recursion/lego/spiral/Spiral.html:4
9736 msgid ""
9737 "We will now draw our first recursive function with the turtle. The goal is "
9738 "to draw different kind of spirals with the same function, which prototype is "
9739 "the following:"
9740 msgstr ""
9741
9742 #. type: Content of: <pre>
9743 #: src/lessons/recursion/lego/spiral/Spiral.html:7
9744 #, no-wrap
9745 msgid ""
9746 "[!java|c]void [/!]spiral([!java|c]int [/!]steps[!scala]:Int[/!], "
9747 "[!java|c]int [/!]angle[!scala]:Int[/!], [!java|c]int "
9748 "[/!]length[!scala]:Int[/!], [!java|c]int [/!]increment[!scala]:Int[/!])"
9749 msgstr ""
9750
9751 #. type: Content of: outside any tag (error?)
9752 #: src/lessons/recursion/lego/spiral/Spiral.html:9
9753 msgid ""
9754 "To help you understanding how to write it, here is an example of how the "
9755 "parameters change during one specific call:"
9756 msgstr ""
9757
9758 #. type: Content of: <pre>
9759 #: src/lessons/recursion/lego/spiral/Spiral.html:12
9760 #, no-wrap
9761 msgid ""
9762 "spiral(5, 90, 0, 3);\n"
9763 " forward(0);\n"
9764 " left(90);\n"
9765 " spiral(4,90,3,3);\n"
9766 " forward(3);\n"
9767 " left(90);\n"
9768 " spiral(3,90,6,3);\n"
9769 " forward(6);\n"
9770 " left(90);\n"
9771 " spiral(2,90,9,3);\n"
9772 " forward(9);\n"
9773 " left(90);\n"
9774 " spiral(1,90,12,3);\n"
9775 " forward(12);\n"
9776 " left(90);\n"
9777 " spiral(0,90,12,3);\n"
9778 msgstr ""
9779
9780 #. type: Content of: outside any tag (error?)
9781 #: src/lessons/recursion/lego/spiral/Spiral.html:30
9782 msgid ""
9783 "Note that you only have to write the function, not the initial call. Each "
9784 "world will provide a specific set of initial parameters (use the combobox to "
9785 "switch to other worlds). For example, the \"Square Pyramid\" world will call "
9786 "your function as follows:"
9787 msgstr ""
9788
9789 #. type: Content of: <pre>
9790 #: src/lessons/recursion/lego/spiral/Spiral.html:36
9791 #, no-wrap
9792 msgid "spiral(100, 90, 0, 3);\n"
9793 msgstr ""
9794
9795 #. type: Content of: <h2>
9796 #: src/lessons/recursion/lego/spiral/SpiralUse.html:2
9797 msgid "Drawing spirals"
9798 msgstr ""
9799
9800 #. type: Content of: <p>
9801 #: src/lessons/recursion/lego/spiral/SpiralUse.html:4
9802 msgid ""
9803 "This exercise is not really an exercise in that sense that you just have to "
9804 "click on the Execute button to get the reward: All the needed code is "
9805 "already provided. Instead, you can here explore the possibilities of the "
9806 "code you just wrote by changing the parameters of the call to the "
9807 "<code>spiral</code> function. You can move on to the next exercise if you "
9808 "are short on time, and come back later to play around."
9809 msgstr ""
9810
9811 #. type: Content of: <p>
9812 #: src/lessons/recursion/lego/spiral/SpiralUse.html:10
9813 msgid ""
9814 "Here are some of the figures that you can produce with your "
9815 "<code>Spiral</code> function, provided that you come with the right "
9816 "parameters. You can switch to the creative mode (from the Exercise menu) to "
9817 "disable the world comparison when you explore with these spirals."
9818 msgstr ""
9819
9820 #. type: Content of: <p>
9821 #: src/lessons/recursion/lego/spiral/SpiralUse.html:21
9822 msgid ""
9823 "If you discover a cool figure, don't forget to send your parameters (menu "
9824 "Help/feedback) so that we can add it to the list!"
9825 msgstr ""
9826
9827 #. type: Content of: <h2>
9828 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:2
9829 msgid "Dragon curve (1)"
9830 msgstr ""
9831
9832 #. type: Content of: <p>
9833 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:4
9834 msgid "The dragon curve is a classical example of recursive method."
9835 msgstr ""
9836
9837 #. type: Content of: <p>
9838 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:6
9839 msgid "The definition of this curve is the following:"
9840 msgstr ""
9841
9842 #. type: Content of: <p>
9843 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:7
9844 msgid "the dragon curve of order 1 is a vector between to arbitrary points P and Q,"
9845 msgstr ""
9846
9847 #. type: Content of: <p>
9848 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:8
9849 msgid ""
9850 "the dragon curve of order n is the dragon curve of order n-1 between P and "
9851 "R, followed by the same curve of order n-1 between Q and R, where PRQ is an "
9852 "isosceles triangle with angle R being a right angle, and R being at the "
9853 "right of the PQ vector. Thus, if P and Q coordinates are (x, y) and (z, t), "
9854 "the coordinate (u, v) of R are given by:"
9855 msgstr ""
9856
9857 #. type: Content of: <pre>
9858 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:14
9859 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:27
9860 #, no-wrap
9861 msgid ""
9862 "u = (x + z)/2 + (t - y)/2\n"
9863 "v = (y + t)/2 - (z - x)/2\n"
9864 msgstr ""
9865
9866 #. type: Content of: <p>
9867 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:18
9868 msgid "The prototype of the method drawing the curve is the following:"
9869 msgstr ""
9870
9871 #. type: Content of: <pre>
9872 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:19
9873 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:23
9874 #, no-wrap
9875 msgid ""
9876 "[!java|c]void [/!]dragon([!java|c]int [/!]order[!scala]:Int[/!], "
9877 "[!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double "
9878 "[/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], "
9879 "[!java|c]double [/!]t[!scala]:Double[/!])"
9880 msgstr ""
9881
9882 #. type: Content of: <p>
9883 #: src/lessons/recursion/lego/dragoncurve/DragonCurve1.html:22
9884 msgid ""
9885 "You should use the method <code>setPos(x,y)</code> to put your turtle at "
9886 "coordinates (x,y) and the method <code>moveTo(z,t)</code> to draw a line "
9887 "between the turtle position and the point(z,t)."
9888 msgstr ""
9889
9890 #. type: Content of: <h2>
9891 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:2
9892 msgid "The dragon curve (2)"
9893 msgstr ""
9894
9895 #. type: Content of: <p>
9896 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:4
9897 msgid ""
9898 "Previous solution induce that the turtle teleports to other location, or at "
9899 "the very least, that it moves its pen up during the drawing. Indeed, the end "
9900 "of the drawing of the first recursive call does not match the beginning of "
9901 "the second recursive call. That is why we had to use the method "
9902 "<code>setPos()</code>"
9903 msgstr ""
9904
9905 #. type: Content of: <p>
9906 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:10
9907 msgid ""
9908 "In this lesson, you will write a recursive method allowing to draw the "
9909 "dragon curve without taking the pen up. For that, we need another recursive "
9910 "method drawing the mirror side of the curve."
9911 msgstr ""
9912
9913 #. type: Content of: <p>
9914 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:14
9915 msgid ""
9916 "The method <code>dragon()</code> is then recursively defined using itself "
9917 "and <code>dragonReverse()</code>. Likewise, the method "
9918 "<code>dragonReverse()</code> is defined recursively using itself and "
9919 "<code>dragon()</code>. This is thus an example of <i>mutual recursion</i>."
9920 msgstr ""
9921
9922 #. type: Content of: <p>
9923 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:21
9924 msgid ""
9925 "The prototype of the <code>dragon()</code> method remains unchanged from "
9926 "previous exercise:"
9927 msgstr ""
9928
9929 #. type: Content of: <p>
9930 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:25
9931 msgid ""
9932 "The new point's coordinate (u, v) introduced by the <code>dragon()</code> "
9933 "are:"
9934 msgstr ""
9935
9936 #. type: Content of: <p>
9937 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:31
9938 msgid "The prototype of the method <code>dragonReverse</code> is similar:"
9939 msgstr ""
9940
9941 #. type: Content of: <pre>
9942 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:32
9943 #, no-wrap
9944 msgid ""
9945 "[!java|c]void [/!]dragonReverse([!java|c]int [/!]order[!scala]:Int[/!], "
9946 "[!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double "
9947 "[/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], "
9948 "[!java|c]double [/!]t[!scala]:Double[/!])"
9949 msgstr ""
9950
9951 #. type: Content of: <p>
9952 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:34
9953 msgid ""
9954 "The new point's coordinate (u, v) introduced by the "
9955 "<code>dragonReverse()</code> are:"
9956 msgstr ""
9957
9958 #. type: Content of: <pre>
9959 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:36
9960 #, no-wrap
9961 msgid ""
9962 "u = (x + z)/2 - (t - y)/2\n"
9963 "v = (y + t)/2 + (z - x)/2\n"
9964 msgstr ""
9965
9966 #. type: Content of: <p>
9967 #: src/lessons/recursion/lego/dragoncurve/DragonCurve2.html:40
9968 msgid ""
9969 "To make the work of each method recursiv more visible, the line painted by "
9970 "the <code>dragon()</code> must be red (<code>Color.red</code>) while the "
9971 "line painted by the <code>dragonReverse()</code> must be blue "
9972 "(<code>Color.blue</code>)."
9973 msgstr ""
9974
9975 #. type: Content of: <h3>
9976 #: src/lessons/recursion/hanoi/Main.html:2
9977 #: src/lessons/recursion/hanoi/short_desc.html:2
9978 msgid "Hanoi towers"
9979 msgstr ""
9980
9981 #. type: Content of: <p>
9982 #: src/lessons/recursion/hanoi/Main.html:3
9983 msgid ""
9984 "Here comes the super classical exercise on recursion along with some "
9985 "variations. If you have any other nice variations, please submit them. At "
9986 "some point, someone should also probably contribute these variations to "
9987 "wikipedia, as only the base problem is nicely described there."
9988 msgstr ""
9989
9990 #. type: Content of: <p>
9991 #: src/lessons/recursion/hanoi/Main.html:8
9992 msgid ""
9993 "The Interleaved and Split variations come from the following article: "
9994 "\"Exploring Recursion with Variations on the Towers of Hanoi\", Daniel "
9995 "W. Palmer. Available at "
9996 "http://www.ccscjournal.willmitchell.info/Vol12-96/No2a/Daniel%20W%20Palmer.pdf"
9997 msgstr ""
9998
9999 #. type: Content of: <p>
10000 #: src/lessons/recursion/hanoi/Main.html:13
10001 msgid ""
10002 "The Linear Hanoi is briefly discussed in the article presenting the Linear "
10003 "Twin Towers of Hanoi: \"The Linear Twin Towers of Hanoi Problem\", Steven "
10004 "Minsker (ACM SIGCSE Bulletin Volume 39 Issue 4, December 2007). This article "
10005 "can only be accessed through the paywall of the editor, sorry."
10006 msgstr ""
10007
10008 #. type: Content of: <p>
10009 #: src/lessons/recursion/hanoi/Main.html:18
10010 msgid ""
10011 "The 3-colors Towers of Hanoi problem was presented on this web page: "
10012 "http://www.cut-the-knot.org/recurrence/TricolorHanoiAuto.shtml"
10013 msgstr ""
10014
10015 #. type: Content of: <p>
10016 #: src/lessons/recursion/hanoi/Main.html:21
10017 msgid ""
10018 "The Cyclic Towers of Hanoi was proposed by M.D. Atkinson in an article of "
10019 "1981 titled \"The cyclic towers of Hanoi\" (Information Processing Letters, "
10020 "Volume 13:3). The article is available at "
10021 "http://www.cs.otago.ac.nz/staffpriv/mike/Papers/Hanoi/CyclicHanoi.pdf."
10022 msgstr ""
10023
10024 #. type: Content of: <p>
10025 #: src/lessons/recursion/hanoi/short_desc.html:3
10026 msgid "Here comes the super classical exercise on recursion."
10027 msgstr ""
10028
10029 #. type: Content of: <p>
10030 #: src/lessons/recursion/hanoi/short_desc.html:5
10031 msgid ""
10032 "This is an application exercise of recursion, that you should master to take "
10033 "this lesson."
10034 msgstr ""
10035
10036 #. type: Content of: <h2>
10037 #: src/lessons/recursion/hanoi/HanoiBoard.html:2
10038 msgid "Tower of Hanoi"
10039 msgstr ""
10040
10041 #. type: Content of: <p>
10042 #: src/lessons/recursion/hanoi/HanoiBoard.html:4
10043 msgid ""
10044 "The Tower of Hanoi or Towers of Hanoi, also called the Tower of Brahma or "
10045 "Towers of Brahma, is a mathematical game or puzzle. It consists of three "
10046 "pegs, and a number of disks of different sizes which can slide onto any "
10047 "peg. The puzzle starts with the disks in a neat stack in ascending order of "
10048 "size on one peg, the smallest at the top, thus forming a pyramid."
10049 msgstr ""
10050
10051 #. type: Content of: outside any tag (error?)
10052 #: src/lessons/recursion/hanoi/HanoiBoard.html:10
10053 msgid ""
10054 "The objective of the puzzle is to move the entire stack to another peg, "
10055 "obeying the following rules:"
10056 msgstr ""
10057
10058 #. type: Content of: <ul><li>
10059 #: src/lessons/recursion/hanoi/HanoiBoard.html:12
10060 msgid "Only one disk may be moved at a time."
10061 msgstr ""
10062
10063 #. type: Content of: <ul><li>
10064 #: src/lessons/recursion/hanoi/HanoiBoard.html:14
10065 msgid ""
10066 "Each move consists of taking the upper disk from one of the pegs and sliding "
10067 "it onto another peg, on top of the other disks that may already be present "
10068 "on that peg."
10069 msgstr ""
10070
10071 #. type: Content of: <ul><li>
10072 #: src/lessons/recursion/hanoi/HanoiBoard.html:18
10073 msgid "No disk may be placed on top of a smaller disk."
10074 msgstr ""
10075
10076 #. type: Content of: outside any tag (error?)
10077 #: src/lessons/recursion/hanoi/HanoiBoard.html:23
10078 msgid ""
10079 "Write the core of the method: <code>[!java|c]void "
10080 "[/!]hanoi[!c]Rec[/!]([!java|c]int [/!]height[!scala]:Int[/!], [!java|c]int "
10081 "[/!]src[!scala]:Int[/!], [!java|c]int [/!]other[!scala]:Int[/!],[!java|c]int "
10082 "[/!]dst[!scala]:Int[/!])</code>"
10083 msgstr ""
10084
10085 #. type: Content of: <p>
10086 #: src/lessons/recursion/hanoi/HanoiBoard.html:26
10087 msgid ""
10088 "This method will recursively solve the presented problem. The first "
10089 "parameter named <code>height</code> is the height of the tower to move; The "
10090 "second parameter <code>src</code> is the index of the initial tower, the "
10091 "third parameter <code>other</code> is the index of the unused peg while the "
10092 "fourth parameter <code>dst</code> is the index of the expected final tower."
10093 msgstr ""
10094
10095 #. type: Content of: <p>
10096 #: src/lessons/recursion/hanoi/HanoiBoard.html:32
10097 msgid ""
10098 "A key to solving this puzzle is to recognize that it can be solved by "
10099 "breaking the problem down into a collection of smaller problems and further "
10100 "breaking those problems down into even smaller problems until a solution is "
10101 "reached."
10102 msgstr ""
10103
10104 #. type: Attribute 'alt' of: <div>
10105 #: src/lessons/recursion/hanoi/HanoiBoard.html:36
10106 msgid "I don't get it, please give me some extra indications"
10107 msgstr ""
10108
10109 #. type: Content of: <div>
10110 #: src/lessons/recursion/hanoi/HanoiBoard.html:37
10111 msgid "Here is the pseudo-code of the solution:"
10112 msgstr ""
10113
10114 #. type: Content of: <div><ul><li>
10115 #: src/lessons/recursion/hanoi/HanoiBoard.html:39
10116 msgid "label the pegs A, B, C (these labels may move at different steps)"
10117 msgstr ""
10118
10119 #. type: Content of: <div><ul><li>
10120 #: src/lessons/recursion/hanoi/HanoiBoard.html:40
10121 msgid "let n be the total number of discs (the height of the initial tower)"
10122 msgstr ""
10123
10124 #. type: Content of: <div><ul><li>
10125 #: src/lessons/recursion/hanoi/HanoiBoard.html:41
10126 msgid "number the discs from 1 (smallest, topmost) to n (largest, bottommost)"
10127 msgstr ""
10128
10129 #. type: Content of: <div>
10130 #: src/lessons/recursion/hanoi/HanoiBoard.html:44
10131 msgid "To move n discs from peg A to peg C:"
10132 msgstr ""
10133
10134 #. type: Content of: <div><ul><li>
10135 #: src/lessons/recursion/hanoi/HanoiBoard.html:46
10136 msgid "move n−1 discs from A to B. This leaves disc number n alone on peg A"
10137 msgstr ""
10138
10139 #. type: Content of: <div><ul><li>
10140 #: src/lessons/recursion/hanoi/HanoiBoard.html:47
10141 msgid "move disc number n from A to C"
10142 msgstr ""
10143
10144 #. type: Content of: <div><ul><li>
10145 #: src/lessons/recursion/hanoi/HanoiBoard.html:48
10146 msgid "move n−1 discs from B to C so they sit on disc number n"
10147 msgstr ""
10148
10149 #. type: Content of: <h2>
10150 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:2
10151 msgid "Interleaved Towers of Hanoi"
10152 msgstr ""
10153
10154 #. type: Content of: <p>
10155 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:4
10156 msgid ""
10157 "In this classical variation of the Towers of Hanoi, you are given 4 pegs "
10158 "with 2 stacks, one white and one black. You should mix the two stacks as "
10159 "depicted in the Objective world. As previously, you cannot move a disk on a "
10160 "smaller disk."
10161 msgstr ""
10162
10163 #. type: Content of: <p>
10164 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:8
10165 msgid ""
10166 "You will probably need to reuse the <code>hanoi()</code> method that you "
10167 "wrote in the previous exercise."
10168 msgstr ""
10169
10170 #. type: Attribute 'alt' of: <div>
10171 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:10
10172 #: src/lessons/recursion/hanoi/SplitHanoi1.html:10
10173 msgid "Please show me an intermediate step"
10174 msgstr ""
10175
10176 #. type: Content of: <div>
10177 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:12
10178 #: src/lessons/recursion/hanoi/SplitHanoi1.html:12
10179 msgid "If your initial situation is as follows:"
10180 msgstr ""
10181
10182 #. type: Content of: <div>
10183 #: src/lessons/recursion/hanoi/InterleavedHanoi.html:15
10184 #: src/lessons/recursion/hanoi/SplitHanoi1.html:15
10185 msgid "then you have the following situation right before the main recursive call:"
10186 msgstr ""
10187
10188 #. type: Content of: <h2>
10189 #: src/lessons/recursion/hanoi/SplitHanoi1.html:2
10190 msgid "Split Towers of Hanoi"
10191 msgstr ""
10192
10193 #. type: Content of: <p>
10194 #: src/lessons/recursion/hanoi/SplitHanoi1.html:4
10195 msgid ""
10196 "Given one interleaved stack (e.g. resulting from the previous exercise), you "
10197 "should build two separate stacks. In other words, your code should revert "
10198 "the operations done to solve the previous exercise."
10199 msgstr ""
10200
10201 #. type: Content of: <p>
10202 #: src/lessons/recursion/hanoi/SplitHanoi1.html:7
10203 msgid ""
10204 "You will need an extra function that can move an interleaved stack of n "
10205 "pairs of disks, without changing the relative positions of disks of the same "
10206 "size."
10207 msgstr ""
10208
10209 #. type: Content of: <h2>
10210 #: src/lessons/recursion/hanoi/SplitHanoi2.html:2
10211 msgid "Better Split Towers of Hanoi"
10212 msgstr ""
10213
10214 #. type: Content of: <p>
10215 #: src/lessons/recursion/hanoi/SplitHanoi2.html:4
10216 msgid ""
10217 "Surprisingly, our solution to split the towers generates much more moves "
10218 "than our solution to interleave them. As both problems are symmetric, this "
10219 "should not be."
10220 msgstr ""
10221
10222 #. type: Content of: <br><table><tr><td>
10223 #: src/lessons/recursion/hanoi/SplitHanoi2.html:7
10224 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
10225 msgid "Disks amount"
10226 msgstr ""
10227
10228 #. type: Content of: <br><table><tr><td>
10229 #: src/lessons/recursion/hanoi/SplitHanoi2.html:7
10230 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
10231 msgid "Interleaved"
10232 msgstr ""
10233
10234 #. type: Content of: <table><tr><td>
10235 #: src/lessons/recursion/hanoi/SplitHanoi2.html:7
10236 msgid "Split"
10237 msgstr ""
10238
10239 #. type: Content of: <br><table><tr><td>
10240 #: src/lessons/recursion/hanoi/SplitHanoi2.html:8
10241 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
10242 msgid "5 pairs"
10243 msgstr ""
10244
10245 #. type: Content of: <br><table><tr><td>
10246 #: src/lessons/recursion/hanoi/SplitHanoi2.html:8
10247 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
10248 msgid "62 moves"
10249 msgstr ""
10250
10251 #. type: Content of: <br><table><tr><td>
10252 #: src/lessons/recursion/hanoi/SplitHanoi2.html:8
10253 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
10254 msgid "88 moves"
10255 msgstr ""
10256
10257 #. type: Content of: <br><table><tr><td>
10258 #: src/lessons/recursion/hanoi/SplitHanoi2.html:9
10259 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
10260 msgid "6 pairs"
10261 msgstr ""
10262
10263 #. type: Content of: <br><table><tr><td>
10264 #: src/lessons/recursion/hanoi/SplitHanoi2.html:9
10265 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
10266 msgid "126 moves"
10267 msgstr ""
10268
10269 #. type: Content of: <br><table><tr><td>
10270 #: src/lessons/recursion/hanoi/SplitHanoi2.html:9
10271 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
10272 msgid "183 moves"
10273 msgstr ""
10274
10275 #. type: Content of: <br><table><tr><td>
10276 #: src/lessons/recursion/hanoi/SplitHanoi2.html:10
10277 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
10278 msgid "7 pairs"
10279 msgstr ""
10280
10281 #. type: Content of: <br><table><tr><td>
10282 #: src/lessons/recursion/hanoi/SplitHanoi2.html:10
10283 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
10284 msgid "254 moves"
10285 msgstr ""
10286
10287 #. type: Content of: <br><table><tr><td>
10288 #: src/lessons/recursion/hanoi/SplitHanoi2.html:10
10289 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
10290 msgid "374 moves"
10291 msgstr ""
10292
10293 #. type: Content of: <p>
10294 #: src/lessons/recursion/hanoi/SplitHanoi2.html:13
10295 msgid "Can you make the split tower as efficient as the interleaved one?"
10296 msgstr ""
10297
10298 #. type: Attribute 'alt' of: <div>
10299 #: src/lessons/recursion/hanoi/SplitHanoi2.html:15
10300 msgid "I need a starter hint"
10301 msgstr ""
10302
10303 #. type: Content of: <div>
10304 #: src/lessons/recursion/hanoi/SplitHanoi2.html:16
10305 msgid ""
10306 "The source of discrepancy is an inefficient problem decomposition. "
10307 "Satisfied that it merely worked, we looked no futher for a better solution. "
10308 "Keeping the disks of the interleaved tower in the correct order during every "
10309 "move is unnecessary. In fact, we can avoid moving the interleaved tower at "
10310 "all. A better problem decomposition splits the pair of disks into two "
10311 "colored towers as they are removed from the interleaved tower."
10312 msgstr ""
10313
10314 #. type: Attribute 'alt' of: <br><br><div>
10315 #: src/lessons/recursion/hanoi/SplitHanoi2.html:24
10316 msgid "The starter hint was not enough"
10317 msgstr ""
10318
10319 #. type: Content of: <br><br><div>
10320 #: src/lessons/recursion/hanoi/SplitHanoi2.html:25
10321 msgid ""
10322 "If someone could split the (n-1) pairs of disks beforehand, could you split "
10323 "the remaining pair?"
10324 msgstr ""
10325
10326 #. type: Attribute 'alt' of: <br><br><br><br><div>
10327 #: src/lessons/recursion/hanoi/SplitHanoi2.html:30
10328 msgid "You need to be more explicit"
10329 msgstr ""
10330
10331 #. type: Content of: <br><br><br><br><div><ul><li>
10332 #: src/lessons/recursion/hanoi/SplitHanoi2.html:32
10333 msgid ""
10334 "First split the first (n-1) pairs of disks from the interleaved stack into a "
10335 "white tower and a black tower (calling recursively your main function)."
10336 msgstr ""
10337
10338 #. type: Content of: <br><br><br><br><div><ul><li>
10339 #: src/lessons/recursion/hanoi/SplitHanoi2.html:33
10340 msgid "Then move the large white disk on its target pole."
10341 msgstr ""
10342
10343 #. type: Content of: <br><br><br><br><div><ul><li>
10344 #: src/lessons/recursion/hanoi/SplitHanoi2.html:34
10345 msgid "Then move the (n-1) smaller white disks on top of the large one."
10346 msgstr ""
10347
10348 #. type: Content of: <br><br><br><br><div><ul><li>
10349 #: src/lessons/recursion/hanoi/SplitHanoi2.html:35
10350 msgid "Then move the large black disk on its target pole."
10351 msgstr ""
10352
10353 #. type: Content of: <br><br><br><br><div><ul><li>
10354 #: src/lessons/recursion/hanoi/SplitHanoi2.html:36
10355 msgid "Then move the smaller black disks in position."
10356 msgstr ""
10357
10358 #. type: Content of: <h2>
10359 #: src/lessons/recursion/hanoi/SplitHanoi3.html:2
10360 msgid "Fast Split Towers of Hanoi"
10361 msgstr ""
10362
10363 #. type: Content of: <p>
10364 #: src/lessons/recursion/hanoi/SplitHanoi3.html:4
10365 msgid ""
10366 "Again, our previous solution is working, but it is far from being optimal. "
10367 "When moving the towers, we use the algorithm for 3 pegs even if we have 4 "
10368 "pegs. Of course, movements to the last peg are restricted since it contains "
10369 "the other stack, but we can always store the smallest disk on top of the "
10370 "other stack before moving our stack."
10371 msgstr ""
10372
10373 #. type: Content of: <p>
10374 #: src/lessons/recursion/hanoi/SplitHanoi3.html:9
10375 msgid ""
10376 "For that, we need to devise a new function <code>hanoi_fast(height, src, "
10377 "free, full, dst)</code> that moves the stack from <code>src</code> to "
10378 "<code>dst</code> using <code>free</code>, but storing the smallest disk onto "
10379 "<code>full</code> beforehand."
10380 msgstr ""
10381
10382 #. type: Attribute 'alt' of: <div>
10383 #: src/lessons/recursion/hanoi/SplitHanoi3.html:13
10384 msgid "I'm lost"
10385 msgstr ""
10386
10387 #. type: Content of: <div>
10388 #: src/lessons/recursion/hanoi/SplitHanoi3.html:14
10389 msgid ""
10390 "The <code>hanoi_fast(height, src, free, full, dst)</code> function is not "
10391 "recursive. It moves the first disk and then call the regular "
10392 "<code>hanoi()</code> function."
10393 msgstr ""
10394
10395 #. type: Content of: <br><p>
10396 #: src/lessons/recursion/hanoi/SplitHanoi3.html:18
10397 msgid ""
10398 "This change greatly improve the performance, as you can see below. Of "
10399 "course, this trick could also be used for the interleaved algorithm, leading "
10400 "as expected to the exact same performance."
10401 msgstr ""
10402
10403 #. type: Content of: <br><table><tr><td>
10404 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
10405 msgid "Slow Split"
10406 msgstr ""
10407
10408 #. type: Content of: <br><table><tr><td>
10409 #: src/lessons/recursion/hanoi/SplitHanoi3.html:21
10410 msgid "Fast Split"
10411 msgstr ""
10412
10413 #. type: Content of: <br><table><tr><td>
10414 #: src/lessons/recursion/hanoi/SplitHanoi3.html:22
10415 msgid "46 moves"
10416 msgstr ""
10417
10418 #. type: Content of: <br><table><tr><td>
10419 #: src/lessons/recursion/hanoi/SplitHanoi3.html:23
10420 msgid "82 moves"
10421 msgstr ""
10422
10423 #. type: Content of: <br><table><tr><td>
10424 #: src/lessons/recursion/hanoi/SplitHanoi3.html:24
10425 msgid "150 moves"
10426 msgstr ""
10427
10428 #. type: Content of: <br><p>
10429 #: src/lessons/recursion/hanoi/SplitHanoi3.html:27
10430 msgid ""
10431 "As a conclusion, most of us are satisfied with a working solution and we "
10432 "easily overlook possibilities to improve the problem "
10433 "decomposition. <b>You</b> should not do that ;)"
10434 msgstr ""
10435
10436 #. type: Content of: <h2>
10437 #: src/lessons/recursion/hanoi/LinearHanoi.html:2
10438 msgid "Linear Towers of Hanoi"
10439 msgstr ""
10440
10441 #. type: Content of: <p>
10442 #: src/lessons/recursion/hanoi/LinearHanoi.html:4
10443 msgid ""
10444 "This is a classical variation over the Towers of Hanoi where some moves are "
10445 "forbidden. Specifically, disks cannot move directly between the left-most "
10446 "and the right-most pegs. The middle peg must be involved in every moves."
10447 msgstr ""
10448
10449 #. type: Content of: <p>
10450 #: src/lessons/recursion/hanoi/LinearHanoi.html:8
10451 msgid ""
10452 "Beside of that extra complexity, the problem remains unchanged: you are "
10453 "requested to move the whole stack of disks from one extremity peg to the "
10454 "other one. You can only move one disk at a time, and a bigger disk cannot be "
10455 "placed over a smaller one."
10456 msgstr ""
10457
10458 #. type: Content of: <p>
10459 #: src/lessons/recursion/hanoi/LinearHanoi.html:12
10460 msgid ""
10461 "As with the classical version, it is much easier to produce a recursive "
10462 "solution, and you are absolutely able to devise this solution if you think "
10463 "hard enough about it."
10464 msgstr ""
10465
10466 #. type: Attribute 'alt' of: <div>
10467 #: src/lessons/recursion/hanoi/LinearHanoi.html:15
10468 msgid "I tried, but I don't get it"
10469 msgstr ""
10470
10471 #. type: Content of: <div>
10472 #: src/lessons/recursion/hanoi/LinearHanoi.html:16
10473 msgid ""
10474 "The standard recursive algorithm for classical Hanoi is of complexity "
10475 "<i>2^n-1</i> where the standard recursive algorithm for this variation is of "
10476 "complexity <i>3^n-1</i>."
10477 msgstr ""
10478
10479 #. type: Attribute 'alt' of: <div>
10480 #: src/lessons/recursion/hanoi/LinearHanoi.html:20
10481 msgid "That first tip was not enough"
10482 msgstr ""
10483
10484 #. type: Content of: <div>
10485 #: src/lessons/recursion/hanoi/LinearHanoi.html:21
10486 msgid ""
10487 "The standard recursive algorithm for classical Hanoi involves two recursive "
10488 "calls sandwiching one movement of the largest disk, the standard recursive "
10489 "algorithm for Linear Hanoi involves three recursive calls sandwiched around "
10490 "two movements of the same disk."
10491 msgstr ""
10492
10493 #. type: Content of: <h2>
10494 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:2
10495 msgid "Linear Twin Towers of Hanoi"
10496 msgstr ""
10497
10498 #. type: Content of: <p>
10499 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:4
10500 msgid ""
10501 "This is a mix between both the Split and Interleaved problems, and the "
10502 "linear problem. We are given two stacks of disks, on three pegs. We are "
10503 "expected to swap the stacks' position while respecting the classical Hanoi "
10504 "movement restrictions (one disk at a time, and no large disk over smaller "
10505 "disks) and the linear movement restriction (no direct exchange between the "
10506 "left-most and right-most pegs)."
10507 msgstr ""
10508
10509 #. type: Content of: <p>
10510 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:10
10511 msgid "You will use three recursive functions:"
10512 msgstr ""
10513
10514 #. type: Content of: <ul><li>
10515 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:12
10516 msgid ""
10517 "<b>moveDouble(k,from, to)</b>: moves an interleaved stack of k pairs of "
10518 "disks, without changing the relative positions of disks of the same size. As "
10519 "in the Split Hanoi problem, an interleaved stack alternates white and black "
10520 "disks of each sizes. This function is not completely new: you wrote a "
10521 "version with 4 pegs (but using only 3 of them) for the first version of the "
10522 "Split Hanoi problem."
10523 msgstr ""
10524
10525 #. type: Content of: <ul><li>
10526 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:17
10527 msgid ""
10528 "<b>gather(k)</b>: from the initial split situation, build on peg #2 an "
10529 "interleaved stack of k pairs of disks. You may parametrize your function so "
10530 "that it can be used to gather the disk on any peg passed as parameter, but "
10531 "in practice, your function will only be used to gather on the last peg."
10532 msgstr ""
10533
10534 #. type: Content of: <ul><li>
10535 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:21
10536 msgid ""
10537 "<b>scatter(k)</b>: from a situation where k pairs of disks are interleaved "
10538 "on peg #0, split it down by moving the white disks to peg #1 and black ones "
10539 "to peg #2."
10540 msgstr ""
10541
10542 #. type: Content of: <p>
10543 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:25
10544 msgid ""
10545 "In <code>gather()</code>, the recursive call comes before two calls to "
10546 "<code>moveDouble()</code> while in <code>scatter()</code>, the calls to "
10547 "<code>moveDouble()</code> come before the recursive call. The main function "
10548 "that you should write is not recursive, but simply gather almost all disks, "
10549 "moves directly the remaining disks, and then scatters back the small disks."
10550 msgstr ""
10551
10552 #. type: Content of: <p>
10553 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:31
10554 msgid ""
10555 "The linearity naturally induces some extra complexity as you have to "
10556 "decompose every move between pegs 0 and 2. I am still confident in your "
10557 "ability to overcome the challenge :)"
10558 msgstr ""
10559
10560 #. type: Content of: <p>
10561 #: src/lessons/recursion/hanoi/LinearTwinHanoi.html:35
10562 msgid ""
10563 "Note that the requested algorithm was proved optimal for that problem, so "
10564 "you don't need to fiddle the performance this time."
10565 msgstr ""
10566
10567 #. type: Content of: <h2>
10568 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:2
10569 msgid "Tricolor Hanoi: stack move"
10570 msgstr ""
10571
10572 #. type: Content of: <p>
10573 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:4
10574 msgid ""
10575 "In this set of exercises, we will devise an algorithm for the Tricolor Hanoi "
10576 "problem. There will be 3 stacks on 3 pegs, each stack of a differing color, "
10577 "and the problem is to exchange the stacks' positions under the classical "
10578 "move rules (one disk at a time, and no bigger disk over smaller disk)."
10579 msgstr ""
10580
10581 #. type: Content of: <p>
10582 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:9
10583 msgid "As in previous exercises, our solution will use three functions:"
10584 msgstr ""
10585
10586 #. type: Content of: <ul><li>
10587 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:11
10588 msgid ""
10589 "<code>move3(n, src, mid, dst)</code>: moves a stack of interleaved disks, ie "
10590 "a stack of (n*3) disks of alternating colors from peg <code>src</code> to "
10591 "peg <code>dst</code>."
10592 msgstr ""
10593
10594 #. type: Content of: <ul><li>
10595 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:13
10596 msgid ""
10597 "<code>gather()</code>: builds an interleaved stack from the regular split "
10598 "ones."
10599 msgstr ""
10600
10601 #. type: Content of: <ul><li>
10602 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:14
10603 msgid ""
10604 "<code>scatter()</code>: splits an interleaved stack into several regular "
10605 "ones."
10606 msgstr ""
10607
10608 #. type: Content of: <p>
10609 #: src/lessons/recursion/hanoi/TricolorHanoi1.html:17
10610 msgid ""
10611 "The goal of this first exercise in the series is to devise the "
10612 "<code>move3()</code> function. This starter task should not block you for "
10613 "too long, actually. It is ok if your function changes the order of the "
10614 "bottom triplet of disks, but it must preserve the order of the other "
10615 "triplets."
10616 msgstr ""
10617
10618 #. type: Content of: <h2>
10619 #: src/lessons/recursion/hanoi/TricolorHanoi2.html:2
10620 msgid "Tricolor Hanoi: the Gathering"
10621 msgstr ""
10622
10623 #. type: Content of: <p>
10624 #: src/lessons/recursion/hanoi/TricolorHanoi2.html:4
10625 msgid ""
10626 "It is now time to write the second function required by the Tricolor Hanoi "
10627 "problem. <code>gather()</code> builds an interleaved stack from the regular "
10628 "split ones. This function takes four arguments, the last one being the "
10629 "target peg where the interleaved stack must be assembled. As you can see in "
10630 "the examples, the colors of must be in the same order for each triplet of "
10631 "disks."
10632 msgstr ""
10633
10634 #. type: Content of: <p>
10635 #: src/lessons/recursion/hanoi/TricolorHanoi2.html:9
10636 msgid ""
10637 "That function actually uses the <code>move3()</code> that you wrote just "
10638 "before. Simply copy/paste your code over to reuse it. If you're lost, please "
10639 "refer to the Interleaved Hanoi exercise. Gathering 3 stacks on 3 pegs is "
10640 "rather similar to gathering 2 stacks on 4 pegs. You can find that exercise "
10641 "<a href=\"plm://lessons.recursion.hanoi/InterleavedHanoi\">here</a>."
10642 msgstr ""
10643
10644 #. type: Content of: <h2>
10645 #: src/lessons/recursion/hanoi/TricolorHanoi3.html:2
10646 msgid "Tricolor Hanoi: the Final"
10647 msgstr ""
10648
10649 #. type: Content of: <p>
10650 #: src/lessons/recursion/hanoi/TricolorHanoi3.html:4
10651 msgid ""
10652 "We are almost ready to write the whole tricolor algorithm. We just need the "
10653 "<code>scatter()</code> function, very inspired from the first one that we "
10654 "wrote for the <a href=\"plm://lessons.recursion.hanoi/SplitHanoi1\">Split "
10655 "Hanoi problem</a>. Assuming that your interleaved stack is placed on the "
10656 "<code>mid</code> peg, spread the disks over all pegs. Make sure to use "
10657 "<code>move3()</code> an even amount of time at each recursive level to "
10658 "ensure that the bottom disks are in the correct order."
10659 msgstr ""
10660
10661 #. type: Content of: <p>
10662 #: src/lessons/recursion/hanoi/TricolorHanoi3.html:10
10663 msgid ""
10664 "As you can see, the initial situation is not the one expected by "
10665 "<code>scatter()</code>. You first have to apply <code>gather()</code> and "
10666 "<code>move3()</code> (twice to get the bottom triplet in the right "
10667 "order). These few steps plus the new <code>scatter()</code> function are "
10668 "enough to entirely solve the Tricolor Hanoi problem."
10669 msgstr ""
10670
10671 #. type: Content of: <h2>
10672 #: src/lessons/recursion/hanoi/CyclicHanoi.html:2
10673 msgid "Cyclic Towers of Hanoi"
10674 msgstr ""
10675
10676 #. type: Content of: <p>
10677 #: src/lessons/recursion/hanoi/CyclicHanoi.html:4
10678 msgid ""
10679 "This variation of the Towers of Hanoi is very similar to the regular "
10680 "problem: you are given one stack of disks and three pegs, and you cannot "
10681 "move a larger disk over a smaller one. The change is that you can only move "
10682 "disks clockwise: 0->1 or 1->2 or 2->0, but never in the other direction."
10683 msgstr ""
10684
10685 #. type: Content of: <p>
10686 #: src/lessons/recursion/hanoi/CyclicHanoi.html:8
10687 msgid ""
10688 "Obviously, the movements are not symmetric anymore. Moves from A to B are "
10689 "now very different from moves to B to A. As a result, you need two "
10690 "recursive functions depending on whether you are moving the stack clockwise "
10691 "or counterclockwise."
10692 msgstr ""
10693
10694 #. type: Content of: <p>
10695 #: src/lessons/recursion/hanoi/CyclicHanoi.html:11
10696 msgid ""
10697 "That being said, the problem decomposition is very similar to the classical "
10698 "Hanoi. The twist is that each function call the other one, constituting a "
10699 "nice example of mutual recursion."
10700 msgstr ""
10701
10702 #. type: Content of: <h2>
10703 #: src/lessons/recursion/hanoi/IterativeHanoi.html:2
10704 msgid "Iterative Towers of Hanoi"
10705 msgstr ""
10706
10707 #. type: Content of: <p>
10708 #: src/lessons/recursion/hanoi/IterativeHanoi.html:4
10709 msgid ""
10710 "In this last exercise of the series, we will implement an iterative "
10711 "algorithm for the base problem of the Towers of Hanoi (one stack, 3 pegs, no "
10712 "extra movement restriction)."
10713 msgstr ""
10714
10715 #. type: Content of: <p>
10716 #: src/lessons/recursion/hanoi/IterativeHanoi.html:8
10717 msgid ""
10718 "This algorithm is actually very simple: On odd moves, the smallest disk is "
10719 "moved in a given direction (either increasing 0-&gt;1-&gt;2-&gt;0 or "
10720 "decreasing 2-&lt;1-&lt;0-&lt;2) while on even moves, the only possible move "
10721 "that does not imply the smallest disk is made. You stop as soon as the stack "
10722 "is rebuilt on another location."
10723 msgstr ""
10724
10725 #. type: Content of: <p>
10726 #: src/lessons/recursion/hanoi/IterativeHanoi.html:13
10727 msgid ""
10728 "The function that you now need to write takes two parameters: the initial "
10729 "position of the smallest disk (i.e., the peg initially containing the stack) "
10730 "and a boolean indicating whether the smallest disk should move in the "
10731 "increasing order or not."
10732 msgstr ""
10733
10734 #. type: Content of: <p>
10735 #: src/lessons/recursion/hanoi/IterativeHanoi.html:17
10736 msgid ""
10737 "The simplicity of this algorithm is actually almost deceiving. One could "
10738 "wonder on the interest of the recursive algorithms when such a simple "
10739 "iterative algorithm exists. My personal feeling is that this solution is "
10740 "nice to execute, but almost impossible to devise in the first place (I even "
10741 "suspect that the authors built this iterative solution from observations of "
10742 "the recursive execution)..."
10743 msgstr ""
10744
10745 #. type: Content of: <p>
10746 #: src/lessons/recursion/hanoi/IterativeHanoi.html:23
10747 msgid ""
10748 "Predicting the effect of this function is also difficult: When the small "
10749 "disk moves in the increasing order, the stack is reconstructed on the right "
10750 "peg with 5 disks but on the left with 6 disks."
10751 msgstr ""
10752
10753 #. type: Content of: <p>
10754 #: src/lessons/recursion/hanoi/IterativeHanoi.html:27
10755 msgid ""
10756 "An interesting question is whether such simple iterative algorithms exist "
10757 "for the other variation of the problem. Some were given in the literature "
10758 "(e.g. for the cyclic variation). I would happily integrate your solutions to "
10759 "the PLM, especially if you can hint (without spoiling) the solution to guide "
10760 "the next ones."
10761 msgstr ""
10762
10763 #. type: Content of: <h1>
10764 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:2
10765 msgid "HanoiWorld"
10766 msgstr ""
10767
10768 #. type: Content of: <p>
10769 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:5
10770 msgid ""
10771 "This world implements the ultra-classical Hanoi problem. You are asked to "
10772 "move the disk pile from the stick where they are to the target stick (given "
10773 "as second parameter in the world's name -- number 1 for the default "
10774 "world). There is some extra constraint: you can only move one disk at a "
10775 "time, and you cannot move a big disk over a smaller one."
10776 msgstr ""
10777
10778 #. type: Content of: <p>
10779 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:12
10780 msgid "Only 4 functions are provided:"
10781 msgstr ""
10782
10783 #. type: Content of: <pre>
10784 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:14
10785 #, no-wrap
10786 msgid "[!java|c]void [/!]move([!java|c]int [/!]src, [!java|c]int [/!]dst)"
10787 msgstr ""
10788
10789 #. type: Content of: outside any tag (error?)
10790 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:16
10791 msgid ""
10792 "Moves one disk from the stick <code>src</code> onto the stick "
10793 "<code>dst</code>. If you try to do an invalid move (like laying a disk over "
10794 "a smaller one), an IllegalArgumentException is thrown."
10795 msgstr ""
10796
10797 #. type: Content of: <pre>
10798 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:20
10799 #, no-wrap
10800 msgid "[!java|c]int [/!]getSlotSize([!java|c]int [/!]slot)[!scala]:Int[/!]"
10801 msgstr ""
10802
10803 #. type: Content of: outside any tag (error?)
10804 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:21
10805 msgid ""
10806 "Returns the amount of disks placed on the specified slot. This is mainly "
10807 "used to initialize the recursion and set the amount of recursive call to "
10808 "execute."
10809 msgstr ""
10810
10811 #. type: Content of: <pre>
10812 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:24
10813 #, no-wrap
10814 msgid "[!java|c]int [/!]getSlotRadius([!java|c]int [/!]slot)[!scala]:Int[/!]"
10815 msgstr ""
10816
10817 #. type: Content of: outside any tag (error?)
10818 #: src/lessons/recursion/hanoi/universe/HanoiWorld.html:25
10819 msgid "Returns the radius of the top-most disk of the specified slot."
10820 msgstr ""
10821
10822 #. type: Content of: <h3>
10823 #: src/lessons/maze/Main.html:2 src/lessons/maze/short_desc.html:2
10824 msgid "Labyrinths"
10825 msgstr ""
10826
10827 #. type: Content of: <p>
10828 #: src/lessons/maze/Main.html:4 src/lessons/maze/short_desc.html:4
10829 msgid "This lesson proposes several exercises about labyrinths in the buggle world."
10830 msgstr ""
10831
10832 #. type: Content of: <h2>
10833 #: src/lessons/maze/randommouse/RandomMouseMaze.html:2
10834 msgid "The crazy mouse"
10835 msgstr ""
10836
10837 #. type: Content of: <p>
10838 #: src/lessons/maze/randommouse/RandomMouseMaze.html:4
10839 msgid ""
10840 "The day of your buggle starts badly. Out of luck, it got trapped into a "
10841 "maze. Help it finding its path out of there."
10842 msgstr ""
10843
10844 #. type: Content of: <p>
10845 #: src/lessons/maze/randommouse/RandomMouseMaze.html:9
10846 msgid ""
10847 "The exit is represented by a baggle and you need to pick this baggle in "
10848 "order to exit the maze."
10849 msgstr ""
10850
10851 #. type: Content of: <p>
10852 #: src/lessons/maze/randommouse/RandomMouseMaze.html:14
10853 msgid ""
10854 "Since the maze is so small, we can write the dumbest possible algorithm to "
10855 "do so. It relies on randomness and proves quite inefficient."
10856 msgstr ""
10857
10858 #. type: Content of: <p>
10859 #: src/lessons/maze/randommouse/RandomMouseMaze.html:19
10860 msgid ""
10861 "While the buggle didn't find the path to the escape, it must proceed the "
10862 "following way: pick a random integer between 0 and 2 by using the provided "
10863 "<code>random3()</code> method and make one of the following actions: moving "
10864 "forward if possible, turn left or turn right."
10865 msgstr ""
10866
10867 #. type: Content of: <p>
10868 #: src/lessons/maze/randommouse/RandomMouseMaze.html:25
10869 msgid ""
10870 "You don't believe that it could work? Well, give it a try, you will see... "
10871 "Don't forget to pick up the baggle once you've reached it."
10872 msgstr ""
10873
10874 #. type: Content of: <h2>
10875 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:2
10876 msgid "Following the walls"
10877 msgstr ""
10878
10879 #. type: Content of: <p>
10880 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:4
10881 msgid ""
10882 "This time, the maze is a bit more complicated. Random won't be enough, we "
10883 "ough to be smart!"
10884 msgstr ""
10885
10886 #. type: Content of: <p>
10887 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:7
10888 msgid ""
10889 "The good news is that this maze is simpler that it seems at the first "
10890 "glance: every wall are connected to each other. To get out of this kind of "
10891 "maze, the buggle only have to follow a wall (the one on its left or the one "
10892 "on its right, it doesn't matter). While keeping a paw on the wall, the "
10893 "buggle must move forward until it finds the maze exit and this biscuit it "
10894 "loves so much."
10895 msgstr ""
10896
10897 #. type: Content of: <p>
10898 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:14
10899 msgid ""
10900 "This works here because there is no island of isolated walls, so our buggle "
10901 "cannot loop around for ever without encountering its baggle."
10902 msgstr ""
10903
10904 #. type: Content of: outside any tag (error?)
10905 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:18
10906 msgid ""
10907 "The goal of this exercise is to write an algorithm allowing the buggle to "
10908 "get out of this maze."
10909 msgstr ""
10910
10911 #. type: Content of: <p>
10912 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:21
10913 msgid ""
10914 "As said earlier, it does not matter whether you decide to follow the left "
10915 "wall or the right one. Simply, the demo follows the left one, so you should "
10916 "do the same in your solution to ease the comparison of your solution and the "
10917 "demo."
10918 msgstr ""
10919
10920 #. type: Content of: <p>
10921 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:26
10922 msgid ""
10923 "Write a method <code>keepHandOnSideWall()</code> which lets the buggle move "
10924 "one step forward while keeping the paw on the wall of the selected side. You "
10925 "must ensure that the buggle always keep the paw on the wall, but also that "
10926 "it won't crash into a wall. You can check the tip for more info on this, but "
10927 "only do so if you're stuck. Try to do it without the tip first."
10928 msgstr ""
10929
10930 #. type: Content of: <p>
10931 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:33
10932 msgid ""
10933 "Then, write the whole algorithm to traverse the maze step by step (using "
10934 "<code>keepHandOnSideWall()</code>) until it finds the biscuit and the "
10935 "exit. Don't forget to pick the baggle up once you've found it."
10936 msgstr ""
10937
10938 #. type: Attribute 'alt' of: <div>
10939 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:38
10940 msgid "I'm lost, please give me some extra indications"
10941 msgstr ""
10942
10943 #. type: Content of: <div><p>
10944 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:39
10945 msgid ""
10946 "When your buggle has a wall on the left, there is three situations to "
10947 "consider, depending on the surrounding walls. The following table depicts "
10948 "each initial situation, and where you should let your buggle end after one "
10949 "step."
10950 msgstr ""
10951
10952 #. type: Content of: <div><table><tr><td>
10953 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:46
10954 msgid "Case 1"
10955 msgstr ""
10956
10957 #. type: Content of: <div><table><tr><td>
10958 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:47
10959 msgid "Case 2"
10960 msgstr ""
10961
10962 #. type: Content of: <div><table><tr><td>
10963 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:48
10964 msgid "Case 3"
10965 msgstr ""
10966
10967 #. type: Content of: <div><table><tr><td>
10968 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:50
10969 msgid "Initial situation"
10970 msgstr ""
10971
10972 #. type: Content of: <div><table><tr><td>
10973 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:55
10974 msgid "Where is the next step"
10975 msgstr ""
10976
10977 #. type: Content of: <div><p>
10978 #: src/lessons/maze/wallfollower/WallFollowerMaze.html:61
10979 msgid ""
10980 "If you do a <code>right()</code> in any case at the end of your function, "
10981 "it's possible to write it in 3 lines with a <code>while</code> loop."
10982 msgstr ""
10983
10984 #. type: Content of: <h2>
10985 #: src/lessons/maze/pledge/PledgeMaze.html:2
10986 msgid "Pledge algorithm"
10987 msgstr ""
10988
10989 #. type: Content of: <p>
10990 #: src/lessons/maze/pledge/PledgeMaze.html:4
10991 msgid ""
10992 "Once again, you thought that your algorithm were good enough to escape the "
10993 "maze, and once again, you buggle is now in a maze where your previous "
10994 "algorithm fails. Just give it a try: copy/paste your code and hit the "
10995 "\"Run\" button and see your creation fail. The trap is shaped like an upper "
10996 "case \"G\". The buggle enters the trap and follows the inner border. At some "
10997 "point, it finds the north direction free, run into that direction, and falls "
10998 "again in the trap."
10999 msgstr ""
11000
11001 #. type: Content of: <p>
11002 #: src/lessons/maze/pledge/PledgeMaze.html:14
11003 msgid ""
11004 "The Pledge's algorithm (named after Jon Pledge of Exeter) can solve this "
11005 "maze."
11006 msgstr ""
11007
11008 #. type: Content of: <p>
11009 #: src/lessons/maze/pledge/PledgeMaze.html:17
11010 msgid ""
11011 "This algorithm is a modification of the previous one thought to avoid "
11012 "obstacles. It randomly picks a heading and let the buggle move in that "
11013 "direction. When it encounters an obstacle, a paw (for example the left one) "
11014 "is kept on the wall following the obstacle while counting the turns. When "
11015 "the buggle is back to its original heading and when the sum of the turns is "
11016 "0, the buggle leaves the obstacle and continues keeping its original "
11017 "heading."
11018 msgstr ""
11019
11020 #. type: Content of: <p>
11021 #: src/lessons/maze/pledge/PledgeMaze.html:25
11022 msgid ""
11023 "Note that the use of \"total turning\" rather than just the \"current "
11024 "direction\" allows the algorithm to avoid G-shapped traps. If one proceeds "
11025 "left into the trap, one gets turned around a full 360 degrees by the "
11026 "walls. As we said before, the naive \"current direction\" algorithm gets "
11027 "into a limit cycle as it leaves the lower rightmost wall heading left and "
11028 "runs into the curved section on the left again."
11029 msgstr ""
11030
11031 #. type: Content of: <p>
11032 #: src/lessons/maze/pledge/PledgeMaze.html:32
11033 msgid ""
11034 "The Pledge's algorithm does not leave the rightmost wall due to the total "
11035 "turning not being zero at that point. It follows the wall all the way "
11036 "around, finally leaving it heading left on the bottom outside"
11037 msgstr ""
11038
11039 #. type: Content of: <p>
11040 #: src/lessons/maze/pledge/PledgeMaze.html:39
11041 msgid ""
11042 "<a name=\"Objective\"/>You now have to modify your solution to implement the "
11043 "Pledge algorithm to escape this maze."
11044 msgstr ""
11045
11046 #. type: Content of: <p>
11047 #: src/lessons/maze/pledge/PledgeMaze.html:42
11048 msgid ""
11049 "Change your <code>keepHandOnSideWall()</code> method to count the amount of "
11050 "turns done by the buggle (+1 when it turns left, and -1 when it turns "
11051 "right). This counting may require the addition of an <code>angleSum</code> "
11052 "integer value in your program."
11053 msgstr ""
11054
11055 #. type: Content of: <p>
11056 #: src/lessons/maze/pledge/PledgeMaze.html:47
11057 msgid ""
11058 "Write a boolean method <code>isDirectionFree(dir)</code> indicating if the "
11059 "provided direction is free, ie, if you can move in that direction (Note that "
11060 "the demo uses the NORTH direction for that). You can retrieve the current "
11061 "direction of the buggle using the method <code>getDirection()</code>. You "
11062 "can change your direction (without moving) using "
11063 "<code>setDirection(dir)</code>. Don't forget to store the previous direction "
11064 "of your buggle (in a dedicated variable) before checking if your favorite "
11065 "direction is free in order to restore your state afterward."
11066 msgstr ""
11067
11068 #. type: Content of: <p>
11069 #: src/lessons/maze/pledge/PledgeMaze.html:56
11070 msgid ""
11071 "You may have to change the rest of your code also, but these changes should "
11072 "remain limited."
11073 msgstr ""
11074
11075 #. type: Content of: <p>
11076 #: src/lessons/maze/pledge/PledgeMaze.html:59
11077 msgid ""
11078 "Don't forget that if you have a method modifying a global variable (such as "
11079 "angleSum), you should ensure that it declares this variable as "
11080 "global. Without it, the method creates a new variable of the same name, and "
11081 "the global never gets modified."
11082 msgstr ""
11083
11084 #. type: Content of: <pre>
11085 #: src/lessons/maze/pledge/PledgeMaze.html:63
11086 #, no-wrap
11087 msgid ""
11088 "def myMethod():\n"
11089 " global angleSum\n"
11090 " ...\n"
11091 " angleSum = angleSum + 1\n"
11092 msgstr ""
11093
11094 #. type: Attribute 'alt' of: <div>
11095 #: src/lessons/maze/pledge/PledgeMaze.html:70
11096 msgid "Show an additional tip"
11097 msgstr ""
11098
11099 #. type: Content of: <div>
11100 #: src/lessons/maze/pledge/PledgeMaze.html:71
11101 msgid ""
11102 "You should set your direction to your favorite one (NORTH is advised). Then, "
11103 "you should write the algorithm main loop. In other words, while your buggle "
11104 "did not find its biscuit, you have to move forward until next obstacle in "
11105 "the favorite direction. Then, put a paw on a wall (using "
11106 "<code>keepHandOnSideWall()</code>) while the sum of turns is not null and "
11107 "the favorite direction is not free. Do that until you find your baggle."
11108 msgstr ""
11109
11110 #. type: Content of: <h2>
11111 #: src/lessons/maze/island/IslandMaze.html:2
11112 msgid "Lost between islands"
11113 msgstr ""
11114
11115 #. type: Content of: <p>
11116 #: src/lessons/maze/island/IslandMaze.html:4
11117 msgid ""
11118 "You thought that your algorithm was enough to escape mazes? Well, not every "
11119 "mazes..."
11120 msgstr ""
11121
11122 #. type: Content of: <p>
11123 #: src/lessons/maze/island/IslandMaze.html:8
11124 msgid ""
11125 "The <i>wall follower algorithm</i> we used so far only works if the entry "
11126 "and the exit are placed near to walls connected to the external wall. But if "
11127 "the buggle begins in the middle of the maze, it may exist wall sections "
11128 "disconnected from the external wall."
11129 msgstr ""
11130
11131 #. type: Content of: <p><p>
11132 #: src/lessons/maze/island/IslandMaze.html:13
11133 msgid ""
11134 "That is why the previous strategy would let the buggle round around for "
11135 "ever. Indeed, the maze you should now escape from contains islands, and the "
11136 "buggle does not start along one of the external walls. Just give it a try if "
11137 "you want: copy your code over, push the run button and see your previous "
11138 "solution failing miserabily."
11139 msgstr ""
11140
11141 #. type: Content of: <p><p>
11142 #: src/lessons/maze/island/IslandMaze.html:19
11143 msgid ""
11144 "The method of following a wall is still good and allow to escape very "
11145 "efficiently some sections of the maze, so we do not want to remove it "
11146 "entierely. Instead, we want to stop following the wall under some "
11147 "conditions. Notice that the baggle lays near to the external border of the "
11148 "maze. So, we want to reach the border and then follow that wall. We need for "
11149 "example to search for the north wall before following it to the baggle."
11150 msgstr ""
11151
11152 #. type: Content of: <p><p><p>
11153 #: src/lessons/maze/island/IslandMaze.html:27
11154 msgid ""
11155 "To find the north wall, you simply run to the north as long as it's "
11156 "possible, and when facing an obstacle, you avoid it (using previous method)."
11157 msgstr ""
11158
11159 #. type: Attribute 'alt' of: <p><p><div>
11160 #: src/lessons/maze/island/IslandMaze.html:31
11161 msgid "I'm lost now, please give me some extra indications"
11162 msgstr ""
11163
11164 #. type: Content of: <p><p><div>
11165 #: src/lessons/maze/island/IslandMaze.html:32
11166 msgid ""
11167 "Our new run() method will consist in two modes: our buggle will alternate "
11168 "between the \"north runner mode\" and the \"left follower mode\". You begin "
11169 "in \"north runner mode\", and switch to \"left follower\" when you have a "
11170 "wall at the north (do not forget to make sure you have a wall at your left "
11171 "before switching to \"left follower\" mode). You switch to \"north runner\" "
11172 "as soon as your buggle is facing north and is not in front of a wall during "
11173 "its trip around its left wall. The easiest way to write such a state machine "
11174 "is something like"
11175 msgstr ""
11176
11177 #. type: Content of: <p><p><div><pre>
11178 #: src/lessons/maze/island/IslandMaze.html:40
11179 #, no-wrap
11180 msgid ""
11181 "[!scala]var state=0;\n"
11182 "state match {\n"
11183 " case 0 => // North runner\n"
11184 " ...\n"
11185 " state = 1;\n"
11186 " case 1 => // Left follower\n"
11187 " ...\n"
11188 " state = 0;\n"
11189 " case _ => println(\"This case should not happen. Please fix me\")\n"
11190 "}[/!][!java|c]int state=0;\n"
11191 "switch (state) {\n"
11192 " case 0: // North runner\n"
11193 " ...\n"
11194 " state = 1;\n"
11195 " break;\n"
11196 " case 1: // Left follower\n"
11197 " ...\n"
11198 " state = 0;\n"
11199 " break;\n"
11200 "}[/!][!python]northRunner = True\n"
11201 "if northRunner:\n"
11202 " ...\n"
11203 " northRunner = False\n"
11204 "else: # left follower\n"
11205 " ...\n"
11206 " northRunner = True[/!]"
11207 msgstr ""
11208
11209 #. type: Content of: <p><p><div>
11210 #: src/lessons/maze/island/IslandMaze.html:67
11211 msgid ""
11212 "Don't forget the default case (matching _), or scala will issue an error "
11213 "since your matching would be incomplete.[/!]"
11214 msgstr ""
11215
11216 #. type: Content of: <p><p><p>
11217 #: src/lessons/maze/island/IslandMaze.html:70
11218 msgid "Don't forget to let the buggle pick the baggle at the end of your code."
11219 msgstr ""
11220
11221 #. type: Content of: <p><p><p>
11222 #: src/lessons/maze/island/IslandMaze.html:73
11223 msgid ""
11224 "You're up. That should be enough for you to figure out how to escape this "
11225 "maze, but if not, you can always request for the tip. But you do not need "
11226 "any more help, do you?"
11227 msgstr ""
11228
11229 #. type: Content of: <h2>
11230 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:2
11231 msgid "Basic Shortest Path algorithm"
11232 msgstr ""
11233
11234 #. type: Content of: <p>
11235 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:4
11236 msgid ""
11237 "To conclude with this introductory lesson to maze solving algorithms, we "
11238 "will investigate another way to find the exit. The buggle in this lesson is "
11239 "a special buggle: he is a jedi. He can feel the Force. This means he is able "
11240 "to feel his environment."
11241 msgstr ""
11242
11243 #. type: Content of: <p>
11244 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:8
11245 msgid ""
11246 "Without even leaving his position, he can retrieve information about the "
11247 "world he is leaving in, with the following functions:"
11248 msgstr ""
11249
11250 #. type: Content of: <ul><li>
11251 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:10
11252 msgid "<code>getWorldWidth()</code> gives the width of its world."
11253 msgstr ""
11254
11255 #. type: Content of: <ul><li>
11256 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:11
11257 msgid "<code>getWorldHeight()</code> gives the height of its world."
11258 msgstr ""
11259
11260 #. type: Content of: <ul><li>
11261 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:12
11262 msgid ""
11263 "<code>hasTopWall(x,y)</code> tells whether the cell (x,y) of this world has "
11264 "a wall on top."
11265 msgstr ""
11266
11267 #. type: Content of: <ul><li>
11268 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:13
11269 msgid ""
11270 "<code>hasLeftWall(x,y)</code> tells whether the cell (x,y) of this world has "
11271 "a wall on the left."
11272 msgstr ""
11273
11274 #. type: Content of: <ul><li>
11275 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:14
11276 msgid ""
11277 "<code>hasBaggle(x,y)</code> tells whether the cell (x,y) of this world has a "
11278 "baggle."
11279 msgstr ""
11280
11281 #. type: Content of: <ul><li>
11282 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:15
11283 msgid ""
11284 "<code>setIndication(x,y,i)</code> adds the integer indication <code>i</code> "
11285 "to the cell (x,y)."
11286 msgstr ""
11287
11288 #. type: Content of: <ul><li>
11289 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:16
11290 msgid ""
11291 "<code>getIndication(x,y,i)</code> retrieves the integer indication of the "
11292 "cell (x,y) (or 9999 if there is no indication)."
11293 msgstr ""
11294
11295 #. type: Content of: <p>
11296 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:19
11297 msgid ""
11298 "It has to be noted that it is not possible to build a wall on the bottom "
11299 "edge or on the right edge of a cell. Therefore when such wall exists, it "
11300 "means it was built on a sibling cells -- as a top (respectively left) wall "
11301 "on the cell that is located below (respectively at the right of) the current "
11302 "cell."
11303 msgstr ""
11304
11305 #. type: Content of: <p>
11306 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:25
11307 msgid ""
11308 "Your buggle should first write the distance to the exit on each cell (or at "
11309 "least the useful ones)."
11310 msgstr ""
11311
11312 #. type: Content of: <p>
11313 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:26
11314 msgid ""
11315 "For that, find the exit and write 0 there. Then, write 1 on every "
11316 "neighboring cells that is not separated from the exit with a wall. And then "
11317 "mark every cells from which you can reach the exit in 2 steps, and iterate "
11318 "for all cells until all cells are marked."
11319 msgstr ""
11320
11321 #. type: Content of: <p>
11322 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:31
11323 msgid ""
11324 "Once the cells are marked, get your jedi buggle to follow the shortest "
11325 "path. Basically the buggle has only to walk on each case with the lesser "
11326 "distance from the exit. You can use the method "
11327 "<code>setDirection(direction)</code> to make your buggle look at the "
11328 "specific direction such as "
11329 "<code>[!scala|java|python]Direction.[/!]NORTH</code> or "
11330 "<code>[!scala|java|python]Direction.[/!]EAST</code>."
11331 msgstr ""
11332
11333 #. type: Attribute 'alt' of: <div>
11334 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:36
11335 msgid "I'm lost now. Please give me some extra indications."
11336 msgstr ""
11337
11338 #. type: Content of: <div>
11339 #: src/lessons/maze/shortestpath/ShortestPathMaze.html:37
11340 msgid "Use the Force, Luke!"
11341 msgstr ""
11342
11343 #. type: Content of: <h2>
11344 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:2
11345 msgid "Finding the walls to follow"
11346 msgstr ""
11347
11348 #. type: Content of: <p>
11349 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:4
11350 msgid ""
11351 "This is exactly the same maze than before, but the buggle does not start at "
11352 "the same location. In particular, it does not have any wall to its left at "
11353 "the beginning."
11354 msgstr ""
11355
11356 #. type: Content of: <p>
11357 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:8
11358 msgid ""
11359 "As a result, the method you wrote for the previous exercise probably don't "
11360 "work for this one. If you use it here with no modification, your buggle "
11361 "probably start looping over the four free cells around its start position "
11362 "(if that's not the case, well, you didn't really stick to the mission on "
11363 "previous exercise. Feel lucky and proceed to the next :)"
11364 msgstr ""
11365
11366 #. type: Content of: <p>
11367 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:15
11368 msgid ""
11369 "This is because your <code>keepHandOnSideWall()</code> method has an "
11370 "implicit <b>pre-condition</b>: it works well if and only if the buggle has a "
11371 "wall to its left when you call it. Such pre-condition are very heavily used "
11372 "when programming. Specifying them explicitly helps understanding the code "
11373 "written by other, and they even allow sometimes to prove that the code works "
11374 "correctly."
11375 msgstr ""
11376
11377 #. type: Content of: <p>
11378 #: src/lessons/maze/wallfindfollow/WallFindFollowMaze.html:25
11379 msgid ""
11380 "Fixing the problem should be very easy. Simply make sure that the "
11381 "pre-condition of <code>keepHandOnSideWall()</code> is verified before "
11382 "calling it. For that, update your code to first look for a wall on its left "
11383 "before the big <code>while</code> loop."
11384 msgstr ""
11385
11386 #. type: Content of: <h3>
11387 #: src/lessons/lightbot/universe/LightBotWorld.html:2
11388 #: src/lessons/lightbot/Main.html:2 src/lessons/lightbot/short_desc.html:2
11389 msgid "LightBot"
11390 msgstr ""
11391
11392 #. type: Content of: outside any tag (error?)
11393 #: src/lessons/lightbot/universe/LightBotWorld.html:4
11394 msgid ""
11395 "This universe introduces a little programming puzzle which can somehow be "
11396 "used to introduce programmation to non-reading kids since it is programmed "
11397 "graphically. The goal of each board is to light up all the lights. Your "
11398 "robot understands the following orders:"
11399 msgstr ""
11400
11401 #. type: Content of: <table><tr><td>
11402 #: src/lessons/lightbot/universe/LightBotWorld.html:8
11403 msgid "<b>Order</b>"
11404 msgstr ""
11405
11406 #. type: Content of: <table><tr><td>
11407 #: src/lessons/lightbot/universe/LightBotWorld.html:8
11408 msgid "<b>Meaning</b>"
11409 msgstr ""
11410
11411 #. type: Content of: <table><tr><td>
11412 #: src/lessons/lightbot/universe/LightBotWorld.html:9
11413 msgid "<b>Move forward</b>"
11414 msgstr ""
11415
11416 #. type: Content of: <table><tr><td>
11417 #: src/lessons/lightbot/universe/LightBotWorld.html:9
11418 msgid "Cannot be done if the destination cell is of another height than source cell"
11419 msgstr ""
11420
11421 #. type: Content of: <table><tr><td>
11422 #: src/lessons/lightbot/universe/LightBotWorld.html:10
11423 msgid "<b>Jump forward</b>"
11424 msgstr ""
11425
11426 #. type: Content of: <table><tr><td>
11427 #: src/lessons/lightbot/universe/LightBotWorld.html:10
11428 msgid ""
11429 "Can only be done if the destination cell is one step higher than source "
11430 "cell, or if destination is lower than source. Cannot be used for plain "
11431 "moves."
11432 msgstr ""
11433
11434 #. type: Content of: <table><tr><td>
11435 #: src/lessons/lightbot/universe/LightBotWorld.html:11
11436 msgid "<b>Turn left</b>."
11437 msgstr ""
11438
11439 #. type: Content of: <table><tr><td>
11440 #: src/lessons/lightbot/universe/LightBotWorld.html:12
11441 msgid "<b>Turn right</b>."
11442 msgstr ""
11443
11444 #. type: Content of: <table><tr><td>
11445 #: src/lessons/lightbot/universe/LightBotWorld.html:13
11446 msgid "<b>Switch the light</b>."
11447 msgstr ""
11448
11449 #. type: Content of: <table><tr><td>
11450 #: src/lessons/lightbot/universe/LightBotWorld.html:13
11451 msgid ""
11452 "Turn it on if it was off, and off if it was on. No effect if the cell does "
11453 "not contain any light."
11454 msgstr ""
11455
11456 #. type: Content of: <table><tr><td>
11457 #: src/lessons/lightbot/universe/LightBotWorld.html:14
11458 msgid "<b>Call function 1</b>."
11459 msgstr ""
11460
11461 #. type: Content of: <table><tr><td>
11462 #: src/lessons/lightbot/universe/LightBotWorld.html:15
11463 msgid "<b>Call function 2</b>."
11464 msgstr ""
11465
11466 #. type: Content of: <p>
11467 #: src/lessons/lightbot/universe/LightBotWorld.html:18
11468 msgid ""
11469 "Please note that this world is not completely suited to small kids since the "
11470 "main difficulty comes from the fact that your are highly limited in the "
11471 "amount of instructions you can give to your robot. Advanced levels thus "
11472 "require to write sound functions, and are often above the capacities of "
11473 "small kids."
11474 msgstr ""
11475
11476 #. type: Content of: <p>
11477 #: src/lessons/lightbot/universe/LightBotWorld.html:20
11478 msgid ""
11479 "This game is heavily inspirated from a flash game of the same name, which "
11480 "can for example be played on kongregate.com. It was written by Danny "
11481 "Yaroslavski (Coolio-Niato), the original idea being of Matt Chase."
11482 msgstr ""
11483
11484 #. type: Content of: outside any tag (error?)
11485 #: src/lessons/lightbot/Main.html:3
11486 msgid ""
11487 "This lesson introduces a little programming puzzle inspired from a flash "
11488 "game."
11489 msgstr ""
11490
11491 #. type: Content of: <p>
11492 #: src/lessons/lightbot/Main.html:5
11493 msgid "See the <i>About this world</i> dialog for more details."
11494 msgstr ""
11495
11496 #. type: Content of: <p>
11497 #: src/lessons/lightbot/short_desc.html:4
11498 msgid ""
11499 "This lesson constitutes a little brain teaser for programmers. You have to "
11500 "instruct your robot to turn off all lights. The trick is that you program "
11501 "your robot graphically, and that you are limited in the amount of "
11502 "instructions."
11503 msgstr ""
11504
11505 #. type: Content of: <p>
11506 #: src/lessons/lightbot/short_desc.html:9
11507 msgid "No previous experience is expected to take this lesson."
11508 msgstr ""
11509
11510 #. type: Content of: <h1>
11511 #: src/lessons/lightbot/Board01TwoSteps.html:2
11512 msgid "Welcome"
11513 msgstr ""
11514
11515 #. type: Content of: <p>
11516 #: src/lessons/lightbot/Board01TwoSteps.html:4
11517 msgid ""
11518 "Welcome to the lightbot world. This is merely a programmer puzzle rather "
11519 "than a real lesson (although some use it to teach programming). The robot "
11520 "is not programmed in Java, but rather graphically. You can see the existing "
11521 "orders in the documentation using the <i>About this world</i> menu."
11522 msgstr ""
11523
11524 #. type: Content of: <p><</p><p>
11525 #: src/lessons/lightbot/Board01TwoSteps.html:7
11526 msgid ""
11527 "The goal of each board is simply to switch on every lights of the board "
11528 "using your little robot."
11529 msgstr ""
11530
11531 #. type: Content of: <p><</p><p>
11532 #: src/lessons/lightbot/Board01TwoSteps.html:9
11533 msgid ""
11534 "This is a introduction exercise, which should be solvable by only moving "
11535 "forward and switching the light, using respectively"
11536 msgstr ""
11537
11538 #. type: Content of: <p>
11539 #: src/lessons/lightbot/Board01TwoSteps.html:11
11540 #: src/lessons/lightbot/Board02Turn.html:5
11541 #: src/lessons/lightbot/Board06Func.html:4
11542 msgid "and"
11543 msgstr ""
11544
11545 #. type: Content of: <p><</p><p>
11546 #: src/lessons/lightbot/Board01TwoSteps.html:11
11547 msgid "."
11548 msgstr ""
11549
11550 #. type: Content of: <h1>
11551 #: src/lessons/lightbot/Board02Turn.html:2
11552 msgid "Turn around"
11553 msgstr ""
11554
11555 #. type: Content of: <p>
11556 #: src/lessons/lightbot/Board02Turn.html:4
11557 msgid "Now, you probably need to turn in addition (using"
11558 msgstr ""
11559
11560 #. type: Content of: <p>
11561 #: src/lessons/lightbot/Board02Turn.html:5
11562 msgid ")."
11563 msgstr ""
11564
11565 #. type: Content of: <h1>
11566 #: src/lessons/lightbot/Board03Jump.html:2
11567 msgid "Jump"
11568 msgstr ""
11569
11570 #. type: Content of: <p>
11571 #: src/lessons/lightbot/Board03Jump.html:4
11572 msgid "You can also jump using"
11573 msgstr ""
11574
11575 #. type: Content of: <p>
11576 #: src/lessons/lightbot/Board03Jump.html:4
11577 msgid ""
11578 "to pass obstacles. You can either jump one level up or any amount of levels "
11579 "down, but you cannot jump to go on a cell of the same height."
11580 msgstr ""
11581
11582 #. type: Content of: <h1>
11583 #: src/lessons/lightbot/Board04Stairs.html:2
11584 msgid "Stairs"
11585 msgstr ""
11586
11587 #. type: Content of: <p>
11588 #: src/lessons/lightbot/Board04Stairs.html:4
11589 msgid "Can you pass these stairs?"
11590 msgstr ""
11591
11592 #. type: Content of: <h1>
11593 #: src/lessons/lightbot/Board05Higher.html:2
11594 msgid "Higher"
11595 msgstr ""
11596
11597 #. type: Content of: <p>
11598 #: src/lessons/lightbot/Board05Higher.html:4
11599 msgid "Let's go higher"
11600 msgstr ""
11601
11602 #. type: Content of: <p>
11603 #: src/lessons/lightbot/Board06Func.html:4
11604 msgid "You can use"
11605 msgstr ""
11606
11607 #. type: Content of: <p>
11608 #: src/lessons/lightbot/Board06Func.html:4
11609 msgid ""
11610 "to call respectively the first and second functions. Define their code in "
11611 "their own tab."
11612 msgstr ""
11613
11614 #. type: Content of: <p><p>
11615 #: src/lessons/lightbot/Board06Func.html:6
11616 msgid "This is great if you get out of space in your main function"
11617 msgstr ""
11618
11619 #. type: Content of: <h1>
11620 #: src/lessons/lightbot/Board07Repeat.html:2
11621 msgid "Repetitive tasks"
11622 msgstr ""
11623
11624 #. type: Content of: <p>
11625 #: src/lessons/lightbot/Board07Repeat.html:4
11626 msgid "Functions are also of great use for repetitive tasks"
11627 msgstr ""
11628
11629 #. type: Content of: <h1>
11630 #: src/lessons/lightbot/Board08Rec.html:2
11631 msgid "Calling functions from functions"
11632 msgstr ""
11633
11634 #. type: Content of: <p>
11635 #: src/lessons/lightbot/Board08Rec.html:4
11636 msgid "It is perfectly okay to call a function from within a function!"
11637 msgstr ""
11638
11639 #. type: Content of: <h1>
11640 #: src/lessons/lightbot/Board09Castle.html:2
11641 msgid "Castle"
11642 msgstr ""
11643
11644 #. type: Content of: <p>
11645 #: src/lessons/lightbot/Board09Castle.html:4
11646 msgid "You're getting good at this..."
11647 msgstr ""
11648
11649 #. type: Content of: <h1>
11650 #: src/lessons/lightbot/Board10Wall.html:2
11651 msgid "Wall"
11652 msgstr ""
11653
11654 #. type: Content of: <p>
11655 #: src/lessons/lightbot/Board10Wall.html:4
11656 msgid "Ready to climb the wall?"
11657 msgstr ""
11658
11659 #. type: Content of: <h1>
11660 #: src/lessons/lightbot/Board11Sea.html:2
11661 msgid "Sea"
11662 msgstr ""
11663
11664 #. type: Content of: <p>
11665 #: src/lessons/lightbot/Board11Sea.html:4
11666 msgid "You now have to surf these waves of lamps."
11667 msgstr ""
11668
11669 #. type: Content of: <h1>
11670 #: src/lessons/lightbot/Board12Escher.html:2
11671 msgid "Escher Castle"
11672 msgstr ""
11673
11674 #. type: Content of: <p>
11675 #: src/lessons/lightbot/Board12Escher.html:4
11676 msgid "This one aint easy."
11677 msgstr ""
11678
11679 #. type: Content of: <h1>
11680 #: src/lessons/welcome/bat/bool1/Close10.html:2
11681 msgid "Close to 10"
11682 msgstr ""
11683
11684 #. type: Content of: <p>
11685 #: src/lessons/welcome/bat/bool1/Close10.html:3
11686 msgid ""
11687 "Given 2 int values, return whichever value is nearest to the value 10, or "
11688 "return 0 in the event of a tie. [!java|scala]Note that Math.abs(n) returns "
11689 "the absolute value of a number.[/!] [!python]Note that math.fabs(n) returns "
11690 "the absolute value of a number. This function can only be used if you "
11691 "imported the math module.[/!]"
11692 msgstr ""
11693
11694 #. type: Content of: <h1>
11695 #: src/lessons/welcome/bat/bool1/CountTeen.html:2
11696 msgid "Count Teen"
11697 msgstr ""
11698
11699 #. type: Content of: <p>
11700 #: src/lessons/welcome/bat/bool1/CountTeen.html:3
11701 msgid ""
11702 "We'll say that a number is \"teen\" if it is in the range 13..19 "
11703 "inclusive. Given 4 int values, return the amount of teen ones."
11704 msgstr ""
11705
11706 #. type: Content of: <h1>
11707 #: src/lessons/welcome/bat/bool1/Diff21.html:2
11708 msgid "Diff 21"
11709 msgstr ""
11710
11711 #. type: Content of: outside any tag (error?)
11712 #: src/lessons/welcome/bat/bool1/Diff21.html:3
11713 msgid ""
11714 "Given an int n, return the absolute difference between n and 21, except "
11715 "return double the absolute difference if n is over 21."
11716 msgstr ""
11717
11718 #. type: Content of: <h1>
11719 #: src/lessons/welcome/bat/bool1/HasTeen.html:2
11720 msgid "Has Teen"
11721 msgstr ""
11722
11723 #. type: Content of: outside any tag (error?)
11724 #: src/lessons/welcome/bat/bool1/HasTeen.html:3
11725 msgid ""
11726 "We'll say that a number is \"teen\" if it is in the range 13..19 "
11727 "inclusive. Given 3 int values, return true if 1 or more of them are teen."
11728 msgstr ""
11729
11730 #. type: Content of: <h1>
11731 #: src/lessons/welcome/bat/bool1/IcyHot.html:2
11732 msgid "Icy Hot"
11733 msgstr ""
11734
11735 #. type: Content of: outside any tag (error?)
11736 #: src/lessons/welcome/bat/bool1/IcyHot.html:3
11737 msgid ""
11738 "Given two temperatures, return true if one is less than 0 and the other is "
11739 "greater than 100."
11740 msgstr ""
11741
11742 #. type: Content of: <h1>
11743 #: src/lessons/welcome/bat/bool1/In1020.html:2
11744 msgid "In [10;20]"
11745 msgstr ""
11746
11747 #. type: Content of: outside any tag (error?)
11748 #: src/lessons/welcome/bat/bool1/In1020.html:3
11749 msgid ""
11750 "Given 2 int values, return true if either of them is in the range 10..20 "
11751 "inclusive."
11752 msgstr ""
11753
11754 #. type: Content of: <h1>
11755 #: src/lessons/welcome/bat/bool1/In3050.html:2
11756 msgid "In [30;50]"
11757 msgstr ""
11758
11759 #. type: Content of: outside any tag (error?)
11760 #: src/lessons/welcome/bat/bool1/In3050.html:3
11761 msgid ""
11762 "Given 2 int values, return true if they are both in the range 30..40 "
11763 "inclusive, or they are both in the range 40..50 inclusive."
11764 msgstr ""
11765
11766 #. type: Content of: <h1>
11767 #: src/lessons/welcome/bat/bool1/LastDigit.html:2
11768 msgid "LastDigit"
11769 msgstr ""
11770
11771 #. type: Content of: outside any tag (error?)
11772 #: src/lessons/welcome/bat/bool1/LastDigit.html:3
11773 msgid ""
11774 "Given two non-negative int values, return true if they have the same last "
11775 "digit, such as with 27 and 57. Note that the % \"mod\" operator computes "
11776 "remainders, so 17 % 10 is 7."
11777 msgstr ""
11778
11779 #. type: Content of: <p>
11780 #: src/lessons/welcome/bat/bool1/LastDigit.html:10
11781 #: src/lessons/welcome/bat/bool2/ShareDigit.html:10
11782 msgid ""
11783 "This exercise was converted to PLM from the excellent exercising site "
11784 "http://javabat.com/"
11785 msgstr ""
11786
11787 #. type: Content of: <h1>
11788 #: src/lessons/welcome/bat/bool1/LoneTeen.html:2
11789 msgid "Lone Teen"
11790 msgstr ""
11791
11792 #. type: Content of: outside any tag (error?)
11793 #: src/lessons/welcome/bat/bool1/LoneTeen.html:3
11794 msgid ""
11795 "We'll say that a number is \"teen\" if it is in the range 13..19 "
11796 "inclusive. Given 2 int values, return true if one or the other is teen, but "
11797 "not both."
11798 msgstr ""
11799
11800 #. type: Content of: <h1>
11801 #: src/lessons/welcome/bat/bool1/Main.html:2
11802 msgid "Boolean fun"
11803 msgstr ""
11804
11805 #. type: Content of: <p>
11806 #: src/lessons/welcome/bat/bool1/Main.html:4
11807 msgid ""
11808 "Boolean operations are one of the very basic task in programming. As long "
11809 "as you cannot write a not so simple boolean test under the minute, you "
11810 "probably will have a very bad time writing a real program."
11811 msgstr ""
11812
11813 #. type: Content of: <p>
11814 #: src/lessons/welcome/bat/bool1/Main.html:9
11815 msgid ""
11816 "That is why this lesson provides you a bunch of such exercises, so that you "
11817 "can get trained in this."
11818 msgstr ""
11819
11820 #. type: Content of: <h1>
11821 #: src/lessons/welcome/bat/bool1/Makes10.html:2
11822 msgid "Makes 10"
11823 msgstr ""
11824
11825 #. type: Content of: outside any tag (error?)
11826 #: src/lessons/welcome/bat/bool1/Makes10.html:3
11827 msgid ""
11828 "Given 2 ints, a and b, return true if one of them is 10 or if their sum is "
11829 "10."
11830 msgstr ""
11831
11832 #. type: Content of: <h1>
11833 #: src/lessons/welcome/bat/bool1/Max1020.html:2
11834 msgid "Max1020"
11835 msgstr ""
11836
11837 #. type: Content of: <p>
11838 #: src/lessons/welcome/bat/bool1/Max1020.html:3
11839 msgid ""
11840 "Given 2 positive int values, return the larger value that is in the range "
11841 "10..20 inclusive, or return 0 if neither is in that range."
11842 msgstr ""
11843
11844 #. type: Content of: <p>
11845 #: src/lessons/welcome/bat/bool1/Max1020.html:6
11846 msgid ""
11847 "Note that Math.max(Int,Int):Int and Math.min(Int,Int):Int return the maximum "
11848 "and minimum of two integers"
11849 msgstr ""
11850
11851 #. type: Content of: <h1>
11852 #: src/lessons/welcome/bat/bool1/MonkeyTrouble.html:2
11853 msgid "MonkeyTrouble"
11854 msgstr ""
11855
11856 #. type: Content of: outside any tag (error?)
11857 #: src/lessons/welcome/bat/bool1/MonkeyTrouble.html:4
11858 msgid ""
11859 "We have two monkeys, a and b, and the parameters aSmile and bSmile indicate "
11860 "if each is smiling. We are in trouble if they are both smiling or if "
11861 "neither of them is smiling. Return true if we are in trouble."
11862 msgstr ""
11863
11864 #. type: Content of: <h1>
11865 #: src/lessons/welcome/bat/bool1/NearHundred.html:2
11866 msgid "Near Hundred"
11867 msgstr ""
11868
11869 #. type: Content of: <p>
11870 #: src/lessons/welcome/bat/bool1/NearHundred.html:3
11871 msgid ""
11872 "Given an int n, return true if it is within 10 of 100 or 200. "
11873 "[!java|scala]Note that Math.abs(n) returns the absolute value of a "
11874 "number.[/!] [!python]Note that math.fabs(n) returns the absolute value of a "
11875 "number. This function can only be used if you imported the math module.[/!]"
11876 msgstr ""
11877
11878 #. type: Content of: <h1>
11879 #: src/lessons/welcome/bat/bool1/ParotTrouble.html:2
11880 msgid "Parot Trouble"
11881 msgstr ""
11882
11883 #. type: Content of: outside any tag (error?)
11884 #: src/lessons/welcome/bat/bool1/ParotTrouble.html:4
11885 msgid ""
11886 "We have a loud talking parrot. The \"hour\" parameter is the current hour "
11887 "time in the range 0..23. We are in trouble if the parrot is talking and the "
11888 "hour is before 7 or after 20. Return true if we are in trouble."
11889 msgstr ""
11890
11891 #. type: Content of: <h1>
11892 #: src/lessons/welcome/bat/bool1/PosNeg.html:2
11893 msgid "Positive Negative"
11894 msgstr ""
11895
11896 #. type: Content of: outside any tag (error?)
11897 #: src/lessons/welcome/bat/bool1/PosNeg.html:3
11898 msgid ""
11899 "Given 2 int values, return true if one is negative and one is "
11900 "positive. Unless negative is true, then they both must be negative."
11901 msgstr ""
11902
11903 #. type: Content of: <h1>
11904 #: src/lessons/welcome/bat/bool1/SleepIn.html:2
11905 msgid "SleepDay"
11906 msgstr ""
11907
11908 #. type: Content of: outside any tag (error?)
11909 #: src/lessons/welcome/bat/bool1/SleepIn.html:4
11910 msgid ""
11911 "The parameter weekday is true if it is a weekday, and the parameter vacation "
11912 "is true if we are on vacation. We sleep in if it is not a weekday or we're "
11913 "on vacation. Return true if we sleep in."
11914 msgstr ""
11915
11916 #. type: Content of: <h1>
11917 #: src/lessons/welcome/bat/bool1/SumDouble.html:2
11918 msgid "Sum Double"
11919 msgstr ""
11920
11921 #. type: Content of: outside any tag (error?)
11922 #: src/lessons/welcome/bat/bool1/SumDouble.html:3
11923 msgid ""
11924 "Given two int values, return their sum. Unless the two values are the same, "
11925 "then return double their sum."
11926 msgstr ""
11927
11928 #. type: Content of: <h1>
11929 #: src/lessons/welcome/bat/bool2/AlarmClock.html:2
11930 msgid "AlarmClock"
11931 msgstr ""
11932
11933 #. type: Content of: outside any tag (error?)
11934 #: src/lessons/welcome/bat/bool2/AlarmClock.html:3
11935 msgid ""
11936 "Given a day of the week encoded as 0=Sun, 1=Mon, 2=Tue, ...6=Sat, and a "
11937 "boolean indicating if we are on vacation, return a string of the form "
11938 "\"7:00\" indicating when the alarm clock should ring. Weekdays, the alarm "
11939 "should be \"7:00\" and on the weekend it should be \"10:00\". Unless we are "
11940 "on vacation -- then on weekdays it should be \"10:00\" and weekends it "
11941 "should be \"off\"."
11942 msgstr ""
11943
11944 #. type: Content of: <h1>
11945 #: src/lessons/welcome/bat/bool2/AnswerCell.html:2
11946 msgid "AnswerCell"
11947 msgstr ""
11948
11949 #. type: Content of: outside any tag (error?)
11950 #: src/lessons/welcome/bat/bool2/AnswerCell.html:3
11951 msgid ""
11952 "Your cell phone rings. Return true if you should answer it. Normally you "
11953 "answer, except in the morning you only answer if it is your mom calling. In "
11954 "all cases, if you are asleep, you do not answer."
11955 msgstr ""
11956
11957 #. type: Content of: <h1>
11958 #: src/lessons/welcome/bat/bool2/BlueTicket.html:2
11959 msgid "BlueTicket"
11960 msgstr ""
11961
11962 #. type: Content of: outside any tag (error?)
11963 #: src/lessons/welcome/bat/bool2/BlueTicket.html:3
11964 msgid ""
11965 "You have a blue lottery ticket, with ints a, b, and c on it. This makes "
11966 "three pairs, which we'll call ab, bc, and ac. Consider the sum of the "
11967 "numbers in each pair. If any pair sums to exactly 10, the result is 10. "
11968 "Otherwise if the ab sum is exactly 10 more than either bc or ac sums, the "
11969 "result is 5. Otherwise the result is 0."
11970 msgstr ""
11971
11972 #. type: Content of: <h1>
11973 #: src/lessons/welcome/bat/bool2/CaughtSpeeding.html:2
11974 msgid "CaughtSpeeding"
11975 msgstr ""
11976
11977 #. type: Content of: outside any tag (error?)
11978 #: src/lessons/welcome/bat/bool2/CaughtSpeeding.html:3
11979 msgid ""
11980 "You are driving a little too fast, and a police officer stops you. Write "
11981 "code to compute the result, encoded as an int value: 0=no ticket, 1=small "
11982 "ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is "
11983 "between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the "
11984 "result is 2. Unless it is your birthday -- on that day, your speed can be 5 "
11985 "higher in all cases."
11986 msgstr ""
11987
11988 #. type: Content of: <h1>
11989 #: src/lessons/welcome/bat/bool2/CigarParty.html:2
11990 msgid "CigarParty"
11991 msgstr ""
11992
11993 #. type: Content of: outside any tag (error?)
11994 #: src/lessons/welcome/bat/bool2/CigarParty.html:3
11995 msgid ""
11996 "When squirrels get together for a party, they like to have cigars. A "
11997 "squirrel party is successful when the number of cigars is between 40 and 60, "
11998 "inclusive. Unless it is the weekend, in which case there is no upper bound "
11999 "on the number of cigars. Return true if the party was successful."
12000 msgstr ""
12001
12002 #. type: Content of: <h1>
12003 #: src/lessons/welcome/bat/bool2/DateFashion.html:2
12004 msgid "DateFashion"
12005 msgstr ""
12006
12007 #. type: Content of: outside any tag (error?)
12008 #: src/lessons/welcome/bat/bool2/DateFashion.html:3
12009 msgid ""
12010 "You and your date are trying to get a table at a restaurant. The parameter "
12011 "\"you\" is the stylishness of your clothes, in the range 0..10, and \"date\" "
12012 "is the stylishness of your date's clothes. The result getting the table is "
12013 "encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very "
12014 "stylish, 8 or more, then the result is 2 (yes). With the exception that if "
12015 "either of you has style of 2 or less, then the result is 0 (no). Otherwise "
12016 "the result is 1 (maybe)."
12017 msgstr ""
12018
12019 #. type: Content of: <h1>
12020 #: src/lessons/welcome/bat/bool2/FizzBuzz.html:2
12021 msgid "Fizz Buzz"
12022 msgstr ""
12023
12024 #. type: Content of: <p>
12025 #: src/lessons/welcome/bat/bool2/FizzBuzz.html:3
12026 msgid ""
12027 "According to Wikipedia, Fizz buzz is a group word game for children to teach "
12028 "them about division. Players take turns to count incrementally, replacing "
12029 "any number divisible by three with the word \"Fizz\", and any number "
12030 "divisible by five with the word \"Buzz\". Any number that is divisible by "
12031 "both three and five is replaced with the string \"Fizz Buzz\"."
12032 msgstr ""
12033
12034 #. type: Content of: <p>
12035 #: src/lessons/welcome/bat/bool2/FizzBuzz.html:8
12036 msgid ""
12037 "Unchanged numbers are simply returned as a string. [!java|scala]The easiest "
12038 "for that is to use that [!thelang] idiomatic: <code>\"\"+a</code>[/!] "
12039 "[!python]The function <code>str(a)</code> changes an integer <code>a</code> "
12040 "into a string.[/!]"
12041 msgstr ""
12042
12043 #. type: Content of: <h1>
12044 #: src/lessons/welcome/bat/bool2/GreenTicket.html:2
12045 msgid "GreenTicket"
12046 msgstr ""
12047
12048 #. type: Content of: outside any tag (error?)
12049 #: src/lessons/welcome/bat/bool2/GreenTicket.html:3
12050 msgid ""
12051 "You have a green lottery ticket, with ints a, b, and c on it. If the numbers "
12052 "are all different from each other, the result is 0. If all of the numbers "
12053 "are the same, the result is 20. If two of the numbers are the same, the "
12054 "result is 10."
12055 msgstr ""
12056
12057 #. type: Content of: <h1>
12058 #: src/lessons/welcome/bat/bool2/In1To10.html:2
12059 msgid "In1To10"
12060 msgstr ""
12061
12062 #. type: Content of: outside any tag (error?)
12063 #: src/lessons/welcome/bat/bool2/In1To10.html:3
12064 msgid ""
12065 "Given a number n, return true if n is in the range 1..10, inclusive. Unless "
12066 "\"outsideMode\" is true, in which case return true if the number is less or "
12067 "equal to 1, or greater or equal to 10."
12068 msgstr ""
12069
12070 #. type: Content of: <h1>
12071 #: src/lessons/welcome/bat/bool2/InOrderEqual.html:2
12072 msgid "InOrderEqual"
12073 msgstr ""
12074
12075 #. type: Content of: outside any tag (error?)
12076 #: src/lessons/welcome/bat/bool2/InOrderEqual.html:3
12077 msgid ""
12078 "Given three ints, a b c, return true if they are in strict increasing order, "
12079 "such as 2 5 11, or 5 6 7, but not 6 5 7 or 5 5 7. However, with the "
12080 "exception that if \"equalOk\" is true, equality is allowed, such as 5 5 7 or "
12081 "5 5 5."
12082 msgstr ""
12083
12084 #. type: Content of: <h1>
12085 #: src/lessons/welcome/bat/bool2/InOrder.html:2
12086 msgid "InOrder"
12087 msgstr ""
12088
12089 #. type: Content of: outside any tag (error?)
12090 #: src/lessons/welcome/bat/bool2/InOrder.html:3
12091 msgid ""
12092 "Given three ints, a b c, return true if b is greater than a, and c is "
12093 "greater than b. However, with the exception that if \"bOk\" is true, b does "
12094 "not need to be greater than a."
12095 msgstr ""
12096
12097 #. type: Content of: <h1>
12098 #: src/lessons/welcome/bat/bool2/LastDigit2.html:2
12099 msgid "LastDigit 2"
12100 msgstr ""
12101
12102 #. type: Content of: outside any tag (error?)
12103 #: src/lessons/welcome/bat/bool2/LastDigit2.html:3
12104 msgid ""
12105 "Given three ints, a b c, return true if two or more of them have the same "
12106 "rightmost digit. The ints are non-negative. Note: the % \"mod\" operator "
12107 "computes the remainder, e.g. 17 % 10 is 7."
12108 msgstr ""
12109
12110 #. type: Content of: <h1>
12111 #: src/lessons/welcome/bat/bool2/LessBy10.html:2
12112 msgid "LessBy10"
12113 msgstr ""
12114
12115 #. type: Content of: outside any tag (error?)
12116 #: src/lessons/welcome/bat/bool2/LessBy10.html:3
12117 msgid ""
12118 "Given three ints, a b c, return true if one of them is 10 or more less than "
12119 "one of the others."
12120 msgstr ""
12121
12122 #. type: Content of: <h1>
12123 #: src/lessons/welcome/bat/bool2/Main.html:2
12124 msgid "Boolean (even more) fun"
12125 msgstr ""
12126
12127 #. type: Content of: <p>
12128 #: src/lessons/welcome/bat/bool2/Main.html:4
12129 msgid ""
12130 "A very good introduction to this type is available here: "
12131 "http://codingbat.com/doc/java-if-boolean-logic.html"
12132 msgstr ""
12133
12134 #. type: Content of: <h1>
12135 #: src/lessons/welcome/bat/bool2/MaxMod5.html:2
12136 msgid "MaxMod5"
12137 msgstr ""
12138
12139 #. type: Content of: outside any tag (error?)
12140 #: src/lessons/welcome/bat/bool2/MaxMod5.html:3
12141 msgid ""
12142 "Given two int values, return whichever value is larger. However if the two "
12143 "values have the same remainder when divided by 5, then the return the "
12144 "smaller value. However, in all cases, if the two values are the same, return "
12145 "0. Note: the % \"mod\" operator computes the remainder, e.g. 7 % 5 is 2."
12146 msgstr ""
12147
12148 #. type: Content of: <h1>
12149 #: src/lessons/welcome/bat/bool2/NearTen.html:2
12150 msgid "NearTen"
12151 msgstr ""
12152
12153 #. type: Content of: outside any tag (error?)
12154 #: src/lessons/welcome/bat/bool2/NearTen.html:3
12155 msgid ""
12156 "Given a non-negative number \"num\", return true if num is within 2 of a "
12157 "multiple of 10. Note: (a % b) is the remainder of dividing a by b, so (7 % "
12158 "5) is 2."
12159 msgstr ""
12160
12161 #. type: Content of: <h1>
12162 #: src/lessons/welcome/bat/bool2/RedTicket.html:2
12163 msgid "RedTicket"
12164 msgstr ""
12165
12166 #. type: Content of: outside any tag (error?)
12167 #: src/lessons/welcome/bat/bool2/RedTicket.html:3
12168 msgid ""
12169 "You have a red lottery ticket showing ints a, b, and c, each of which is 0, "
12170 "1, or 2. If they are all the value 2, the result is 10. Otherwise if they "
12171 "are all the same, the result is 5. Otherwise so long as both b and c are "
12172 "different from a, the result is 1. Otherwise the result is 0."
12173 msgstr ""
12174
12175 #. type: Content of: <h1>
12176 #: src/lessons/welcome/bat/bool2/ShareDigit.html:2
12177 msgid "ShareDigit"
12178 msgstr ""
12179
12180 #. type: Content of: outside any tag (error?)
12181 #: src/lessons/welcome/bat/bool2/ShareDigit.html:3
12182 msgid ""
12183 "Given two ints, each in the range 10..99, return true if there is a digit "
12184 "that appears in both numbers, such as the 2 in 12 and 23. (Note: division, "
12185 "e.g. n/10, gives the left digit while the % \"mod\" n%10 gives the right "
12186 "digit.)"
12187 msgstr ""
12188
12189 #. type: Content of: <h1>
12190 #: src/lessons/welcome/bat/bool2/SortaSum.html:2
12191 msgid "SortaSum"
12192 msgstr ""
12193
12194 #. type: Content of: outside any tag (error?)
12195 #: src/lessons/welcome/bat/bool2/SortaSum.html:3
12196 msgid ""
12197 "Given 2 ints, a and b, return their sum. However, sums in the range 10..19 "
12198 "inclusive, are forbidden, so in that case just return 20."
12199 msgstr ""
12200
12201 #. type: Content of: <h1>
12202 #: src/lessons/welcome/bat/bool2/SquirrelPlay.html:2
12203 msgid "SquirrelPlay"
12204 msgstr ""
12205
12206 #. type: Content of: outside any tag (error?)
12207 #: src/lessons/welcome/bat/bool2/SquirrelPlay.html:3
12208 msgid ""
12209 "The squirrels in Palo Alto spend most of the day playing. In particular, "
12210 "they play if the temperature is between 60 and 90 (inclusive). Unless it is "
12211 "summer, then the upper limit is 100 instead of 90. Given an int temperature "
12212 "and a boolean isSummer, return true if the squirrels play and false "
12213 "otherwise."
12214 msgstr ""
12215
12216 #. type: Content of: <h1>
12217 #: src/lessons/welcome/bat/bool2/TeaParty.html:2
12218 msgid "TeaParty"
12219 msgstr ""
12220
12221 #. type: Content of: outside any tag (error?)
12222 #: src/lessons/welcome/bat/bool2/TeaParty.html:3
12223 msgid ""
12224 "We are having a party with amounts of tea and candy. Return the int outcome "
12225 "of the party encoded as 0=bad, 1=good, or 2=great. A party is good (1) if "
12226 "both tea and candy are at least 5. However, if either tea or candy is at "
12227 "least double the amount of the other one, the party is great (2). However, "
12228 "in all cases, if either tea or candy is less than 5, the party is always bad "
12229 "(0)."
12230 msgstr ""
12231
12232 #. type: Content of: <h1>
12233 #: src/lessons/welcome/bat/bool2/TeenSum.html:2
12234 msgid "TeenSum"
12235 msgstr ""
12236
12237 #. type: Content of: outside any tag (error?)
12238 #: src/lessons/welcome/bat/bool2/TeenSum.html:3
12239 msgid ""
12240 "Given 2 ints, a and b, return their sum. However, \"teen\" values in the "
12241 "range 13..19 inclusive, are extra lucky. So if either value is a teen, just "
12242 "return 19."
12243 msgstr ""
12244
12245 #. type: Content of: <h1>
12246 #: src/lessons/welcome/bat/bool2/TwoAsOne.html:2
12247 msgid "TwoAsOne"
12248 msgstr ""
12249
12250 #. type: Content of: outside any tag (error?)
12251 #: src/lessons/welcome/bat/bool2/TwoAsOne.html:3
12252 msgid ""
12253 "Given three ints, a b c, return true if it is possible to add two of the "
12254 "ints to get the third."
12255 msgstr ""
12256
12257 #. type: Content of: <h1>
12258 #: src/lessons/welcome/bat/bool2/WithoutDoubles.html:2
12259 msgid "WithoutDoubles"
12260 msgstr ""
12261
12262 #. type: Content of: outside any tag (error?)
12263 #: src/lessons/welcome/bat/bool2/WithoutDoubles.html:3
12264 msgid ""
12265 "Return the sum of two 6-sided dice rolls, each in the range 1..6. However, "
12266 "if noDoubles is true, if the two dice show the same value, increment one die "
12267 "to the next value, wrapping around to 1 if its value was 6."
12268 msgstr ""
12269
12270 #. type: Content of: <h1>
12271 #: src/lessons/bat/string1/Main.html:2
12272 msgid "String fun"
12273 msgstr ""
12274
12275 #. type: Content of: <p>
12276 #: src/lessons/bat/string1/Main.html:4
12277 msgid ""
12278 "Strings are the simplest of the complex data types :) They provide several "
12279 "operations, such as getting the length of the string, or a substring of it."
12280 msgstr ""
12281
12282 #. type: Content of: <p>
12283 #: src/lessons/bat/string1/Main.html:8
12284 msgid ""
12285 "A very good introduction to this type is available here: "
12286 "http://codingbat.com/doc/java-string-introduction.html"
12287 msgstr ""
12288
12289 #. type: Content of: <h3>
12290 #: src/lessons/bat/string1/short_desc.html:2
12291 msgid "Small exercises about strings"
12292 msgstr ""
12293
12294 #. type: Content of: <p>
12295 #: src/lessons/bat/string1/short_desc.html:4
12296 msgid ""
12297 "These are some training exercises around strings. But unfortunately, its "
12298 "integration within PLM is still ongoing."
12299 msgstr ""
12300
12301 #. type: Content of: <p>
12302 #: src/lessons/bat/string1/short_desc.html:7
12303 msgid "Please be patient with us."
12304 msgstr ""
12305
12306 #. type: Content of: <h1>
12307 #: src/lessons/bat/string1/AltPairs.html:2
12308 msgid "AltPairs"
12309 msgstr ""
12310
12311 #. type: Content of: outside any tag (error?)
12312 #: src/lessons/bat/string1/AltPairs.html:3
12313 msgid ""
12314 "Given a string, return a string made of the chars at indexes 0,1, 4,5, 8,9 "
12315 "... so \"kittens\" yields \"kien\"."
12316 msgstr ""
12317
12318 #. type: Content of: <h1>
12319 #: src/lessons/bat/string1/FrontTimes.html:2
12320 msgid "FrontTimes"
12321 msgstr ""
12322
12323 #. type: Content of: outside any tag (error?)
12324 #: src/lessons/bat/string1/FrontTimes.html:3
12325 msgid ""
12326 "Given a string and a non-negative int n, we'll say that the front of the "
12327 "string is the first 3 chars, or whatever is there if the string is less than "
12328 "length 3. Return n copies of the front;"
12329 msgstr ""
12330
12331 #. type: Content of: <h1>
12332 #: src/lessons/bat/string1/Last2.html:2
12333 msgid "Last2"
12334 msgstr ""
12335
12336 #. type: Content of: <p>
12337 #: src/lessons/bat/string1/Last2.html:4
12338 msgid ""
12339 "Given a string, return the amount of times that the two last letters appear "
12340 "as a substring of the string. So \"hixxxhi\" yields 1 (we won't count the "
12341 "end substring) while \"aaaNaa\" yields 2 (substrings may overlap)."
12342 msgstr ""
12343
12344 #. type: Content of: <h1>
12345 #: src/lessons/bat/string1/StringBits.html:2
12346 msgid "StringBits"
12347 msgstr ""
12348
12349 #. type: Content of: outside any tag (error?)
12350 #: src/lessons/bat/string1/StringBits.html:3
12351 msgid ""
12352 "Given a string, return a new string made of every other char starting with "
12353 "the first, so \"Hello\" yields \"Hlo\"."
12354 msgstr ""
12355
12356 #. type: Content of: <h1>
12357 #: src/lessons/bat/string1/StringMatch.html:2
12358 msgid "StringMatch"
12359 msgstr ""
12360
12361 #. type: Content of: outside any tag (error?)
12362 #: src/lessons/bat/string1/StringMatch.html:3
12363 msgid ""
12364 "Given 2 strings, a and b, return the number of the positions where they "
12365 "contain the same length 2 substring. So \"xxcaazz\" and \"xxbaaz\" yields 3, "
12366 "since the \"xx\", \"aa\", and \"az\" substrings appear in the same place in "
12367 "both strings."
12368 msgstr ""
12369
12370 #. type: Content of: <h1>
12371 #: src/lessons/bat/string1/StringSplosion.html:2
12372 msgid "StringSplosion"
12373 msgstr ""
12374
12375 #. type: Content of: outside any tag (error?)
12376 #: src/lessons/bat/string1/StringSplosion.html:3
12377 msgid "Given a non-empty string like \"Code\" return a string like \"CCoCodCode\"."
12378 msgstr ""
12379
12380 #. type: Content of: <h1>
12381 #: src/lessons/bat/string1/StringTimes.html:2
12382 msgid "StringTimes"
12383 msgstr ""
12384
12385 #. type: Content of: outside any tag (error?)
12386 #: src/lessons/bat/string1/StringTimes.html:3
12387 msgid ""
12388 "Given a string and a non-negative int n, return a larger string that is n "
12389 "copies of the original string."
12390 msgstr ""
12391
12392 #. type: Content of: <h1>
12393 #: src/lessons/bat/string1/StringX.html:2
12394 msgid "StringX"
12395 msgstr ""
12396
12397 #. type: Content of: outside any tag (error?)
12398 #: src/lessons/bat/string1/StringX.html:3
12399 msgid ""
12400 "Given a string, return a version where all the \"x\" have been "
12401 "removed. Except an \"x\" at the very start or end should not be removed."
12402 msgstr ""
12403
12404 #. type: Content of: <h1>
12405 #: src/lessons/bat/string1/StringYak.html:2
12406 msgid "StringYak"
12407 msgstr ""
12408
12409 #. type: Content of: outside any tag (error?)
12410 #: src/lessons/bat/string1/StringYak.html:3
12411 msgid ""
12412 "Suppose the string \"yak\" is unlucky. Given a string, return a version "
12413 "where all the \"yak\" are removed, but the \"a\" can be any char. The "
12414 "\"yak\" strings will not overlap."
12415 msgstr ""
12416
12417 #. type: Content of: <h2>
12418 #: src/lessons/lander/Main.html:2 src/lessons/lander/short_desc.html:2
12419 #: src/lessons/lander/universe/DelegatingLanderWorld.html:2
12420 msgid "Lunar Lander"
12421 msgstr ""
12422
12423 #. type: Content of: <p>
12424 #: src/lessons/lander/Main.html:4 src/lessons/lander/short_desc.html:4
12425 msgid ""
12426 "In this lesson you pilot a lunar landing module in increasingly complex "
12427 "situations."
12428 msgstr ""
12429
12430 #. type: Content of: <p>
12431 #: src/lessons/lander/Main.html:7
12432 msgid ""
12433 "At each step of the simulation, the player issues a command controlling how "
12434 "much the angle and thrust of the lander should change"
12435 msgstr ""
12436
12437 #. type: Content of: <p>
12438 #: src/lessons/lander/Main.html:10
12439 msgid "Ideas concerning the progression of exercises:"
12440 msgstr ""
12441
12442 #. type: Content of: <ul><li>
12443 #: src/lessons/lander/Main.html:12
12444 msgid ""
12445 "A lander in vertical position above flat ground, the player can only control "
12446 "thrust (done)"
12447 msgstr ""
12448
12449 #. type: Content of: <ul><li>
12450 #: src/lessons/lander/Main.html:14
12451 msgid ""
12452 "A lander in vertical position not above flat ground, the player control "
12453 "thrust and angle (done)"
12454 msgstr ""
12455
12456 #. type: Content of: <ul><li>
12457 #: src/lessons/lander/Main.html:16
12458 msgid ""
12459 "A lander with difficult angle and speed not above flat ground, the player "
12460 "control thrust and angle"
12461 msgstr ""
12462
12463 #. type: Content of: <ul><li>
12464 #: src/lessons/lander/Main.html:18
12465 msgid ""
12466 "A lander with difficult angle and speed not above flat ground, with "
12467 "difficult ground, the player control thrust and angle"
12468 msgstr ""
12469
12470 #. type: Content of: <ul><li>
12471 #: src/lessons/lander/Main.html:20
12472 msgid "Same with wind?"
12473 msgstr ""
12474
12475 #. type: Content of: <p>
12476 #: src/lessons/lander/short_desc.html:7
12477 msgid "This lesson assumes some basic programming and physics skills."
12478 msgstr ""
12479
12480 #. type: Content of: <p>
12481 #: src/lessons/lander/universe/DelegatingLanderWorld.html:4
12482 msgid ""
12483 "In this universe you pilot a lunar lander. At each simulation step you're "
12484 "given the lander's position, speed, angle and thrust and must issue a "
12485 "command adjusting its angle and thrust."
12486 msgstr ""
12487
12488 #. type: Content of: outside any tag (error?)
12489 #: src/lessons/lander/universe/DelegatingLanderWorld.html:12
12490 msgid "Get the X and Y position of the lander."
12491 msgstr ""
12492
12493 #. type: Content of: <pre>
12494 #: src/lessons/lander/universe/DelegatingLanderWorld.html:13
12495 #, no-wrap
12496 msgid ""
12497 "[!java|c]double [/!]getSpeedX()[!scala]:Double[/!]\n"
12498 "[!java|c]double [/!]getSpeedY()[!scala]:Double[/!]"
12499 msgstr ""
12500
12501 #. type: Content of: outside any tag (error?)
12502 #: src/lessons/lander/universe/DelegatingLanderWorld.html:15
12503 msgid "Get the horizontal and vertical speed of the lander."
12504 msgstr ""
12505
12506 #. type: Content of: <pre>
12507 #: src/lessons/lander/universe/DelegatingLanderWorld.html:17
12508 #, no-wrap
12509 msgid ""
12510 "[!java|c]double [/!]getAngle()[!scala]:Double[/!]\n"
12511 "[!java|c]void [/!]setDesiredAngle([!java|c]double "
12512 "[/!]desiredAngle[!scala]:Double[/!])"
12513 msgstr ""
12514
12515 #. type: Content of: outside any tag (error?)
12516 #: src/lessons/lander/universe/DelegatingLanderWorld.html:19
12517 msgid "Get or set the angle of the lander."
12518 msgstr ""
12519
12520 #. type: Content of: outside any tag (error?)
12521 #: src/lessons/lander/universe/DelegatingLanderWorld.html:20
12522 msgid ""
12523 "An angle of 0° denotes a vertical position where the \"head\" of the lander "
12524 "points up. This is the angle you must land with. A positive angle denotes a "
12525 "left-leaning lander, a negative angle a right-leaning one. You cannot lean "
12526 "more than by ±90°, and the angle can vary by at most ±5° in one step."
12527 msgstr ""
12528
12529 #. type: Content of: <pre>
12530 #: src/lessons/lander/universe/DelegatingLanderWorld.html:25
12531 #, no-wrap
12532 msgid ""
12533 "[!java|c]int [/!]getThrust()[!scala]:Int[/!]\n"
12534 "[!java|c]void [/!]setDesiredThrust([!java|c]int [/!]thrust[!scala]:Int[/!])"
12535 msgstr ""
12536
12537 #. type: Content of: outside any tag (error?)
12538 #: src/lessons/lander/universe/DelegatingLanderWorld.html:27
12539 msgid "Get or set the thrust of the lander."
12540 msgstr ""
12541
12542 #. type: Content of: outside any tag (error?)
12543 #: src/lessons/lander/universe/DelegatingLanderWorld.html:27
12544 msgid ""
12545 "You can only increment or decrement the thrust by 1 between two simulation "
12546 "steps, so if the current thrust is 2 and you ask for 4, you'll only get 3 in "
12547 "the next step. If you ask for less than 0 (resp. more than 4), everything "
12548 "will be as if you had asked for 0 (resp. 4)."
12549 msgstr ""
12550
12551 #. type: Content of: <pre>
12552 #: src/lessons/lander/universe/DelegatingLanderWorld.html:33
12553 #, no-wrap
12554 msgid "[!java|c]int [/!]getFuel()[!scala]:Int[/!]"
12555 msgstr ""
12556
12557 #. type: Content of: outside any tag (error?)
12558 #: src/lessons/lander/universe/DelegatingLanderWorld.html:34
12559 msgid ""
12560 "Get the remaining fuel in the lander. At each step of the simulation the "
12561 "lander consumes as many fuel units as the current thrust. Once you run out "
12562 "of fuel you're in free fall so beware!"
12563 msgstr ""
12564
12565 #. type: Content of: <pre>
12566 #: src/lessons/lander/universe/DelegatingLanderWorld.html:38
12567 #, no-wrap
12568 msgid "[!java]List&lt;Point&gt; [/!]getGround() [!scala]:List[Point][/!]"
12569 msgstr ""
12570
12571 #. type: Content of: outside any tag (error?)
12572 #: src/lessons/lander/universe/DelegatingLanderWorld.html:39
12573 msgid ""
12574 "Get the vertices of the ground's profile from left to right. "
12575 "[!java|scala]You can retrieve the X and Y coordinates of each point with the "
12576 "corresponding methods of your point: <code>p.x()</code> and "
12577 "<code>p.y()</code>.[/!] [!python]Each point is an array of two integers "
12578 "denoting respectively the X and Y coordinates of that point.[/!]"
12579 msgstr ""
12580
12581 #. type: Content of: <h1>
12582 #: src/lessons/lander/lvl1_lander_101/Lander101.html:2
12583 msgid "Lander 101"
12584 msgstr ""
12585
12586 #. type: Content of: <p>
12587 #: src/lessons/lander/lvl1_lander_101/Lander101.html:4
12588 msgid ""
12589 "Congratulations! You won a (one-way) trip to Mars in a cereal box. NASA was "
12590 "kind enough to donate the Lunar Excursion Module for this mission, so that's "
12591 "what you'll be flying."
12592 msgstr ""
12593
12594 #. type: Content of: <p>
12595 #: src/lessons/lander/lvl1_lander_101/Lander101.html:8
12596 msgid ""
12597 "Before you take off, you must go through some basic landing simulation. You "
12598 "shouldn't have to fly the lander if all goes as planned but, as they say, "
12599 "\"better safe than sorry\"."
12600 msgstr ""
12601
12602 #. type: Content of: <p>
12603 #: src/lessons/lander/lvl1_lander_101/Lander101.html:12
12604 msgid ""
12605 "Your mission is to <b>land the lander with a vertical speed of at most 10 "
12606 "m/s.</b> There are two ways you can influence the lander's course: by "
12607 "adjusting its angle or by adjusting its thrust. In this simulation we only "
12608 "care about adjusting the thrust, expressed in m/s²."
12609 msgstr ""
12610
12611 #. type: Content of: <p>
12612 #: src/lessons/lander/lvl1_lander_101/Lander101.html:17
12613 msgid ""
12614 "The [!python]<code>step()</code> function[/!][!scala|java|c]code[/!] that "
12615 "you should write now will be called every 0.1 second during the "
12616 "simulation. Make sure that your code does not last too long, with no while "
12617 "loop! It should only set the desired thrust of the next simulation step, by "
12618 "calling <code>[!java]void [/!]setDesiredThrust([!java]int "
12619 "[/!]desiredThrust[!scala]:Integer[/!])</code> where "
12620 "<code>desiredThrust</code> is some integer between 0 and 4 (that is, a "
12621 "thrust between 0 m/s² and 4 m/s²). You can only increment or decrement the "
12622 "thrust by 1 between two simulation steps, so if the current thrust is 2 and "
12623 "you ask for 4, you'll only get 3 in the next step. If you ask for less than "
12624 "0 (resp. more than 4), everything will be as if you had asked for 0 "
12625 "(resp. 4)."
12626 msgstr ""
12627
12628 #. type: Content of: <p>
12629 #: src/lessons/lander/lvl1_lander_101/Lander101.html:28
12630 msgid ""
12631 "In order to take informed decisions, you can query the lander's state. In "
12632 "this simulation you'll probably be interested in its vertical position: "
12633 "<code>[!java]double [/!]getY()[!scala]:Double[/!]</code>, and its vertical "
12634 "speed: <code>[!java]double [/!]getSpeedY()[!scala]:Double[/!]</code>. You "
12635 "can also ask for the thrust via <code>[!java]int "
12636 "[/!]getThrust()[!scala]:Integer[/!]</code> in case you don't remember what "
12637 "you asked for. Remember that Mars' gravity is 3.711 m/s², it might come in "
12638 "handy."
12639 msgstr ""
12640
12641 #. type: Content of: <p>
12642 #: src/lessons/lander/lvl1_lander_101/Lander101.html:36
12643 msgid ""
12644 "One last thing: the lander is pretty small so you don't have much fuel. At "
12645 "each step of the simulation the lander consumes as many fuel units as the "
12646 "current thrust. Once you run out of fuel you're in free fall so beware! You "
12647 "can consult the remaining amount of available fuel units using "
12648 "<code>[!java]int [/!]getFuel()[!scala]:Integer[/!]</code>."
12649 msgstr ""
12650
12651 #. type: Content of: <h2>
12652 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:2
12653 msgid "Locate a Landing Zone"
12654 msgstr ""
12655
12656 #. type: Content of: <p>
12657 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:4
12658 msgid ""
12659 "After 200 days of traveling space and eating cereals you finally reach "
12660 "Mars. Time to land at last!"
12661 msgstr ""
12662
12663 #. type: Content of: <p>
12664 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:7
12665 msgid ""
12666 "The lander is on autopilot and all you have to do is look around and tell it "
12667 "where to land. The lander must <b>land on a flat zone</b> if you want to "
12668 "remain in one piece. You indicate the lander where to land by modifying the "
12669 "<code>getLandingZone</code> function so that it returns a "
12670 "[!java|scala]<code>Segment</code> representing the zone of your choice."
12671 msgstr ""
12672
12673 #. type: Content of: <p><p>
12674 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:13
12675 msgid ""
12676 "A segment is composed of two <code>Point</code>s, each of them composed of "
12677 "two <code>double</code>s. A segment is built via the "
12678 "<code>Segment([!java]Point [/!]start[!scala]:Point[/!], [!java]Point "
12679 "[/!]end[!scala]:Point[/!])</code> constructor. A point is built via the "
12680 "<code>Point([!java]double [/!]x[!scala]:Double[/!], [!java]double "
12681 "[/!]y[!scala]:Double[/!])</code> constructor. A point's coordinates are "
12682 "accessible via its <code>[!java]double [/!]x()[!scala]:Double[/!]</code> and "
12683 "<code>[!java]double [/!]y()[!scala]:Double[/!]</code> methods."
12684 msgstr ""
12685
12686 #. type: Content of: <p>
12687 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:18
12688 msgid ""
12689 "[/!] [!python]tuple of two X coordinates representing the zone of your "
12690 "choice.[/!]"
12691 msgstr ""
12692
12693 #. type: Content of: <p><p>
12694 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:22
12695 msgid ""
12696 "In order to determine which zone to return, you'll need to call "
12697 "<code>[!java]List&lt;Point&gt; "
12698 "[/!]getGround()[!scala]List[Point][/!]</code>, which returns the vertices of "
12699 "the ground's profile as a list of [!java|scala]<code>Point</code>[/!] "
12700 "[!python]tuples (x,y)[/!]."
12701 msgstr ""
12702
12703 #. type: Content of: <p><p>
12704 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:27
12705 msgid ""
12706 "One more thing: your function should return a valid flat zone in any kind of "
12707 "situation, not just for the currently visualized one. That's because it will "
12708 "be not only tested against that world, but also against the one we had in "
12709 "the previous exercise. As usual, you can see the other existing worlds with "
12710 "the appropriate combobox."
12711 msgstr ""
12712
12713 #. type: Content of: <p><p>
12714 #: src/lessons/lander/lvl2_locate_landing_zone/LocateLandingZone.html:33
12715 msgid "Have a safe landing! Don't forget to put on your space suit on your way out."
12716 msgstr ""
12717
12718 #. type: Content of: <h1>
12719 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:2
12720 msgid "Fly the Lander!"
12721 msgstr ""
12722
12723 #. type: Content of: <p>
12724 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:4
12725 msgid ""
12726 "After 30 days of staring at rocks and eating cereals you decide it's time to "
12727 "go explore other parts of the planet."
12728 msgstr ""
12729
12730 #. type: Content of: <p>
12731 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:7
12732 msgid ""
12733 "You fly for a while and suddenly realize you're almost out of fuel. "
12734 "Unfortunately you're in a delicate situation and the autopilot is helpless. "
12735 "You will have to pilot the lander yourself. Your mission is to <b>land the "
12736 "lander on a flat zone with a vertical speed less than 10 m/s, an horizontal "
12737 "speed less than 5 m/s and an angle of 0°.</b>"
12738 msgstr ""
12739
12740 #. type: Content of: <p>
12741 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:13
12742 msgid ""
12743 "You must define two functions: <code>[!java]void [/!]initialize()</code> and "
12744 "<code>[!java]void [/!]step()</code>. <code>initialize()</code> is called "
12745 "once just after you press \"Run\". You can use it to chose some flat "
12746 "zone. As before, <code>step()</code> is called every 0.1 second and is used "
12747 "for adjusting the lander's thrust and angle. As in the first exercise the "
12748 "lander's thrust is adjusted via <code>[!java]void "
12749 "[/!]setDesiredThrust([!java]int "
12750 "[/!]desiredThrust[!scala]:Integer[/!])</code>. But you can also control its "
12751 "angle via <code>[!java]void [/!]setDesiredAngle([!java]double "
12752 "[/!]desiredAngle[!scala]:Double[/!])</code>. An angle of 0° denotes a "
12753 "vertical position where the \"head\" of the lander points up. This is the "
12754 "angle you must land with. A positive angle denotes a left-leaning lander, a "
12755 "negative angle a right-leaning one. You cannot lean more than by ±90°, and "
12756 "the angle can vary by at most ±5° in one step."
12757 msgstr ""
12758
12759 #. type: Content of: <p>
12760 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:26
12761 msgid ""
12762 "As in the previous exercise, <code>[!java]List&lt;Point&gt; "
12763 "[/!]getGround()[!scala]:List[Point][/!]</code> returns the vertices of the "
12764 "ground's profile from left to right. Please refer to the documentation "
12765 "(Help/About this world) for a reference manual of your lunar lander."
12766 msgstr ""
12767
12768 #. type: Content of: <p>
12769 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:30
12770 msgid ""
12771 "As before, your program must safely land the lander in all the situations "
12772 "encountered so far in addition to this new one."
12773 msgstr ""
12774
12775 #. type: Content of: <p>
12776 #: src/lessons/lander/lvl3_fly_the_lander/FlyTheLander.html:33
12777 msgid "Good luck, try not to crash!"
12778 msgstr ""
12779
12780 #. type: Content of: <h2>
12781 #: lib/doc/MainWindow.html:1
12782 msgid "The PLM Main Window"
12783 msgstr ""
12784
12785 #. type: Content of: outside any tag (error?)
12786 #: lib/doc/MainWindow.html:3
12787 msgid ""
12788 "The PLM working environment should be self-explanatory, in particular with "
12789 "the tool tips appearing when your mouse is over the elements. Here is a "
12790 "little explanation of the components in case you fail to understand "
12791 "something. The main window is made of 5 main components:"
12792 msgstr ""
12793
12794 #. type: Content of: <ul><li>
12795 #: lib/doc/MainWindow.html:10
12796 msgid ""
12797 "<b>The menu:</b> Placed on top of the window, it gives you access to some "
12798 "advanced commands such as exiting the program, and some other that we will "
12799 "detail later."
12800 msgstr ""
12801
12802 #. type: Content of: <ul><li>
12803 #: lib/doc/MainWindow.html:14
12804 msgid ""
12805 "<b>The tool bar:</b> Placed just below the menu, it gives you access to the "
12806 "four main commands:"
12807 msgstr ""
12808
12809 #. type: Content of: <ul><li><ul><li>
12810 #: lib/doc/MainWindow.html:19
12811 msgid ""
12812 "The <b>Start</b> button, which begins the compilation and execution of the "
12813 "code you may have typed in the editor. At the end of the execution, it "
12814 "verifies whether you reach the situation constituting the objective of the "
12815 "exercise or not. If yes, you gain access to the next exercise using the "
12816 "<b>Exercise</b> menu. If not, you need to rework your code."
12817 msgstr ""
12818
12819 #. type: Content of: <ul><li><ul><li>
12820 #: lib/doc/MainWindow.html:25
12821 msgid ""
12822 "The <b>Stop</b> button allows you to interupt the execution of your code, "
12823 "what may reveal useful if you encounter an <i>infinite loop</i>."
12824 msgstr ""
12825
12826 #. type: Content of: <ul><li><ul><li>
12827 #: lib/doc/MainWindow.html:28
12828 msgid ""
12829 "The <b>Reset</b> button can be used to reset the world into its initial "
12830 "state."
12831 msgstr ""
12832
12833 #. type: Content of: <ul><li><ul><li>
12834 #: lib/doc/MainWindow.html:31
12835 msgid ""
12836 "The <b>Demo</b> button shows you the execution of the expected "
12837 "solution. During its execution, you may want to switch the seen world to see "
12838 "the different expected solutions."
12839 msgstr ""
12840
12841 #. type: Content of: <ul><li><ul><li>
12842 #: lib/doc/MainWindow.html:34
12843 msgid ""
12844 "Please note that there is often several ways of achieving the awaited "
12845 "solution, and that the one presented during the demo is not more or less "
12846 "correct than the others. You are completely free to not follow strictly the "
12847 "process shown by the demo, as long as your final solution matches the "
12848 "exercise expectations."
12849 msgstr ""
12850
12851 #. type: Content of: <ul><li>
12852 #: lib/doc/MainWindow.html:41
12853 msgid ""
12854 "<b>Mission and editor tabs:</b> this is were you read this very text. This "
12855 "area contains several tabs to which you can access by clicking on their name "
12856 "on the top left. The first tab (which is always named <b>Mission</b>) "
12857 "contains a presentation of the current exercise. To solve an exercise, you "
12858 "need to write your code in the other tabs. For example, you can now clic on "
12859 "the <b>Source Code</b> tab to see the actual source. If it is empty, that's "
12860 "because you did not write any code yet."
12861 msgstr ""
12862
12863 #. type: Content of: <ul><li>
12864 #: lib/doc/MainWindow.html:49
12865 msgid ""
12866 "<b>The console:</b> Placed under the tabs, this is where any messages of the "
12867 "application will appear. This area is initially empty and white."
12868 msgstr ""
12869
12870 #. type: Content of: <ul><li>
12871 #: lib/doc/MainWindow.html:52
12872 msgid ""
12873 "<b>World view</b> Placed on the right of the tabs, it is constituted of five "
12874 "elements:"
12875 msgstr ""
12876
12877 #. type: Content of: <ul><li><ul><li>
12878 #: lib/doc/MainWindow.html:57
12879 msgid ""
12880 "A scrolling menu allows to choose the world. Indeed, the program you write "
12881 "may be executed in several worlds to test it in differing conditions. This "
12882 "menu allows you to choose the world you want to see. Note that this "
12883 "scrolling menu is hidden if there is only one world in your exercise."
12884 msgstr ""
12885
12886 #. type: Content of: <ul><li><ul><li>
12887 #: lib/doc/MainWindow.html:62
12888 msgid ""
12889 "A slider placed right bellow allows to choose the animation speed of the "
12890 "world. More precisely, it allows to choose the delay (in milliseconds) that "
12891 "the buggles must wait after each action to allow you to see what they are "
12892 "doing."
12893 msgstr ""
12894
12895 #. type: Content of: <ul><li><ul><li>
12896 #: lib/doc/MainWindow.html:67
12897 msgid ""
12898 "A tab <b>World</b> represents the view of the world currently selected (from "
12899 "the scrolling menu). This view is thus constitued of a grid forming the "
12900 "several cells of the world, as well as several <i>buggles</i> awaiting for "
12901 "your orders."
12902 msgstr ""
12903
12904 #. type: Content of: <ul><li><ul><li>
12905 #: lib/doc/MainWindow.html:72
12906 msgid ""
12907 "An <b>Objective</b> tab displaying the world as it must be by the end of the "
12908 "exercise."
12909 msgstr ""
12910
12911 #. type: Content of: <ul><li><ul><li>
12912 #: lib/doc/MainWindow.html:76
12913 msgid ""
12914 "<b>The interactive controls</b>. Placed under the world view, these buttons "
12915 "allows you to interactively control the buggles. This way, you can try to "
12916 "<i>manually</i> bring your buggle to the scenario objective before writting "
12917 "the needed code in the editor."
12918 msgstr ""
12919
12920 #. type: Content of: <ul><li><ul><li><ul><li>
12921 #: lib/doc/MainWindow.html:82
12922 msgid "A scrolling menu allows to select the buggle you want to control."
12923 msgstr ""
12924
12925 #. type: Content of: <ul><li><ul><li><ul><li>
12926 #: lib/doc/MainWindow.html:84
12927 msgid "The <b>Forward</b> button let your buggle do one step forward."
12928 msgstr ""
12929
12930 #. type: Content of: <ul><li><ul><li><ul><li>
12931 #: lib/doc/MainWindow.html:86
12932 msgid "The <b>Backward</b> button let it do one step backward."
12933 msgstr ""
12934
12935 #. type: Content of: <ul><li><ul><li><ul><li>
12936 #: lib/doc/MainWindow.html:88
12937 msgid "The <b>Turn left</b> button ask your buggle to turn of 90° to its left."
12938 msgstr ""
12939
12940 #. type: Content of: <ul><li><ul><li><ul><li>
12941 #: lib/doc/MainWindow.html:90
12942 msgid ""
12943 "The <b>Turn right</b> button asks the buggle to turn to the right (isn't "
12944 "this amazing?)."
12945 msgstr ""
12946
12947 #. type: Content of: <ul><li><ul><li><ul><li>
12948 #: lib/doc/MainWindow.html:93
12949 msgid ""
12950 "The <b>Mark</b> button requests your buggle to leave a mark behind it when "
12951 "it goes."
12952 msgstr ""
44 msgid ""
55 msgstr ""
66 "Project-Id-Version: PACKAGE VERSION\n"
7 "POT-Creation-Date: 2020-09-20 15:30+0200\n"
7 "POT-Creation-Date: 2020-09-25 22:29+0200\n"
88 "PO-Revision-Date: 2020-09-13 05:36+0000\n"
99 "Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
1010 "Language-Team: Ukrainian <https://hosted.weblate.org/projects/programmers-"
10041004 "communication abilities, but it's not mean. If you look closer, the solution "
10051005 "to solve your issue is written somewhere in those cryptic messages. You will "
10061006 "see, with a bit of habit, we get used to it."
1007 msgstr ""
1008
1009 #. type: Content of: <h3>
1010 #: src/lessons/welcome/environment/Environment.html:36
1011 msgid "But that's [!thelang]!"
1012 msgstr ""
1013
1014 #. type: Content of: outside any tag (error?)
1015 #: src/lessons/welcome/environment/Environment.html:37
1016 msgid ""
1017 "Currently, the PLM is configured to accept [!thelang] programs, but it can "
1018 "also accept [!java]Python or Scala[/!][!scala]Java or Python[/!][!"
1019 "python]Java or Scala[/!] programs. Either click on the language icon at the "
1020 "very bottom right of the window, or head to the <tt>Language/Computer</tt> "
1021 "menu item to change it."
10071022 msgstr ""
10081023
10091024 #. type: Content of: outside any tag (error?)
95979612 " spiral(0,90,12,3);\n"
95989613 msgstr ""
95999614
9615 #. type: Content of: outside any tag (error?)
9616 #: src/lessons/recursion/lego/spiral/Spiral.html:30
9617 msgid ""
9618 "Note that you only have to write the function, not the initial call. Each "
9619 "world will provide a specific set of initial parameters (use the combobox to "
9620 "switch to other worlds). For example, the \"Square Pyramid\" world will call "
9621 "your function as follows:"
9622 msgstr ""
9623
9624 #. type: Content of: <pre>
9625 #: src/lessons/recursion/lego/spiral/Spiral.html:36
9626 #, no-wrap
9627 msgid "spiral(100, 90, 0, 3);\n"
9628 msgstr ""
9629
96009630 #. type: Content of: <h2>
96019631 #: src/lessons/recursion/lego/spiral/SpiralUse.html:2
96029632 msgid "Drawing spirals"
0 <h2>A Janela Principal do PLM</h2>
1
2 O ambiente de trabalho do PLM é auto-explicativo, principalmente com as
3 dicas que aparecem quando o mouse passa sobre elementos. Aqui está uma breve
4 explicação dos componentes caso não entenda algo. A janela principal é
5 composta de 5 componentes principais:
6
7 <ul>
8
9 <li><b>O menu:</b> posto na parte de cima da janela, dá-lhe acesso a alguns
10 comandos avançados, como sair do programa e alguns outros que falaremos mais
11 tarde.</li>
12
13 <li><b>A barra de ferramentas:</b> Posta logo abaixo do menu, ela te dá acesso
14 aos quatro comandos principais:
15
16 <ul>
17
18 <li>O botão <b>início</b>, que começa a compilação e a execução do código que
19 digitou no editor. No final da execução, verifica se alcançou uma situação
20 que constitui o objetivo do exercício ou não. Se sim, ganha acesso ao
21 próximo exercício a usar o menu <b>Exercício</b>. Se não, vai precisar
22 refazer o seu código.</li>
23
24 <li>O botão <b>Parar</b> sempre serve para interromper a execução do seu código,
25 o que pode ser útil se entrar num <i>loop infinito</i>.</li>
26
27 <li>O botão <b>Reset</b> pode ser usado para reconfigurar o mundo para o estado
28 inicial.</li>
29
30 <li>O botão <b>Demo</b> mostra a execução da solução esperada. Durante a
31 execução pode alternar o mundo visto para ver as diferentes soluções
32 esperadas.<br/>
33 Note que às vezes existem várias maneiras de alcançar a solução esperada e
34 que aquela apresentada durante a demonstração não é mais ou menos certa que
35 as outras. É completamente livre para não seguir estritamente o processo
36 mostrado pela demonstração, desde que a sua solução final atinja o que
37 exercício pede.</li>
38 </ul></li>
39
40 <li><b>Guias de missão e editor:</b> é onde está a ler este texto. Esta área
41 contém várias abas as quais pode acessar a clicar no nome deles no canto
42 superior esquerdo. A primeira guia (que se chama sempre <b>Missão</b>)
43 contém uma apresentação do exercício atual. Para resolver um exercício,
44 precisa escrever o seu código nas outras guias. Por exemplo, pode agora
45 clicar na guia <b>Código Fonte</b> para ver o código real. Se estiver vazia,
46 é por que ainda não escreveu nenhum código.</li>
47
48 <li><b>O console:</b> localizado abaixo das abas, é onde aparece qualquer
49 mensagem da aplicação. Esta área inicialmente é vazia e branca.</li>
50
51 <li><b>Visão do mundo</b> localizada à direita das abas, é constituída de cinco
52 elementos:
53
54 <ul>
55
56 <li>Um menu rolante serve para escolher o mundo. Na verdade, o programa que
57 escreveu pode ser executado em vários mundos para testá-lo em diferentes
58 condições. Este menu é para escolher o mundo que quer ver. Observe que este
59 menu rolante fica oculto se houver apenas um mundo no seu exercício.</li>
60
61 <li>Um "slider" posto logo abaixo serve para escolher a velocidade da animação
62 do mundo. Mais precisamente, permite escolher o atraso (em milisegundos) que
63 os buggles devem esperar depois de cada ação para permitir que veja o que
64 eles estão a fazer.</li>
65
66 <li>Uma guia <b>Mundo</b> representa a visão de mundo atualmente selecionada (de
67 menu rolante). Esta visão é então constituída de uma grade a formar várias
68 células do mundo, assim como vários "<i>buggles</i>" a esperar as suas
69 ordens.</li>
70
71 <li>Uma guia <b>Objetivo</b> a mostrar o mundo como deveria ser no final do
72 exercício.</li>
73
74
75 <li><b>Os controles interativos</b>. Localizados abaixo da Visão do mundo, estes
76 botões servem para controlar interativamente os buggles. Desta forma, pode
77 tentar trazer <i>manualmente</i> o seu buggle ao objetivo do cenário antes
78 de escrever o código necessário no editor.
79
80 <ul>
81 <li>Um menu rolante serve para selecionar o "buggle" que quer controlar.</li>
82
83 <li>O botão <b>Avançar</b> faz o seu "buggle" dar um passo à frente.</li>
84
85 <li>O botão <b>Recuar</b> fá-lo dar um passo para trás.</li>
86
87 <li>O botão <b>Virar à esquerda</b> manda o seu "buggle" virar 90° à esquerda.</li>
88
89 <li>O botão <b>Virar à direita</b> manda o seu "buggle" virar à direita
90 (surpreendente, né?).</li>
91
92 <li>O botão <b>Marcar</b> pede que o seu "buggle" deixe uma marca atrás dele
93 depois que sair.</li>
94
95 </ul>
96
97 </li>
98
99 </ul>
0 #Sun, 20 Sep 2020 17:43:59 +0200
0 #Sun, 11 Oct 2020 21:34:56 +0200
11 # PLM default configuration
2 plm.major.version=2.9
3 plm.minor.version=20200920
2 plm.major.version=2.9.2
3 plm.minor.version=20201011
44
55 # This should be self explanatory, actually
66 # Its value is automatically updated and saved in the personal property file
0 [po4a_langs] fr it pt_BR uk
0 [po4a_langs] fr it pt pt_BR sv uk
11 [po4a_paths] l10n/missions/plm.pot $lang:l10n/missions/$lang.po
22
33 [po4a_alias:html] xhtml opt:"-o ontagerror=fail -L UTF-8 -M UTF-8 -k 1"
+0
-75
postats.pl less more
0 #!/usr/bin/perl
1
2 use strict;
3
4 sub postats {
5 my ($dir) = (shift);
6 my @potfiles = glob("$dir/*.pot");
7 die "No POT file found in $dir" if scalar @potfiles == 0;
8 die "More than one POT file found in $dir" if scalar @potfiles > 1;
9 my $potfile = pop @potfiles;
10 my $stat = `msgfmt -o /dev/null --statistics $potfile 2>&1`;
11 $stat =~ /(\d+)\D+?(\d+)/;
12 my $msgids = $1+$2;
13
14 print "Details for $dir\n";
15 my (@t100,@t95,@t90,@t80,@t70,@t50,@t33,@t20,@starting);
16
17 my @files = glob("$dir/*.po");
18 foreach (sort @files) {
19 my $file = $_;
20 $file =~ m|$dir/(.*?).po$|;
21 my $lang = $1;
22 my $stat = `msgfmt -o /dev/null -c --statistics $file 2>&1`;
23 my ($trans, $fuzz, $untr) = (0,0,0);
24 if ($stat =~ /(\d+)\D+?(\d+)\D+?(\d+)/) {
25 ($trans, $fuzz, $untr) = ($1,$2,$3);
26 } elsif ($stat =~ /(\d+)\D+?(\d+)/) {
27 ($trans, $fuzz) = ($1,$2);
28 } elsif ($stat =~ /(\d+)/) {
29 ($trans) = ($1);
30 } else {
31 print "Unparsable content\n";
32 }
33 my $total = $trans+$fuzz+$untr;
34 my $ratio = $trans / $total * 100;
35 # print "$stat -> $ratio| trans: $trans; fuzz: $fuzz; untr: $untr\n";
36 my $Ratio = int($ratio);
37 print " $lang (".(int($ratio*100)/100)."%): $stat";
38 if ($ratio == 100) {
39 push @t100, $lang;
40 } elsif ($ratio >= 95) {
41 push @t95, "$lang ($Ratio%)";
42 } elsif ($ratio >= 90) {
43 push @t90, "$lang ($Ratio%)";
44 } elsif ($ratio >= 80) {
45 push @t80, "$lang ($Ratio%)";
46 } elsif ($ratio >= 70) {
47 push @t70, "$lang ($Ratio%)";
48 } elsif ($ratio >= 50) {
49 push @t50, "$lang ($Ratio%)";
50 } elsif ($ratio >= 33) {
51 push @t33, "$lang ($Ratio%)";
52 } elsif ($ratio >= 20) {
53 push @t20, "$lang ($Ratio%)";
54 } else {
55 push @starting, "$lang ($Ratio%)";
56 }
57 }
58 printf ("Summary for $dir (pot file has $msgids strings and is %.2f kb)\n", ((-s $potfile)/1024));
59 print " ".(scalar (@t100))." language".(scalar (@t100)==1?' ':'s')." = 100%: ". (join(", ", @t100)).".\n" if (scalar(@t100)>0);
60 print " ".(scalar (@t95))." language".(scalar (@t95)==1?' ':'s')." >= 95%: ". (join(", ", @t95)).".\n" if (scalar(@t95)>0);
61 print " ".(scalar (@t90))." language".(scalar (@t90)==1?' ':'s')." >= 90%: ". (join(", ", @t90)).".\n" if (scalar(@t90)>0);
62 print " ".(scalar (@t80))." language".(scalar (@t80)==1?' ':'s')." >= 80%: ". (join(", ", @t80)).".\n" if (scalar(@t80)>0);
63 print " ".(scalar (@t70))." language".(scalar (@t70)==1?' ':'s')." >= 70%: ". (join(", ", @t70)).".\n" if (scalar(@t70)>0);
64 print " ".(scalar (@t50))." language".(scalar (@t50)==1?' ':'s')." >= 50%: ". (join(", ", @t50)).".\n" if (scalar(@t50)>0);
65 print " ".(scalar (@t33))." language".(scalar (@t33)==1?' ':'s')." >= 33%: ". (join(", ", @t33)).".\n" if (scalar(@t33)>0);
66 print " ".(scalar (@t20))." language".(scalar (@t20)==1?' ':'s')." >= 20%: ". (join(", ", @t20)).".\n" if (scalar(@t20)>0);
67 print " ".(scalar (@starting))." starting language".(scalar (@starting)==1?' ':'s').": ". (join(", ", @starting)).".\n" if (scalar(@starting)>0);
68 }
69
70 postats('l10n/engine');
71 print("-------------------\n");
72 postats('l10n/missions');
73
74 1;
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Pares alternados</h1>
3 Dada uma cadeia, retorne outra cadeia feita com os caracteres de índices
4 0,1, 4,5, 8,9 ... por exemplo "kittens" retorna "kien".
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>FrontTimes</h1>
3 Seja uma cadeia e um inteiro n. Definiremos o começo de uma cadeia como os
4 três primeiros caracteres dela, ou toda se o comprimento dela é menor que
5 3. Retorne n cópias do começo de uma cadeia;
6
7 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
8 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Último2</h1>
3
4 <p>Dada uma cadeia retorne a quantidade de vezes que os dois últimos dígitos
5 aparecem como uma sub-cadeia. Assim, "hixxxhi" retorna 1 (não contamos a
6 última sub-cadeia) enquanto "aaaNaa" retorna 2 (as ocorrências podem
7 sobrepor-se parcialmente).</p>
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Diversão com cadeias</h1>
3
4 <p>Cadeias são os mais simples dos tipos de dados complexos :) Elas fornecem
5 diferentes operações, como obter o tamanho da cadeia ou uma sub-cadeia.</p>
6
7 <p>Uma introdução muito boa a este tipo encontra-se em:
8 http://codingbat.com/doc/java-string-introduction.html</p>
9
10 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
11 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>StringBits</h1>
3 Dada uma cadeia, retorne uma nova cadeia formada a escolher um caractere
4 sim, outro não, a começar com o primeiro. Assim, "Primeiro" torna-se "Pier".
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Comparação de cadeia</h1>
3 Sejam duas cadeia a e b, retorne a quantidade de posições onde elas contêm a
4 mesma subcadeia de tamanho 2. Assim, "xxcaazz" e "xxbaaz" retornam 3, pois
5 as subcadeias "xx", "aa" e "az" aparecem nas mesmas posições nas duas
6 cadeias.
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Explosão de cadeias</h1>
3 Dada uma cadeia não vazia como "Code" retorna uma cadeia como "CCoCodCode".
4
5 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
6 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Multiplicação de cadeias</h1>
3 Dada uma cadeia e um inteiro positivo retorna uma cadeia mais comprida que
4 consiste em n cópias da cadeia original.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>StringX</h1>
3 Dada uma cadeia, retorne uma versão onde todos os "x" são removidos. Exceto
4 os "x" no começo e no final que devem permanecer.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>StringYak</h1>
3 A string "yak" não tem sorte. Dada uma cadeia, retorna uma versão onde todas
4 as "yak" são removidas (qualquer que seja o caractere no lugar do 'a'). As
5 diferentes cadeias "yak" não se sobrepõem.
6
7 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
8 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Pequenos exercícios com cadeias</h3>
3
4 <p>Aqui estão alguns exercícios sobre cadeias. Mas infelizmente, a integração
5 dele no PLM ainda está a ser construída.</p>
6
7 <p>Por favor seja paciente conosco.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Módulo lunar</h1>
3
4 <p>Nesta lição vai pilotar um módulo lunar em situações de complexidade
5 crescente.</p>
6
7 <p>A cada passo da simulação, o jogador envia um comando a controlar quanto o
8 ângulo e a potência do módulo devem mudar</p>
9
10 <p>Ideias a respeito da progressão dos exercícios:</p>
11 <ul>
12 <li>Um módulo em posição vertical sobre solo plano, o jogador só controla a
13 potência (feito)</li>
14 <li>Um módulo em posição vertical sobre solo inclinado, o jogador controla
15 potência e ângulo (feito)</li>
16 <li>Um módulo com ângulo ruim e rápido sobre solo inclinado, o jogador controla
17 potência e ângulo</li>
18 <li>Um módulo com ângulo difícil e rápido sobre superfície inclinada, com solo
19 difícil, o jogador controla potência e ângulo</li>
20 <li>O mesmo com vento?</li>
21 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Lander 101</h1>
3
4 <p>Parabéns! Ganhou uma viagem (só de ida) para Marte numa caixa de cereais. A
5 NASA é orgulhosa em doar o módulo da excursão lunar para esta missão e é o
6 que vai pilotar.</p>
7
8 <p>Antes de pousar, vai realizar algumas simulações de pouso. Não tem que
9 pilotar o módulo se tudo for como planeado, mas, como dizem, "é melhor
10 prevenir que remediar".</p>
11
12 <p>A sua missão é <b>pousar o módulo com a velocidade vertical máxima de 10
13 m/s.</b> Existem duas formas de influenciar o curso do módulo: a ajustar o
14 ângulo dele ou a ajustar a potência dele. Nesta simulação vamos nos
15 preocupar apenas a ajustar a potência, expressa em m/s².</p>
16
17 <p>[!scala|java|c]O código[/!] [!python] da função <code>step()</code> [/!],
18 que vai escrever, agora vai ser chamada a cada 0,1 segundos durante a
19 simulação. Certifique-se que o seu código não demora muito para executar,
20 sem usar o loop while! Apenas deve ajustar a potência desejada para o
21 próximo passo da simulação, a chamar <code>[!java]void
22 [/!]setDesiredThrust([!java]int
23 [/!]desiredThrust[!scala]:Integer[/!])</code> onde
24 <code>desiredThrust</code> é algum inteiro entre 0 e 4 (ou seja, uma
25 potência entre 0 m/s² e 4 m/s²). Só pode aumentar ou diminuir a potência por
26 1 entre dois passos da simulação. Portanto, se a potência atual é 2 e pede
27 4, vai conseguir apenas 3 no próximo passo. Se pede por menos que 0 (ou,
28 respetivamente, mais que 4), vai ser como se tivesse pedido 0 (ou,
29 respetivamente, 4).</p>
30
31 <p>Para tomar decisões informadas, pode consultar o estado do módulo. Nesta
32 simulação provavelmente vai estar interessado na posição vertical:
33 <code>[!java]double [/!]getY()[!scala]:Double[/!]</code> e na velocidade
34 vertical: <code>[!java]double
35 [/!]getSpeedY()[!scala]:Double[/!]</code>. Também pode pedir a potência com
36 <code>[!java]int [/!]getThrust()[!scala]:Integer[/!]</code> caso não se
37 lembre o que pediu. Lembre-se que a gravidade de Marte é 3,711 m/s². Isto
38 pode ser útil.</p>
39
40 <p>Uma última coisa: o módulo é bem pequeno, logo não tem muito combustível. Em
41 cada passo da simulação o módulo consome tantas unidades de combustível
42 quanto a potência atual. Uma vez que fique sem combustível vai cair em queda
43 livre, portanto cuidado! Pode consultar a quantidade de unidades de
44 combustível restante a usar <code>[!java]int
45 [/!]getFuel()[!scala]:Integer[/!]</code>.</p>
46
47 <p>Boa Sorte!</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Localizar uma área de pouso</h2>
3
4 <p>Depois de 200 dias a viajar no espaço e a comer cereais finalmente chegou ao
5 Marte. Hora de pousar, finalmente!</p>
6
7 <p>O módulo está no piloto-automático e tudo que tem que fazer é dar uma olhada
8 e dizer ao módulo onde pousar. O módulo deve <b>pousar numa área plana</b>
9 se quiser ficar inteiro. Indica ao módulo onde pousar a modificar a função
10 <code>getLandingZone</code> de forma que retorne um
11 [!java|scala]<code>Segment</code> a representar a área da sua escolha.
12
13 <p>Um segmento é composto de dois <code>Ponto</code>s, cada um deles composto
14 de dois <code>double</code>s. Um segmento é construído com o construtor
15 <code>Segment([!java]Point [/!]start[!scala]:Point[/!], [!java]Point
16 [/!]end[!scala]:Point[/!])</code>. Um ponto é construído com o construtor
17 <code>Point([!java]double [/!]x[!scala]:Double[/!], [!java]double
18 [/!]y[!scala]:Double[/!])</code>. As coordenadas de um ponto são acessíveis
19 através dos métodos <code>[!java]double [/!]x()[!scala]:Double[/!]</code> e
20 <code>[!java]double [/!]y()[!scala]:Double[/!]</code> dele.</p>[/!] [!python]tupla de duas coordenadas X a representar a área
21 escolhida.[/!]
22
23 <p>Para determinar para qual área retornar, precisa chamar
24 <code>[!java]List&lt;Point&gt;
25 [/!]getGround()[!scala]List[Point][/!]</code>, que retorna os vértices do
26 perfil do solo como uma lista de [!python]tuples (x,y)[/!]
27 [!java|scala]<code>Point</code>s[/!].</p>
28
29 <p>Mais um detalhe: a sua função deve retornar uma área plana válida em
30 qualquer situação, não apenas para a atualmente vista. Isto é porque não vai
31 ser testado apenas neste mundo, mas também naquele do exercício
32 anterior. Como sempre, pode ver os outros mundos existentes com a combobox
33 apropriada.</p>
34
35 <p>Tenha um bom pouso! Não se esqueça de vestir seu traje espacial quando for
36 sair.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Pilote o módulo!</h1>
3
4 <p>Depois de 30 dias a olhar a rochas e a comer cereais decide que é hora de
5 explorar outras partes do planeta.</p>
6
7 <p>Voa por um tempo e repentinamente repara que está quase sem
8 combustível. Infelizmente, está numa situação delicada e o piloto automático
9 é inútil. Você mesmo terá que pilotar o módulo. A sua missão é <b>pousar o
10 módulo numa área plana com uma velocidade vertical menor que 10 m/s, uma
11 velocidade horizontal menor que 5 m/s e um ângulo de 0°.</b></p>
12
13 <p>Precisa definir duas funções: <code>[!java]void [/!]initialize()</code> e
14 <code>[!java]void[/!]step()</code>. <code>initialize()</code> é chamada uma
15 única vez depois de apertar "Executar". Pode usá-lo para escolher uma área
16 plana. Como antes, <code>step()</code> é chamado a cada 0,1 segundos e é
17 usada para ajustar a potência e ângulo do módulo. Como no primeiro
18 exercício, a potência do módulo é ajustada através de <code>[!java]void
19 [/!]setDesiredThrust([!java]int
20 [/!]desiredThrust[!scala]:Integer[/!])</code>. Mas também pode controlar o
21 ângulo dele através de <code>[!java]void [/!]setDesiredAngle([!java]double
22 [/!]desiredAngle[!scala]:Double[/!])</code>. Um ângulo de 0° denota uma
23 posição vertical onde a "cabeça" do módulo aponta para cima. Este é o
24 ângulo com o qual deve pousar. Um ângulo positivo denota um módulo inclinado
25 para a esquerda, um ângulo negativo um inclinado para a direita. Não pode
26 inclinar mais que ±90° e o ângulo pode mudar por no máximo ±5° em cada
27 passo.</p>
28
29 <p>Como no exercício anterior, <code>[!java]List&lt;Point&gt;
30 [/!]getGround()[!scala]:List[Point][/!]</code> retorna os vértices do perfil
31 do solo da esquerda para a direita. Favor consulte a documentação
32 (Ajuda/Sobre este mundo) para um manual de referência do módulo lunar.</p>
33
34 <p>Como antes, o seu programa deve pousar o módulo com segurança em todas as
35 situações encontradas além desta nova.</p>
36
37 <p>Boa sorte, tente não cair!</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Módulo lunar</h3>
3
4 <p>Nesta lição vai pilotar um módulo lunar em situações de complexidade
5 crescente.</p>
6
7 <p>Esta lição assume algum conhecimento de física e programação básica.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Módulo lunar</h2>
3
4 <p>Pilota um módulo lunar neste universo. A cada passo da simulação recebe a
5 posição, velocidade, ângulo e potência do módulo e deve enviar um comando a
6 ajustar o ângulo e a potência.</p>
7
8 <h2>Funções fornecidas</h2>
9
10 <pre>[!java|c]double [/!]getX()[!scala]:Double[/!]
11 [!java|c]double [/!]getY()[!scala]:Double[/!]</pre>
12 Obter (Get) as posições X e Y do módulo.
13 <pre>[!java|c]double [/!]getSpeedX()[!scala]:Double[/!]
14 [!java|c]double [/!]getSpeedY()[!scala]:Double[/!]</pre>
15 Obter a velocidade horizontal e vertical do módulo.
16
17 <pre>[!java|c]double [/!]getAngle()[!scala]:Double[/!]
18 [!java|c]void [/!]setDesiredAngle([!java|c]double [/!]desiredAngle[!scala]:Double[/!])</pre>
19 Obter ou ajustar o ângulo do módulo.<br/>
20 Um ângulo de 0° denota uma posição vertical onde a "cabeça" do módulo aponta
21 para cima. É o ângulo com que deve pousar. Um ângulo positivo denota a
22 inclinação para a esquerda, um ângulo negativo denota inclinação para a
23 direita. Não pode inclinar mais que ±90° e o ângulo pode sofrer uma variação
24 de no máximo ±5° a cada passo.
25
26 <pre>[!java|c]int [/!]getThrust()[!scala]:Int[/!]
27 [!java|c]void [/!]setDesiredThrust([!java|c]int [/!]thrust[!scala]:Int[/!])</pre>
28 Obter ou ajustar a potência do módulo. <br/>Só pode aumentar ou diminuir a potência de 1 a cada passo. pois se a
29 potência atual é 2 e pede 4, ela vai mudar para 3 no próximo passo. Se pedir
30 menos que 0 (ou, respetivamente, mais que 4), vai ser como se tivesse pedido
31 0 (ou, respetivamente, 4).
32
33 <pre>[!java|c]int [/!]getFuel()[!scala]:Int[/!]</pre>
34 Obter o combustível restante no módulo. A cada passo da simulação o módulo
35 consome tantas unidades de combustível como a potência atual. Uma vez que
36 fique sem combustível entra em queda livre. Portanto, cuidado!
37
38 <pre>[!java]List&lt;Point&gt; [/!]getGround() [!scala]:List[Point][/!]</pre>
39 Obter os vértices do perfil do solo da esquerda para a direita.
40 [!java|scala]Pode recuperar as coordenadas X e Y de cada ponto com os
41 métodos correspondentes do seu ponto: <code>p.x()</code> e
42 <code>p.y()</code>.[/!] [!python]Cada ponto é uma array de dois inteiros a
43 denotar respetivamente as coordenadas X e Y de cada ponto.[/!]
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Bem-vindo</h1>
3
4 <p>Bem-vindo ao mundo lightbot. Este é apenas um quebra-cabeça para
5 programadores ao invés de uma lição real (embora algumas pessoas usem isto
6 para ensinar programação). O robô não é programado em Java, mas sim
7 graficamente. Pode ver as ordens existentes na documentação a usar o menu
8 <i>Sobre este mundo</i>.<</p>
9
10 <p>O objetivo de cada tabuleiro é simplesmente ligar todas as luzes do
11 tabuleiro a usar o seu pequeno robô.</p>
12
13 <p>Este é um exercício introdutório, que pode ser resolvido simplesmente a
14 mover em frente e a apertar o interruptor, a usar respetivamente
15 <img src="img/lightbot_forward.png" /> e <img src="img/lightbot_light.png" />.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Virar</h1>
3
4 <p>Agora, provavelmente precisa virar adicionalmente (a usar
5 <img src="img/lightbot_left.png" /> e <img src="img/lightbot_right.png" />).
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Pular</h1>
3
4 <p>Também pode pular a usar <img src="img/lightbot_jump.png" /> para passar obstáculos. Pode tanto pular um nível ou qualquer quantidade de
5 níveis para baixo, mas não pode pular para uma célula da mesma altura.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Degraus</h1>
3
4 <p>Pode passar estes degraus?
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Mais alto</h1>
3
4 <p>Vamos mais alto
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Funções</h1>
3
4 <p>Pode usar <img src="img/lightbot_f1.png" /> e <img src="img/lightbot_f2.png" /> chamar respetivamente as primeira e segunda funções. Defina o código na
5 própria guia dele.
6
7 <p>Isto é muito bom se ficar sem espaço na sua função principal
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Tarefas repetitivas</h1>
3
4 <p>Funções também são muitos úteis para tarefas repetitivas
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Chamar funções de dentro de funções</h1>
3
4 <p>Não tem nada de errado em chamar uma função de dentro de uma função!
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Castelo</h1>
3
4 <p>Está a ficar bom nisto...
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Parede</h1>
3
4 <p>Preparado para subir a parede?
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Mar</h1>
3
4 <p>Agora vai ter que surfar neste mar de lâmpadas.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Castelo de Escher</h1>
3
4 <p>Este não é fácil.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>LightBot</h1>
3 Esta lição introduz um pequeno quebra-cabeças de programação inspirado num
4 jogo em flash.
5
6 <p>Veja o diálogo <i>Sobre este mundo</i> para mais detalhes.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>LightBot</h3>
3
4 <p>Esta lição constitui um pequeno "brain teaser" para programadores. Tem que
5 instruir o seu robô a desligar todas as luzes. O truque é que programa o seu
6 robô graficamente e tem uma quantidade limitada de instruções.</p>
7
8 <p>Espera-se experiência prévia para fazer esta lição.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>LightBot</h1>
3
4 Este universo introduz um pequeno quebra-cabeças de programação que pode num
5 sentido ser usado para introduzir programação a crianças que não sabem ler
6 desde ser programado graficamente. O objetivo de cada tabuleiro é ligar
7 todas as luzes. O seu robô entende as seguintes ordens:
8
9 <table border=1>
10 <tr><td><b>Order</b></td><td><b>Meaning</b></td></tr>
11 <tr><td><img src="img/lightbot_forward.png" /></td><td><b>Mover para frente</b><br />Não pode ser feito se a célula de destino é de outra altura que a célula de
12 origem</td></tr>
13 <tr><td><img src="img/lightbot_jump.png" /></td><td><b>Pular pra frente</b><br />Só pode ser feito se a célula de destino está um passo mais alto que a
14 célula de origem, ou se o destino é mais baixo que a origem. Não pode ser
15 usado para movimentos normais.</td></tr>
16 <tr><td><img src="img/lightbot_left.png" /></td><td><b>Virar à esquerda</b>.</td></tr>
17 <tr><td><img src="img/lightbot_right.png" /></td><td><b>Virar à direita</b>.</td></tr>
18 <tr><td><img src="img/lightbot_light.png" /></td><td><b>trocar a luz</b>.<br />Liga-a se estiver desligada e desliga-a se estiver ligada. Sem efeito se a
19 célula não contém nenhuma luz.</td></tr>
20 <tr><td><img src="img/lightbot_f1.png" /></td><td><b>Chamar função 1</b>.</td></tr>
21 <tr><td><img src="img/lightbot_f2.png" /></td><td><b>Chamar função 2</b>.</td></tr>
22 </table>
23
24 <p>Por favor observe que este mundo não é completamente adequado para crianças
25 pequenas uma vez que a principal dificuldade vem do fato de que a quantidade
26 de instruções é muito limitada. Níveis avançados então necessitam que
27 algumas funções de sons são escritas e estão acima das capacidades de
28 crianças pequenas.</p>
29
30 <p>Este jogo é fortemente inspirado dum jogo de flash com o mesmo nome, que
31 pode, por exemplo, ser jogado em kongregate.com. Foi escrito por Danny
32 Yaroslavski (Coolio-Niato) e a ideia original é de Matt Chase.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Labirintos</h1>
3
4 <p>Esta lição propõe vários exercícios sobre labirintos no mundo dos buggles.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Perdido entre ilhas</h2>
3
4 <p>Julga que o seu algoritmo é suficiente para escapar de labirintos? Bem, não
5 de todos...
6 </p>
7
8 <p>O <i>algoritmo de seguir paredes</i> que usamos até agora só funciona se a
9 entrada e a saída estão próximas de paredes conectadas ao muro externo. Mas
10 se o buggle começa na metade do labirinto, podem existir sessões de paredes
11 desconectadas da parede externa.
12
13 <p>É por isto que a estratégia anterior pode deixar o buggle a dar voltas para
14 sempre. Na verdade, o labirinto do qual deve escapar agora contém ilhas e o
15 buggle não começa próximo de um dos muros externos. Experimente se quiser:
16 copie o seu código aqui, aperte o botão executar e veja a sua solução
17 anterior falhar vergonhosamente.</p>
18
19 <p>O método de seguir uma parede ainda é bom e permite escapar com muita
20 eficiência de algumas secções do labirinto, por isso não precisamos
21 removê-lo inteiramente. Ao invés disto, queremos parar de seguir a parede
22 sob certas condições. Observe que o baggle fica próximo da borda externa do
23 labirinto. Queremos chegar à borda e então seguir aquela parede. Precisamos,
24 por exemplo, procurar a parede norte antes de segui-la até ao baggle.
25
26 <p>Para encontrar a parede do norte, simplesmente ande para o norte enquanto
27 for possível e quando encontrar um obstáculo, deve desviar dele (a usar o
28 método anterior).</p>
29
30 <div class="tip" id="tip-1" alt="Estou perdido agora, por favor dê-me algumas orientações adicionais">
31 O nosso novo método run() consistirá de dois modos: o nosso buggle vai
32 alternar entre o "modo de andar para o norte" e o "modo de seguir à
33 esquerda". Começa no "modo de andar para o norte" e alternar para "seguir à
34 esquerda" quando tiver uma parede ao norte (não se esqueça de garantir que
35 tem uma parede à sua esquerda antes de alternar para o modo "seguir a
36 esquerda"). Alterna para "andar para o norte" assim que o seu buggle estiver
37 a olhar para o norte e não estiver em frente de um muro durante a sua viagem
38 ao redor do muro à esquerda dele. O mais fácil de escrever tal máquina de
39 estado é algo como
40 <pre>[!scala]var state=0;
41 state match {
42 case 0 => // para o norte
43 ...
44 state = 1;
45 case 1 => // seguir a esquerda
46 ...
47 state = 0;
48 case _ => println("Isto não deveria acontecer. Favor me conserte")
49 }[/!][!java|c]int state=0;
50 switch (state) {
51 case 0: // para o norte
52 ...
53 state = 1;
54 break;
55 case 1: // seguir a esquerda
56 ...
57 state = 0;
58 break;
59 }[/!][!python]northRunner = True
60 if northRunner:
61 ...
62 northRunner = False
63 else: # left follower
64 ...
65 northRunner = True[/!]</pre>
66
67 [!scala]<br/>Não se esqueça do caso default (matching _), ou scala irá dar um erro já que
68 o seu "matching" vai estar incompleto.[/!]
69 </div>
70
71 <p>Não se esqueça de deixar o buggle apanhar o baggle no final do código.</p>
72
73
74 <p>Tudo pronto. Isto deve ser o suficiente para descobrir como sair deste
75 labirinto e se não for o caso, sempre pode pedir uma dica. Mas não vai
76 precisar, correto?</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Algoritmo de Pledge</h2>
3
4 <p>Novamente, pensou que o seu algoritmo era bom o suficiente para escapar do
5 labirinto e novamente, o seu buggle está agora num labirinto onde o seu
6 algoritmo anterior falhou. Dê-lhe uma hipótese: copie-e-cole o seu código e
7 aperte o botão "Executar" e veja a sua criação falhar. A armadilha é no
8 formato de um "G" maiúsculo. O buggle entra na armadilha e segue a borda
9 interior. Num determinado momento, encontra a direção norte livre, vai nesta
10 direção e cai de novo na armadilha.
11 </p>
12
13 <p>O algoritmo de Pledge (em homenagem a Jon Pledge of Exeter) pode resolver
14 este labirinto.</p>
15
16 <p>Este algoritmo é uma modificação do anterior para evitar obstáculos. Escolhe
17 aleatoriamente uma direção e deixe o buggle ir nesta direção. Quando
18 encontra um obstáculo, uma pata (por exemplo, a da esquerda) é mantida na
19 parede a seguir o obstáculo enquanto conta as curvas. Quando o buggle está
20 de volta à direção original dele e a soma das curvas deu 0, o buggle deixa o
21 obstáculo e continua a manter a direção original dele. </p>
22
23 <p>Observe que o uso de "total turning" ao invés de simplesmente o "current
24 direction" permite que o algoritmo evite armadilhas no formato G. Se alguém
25 escolhe a esquerda para dentro da armadilha acaba a girar 260 graus pelas
26 paredes. Como dissemos antes, o algoritmo simplório "current direction"
27 entra num ciclo limitado à medida que deixa a parede mais à direita a
28 apontar para a esquerda e anda para a secção curvada na esquerda de novo.</p>
29
30 <p>O algoritmo de Pledge não deixa a parede mais à direita devido ao total de
31 curvas não ser zero neste ponto. Segue a parede na volta toda, a deixa-o
32 finalmente a apontar para a esquerda no "fundo exterior"</p>
33
34
35 <h3>Objetivo do exercício</h3>
36
37 <p><a name="Objective"/>Agora tem que modificar a sua solução para implementar
38 o algoritmo de Pledge para escapar deste labirinto.</p>
39
40 <p>Mude o seu método <code>keepHandOnSideWall()</code> para contar a quantidade
41 de curvas feitas pelo buggle (+1 quando gira para a esquerda e -1 quando
42 gira para a direita). Esta contagem pode necessitar a adição de um valor
43 inteiro <code>angleSum</code> no seu programa.</p>
44
45 <p>Escreva um método booleano <code>isDirectionFree(dir)</code> a indicar se a
46 direção dada está livre, ou seja, se pode mover naquela direção (Observe que
47 a demonstração usa a direção NORTH para isto). Pode recuperar a direção
48 atual do buggle a usar o método <code>getDirection()</code>. Pode mudar a
49 sua direção (sem se mover) a usar <code>setDirection(dir)</code>. Não se
50 esqueça de guardar a direção anterior do seu buggle (numa variável
51 exclusiva) antes de verificar se a sua direção favorita está livre para
52 depois recuperar o seu estado.</p>
53
54 <p>Também pode ter que mudar o resto do seu código, mas estas mudanças podiam
55 ser poucas.</p>
56
57 [!python]<p>Não se esqueça que se tem um método que modifica uma variável global (como
58 angleSum), deve garantir que declara esta variável como global. Sem ele, o
59 método cria uma variável de mesmo nome e a global nunca é modificada.</p>
60 <pre>def myMethod():
61 global angleSum
62 ...
63 angleSum = angleSum + 1
64 </pre>
65 [/!]
66
67 <div class="tip" id="tip-1" alt="Mostre uma dica adicional">
68 Deve ajustar a sua direção para a sua favorita (NORTH é a
69 recomendada). Então, deve escrever o loop principal algoritmo. Em outras
70 palavras, enquanto o seu buggle não encontra o biscoito dele, tem que mover
71 para a frente até ao próximo obstáculo na sua direção favorita. Então, ponha
72 uma pata na parede (a usar <code>keepHandOnSideWall()</code>) enquanto a
73 soma de curvas não for null (nula) e a direção favorita não estiver
74 livre. Faça-o até que encontre o seu baggle.</div>
75
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>O rato doido</h2>
3
4 <p>O dia do seu buggle começou ruim. Com falta de sorte, ficou preso num
5 labirinto. Ajude-o a encontrar o caminho para a saída.
6 </p>
7
8 <p>
9 A saída é representada por um baggle e precisa apanhar este baggle para sair
10 do labirinto.
11 </p>
12
13 <p>
14 Como o labirinto é muito pequeno, vamos escrever o algoritmo mais bobo
15 possível. É aleatório e vai mostrar-se bem ineficiente.
16 </p>
17
18 <p>
19 Enquanto o buggle não encontra o caminho para a saída, deve fazer o
20 seguinte: escolher um número inteiro entre 0 e 2 a usar o método
21 <code>random3()</code> fornecido e fazer uma das seguintes ações: andar em
22 frente se for possível, virar à esquerda ou virar à direita.
23 </p>
24
25 <p>Julga que isto não vai funcionar? Bem, experimente e verá... Não se esqueça
26 de apanhar o baggle quando lhe chegar.
27 </p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Labirintos</h3>
3
4 <p>Esta lição propõe vários exercícios sobre labirintos no mundo dos buggles.</p>
5
6 <p>Para fazer esta lição deve dominar as bases da programação.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Algoritmo básico do caminho mais curto</h2>
3
4 <p>Para concluir com esta lição introdutória em algoritmos de resolução de
5 labirintos, vamos investigar outra forma de encontrar a saída. O buggle
6 nesta lição é um buggle especial: é um jedi. Pode sentir a Força. Isto
7 significa que pode sentir o ambiente.</p>
8
9 <p>Sem nem sequer sair da posição dele, pode recuperar informações sobre o
10 mundo que está a viver, com as seguintes funções:</p>
11 <ul>
12 <li><code>getWorldWidth()</code> da a largura ("width") do mundo.</li>
13 <li><code>getWorldHeight()</code> da a altura ("height") do mundo.</li>
14 <li><code>hasTopWall(x,y)</code> diz se a célula (x,y) deste mundo tem uma
15 parede no topo.</li>
16 <li><code>hasLeftWall(x,y)</code> diz se a célula (x,y) deste mundo tem uma
17 parede na esquerda.</li>
18 <li><code>hasBaggle(x,y)</code> diz se a célula (x,y) deste mundo tem um baggle.</li>
19 <li><code>setIndication(x,y,i)</code> adiciona a indicação inteira
20 <code>i</code> à célula (x,y).</li>
21 <li><code>getIndication(x,y,i)</code> obtém a indicação inteira da célula (x,y)
22 (ou 9999 se não houver indicação).</li>
23 </ul>
24
25 <p>Note que não é possível construir uma parede na borda de baixo ou na borda à
26 direita de uma célula. Portanto, se tal parede existe, significa que foi
27 construído nas células vizinhas -- como uma parede na borda de cima
28 (respetivamente da esquerda) da célula que é localizada abaixo
29 (respetivamente à direita) da célula atual.</p>
30
31 <h3>Objetivo do exercício</h3>
32
33 <p>O seu buggle deve primeiro escrever a distância à saída em cada célula (ou
34 pelo menos nas células úteis).<br/>
35 Para isto, encontre a saída e escreva 0 lá. Então, escreva 1 em cada célula
36 vizinha que não esteja separada da saída por uma parede. E depois marque
37 cada célula a partir da qual possa alcançar a saída em 2 passos e itere para
38 todas as células até que todas as células estejam marcadas.</p>
39
40 <p>Uma vez que as células estejam marcadas, faça o seu buggle jedi percorrer a
41 caminho mais curto. Basicamente o buggle tem apenas que andar em cada caso
42 com a menor distância à saída. Pode usar o método
43 <code>setDirection(direction)</code> para fazer o seu buggle virar para a
44 direção específica como <code>[!scala|java|python]Direction.[/!]NORTH</code>
45 ou <code>[!scala|java|python]Direction.[/!]EAST</code>.</p>
46
47 <div class="tip" id="tip-1" alt="Estou perdido agora. Por favor, dê-me algumas indicações adicionais.">
48 Usa a Força, Luke!
49 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Encontrar as paredes para seguir</h2>
3
4 <p>Este é o mesmo labirinto que o anterior, mas o buggle não inicia na mesma
5 localização. Em particular, não existe nenhuma parede à esquerda dele no
6 início.</p>
7
8 <p>O resultado é que o método que escreveu para o exercício anterior
9 provavelmente não vai funcionar neste agora. Se usá-lo aqui sem
10 modificações, o seu buggle provavelmente vai iniciar a percorrer as quatro
11 células ao redor do ponto inicial (se este não é o caso, bem, é porque não
12 fez o exercício anterior completamente. Sinta-se sortudo e vá para o próximo
13 exercício :)</p>
14
15 <p>Isto é porque o seu método <code>keepHandOnSideWall()</code> tem uma
16 <b>pré-condição</b> implícita: funciona bem apenas se o buggle tem uma
17 parede à esquerda quando o chama. Tais pré-condições são muito usadas em
18 programação. Especificá-las explicitamente ajuda a entender o código escrito
19 por outros e até servem, às vezes, para provar que o código funciona
20 corretamente.</p>
21
22 <h3>Objetivo do exercício</h3>
23
24 <p>
25 Consertar o problema deve ser bem fácil. Simplesmente garanta que a
26 pré-condição de <code>keepHandOnSideWall()</code> seja verificada antes de
27 chamá-lo. Para isto, atualize o seu código para primeiro olhar a uma parede
28 à sua esquerda antes do loop <code>while</code> maior.
29 </p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Seguir as paredes</h2>
3
4 <p>Agora, o labirinto é um pouco mais complicado. Aleatoriedade pode não ser
5 suficiente, devemos ser espertos!</p>
6
7 <p>A boa notícia é que este labirinto é mais simples do que pode parecer à
8 primeira vista: todas as paredes são conectadas às outras. Para sair deste
9 tipo de labirinto, o buggle tem que simplesmente seguir uma parede (a que
10 fica à esquerda ou à direita dele, não importa). Enquanto manter uma pata na
11 parede, o buggle deve mover para a frente até encontrar a saída do labirinto
12 e o biscoito que tanto gosta.</p>
13
14 <p>Isto funciona aqui porque não existem ilhas ou paredes isoladas, pois o
15 nosso buggle não vai entrar num loop para sempre sem encontrar o baggle
16 dele.</p>
17
18 <h3>Objetivo do exercício</h3>O objetivo deste exercício é escrever um algoritmo que permita que o buggle
19 saia do labirinto.
20
21 <p>Como dito anteriormente, não importa se decide seguir a parede à esquerda ou
22 à direita. Simplesmente, a demonstração segue a da esquerda, logo deve fazer
23 o mesmo na sua solução para facilitar a comparação da sua solução e da
24 demonstração.</p>
25
26 <p>Escreva um método <code>keepHandOnSideWall()</code> que faz o buggle andar
27 uma casa para a frente enquanto mantém a pata na parede do lado
28 selecionado. Deve garantir que o buggle sempre mantenha a pata na parede,
29 mas também que não bata numa parede. Pode controlar a dica para mais
30 informações, mas faça-o apenas se estiver perdido. Tente primeiro fazer sem
31 a dica.</p>
32
33 <p>Depois escreva o algoritmo inteiro para percorrer o labirinto passo a passo
34 (a usar <code>keepHandOnSideWall()</code>) até encontrar o biscoito e a
35 saída. Não se esqueça de apanhar o baggle quando o encontrar.</p>
36
37 <div class="tip" id="tip-1" alt="Estou perdido, dê-me orientações adicionais">
38 <p>Quando o seu buggle tem uma parede à esquerda, existem três situações a
39 considerar, dependente das paredes à volta. A tabela a seguir explica cada
40 situação inicial e onde deve deixar o seu buggle parar depois de cada passo.</p>
41 <table border=1>
42 <tr>
43 <td></td>
44 <td>Caso 1</td>
45 <td>Caso 2</td>
46 <td>Caso 3</td>
47 </tr><tr>
48 <td>Situação inicial</td>
49 <td><img src="lessons/maze/wallfollower/1A.png"/></td>
50 <td><img src="lessons/maze/wallfollower/2A.png"/></td>
51 <td><img src="lessons/maze/wallfollower/3A.png"/></td>
52 </tr><tr>
53 <td>Onde é o próximo passo</td>
54 <td><img src="lessons/maze/wallfollower/1B.png"/></td>
55 <td><img src="lessons/maze/wallfollower/2B.png"/></td>
56 <td><img src="lessons/maze/wallfollower/3B.png"/></td>
57 </tr>
58 </table>
59 <p>Se faz um <code>right()</code> em qualquer caso no final da sua função, é
60 possível escreve-la com 3 linhas com um loop <code>while</code>.</p>
61 </div>
62
63
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>All Different</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorne true
4 se quaisquer dois elementos da lista são diferentes (ie, se nenhum elemento
5 aparece mais de uma vez na lista).
6
7 <p>A solução mais simples é em O(n²), o que significa que executa em tempo
8 quadrático. Provavelmente terá que definir uma função adicional para
9 isto. Outra solução muito mais complexa executa em O(n log(n)).</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>But Last</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna a
4 lista a conter todos os elementos exceto o último. Pode assumir que a lista
5 é não vazia.
6
7 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>But Nfirst</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro
4 <code>N</code>, retorne a lista sem os primeiros <code>N</code> elementos.
5
6 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>But Nlast</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro
4 <code>N</code>, retorna a lista sem os últimos <code>N</code> elementos.
5
6 <p>A sua solução deve ser linear no tempo, mas provavelmente precisa definir
7 várias funções para alcançar esta complexidade.</p>
8
9 <div class="tip" id="tip-1" alt="Não posso fazer isto em tempo linear">
10 O segredo é calcular apenas uma vez (e previamente) quantos elementos deve
11 guardar.
12 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Concat</h1>
3 Dadas duas [!scala]List[Int][/!][!java|python]recursive list[/!]
4 <code>l1</code> e <code>l2</code>, retorna uma nova lista com todos os
5 elementos de <code>l1</code> seguidos de todos os elementos de
6 <code>l2</code>.
7
8 <p>A sua solução deve ser linear no tempo, mas provavelmente precisa definir
9 várias funções para alcançar esta complexidade.</p>
10
11 <div class="tip" id="tip-1" alt="Não posso fazer isto em tempo linear">
12 Precisa modificar <code>l1</code> antes de forma que os cálculos em cada
13 passo da recursão sejam em tempo constante.
14 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Increasing</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna se
4 os elementos dela estão em ordem crescente (p.ex., se os elementos são
5 ordenados do menor ao maior).
6
7 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>IsMember</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro,
4 retorna true se o dado inteiro é um dos elementos desta lista, ou false se
5 não for encontrado.
6
7 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Last</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna o
4 último elemento dela. Pode assumir que a lista não é vazia.
5
6 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Comprimento</h1>
3 Dada uma [!scala]Lista[Int][/!][!java|python]lista recursiva[/!], retorna o
4 comprimento dele[!scala] (sem usar o método <code>size</code> dele,
5 claro)[/!]. [!java|python]<p>[!python]Cuidado, não pode usar listas de Python, mas sim o tipo específico
6 definido neste exercício. [/!] favor ver a documentação do mundo para mais
7 informações a respeito de listas recursivas.</p>[/!]
8
9 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Listas Recursivas</h1>
3 <p>Esta lição contém um monte de exercícios clássicos com listas
4 recursivas. Com certeza não é a lição mais agradável para fazer, mas das
5 lições do PLM que lidam com recursão, acho esta a mais fácil.</p>
6
7 <p>Como sempre, existem várias coisas que podem ser feitas no código deste
8 universo para melhorá-lo:</p>
9
10 <ul>
11 <li>Novos exercícios podem ser propostos, como
12 http://webloria.loria.fr/~quinson/Teaching/TOP/02-td-recursivite-enonce.pdf.
13 Se conhecer outros, por favor abra uma "issue" para relatar.</li>
14 <li>Pode ser interessante verificar a complexidade assintótica do código do
15 estudante, mas isto não parece fácil de fazer. Em Python e Java (onde
16 fornecemos uma classe RecList feita à mão), podemos contar a quantidade de
17 cons por exercício, mas não é fácil relacionar isto ao BatTest correto. Para
18 Scala, parece ainda mais difícil, pois usamos os operadores :: clássicos da
19 linguagem. Vai ser difícil fazer uma sobreposição ("override") para
20 adicionar um mecanismo de contagem. Outra solução seria garantir que a pilha
21 de chamadas não passe de um dado limiar, mas parece muito difícil de fazer
22 também. Quaisquer ideias são bem-vindas.</li>
23 <ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Min</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna o
4 menor dos seus valores. Vai precisar provavelmente de uma função adicional,
5 mesmo se puder assumir que a lista é não vazia.
6
7 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Nfirst</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro
4 <code>N</code>, retorna a lista constituída dos primeiros <code>N</code>
5 elementos. Pode assumir que a lista é longa o suficiente, p.ex. que existem
6 pelo menos <code>N</code> elementos.
7
8 <p>Pode assumir que a lista é longa o suficiente, p.ex. que existe pelo menos
9 <code>N</code> elementos. A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Nlast</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro
4 <code>N</code>, retorna a lista com apenas os últimos <code>N</code>
5 elementos.
6
7 <p>A sua solução deve ser linear no tempo, mas provavelmente precisa definir
8 várias funções para alcançar esta complexidade.</p>
9
10 <div class="tip" id="tip-1" alt="Não posso fazer isto em tempo linear">
11 O segredo é calcular apenas uma vez (e previamente) quantos elementos deve
12 guardar.
13 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Nth</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro
4 <code>N</code>, retorna o <code>N</code>-ésimo elemento da lista.
5
6 <p>Pode assumir que a lista é longa o suficiente, p.ex. que existe pelo menos
7 <code>N</code> elementos. A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Occurrences</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!] e um inteiro,
4 retorna a quantidade de ocorrências de um dado inteiro na lista. Se o
5 inteiro não for um membro da lista, a função deve retornar 0.
6
7 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>PlusOne</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorne uma
4 nova lista a conter todos os elementos do seu parâmetro incrementados de um.
5
6 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Remove</h1>
3
4 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!]
5 <code>L</code> e um inteiro, retorna uma nova lista a conter todos os
6 elementos de <code>L</code> que não são iguais ao valor recebido como
7 parâmetro.
8
9 <p>A sua solução deve ser linear no tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Reverse</h1>
3 Dada uma [!scala]List[Int][/!][!java|python]recursive list[/!], retorna uma
4 nova lista com todos os elementos em ordem inversa.
5
6 <p>Esta função é muito importante e não deve pular este desafio. Sua solução
7 deve ser linear no tempo, com a ajuda de funções auxiliares.</p>
8
9 <div class="tip" id="tip-1" alt="Não posso fazer isto em tempo linear">
10 Precisa de uma função auxiliar na qual o resultado é acumulado (construído)
11 em cada passo.
12 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>ConsWorld</h1>
3
4 <p>Este mundo permite que experimente com listas recursivas, pois foi
5 introduzido primeiro em Lisp. É muito similar ao BatWorld, mas deve escrever
6 funções recursivas que funcionem em [!python|java]cadeias recursivas. Desde
7 que [!thelang] não fornece tal contrução nativamente, o ConsWorld define
8 listas recursivas do tipo <code>RecList</code>.[/!] [!scala]listas de
9 inteiros (<code>List[Int]</code>).[/!]</p>
10
11 <p>Qualquer lista dada é ou a lista vazia (noted
12 <code>[!scala]Nil[/!][!java]null[/!][!python]None[/!]</code>), ou um inteiro
13 seguido de uma lista. Se uma lista não é vazia, pode recuperar o primeiro
14 inteiro dela com <code>list.head</code> e a lista a conter os demais
15 parâmetros com <code>list.tail</code>. Obviamente, a lista vazia não tem
16 head nem tail, portanto, tentar acessar estes elementos vai resultar numa
17 mensagem de erro (desagradável).</p>
18
19 <p>Para construir a sua própria lista, precisa concatenar um head e um tail
20 como segue: [!java|python]<code>cons(head, tail)</code>[/!]
21 [!scala]<code>head::tail</code> Observe que <code>::</code> é um operador
22 genérico em Scala para construir listas.[/!]</p>
23
24 <p>Logo, a resumir, pode resolver cada exercício desta lição com as seguintes
25 construções.</p>
26
27 <ul>
28 <li><b>A lista vazia:</b> <pre>[!java]null[/!][!scala]Nil[/!][!python]None[/!]</pre></li>
29 <li><b>Obtém o primeiro elemento de <code>l</code></b> <pre>l.head</pre></li>
30 <li><b>Obtém o resto da lista</b>, quando o primeiro elemento é removido: <pre>l.tail</pre></li>
31 <li><b>Constrói uma lista</b> a partir de um <code>valor</code> e uma
32 <code>lista</code>: [!java|python]<pre>cons(value, list)</pre>[/!] [!scala]<pre>value::list</pre>[/!]</li>
33 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Torres de Hanoi cíclicas</h2>
3
4 <p>Esta variação das torres de Hanoi é muito similar ao problema normal: recebe
5 uma pilha de discos e três varas e não pode mover um disco maior sobre um
6 menor. A diferença é que só pode mover discos no sentido horário: 0->1 ou
7 1->2 ou 2->0, mas nunca na outra direção.</p>
8
9 <p>Obviamente, os movimentos não são simétricos de forma alguma. Movimentos de
10 A para B são agora muito diferentes de movimentos de B para A. Como
11 resultado, precisa de duas funções recursivas a depender de estar a mover a
12 pilha no sentido horário ou anti-horário.</p>
13
14 <p>Dito isto, a decomposição do problema é muito similar ao Hanoi clássico. A
15 diferença é que cada função chama a outra, a constituir um bom exemplo de
16 recursão mútua.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Torre de Hanoi</h2>
3
4 <p>A Torre de Hanoi (ou Torres de Hanoi), também conhecida como Torre de Brahma
5 (ou Torres de Brahma), é um quebra-cabeça ou jogo matemático. Consiste de
6 três varas e uma quantidade de discos de tamanhos diferentes que podem
7 encaixar em qualquer das varas. O jogo começa com os discos todos numa vara
8 ordenados em ordem crescente, o menor em cima, a formar uma pirâmide.</p>
9
10 O objetivo do jogo é mover a pilha completa para outra vara, a obedecer as
11 seguintes regras:
12 <ul>
13 <li>Apenas um disco pode ser movido por vez.</li>
14
15 <li>Cada movimento consiste em tirar o disco de cima de uma vara e colocá-lo em
16 outra vara, no topo dos discos que já estiverem presentes.</li>
17
18 <li>Nenhum disco pode ser posto sobre um disco menor.</li>
19 </ul>
20
21 <h3>Objetivo deste exercício</h3>
22
23 Escreva o núcleo do método: <code>[!java|c]void
24 [/!]hanoi[!c]Rec[/!]([!java|c]int [/!]height[!scala]:Int[/!], [!java|c]int
25 [/!]src[!scala]:Int[/!], [!java|c]int [/!]other[!scala]:Int[/!],[!java|c]int
26 [/!]dst[!scala]:Int[/!])</code>
27
28 <p>Este método vai, recursivamente, resolve o problema apresentado. O primeiro
29 parâmetro chamado <code>height</code> é a altura da torre a mover; o segundo
30 parâmetro <code>src</code> é o índice da torre inicial, o terceiro parâmetro
31 <code>other</code> é o índica da vara não utilizada enquanto que o quarto
32 parâmetro <code>dst</code> é o índice da torre final experada.</p>
33
34 <p>O segredo para resolver este enigma é reconhecer que pode ser dividido em
35 problemas menores e este em problemas menores até que uma solução é
36 encontrada.</p>
37
38 <div class="tip" id="tip-1" alt="Ainda não captei, por favor me dê mais orientações">
39 Aqui está um pseudo-código da solução:
40 <ul>
41 <li>Rotule as varas como A, B, C (estes rótulos pode se mover com diferentes
42 passos)</li>
43 <li>Seja n a quantidade total de discos (A altura da torre inicial)</li>
44 <li>quantidade de discos a partir de 1 (menor, mais alto) até n (maior, mais
45 baixo)</li>
46 </ul>
47
48 Para mover n discos da vara A para a vara C:
49 <ul>
50 <li>mova n−1 discos de A para B. Isto deixa o disco n sozinho na vara A</li>
51 <li>Mova o disco de número n de A para C</li>
52 <li>Mova n−1 discos de B para C de forma que eles fiquem sobre o disco de número
53 n</li>
54 </ul>
55 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Torres de Hanoi Intercaladas</h2>
3
4 <p>Nesta variação clássica das Torres de Hanoi tem 4 varas com duas pilhas, uma
5 branca e outra preta. Deve misturar as duas pilhas como descrito no mundo
6 objetivo. Como antes, não pode mover um disco para cima de um disco menor.</p>
7
8 <p>Provavelmente vai precisar reutilizar o método <code>hanoi()</code> que
9 escreveu no exercício anterior.</p>
10
11 <div class="tip" id="tip-1" alt="Favor me mostra um passo intermediário">
12
13 Se a sua situação é a seguinte:<br/>
14 <img src="lessons/recursion/hanoi/img/interleaved-initial-settings.png" /><br/>
15
16 Então tem a seguinte situação exatamente antes da chamada recursiva
17 principal:<br/>
18 <img src="lessons/recursion/hanoi/img/interleaved-intermediate-settings.png" />
19
20 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Torres de Hanoi Iterativas</h2>
3
4 <p>Neste último exercício da série, vamos implementar um algoritmo iterativo
5 para o problema básico das Torres de hanoi (uma pilha, 3 varas, sem
6 restrição de movimento adicional). </p>
7
8 <p>Na verdade, este algoritmo é bastante simples: em movimentos ímpares, o
9 disco menor é movido numa dada direção (tanto a aumentar 0-&gt;1-&gt;2-&gt;0
10 ou a diminuir 2-&lt;1-&lt;0-&lt;2) enquanto em movimentos pares, o único
11 movimento possível que não usa o disco menor é feito. Pare assim que a pilha
12 é reconstruída na outra localização.</p>
13
14 <p>A função que precisa escrever agora tem dois parâmetros: a posição inicial
15 do disco menor (p.ex., a vara inicialmente a conter a pilha) e um booleano a
16 indicar se o disco menor deve mover na ordem de aumento ou não.</p>
17
18 <p>A simplicidade deste algoritmo é, na verdade, enganosa. Podemos pensar sobre
19 o interesse em algoritmos recursivos quando algoritmos iterativos tão
20 simples existem. A minha impressão é que esta solução é boa de executar, mas
21 quase impossível de ser concebida desde o princípio (suspeito que os autores
22 construíram esta solução iterativa da observação da execução da solução
23 recursiva)...</p>
24
25 <p>Prever o efeito desta função também é difícil: quando o pequeno disco move
26 na ordem crescente, a pilha é reconstruída na cavilha direita com 5 discos,
27 mas na esquerda com 6 discos.</p>
28
29 <p>Uma questão interessante é se tais algoritmos simples existem para a outra
30 variante do problema. Alguns estão na literatura (p.ex. para a variante
31 cíclica). Integraria as suas soluções no PLM com alegria, especialmente se
32 puder dar uma dica (sem estragar a surpresa) da solução para guiar as outras
33 pessoas.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Linear Towers of Hanoi</h2>
3
4 <p>Esta é uma variação clássica das Torres de Hanoi onde alguns movimentos são
5 proibidos. Especificamente, os disco não podem ser movidos diretamente da
6 vara mais à esquerda para a vara mais a direita. A vara do meio deve ser
7 envolvida em cada movimento.</p>
8
9 <p>Apesar desta complexidade, o problema permanece o mesmo: tem que mover toda
10 a pilha de discos da vara numa extremidade para a vara na outra
11 extremidade. Só pode mover um disco por vez e um disco não pode ficar sobre
12 outro menor.</p>
13
14 <p>Como na versão clássica, é muito fácil produzir uma solução recursiva e é
15 totalmente capaz de "devise" esta solução se pensar com atenção nela.</p>
16
17 <div class="tip" id="tip-1" alt="Tentei, mas não consegui">
18 O algortimo recursivo padrão para as torres de Hanoi clássicas é de
19 complexidade <i>2^n-1</i> enquanto que o algoritmo recursivo padrão para
20 esta variação é de complexidade <i>3^n-1</i>.
21 </div>
22
23 <div class="tip" id="tip-2" alt="A primeira dica não foi suficiente">
24 A algoritmo recursivo padrão para as torres de Hanoi clássicas envolve duas
25 chamadas recursivas a sanduichar um movimento do disco maior, O algoritmo
26 recursivo padrão para Hanoi Linear envolve três chamadas recursivas a
27 sanduichar dois movimentos do mesmo disco.
28 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Torres gêmeas de Hanoi Lineares</h2>
3
4 <p>Esta é uma mistura entre os problemas "Split", Intercalado e linear. Temos
5 duas pilhas de discos, em três varas. Devemos trocar a posição das pilhas a
6 respeitar as restrições clássicas de movimento (um disco por vez, disco
7 grande não pode ficar sobre disco pequeno) e a restrição do movimento linear
8 (proibido mudança diretamente da vara mais à esquerda para a vara mais à
9 direita).</p>
10
11 <p>Vai usar três funções recursivas:</p>
12 <ul>
13 <li><b>moveDouble(k,from, to)</b>: move uma pilha intercalada de k pares de
14 discos, sem mudar as posições relativas dos discos de mesmo tamanho. Como no
15 problema de hanoi "Split", uma pilha intercalada alterna discos brancos e
16 pretos de cada tamanho. Esta função não é completamente nova: escreveu uma
17 versão com 4 varas (mas a usar apenas 3 delas) para a primeira versão do
18 problema de hanoi "split".</li>
19 <li><b>gather(k)</b>: da situação inicial do caso "separado", constrói na vara
20 #2 uma pilha intercalada de k pares de discos. Pode parametrizar a sua
21 função de forma que ela possa ser usada para obter o disco de qualquer vara
22 passado como parâmetro, mas, na prática, a sua função vai apenas ser usada
23 para obter na última vara.</li>
24 <li><b>scatter(k)</b>: de uma situação onde k pares de discos são intercalados
25 na vara #0, separe eles a mover os discos brancos para a vara #1 e os pretos
26 para a vara #2.</li>
27 </ul>
28
29 <p>Em <code>gather()</code>, a chamada recursiva vem antes das duas chamadas a
30 <code>moveDouble()</code> enquanto em <code>scatter()</code>, as chamadas
31 para <code>moveDouble()</code> vem depois da chamada recursiva. A função
32 principal que deve escrever não é recursiva, mas simplesmente obtém quase
33 todos os discos, move os discos restantes diretamente e então espalha
34 ("scatters") de volta os discos menores.</p>
35
36 <p>A linearidade naturalmente induz alguma complexidade adicional, pois tem que
37 decompor cada movimento entre as varas 0 e 2. Ainda estou confiante na sua
38 capacidade de vencer este desafio :)</p>
39
40 <p>Observe que foi provado que o algoritmo requerido é ótimo para este
41 problema, então não precisa mexer no desempenho desta vez.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Torres de Hanoi</h1>
3 <p>Aqui está o exercício super-clássico sobre recursão junto com algumas
4 variações. Se tiver quaisquer outras variações legais, favor envie elas. Em
5 algum momento, alguém deve enviar estas variações também à wikipédia, pois
6 por enquanto apenas o problema básico é descrito lá.</p>
7
8 <p>As variações intercalada e separada vêm do seguinte artigo: "Exploring
9 Recursion with Variations on the Towers of Hanoi", Daniel
10 W. Palmer. Available at
11 http://www.ccscjournal.willmitchell.info/Vol12-96/No2a/Daniel%20W%20Palmer.pdf</p>
12
13 <p>Hanoi linear é discutida rapidamente na artigo a apresentar as Torres Gêmeas
14 Lineares de Hanoi: "The Linear Twin Towers of Hanoi Problem", Steven Minsker
15 (ACM SIGCSE Bulletin Volume 39 Issue 4, December 2007). Este artigo só pode
16 ser acessado através da via paga do editor, desculpe.</p>
17
18 <p>O problema das Torres de Hanoi de 3 cores foi apresentado nesta página:
19 http://www.cut-the-knot.org/recurrence/TricolorHanoiAuto.shtml</p>
20
21 <p>As Torres de hanoi cíclicas foram propostas por M.D. Atkinson num artigo de
22 1981 intitulado "The cyclic towers of Hanoi" (Information Processing
23 Letters, Volume 13:3). O artigo está disponível em
24 http://www.cs.otago.ac.nz/staffpriv/mike/Papers/Hanoi/CyclicHanoi.pdf.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Torres de hanoi Separadas</h2>
3
4 <p>Dada uma pilha intercalada (e.g. o resultado do exercício anterior), deve
5 construir duas pilhas separadas. Em outras palavras, o seu código deve
6 reverter as operações feitas para resolver o exercício anterior.</p>
7
8 <p>Vai precisar de uma função adicional que mova uma pilha intercalada de n
9 pares de discos, sem mudar as posições relativas dos discos de mesmo
10 tamanho.</p>
11
12 <div class="tip" id="tip-1" alt="Favor me mostra um passo intermediário">
13
14 Se a sua situação é a seguinte:<br/>
15 <img src="lessons/recursion/hanoi/img/split-initial-settings.png" /><br/>
16
17 Então tem a seguinte situação exatamente antes da chamada recursiva
18 principal:<br/>
19 <img src="lessons/recursion/hanoi/img/split-intermediate-settings.png" /><br/>
20
21 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Better Split Towers of Hanoi</h2>
3
4 <p>Surpreendentemente, a nossa solução de dividir (split) as torres gera muito
5 mais movimentos que a solução de intercalá-las. Como os problemas são
6 simétricos, isto não deveria acontecer.</p>
7 <table border="1">
8 <tr><td>Quantidade de discos</td><td>Intercalada</td><td>Split</td></tr>
9 <tr><td>5 pares</td> <td> 62 movimentos</td> <td> 88 movimentos</td></tr>
10 <tr><td>6 pares</td> <td>126 movimentos</td> <td>183 movimentos</td></tr>
11 <tr><td>7 pares</td> <td>254 movimentos</td> <td>374 movimentos</td></tr>
12 </table>
13
14 <p>Consegue deixar o "split" tão eficiente quanto o intercalada?</p>
15
16 <div class="tip" id="tip-1" alt="Preciso de uma dica de principiante">
17 A fonte de discrepância é uma decomposição ineficiente do
18 problema. Satisfeitos com o fato dele simplesmente funcionar, não procuramos
19 mais por uma solução melhor. Manter os discos da torre intercalada na ordem
20 correta durante cada movimento é desnecessário. De fato, podemos evitar
21 completamente mover a torre intercalada. Uma decomposição melhor do problema
22 divide o par de discos em duas torres coloridas à medida em que eles são
23 removidos da torre intercalada.
24 </div>
25
26 <br><br>
27 <div class="tip" id="tip-2" alt="A dica de principiante não foi suficiente">
28 Se alguém puder dividir os (n-1) pares de discos previamente, poderia
29 dividir o par restante?
30 </div>
31
32 <br><br>
33 <div class="tip" id="tip-3" alt="Precisa ser mais explícito">
34 <ul>
35 <li>Primeiro divida os primeiros (n-1) pares de discos da pilha intercalada em
36 uma torre branca e uma torre preta (a chamar recursivamente a sua função
37 principal).</li>
38 <li>Então mova o disco branco grande para sua vara objetivo.</li>
39 <li>Então mova os (n-1) discos brancos menores ao topo do maior.</li>
40 <li>Então mova o disco preto grande para sua vara objetivo.</li>
41 <li>Então mova os discos pretos pequenos para a posição.</li>
42 </ul>
43 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Fast Split Towers of Hanoi</h2>
3
4 <p>Novamente, nossas soluções anteriores funcionam, mas estão longe de serem
5 ótimas. Quando movemos as torres, usamos o algoritmo de 3 varas mesmo quando
6 temos 4 varas. Obviamente, movimentos para a última vara são restritos pois
7 ela contém a outra pilha, mas podemos sempre armazenar o menor disco no topo
8 da outra pilha antes de mover nossa pilha.</p>
9
10 <p>Para isto, precisamos criar uma função <code>hanoi_fast(height, src, free,
11 full, dst)</code> que move a pilha de <code>src</code> para <code>dst</code>
12 a usar <code>free</code>, mas a armazenar o menor disco em <code>full</code>
13 antes.</p>
14
15 <div class="tip" id="tip-1" alt="Estou perdido">
16 A função <code>hanoi_fast(height, src, free, full, dst)</code> não é
17 recursiva. Ela move o primeiro disco e então chama a função regular
18 <code>hanoi()</code>.
19 </div> <br>
20
21 <p>Esta mudança melhora enormemente a eficiência, como pode ver
22 abaixo. Obviamente, este truque também pode ser usado para o algoritmo
23 intercalado, a levar, como esperado, a exatamente a mesma eficiência.</p>
24 <table border="1">
25 <tr><td>Quantidade de discos</td><td>Intercalada</td><td>Slow Split</td><td>Fast Split</td></tr>
26 <tr><td>5 pares</td> <td> 62 movimentos</td> <td> 88 movimentos </td><td> 46 movimentos</td></tr>
27 <tr><td>6 pares</td> <td>126 movimentos</td> <td>183 movimentos </td><td> 82 movimentos</td></tr>
28 <tr><td>7 pares</td> <td>254 movimentos</td> <td>374 movimentos </td><td>150 movimentos</td></tr>
29 </table>
30
31 <p>Como uma conclusão, a maioria das pessoas se satisfaz com uma solução que
32 funcione e rapidamente ignora possibilidades para melhorar a decomposição do
33 problema. <b>Você</b> não deve fazer isto ;)</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Hanoi de tricolor: movimentação de pilhas</h2>
3
4 <p>Neste conjunto de exercícios, vamos "devise" um algoritmo para o problema de
5 Hanoi Tricolor. Vão existir 3 pilhas em 3 varas, cada pilha de uma cor
6 diferente e o problema é alternar a posição das pilhas seguindo as regras
7 clássicas do movimento (um disco por vez, disco grande não pode ficar sobre
8 disco pequeno).</p>
9
10 <p>Como nos exercícios anteriores, nossa solução vai usar três funções:</p>
11 <ul>
12 <li><code>move3(n, src, mid, dst)</code>: move uma pilha de discos intercalados,
13 p.ex. uma pilha de (n*3) discos de cores alternadas de uma vara
14 <code>src</code> para uma vara <code>dst</code>.</li>
15 <li><code>gather()</code>: constrói uma pilha intercalada a partir de três
16 pilhas "split".</li>
17 <li><code>scatter()</code>: separa uma pilha intercalada em três pilhas normais.</li>
18 </ul>
19
20 <p>O objetivo deste primeiro exercício na série é "devise" a função
21 <code>move3()</code>. Esta tarefa inicial não o deve segurar muito, na
22 verdade. Tudo bem se a sua função muda a ordem do trio de discos mais no
23 fundo, mas ela deve preservar a ordem dos outros trios.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Tricolor Hanoi: the Gathering</h2>
3
4 <p>Agora é a hora de escrever a segunda função necessária para o problema de
5 Hanoi Tricolor. <code>gather()</code> constrói uma pilha intercalada a
6 partir de pilhas "split". Esta função recebe quatro argumentos, o último a
7 ser a vara de destino onde a pilha intercalada deve ser montada. Como pode
8 ver nos exemplos, as cores devem estar na mesma ordem para cada trio de
9 discos.</p>
10
11 <p>Esta função, na verdade, usa o <code>move3()</code> que escreveu agora a
12 pouco. Simplesmente copie-e-cole o seu código e reuse-o. Se estiver perdido,
13 favor olhe o exercício Hanoi Intercalada. Obter 3 pilhas em 3 varas é muito
14 similar a obter 2 pilhas em 4 varas. Pode encontrar este exercício <a
15 href="plm://lessons.recursion.hanoi/InterleavedHanoi">aqui</a>.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Hanoi Tricolor: o Final</h2>
3
4 <p>Estamos quase prontos para escrever o algoritmo tricolor. Precisamos apenas
5 da função <code>scatter()</code>, bastante inspirada na primeira que
6 escrevemos para o <a
7 href="plm://lessons.recursion.hanoi/SplitHanoi1">problema de Hanoi
8 Separado</a>. A assumir que a sua pilha intercalada esteja na vara do
9 <code>meio</code>, espalhe os discos por todas as varas. Certifique-se de
10 usar <code>move3()</code> uma quantidade par de vezes em cada nível
11 recursivo para garantir que os discos de baixo estejam na ordem correta.</p>
12
13 <p>Como pode ver, a situação inicial não é a esperada por
14 <code>scatter()</code>. Primeiro tem que aplicar <code>gather()</code> e
15 <code>move3()</code> (duas vezes para pôr o trio do fundo na ordem
16 correta). Estes poucos passos mais a nova função <code>scatter()</code> são
17 o suficiente para resolver inteiramente o problema de Hanoi Tricolor.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Torres de Hanoi</h3>
3 <p>Aqui está o exercício super-clássico de recursão.</p>
4
5 <p>Este é um exercício de aplicação em recursão, que deve dominar para fazer
6 esta lição.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>HanoiWorld</h1>
3
4 <p>
5 Este mundo implementa o problema ultra clássico das torres de Hanói. Deve
6 mover a pilha de discos da pilha onde eles estão para outra pilha (dado um
7 segundo parâmetro no nome do mundo -- número 1 para o mundo
8 predefinido). Existem algumas restrições adicionais: pode mover apenas um
9 disco por vez e não pode pôr um disco sobre um menor.</p>
10
11 <p>Apenas 4 funções são fornecidas:</p>
12
13 <pre>[!java|c]void [/!]mover([!java|c]int [/!]src, [!java|c]int [/!]dst)</pre>
14
15 Move um disco da vara <code>src</code> para a vara <code>dst</code>. Se
16 tentar fazer um movimento inválido (como pôr um disco sobre outro menor),
17 uma IllegalArgumentException é lançada.
18
19 <pre>[!java|c]int [/!]getTamanhoSlot([!java|c]int [/!]slot)[!scala]:Int[/!]</pre>
20 Retorna a quantidade de discos postos num ponto específico. É usado
21 principalmente para inicializar a recursão e ajustar a quantidade de
22 chamadas recursivas para executar.
23
24 <pre>[!java|c]int [/!]getSlotRadius([!java|c]int [/!]slot)[!scala]:Int[/!]</pre>
25 Retorna o raio do disco no topo da vara especificada.
26
27 <pre>[!java]boolean [/!][!c]int [/!]isSelected()[!scala]:Boolean[/!]</pre>
28 Retorna true se o mundo atual está selecionado na interface gráfica.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Algoritmos recursivos</h1>
3 Esta lição permite que se experimente com algoritmos recursivos.
4
5 <p>Se precisa de mais algoritmos recursivos, um exercício em algoritmos de
6 ordenação recursivos (em particular QuickSort e MergeSort) está planejado no
7 futuro dentro da lição de ordenação.</p>
8
9 <h3>O que ru posso fazer para melhorar esta lição?</h3>
10
11 <p>Como sempre, existem várias coisas que podem ser feitas nesta lição para
12 melhorar ela ainda mais:</p>
13 <ul>
14 <li>O triângulo de Sierpinski pode ser desenhado a usar um L-system mais
15 simples. Veja em http://jpvallon.free.fr/recursivite.html</li>
16 <li>A curva "arrowhead" também é interessante:
17 http://www.mathcurve.com/fractals/sierpinski/sierpinskitriangle.shtml</li>
18 <li>A curva do dragão pode ser explicada como um L-system:
19 http://ecademy.agnesscott.edu/~lriddle/ifs/heighway/heighway.htm</li>
20 <li>A curva do dragão2 é chamada de "twin dragon":
21 http://ecademy.agnesscott.edu/~lriddle/ifs/heighway/twindragon.htm</li>
22 <li>As curvas de preenchimento de spaço podem ser adicionadas (Peano, Hildebert,
23 etc). Veja: http://teachout1.net/village/fill.html </li>
24 <li>Podemos fazer outro exercício em polígonos "embeeded":
25 http://www.inrialpes.fr/helix/people/genoud/ENSJAVA/tds/sujets/dessinsReccursifs/actionsrecursives.html</li>
26 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Curva do Dragão (1)</h2>
3
4 <p>A curva do dragão é um exemplo clássico de método recursivo.</p>
5
6 <p>A definição desta curva é a seguinte:<br/>
7 A curva do dragão de ordem 1 é um vetor entre dois pontos P e Q arbitrários,<br/>
8 A curva do dragão de ordem n é a curva do dragão de ordem n-1 entre P e R,
9 seguida da mesma curva de ordem n-1 entre Q e R, onde PRQ é um triângulo
10 isósceles com o ângulo em R a ser um ângulo reto e R situado a direita do
11 vetor PQ. Logo, se as coordenadas P e Q são (x, y) e (z, t), as coordenadas
12 (u, v) de R são dadas por:</p>
13 <pre>
14 u = (x + z)/2 + (t - y)/2
15 v = (y + t)/2 - (z - x)/2
16 </pre>
17
18 <p>O protótipo do método a desenhar a curva é o seguinte:</p>
19 <pre>[!java|c]void [/!]dragão([!java|c]int [/!]ordem[!scala]:Int[/!], [!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double [/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], [!java|c]double [/!]t[!scala]:Double[/!])</pre>
20
21
22 <p>Deve usar o método <code>setPos(x,y)</code> para pôr a sua tartaruga nas
23 coordenadas (x,y) e o método <code>moveTo(z,t)</code> para desenhar uma
24 linha entre a posição da tartaruga e o ponto (z,t).</p>
25
26 <p>Dê uma olhada em cada visão de mundo objetivo para entender como escrever a
27 função.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>A curva do dragão (2)</h2>
3
4 <p>A solução anterior "induz" que a tartaruga se teleporta para outro local, ou
5 pelo menos, que ela levanta a caneta durante o desenho. Na verdade, o final
6 do desenho da primeira chamada recursiva não coincide com o começo da
7 segunda chamada recursiva. É por isto que temos que usar o método
8 <code>setPos()</code></p>
9
10 <p>Nesta lição, vai escrever um método recursivo que permita desenhar a curva
11 do dragão sem levantar a caneta. Para isto, precisamos de outro método
12 recursivo que desenhe o lado espelhado da curva.</p>
13
14 <p>O método <code>dragon()</code> é então definido recursivamente a usá-lo
15 próprio e <code>dragonReverse()</code>. Da mesma forma, o método
16 <code>dragonReverse()</code> é definido recursivamente a usá-lo próprio e
17 <code>dragon()</code>. Este é, portanto, um exemplo de <i>recursão
18 mútua</i>.
19 </p>
20
21 <p>
22 O protótipo do método <code>dragon()</code> é o mesmo do exercício anterior:</p>
23 <pre>[!java|c]void [/!]dragão([!java|c]int [/!]ordem[!scala]:Int[/!], [!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double [/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], [!java|c]double [/!]t[!scala]:Double[/!])</pre>
24
25 <p>A coordenada do novo ponto (u, v) introduzida pelo <code>dragon()</code> é:</p>
26 <pre>
27 u = (x + z)/2 + (t - y)/2
28 v = (y + t)/2 - (z - x)/2
29 </pre>
30
31 <p>O protótipo do método <code>dragonReverse</code> é similar:</p>
32 <pre>[!java|c]void [/!]inverterDragão([!java|c]int [/!]order[!scala]:Int[/!], [!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double [/!]y[!scala]:Double[/!], [!java|c]double [/!]z[!scala]:Double[/!], [!java|c]double [/!]t[!scala]:Double[/!])</pre>
33
34 <p>A coordenada do novo ponto (u, v) introduzida pelo
35 <code>dragonReverse()</code> é:</p>
36 <pre>
37 u = (x + z)/2 - (t - y)/2
38 v = (y + t)/2 + (z - x)/2
39 </pre>
40
41 <p>Para deixar o trabalho de cada um dos dois métodos recursivos mais visíveis,
42 a linha pintada pelo <code>dragon()</code> deve ser vermelha
43 (<code>Color.red</code>) enquanto a linha pintada pelo
44 <code>dragonReverse()</code> deve ser azul(<code>Color.blue</code>).</p>
45
46 <p>Dê uma olhada em cada visão de mundo objetivo para entender como escrever a
47 função.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Carangueijo Fractal</h2>
3
4 <p>A curva do carangueijo não é exatamente uma curva de Koch, mas ainda é um
5 fractal e e construída de forma similar. Desta vez, vamos crescer um
6 triângulo retângulo na lateral da figura: o ângulo é de 45 graus e o
7 comprimento é dividido por
8 [!java|scala]Math.sqrt(2)[/!][!python]math.sqrt(2)[/!][!c]sqrt(2);[/!] em
9 cada passo.</p>
10
11 <p>Verifique as figuras produzidas pelos primeiros passos da recursão para
12 entender o padrão.</p>
13
14 <h3>nota bibliográfica</h3>
15 <p>Esta curva, também chamada de curva C de Lévy foi inventada em 1938 pelo
16 matemático francês Paul Lévy in 1938. Como sempre, a página da wikipédia é
17 bem instrutiva, além de fornecer ótimos extras: <a
18 href="http://www.mathcurve.com/fractals/c/c.shtml">http://www.mathcurve.com/fractals/c/c.shtml</a>.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Snow hexagon</h2>
3
4 <p>Agora vamos desenhar a curva conhecida por curva (6, 0.14)-Koch. Isto
5 significa que tem que crescer polígonos de 6 lados nos segmentos e que o
6 comprimento deve ser multiplicado por 0.14 em cada nível de recursão. </p>
7
8 <p>Para que conste, a curva de Koch original é a curva (3, 1/3)-Koch, a Snow
9 square será a curva (4,1/3)-Koch enquanto a Snow pentagon é também chamada
10 de curva (5, 0.4)-Koch. Se quiser, pode mudar ao modo criativo no menu e
11 explorar livremente outras curvas de Koch. Simplesmente mude a chamada
12 inicial de hexaKoch para o que quiser.</p>
13
14 <p>Para mais referências, favor ler <a
15 href="http://ecademy.agnesscott.edu/~lriddle/ifs/kcurve/kcurve.htm">http://ecademy.agnesscott.edu/~lriddle/ifs/kcurve/kcurve.htm</a>.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Floco de neve</h2>
3
4 Vamos agora desenhar flocos de neve a usar o Koch fractal. Um fractal é um
5 padrão geométrico repetido em cada escala.
6
7 <p>A forma geral é um triângulo, com cada lado dado por várias chamadas
8 recursivas. O seu trabalho é apenas escrever o código do método
9 <code>snowSide</code> de forma que desenhe um lado do triângulo. Para
10 facilitar, cada um dos lados é representado numa cor
11 específica. Simplesmente desenhe as coisas vermelhas (sem mudar a cor da sua
12 caneta) e as outras cores serão desenhadas automaticamente. </p>
13
14 <p>Observe o desenho em cada um dos mundos objetivo para entender a lógica do
15 padrão e então reproduza ele. No nível 0, a curva de Koch é apenas uma linha
16 reta. No nível 1, a curva é dividida em três terços e a parte média é
17 substituída pelos dois lados de um triângulo equilátero do mesmo comprimento
18 do segmento a ser removido. No nível 2, o processo é repetido, com cada um
19 dos segmentos dividido em três partes e a parte do meio a ser substituída
20 pelos dois lados de um triângulo equilátero.</p>
21
22 <p>O pseudo-código do caso geral é o seguinte:</p>
23 <pre>
24 Desenhe recursivamente um segmento menor
25 Gire 60 graus para a esquerda
26 Desenhe recursivamente um segmento menor
27 Gire 120 graus para a direita
28 Desenhe recursivamente um segmento menor
29 Gire 60 graus para a esquerda
30 Desenhe recursivamente um segmento menor
31 </pre>
32 <p>Como pode ver, a função forward() não é chamada no caso recursivo, apenas no
33 caso base quando não existe chamada recursiva.</p>
34
35
36 <p><div class="tip" id="tip-1" alt="Muitas letras. Favor "picture it".">
37 <p>Aqui estão os resultados dos primeiro níveis da recursão.</p>
38 <img src="KochHint.png" />
39 </div></p>
40
41 <p>Deve escrever o método <code>snowSide()</code>, que é recursivo mas <b>não
42 chame snowFlake de dentro de snowSide</b>, ou vão acontecer resultados
43 estranhos e inesperados.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Snow pentagon</h2>
3
4 <p>Aqui vai outra variação da curva de Koch. desta vez, vamos crescer pequenos
5 pentágonos (ie, polígonos com cinco lados cada). Tenho certeza que agora
6 compreendeu.</p>
7
8 <p>Outra diferença com o anterior é que o comprimento não é mais dividido por
9 três em cada passo, mas multiplicado por 0.4. A curva parece melhor desta
10 forma :)</p>
11
12 <p>Desenhamos apenas um lado neste exercício de forma que o seu código vai ser
13 chamado apenas uma vez agora.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Snow square</h2>
3
4 <p>Este exercício é uma variação sobre o snow flake que vimos previamente. A
5 principal diferença é que vamos fazer crescer pequenos quadrados ao invés de
6 triângulos nos lados da figura.</p>
7
8 <p><div class="tip" id="tip-1" alt="Desculpe, não vi isto. Favor "picture it".">
9 <p>Aqui estão os resultados dos primeiro níveis da recursão.</p>
10 <img src="SquareKochHint.png" />
11 </div></p>
12
13
14 <p>Como anteriormente, a sua função <code>squareSide</code> deve apenas
15 desenhar um lado da figura e o modelo vai chamar ela para todos os lados
16 automaticamente (com uma cor por lado).</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Fractal de polígonos</h2>
3
4 O fractal que vamos desenhar agora é formado de um polígono, com pequenos
5 polígonos em cada canto. O protótipo do método que vai desenhá-lo é o
6 seguinte:
7 <pre>[!java|c]void [/!]fractalDoPolígono ([!java|c]int [/!]níveis[!scala]:Int[/!], [!java|c]int [/!]lados[!scala]:Int[/!], [!java|c]double [/!]comprimento[!scala]:Double[/!], [!java|c]double [/!]shrink[!scala]:Double[/!])</pre>
8
9 <p>Dê uma olhada em cada visão de mundo objetivo para entender como escrever a
10 função.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>As bases da recursão</h3>
3 <p>Descobrir a forma recursiva de pensar a desenhar árvores e outras figuras
4 com a tartaruga do Logo.</p>
5
6 <p>Para fazer esta lição deve dominar as bases da programação.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Triângulo de Sierpinski</h2>
3
4 <p>O fractal que vamos desenhar é formado de um grande triângulo dentro do qual
5 há vários pequenos triângulos. O protótipo da função que desenha isto é o
6 seguinte:</p>
7 <pre>[!java|c]void [/!]sierpinski([!java|c]int [/!]nível[!scala]:Int[/!], [!java|c]double [/!]comprimento[!scala]:Double[/!])</pre>
8
9 <p>Dê uma olhada em cada uma das visões do mundo objetivo para entender como
10 escrever a função. Para desenhar um lado do triângulo, desenhe um triângulo
11 recursivo menor (metade do comprimento) e mova para a frente a distancia
12 desejada. Globalmente, tem que desenhar 3 destes lados e girar 120 graus a
13 cada lado.</p>
2727 spiral(0,90,12,3);
2828 </pre>
2929
30 Notez que vous n'avez que cette fonction à écrire, pas l'appel
31 initial. Chaque monde fournira un ensemble spécifique de paramètres pour
32 votre fonction. Utilisez le combobox en haut à droite pour voir les autres
33 mondes. Par exemple, le monde "Pyramide carrée" appellera votre fonction de
34 la manière suivante :
3035
36 <pre>
37 spiral(100, 90, 0, 3);
38 </pre>
2626 spiral(0,90,12,3);
2727 </pre>
2828
29 Note that you only have to write the function, not the initial call.
30 Each world will provide a specific set of initial parameters (use the
31 combobox to switch to other worlds). For example, the "Square Pyramid"
32 world will call your function as follows:
2933
34 <pre>
35 spiral(100, 90, 0, 3);
36 </pre>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Espirais</h2>
3
4 Vamos agora desenhar nossa primeira função recursiva com a tartaruga. O
5 objetivo é desenhar diferentes tipos de espirais com a mesma função, cujo
6 protótipo é o seguinte:
7 <pre>[!java|c]void [/!]espiral([!java|c]int [/!]passos[!scala]:Int[/!], [!java|c]int [/!]ângulo[!scala]:Int[/!], [!java|c]int [/!]comprimento[!scala]:Int[/!], [!java|c]int [/!]incremento[!scala]:Int[/!])</pre>
8
9 Para ajudar a entender como escrever isto, aqui está um exemplo de como os
10 parâmetros mudam durante uma chamada específica:
11 <pre>
12 espiral(5, 90, 0, 3);
13 avançar(0);
14 esquerda(90);
15 espiral(4,90,3,3);
16 avançar(3);
17 esquerda(90);
18 espiral(3,90,6,3);
19 avançar(6);
20 esquerda(90);
21 espiral(2,90,9,3);
22 avançar(9);
23 esquerda(90);
24 espiral(1,90,12,3);
25 avançar(12);
26 esquerda(90);
27 espiral(0,90,12,3);
28 </pre>
29
30 Note que só tem de escrever a função, não a chamada inicial. Cada mundo irá
31 fornecer um conjunto específico de parâmetros iniciais (use a combobox para
32 mudar para outros mundos). Por exemplo, o mundo "Pirâmide Quadrada" irá
33 chamar a sua função da seguinte forma:
34
35 <pre>
36 spiral(100, 90, 0, 3);
37 </pre>
2727 espiral(0,90,12,3);
2828 </pre>
2929
30 Note that you only have to write the function, not the initial call. Each
31 world will provide a specific set of initial parameters (use the combobox to
32 switch to other worlds). For example, the "Square Pyramid" world will call
33 your function as follows:
3034
35 <pre>
36 spiral(100, 90, 0, 3);
37 </pre>
2727 spiral(0,90,12,3);
2828 </pre>
2929
30 Note that you only have to write the function, not the initial call. Each
31 world will provide a specific set of initial parameters (use the combobox to
32 switch to other worlds). For example, the "Square Pyramid" world will call
33 your function as follows:
3034
35 <pre>
36 spiral(100, 90, 0, 3);
37 </pre>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Desenhar espirais</h2>
3
4 <p>Este exercício não é realmente um exercício pois tem que simplesmente clicar
5 no botão Executar para ter uma recompensa: todo o código necessário já está
6 pronto. Na verdade, pode explorar as possibilidades do código que acabou de
7 escrever a mudar os parâmetros da chamada da função
8 <code>spiral</code>. Pode mover ao próximo exercício se estiver com pressa e
9 voltar depois para experimentar este.</p>
10
11 <p>Aqui estão algumas figuras que pode produzir com a sua função
12 <code>Spiral</code>, dado que passe os parâmetros certos. Pode mudar ao modo
13 criativo (do menu Exercício) para desativar a comparação de mundos quando
14 estiver a explorar com estas espirais.</p>
15
16 <img src="example-1.png"/>
17 <!-- spiral(100,120+1,1,2) -->
18 <img src="example-2.png"/>
19 <!-- spiral(5,360/5,100,0) -->
20 <img src="example-3.png"/>
21
22 <!-- spiral(5,2*360/5,150,0) -->
23 <img src="example-4.png"/>
24 <!-- spiral(360,1,1,0) -->
25 <img src="spiral-300-98-10-1.png"/>
26
27 <p>Se descobrir uma figura legal, não se esqueça de enviar os seus parâmetros
28 (menu Ajuda/"Dizer o que achou") para que possamos adicionar a esta lista!</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Os primos menores dos buggles</h2>
3 <p>
4 Hoje vamos conhecer os primos menores dos buggles: as tartarugas. Na
5 verdade, as tartarugas são muito mais velhas que os buggles. Elas foram
6 inventadas nos anos 70 por um cientista do MIT chamado Seymour Papert para
7 ajudar no ensino de programação e os buggles são uma variação da idéia
8 seguinte de Lyn Turbak do Wellesley College.
9 </p>
10 <p>Tartarugas então, são meio parecidas com buggles, mas menores. Como os
11 buggles, pode mandar que elas se movam para a frente, virem, se movam para
12 trás, etc. Como os buggles, elas deixam uma linha no caminho por onde passam
13 (mas a linha é muito menor).</p>
14
15 <p>A principal diferença é que enquanto os buggles podem se mover apenas em
16 ângulos retos, as tartarugas podem se mover em qualquer ângulo especificado
17 por um número real (um double). Isto dá-lhes muito mais liberdade nos
18 movimentos deles. Já os buggles podem fazer vários outros truques, como ler
19 e escrever mensagens, apanhar e soltar objetos e às vezes lidar com paredes
20 existentes nos mundos (mas isto está totalmente além da capacidade das
21 tartarugas).</p>
22
23 <p>De um ponto de vista prático, a maioria dos métodos que conhece sobre
24 buggles ainda funciona com tartarugas, com pequenas adaptações. Em
25 particular, o método <code>forward()</code> leva a quantidade de passos a
26 dar não como inteiro, mas como [!python]point
27 number[/!][!java|scala|c]double[/!] (veja "Sobre este mundo" para maiores
28 detalhes).</p>
29
30 [!java|scala|c]
31 <h3>Doubles? Mas o que é isto?</h3>
32 é simplesmente um número com vírgula. Por exemplo:
33 <pre>
34 double x = 3.72;
35 x + 1.234 // Valor = 4.954
36 x + 2. // Valor = 5.72 (2. significa 2.0)
37 x + 2 // [!java|c]Value = 5.72 (2 convertido automaticamente em 2.0)[/!][!scala]Erro de tipo (o operador + não mistura Double e Int); é obrigatória a conversão manual[/!]
38 x * 2. // Valor = 7.44
39 x / 2. // Valor = 1.86
40 [!java|c](int) x[/!][!scala]x.asInstanceOf[Int][/!] // Valor = 1 (“a fazer cast para int”, convertido para integer a truncar)
41 Math.round(x) // Valor = 2 (1.86 arredondado ao inteiro mais próximo)
42 Math.floor(x) // Valor = 1 (1.86 rounded toward minus infinity)
43 Math.floor(-5.12) // Valor = -6 (rounded toward minus infinity)
44 Math.ceiling(x) // Valor = 2 (1.86 rounded toward plus infinity)
45 Math.ceiling(-5.12) // Valor = -5 (rounded toward plus infinity)
46 [!java|c](double) 17[/!][!scala]17.asInstanceOf[Double][/!] // Valor = 17.0 (“feito cast para double”, convertido para double)
47 </pre>
48 [/!]
49
50 <h3>Objetivo deste exercício</h3>
51 <p>Mesmo este a ser o primeiro exercício da lição de recursividade, o código
52 que tem que escrever não é recursivo. O objetivo é se familiarizar com o
53 mundo da tartaruga antes da coisa começar a ficar séria.</p>
54
55 <p>Deve reproduzir uma pintura geometricamente simples de quatro quadrados de
56 comprimento de 100 passos (veja o mundo objetivo para mais detalhes). É
57 obviamente uma boa ideia escrever um método para desenhar um quadrado e
58 então usá-lo no nosso código.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Árvores</h2>
3
4 <p>Vamos agora construir árvores. Para isto, vamos escrever um método a usar
5 recursão dupla a seguir este protótipo</p>
6 <pre>[!java|c]void [/!]árvore([!java|c]int [/!]passos[!scala]:Int[/!], [!java|c]double [/!]comprimento[!scala]:Double[/!], [!java|c]double [/!]ângulo[!scala]:Double[/!], [!java|c]double [/!]shrink[!scala]:Double[/!])</pre>
7
8 <p>Para desenhar uma árvore de quatro níveis, deve desenhar um tronco do
9 comprimento dado, virar à direita num ângulo dado, desenhar uma árvore de
10 nível 3, virar a esquerda duas vezes no ângulo dado, desenhar outra árvore
11 de nível 3 e voltar à posição inicial. Não se esqueça de voltar à posição
12 inicial!<p>
13
14 <p>Se um tronco da árvore é de comprimento 'len', o tronco da árvore no próximo
15 nível será de comprimento 'len*shrink'.<p>
16
17 <p>Finalmente, aqui está o pseudo-código do caso geral (deve adicionar o caso
18 base por si só):</p>
19 <pre>
20 Mova para a frente no comprimento desejado
21 Desenhe (recursivamente) a sub-árvore da direita
22 Desenhe (recursivamente) a sub-árvore da esquerda
23 Mova para trás para a posição inicial
24 </pre>
25 <p>Não se esqueça de adicionar o caso base ao seu código, ou o seu buggle vai
26 entrar num loop infinito. Então, desenhar a sub-árvore da direita é virar a
27 direita e desenhar a sub-árvore.</p>
28
29 <p>Como pode ver, cada nível de recursão é representado por uma cor
30 diferente. Para isto, tem que chamar o <code>current(step)</code>, passar o
31 nível de recursão atual como parâmetro. Isto vai escolher a cor certa para
32 si. Não apague as suas belas cores quando se mover de volta para sua posição
33 inicial.</p>
34
35 <p>Se a função foi feita errada, pode rapidamente ficar muito difícil de
36 depurar, pois, os erros vão aparecer em cada nível da recursão, a mudar
37 completamente o desenho. Por questões de depuração, pode usar o
38 <code>subtree()</code> que vai desenhar uma sub-árvore corretamente. Esta
39 função é, portanto muito similar àquela que está a tentar escrever. A única
40 diferença é que <code>subtree()</code> apenas desenha em preto. Logo, pode
41 usar ela no lugar da chamada recursiva para depurar o seu código, mas vai
42 ter que mudar para uma chamada recursiva adequada no seu próprio código (uma
43 vez que funcione) para obter as cores certas e passar no exercício.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Bubble Baseball</h1>
3
4 <p>Puxa, adaptamos o insertion sort por que o selection sort precisava de
5 muitos movimentos para pôr os jogadores selecionados nas posições deles, mas
6 o insertion sort necessita de uma quantidade estúpida de mudanças para
7 alcançar os elementos de fronteira para as posições deles dentro da área
8 ordenada sem bagunçar os elementos já ordenados. No final, a nossa variante
9 "selection" era mais eficiente com pelo menos <code>3*amountOfBase</code>
10 movimentos para ordenar um elemento (1 para alcançar o espaço vazio ao lado
11 do jogador e 2 para pôr o espaço vazio e o jogador em posição) enquanto a
12 nossa variante "insertion" precisa de no máximo
13 <code>3*amountOfPlayers</code> para ordenar um elemento (2 para descer o
14 espaço vazio e o jogador na posição, 1 para trazer o espaço vazio de volta
15 para a posição dele). Isto é duas vezes pior que ter dois jogadores por
16 base. Pode ser possível melhorar o insertion sort a mover mais que um
17 elemento enquanto desce, mas parece difícil (pelo menos, enquanto não
18 misturar os elementos já ordenados) e provavelmente isto apenas vai garantir
19 que a nossa variante "insertion" se torne tão eficiente como a nossa
20 variante "selection", não dramaticamente melhor.</p>
21
22 <p>Se não pudermos tornar o ordenamento mais rápido, podemos torná-lo mais
23 fácil. Se pensar a respeito, parece natural adaptar a ordenação bolha para
24 este problema: o buraco se torna a bolha que se move para cima e para baixo,
25 a ordenar um pouco o array a cada passagem. As linhas grandes são simples:
26 "enquanto (while) não estiver ordenado, mova o buraco para baixo até a base
27 0 (a mover o maior jogador de cada base em cada passo) e então de volta à
28 base maximal (a mover o menor jogador de cada base)". Depois de algum tempo,
29 <code>isSorted()</code> vai retornar true e o seu algoritmo vai parar.</p>
30
31 <p>Isto é tão fácil que vamos introduzir outra variante do problema, com mais
32 de dois jogadores por base. Mas isto não vai te segurar por muito tempo, né?</p>
33
34 <p>Surpreendentemente, a variante bubble sort precisa de menos movimentos que
35 as outras variantes. Isto é fantástico, por que normalmente, o bubble sort é
36 muito pior que os outros algoritmos, mas isto é graças à boa combinação
37 entre as linhas grandes deles e o universo do basebol. E, na verdade,
38 acontece bastante de um algoritmo escrito de forma agradável executa de
39 forma bem decente. Mas isto não é uma regra universal, como foi demonstrado
40 pelo algoritmo simplório do primeiro exercício, que era legal, simples e
41 errado ;)</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Insertion Baseball</h1>
3
4 <p>O aspeto bom de adaptar o selection sort para o problema do basebol é que
5 sabemos que isto funciona (desde que a nossa adaptação esteja correta). O
6 que é muito melhor que o nosso primeiro e simplório algoritmo, que é incapaz
7 de convergir à solução em algumas situações. Mas, na verdade, o selection
8 sort também não é perfeito, pois requer muitas trocas: temos que trazer o
9 espaço vazio para e jogador selecionado e então levar o jogador e o espaço
10 vazio à posição e mais. Podemos fazer melhor.</p>
11
12 <p>Por exemplo, cada jogador pode correr por uma longa distância da posição
13 inicial dele para o objetivo. Portanto, pode ser mais interessante dividir o
14 campo em duas partes: uma à esquerda onde todos os jogadores estejam
15 ordenados relativamente uns aos outros e outra à direita onde os jogadores
16 ainda estejam nas posições iniciais deles. Então, em cada iteração,
17 escolhemos o jogador na fronteira entre as áreas ordenada e não ordenada (ou
18 sejam o jogador mais à esquerda da parte não ordenada) e moveremo-lo para a
19 esquerda (dentro da parte ordenada) até que alcance a posição dele (ou seja,
20 até a posição onde seja maior que o vizinho dele da esquerda). Isto pode,
21 pelo menos, reduzir o trajeto dos jogadores à área ordenada já que usamos o
22 mais perto da fronteira.</p>
23
24 <p>Na verdade, é exatamente isto que o insertion sort deve fazer: manter uma
25 área ordenada na esquerda e pôr iterativamente o jogador na fronteira com
26 esta posição dentro da área ordenada. Isto é bom, já que sabemos que nosso
27 algoritmo não é inerentemente "flawed" pois adaptamos um algoritmo bem
28 conhecido.</p>
29
30 <p>O mais fácil de adaptar o insertion sort ao problema do basebol é considerar
31 todas as posições como adjacentes e esquecer-se das bases. Para isto,
32 definimos os métodos <code>getColor[!c]Insert[/!](pos)</code>,
33 <code>move[!c]Insert[/!](pos)</code> e <code>getHole[!c]Insert[/!]()</code>
34 que usam, todos, um único inteiro para designar uma dada posição. Estas
35 funções simplesmente convertem a forma de especificar uma posição para em
36 seguida chamar as funções usuais para interagir com o mundo. Se tem um
37 <code>index</code> e quer convertê-lo a <code>base,pos</code>, para então a
38 <code>base=index/2</code> e <code>pos=index%2</code>. Para calcular o
39 reverso, <code>index=base*2+pos</code> (isto funciona, pois
40 <code>getPositionsAmount()</code> sempre retorna 2).</p>
41
42 <p>Para o algoritmo em si, deve primeiro mover o espaço vazio à posição 1. A
43 posição 0 é considerada como a área ordenada (de tamanho 1 por enquanto)
44 enquanto que a área acima de 2 é a área não-ordenada. Então fazemos uma
45 iteração para ordenar cada elemento da área não-ordenada. Já que esta
46 iteração é um pouco complexa, deve pensar no invariante dela do loop, ou
47 seja, a condição que é verdadeira antes e depois do loop e que explica que o
48 loop satisfaz o objetivo dele. Aqui, o invariante do loop é duplo: Primeiro,
49 o espaço vazio está entre a área ordenada e a não-ordenada is between the
50 sorted area and the unsorted area, and then, the every elements of the
51 sorted area are ... well sorted relatively to their neighbors.</p>
52
53 <p>Então, o corpo do loop para ordenar um elemento deve primeiro empurrar para
54 baixo o espaço vazio e os elementos dentro da área ordenada até que o
55 elemento seja maior que o elemento que está depois na área ordenada (2
56 movimentos por posição para se mover) e então mover o espaço vazio de volta
57 para sua posição entre as áreas ordenadas e não-ordenadas (1 movimento por
58 posição).</p>
59
60 <p>Uma vez que insira o último elemento dentro da área ordenada, o seu conjunto
61 como um todo estará ordenado e terá terminado. Vou deixar como surpresa os
62 casos da fronteira que vão precisar de alguns pequenos ajustes no seu
63 algoritmo para funcionar corretamente :)</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>O jogo do basebal multicores</h1>
3
4 <p>Esta atividade é inspirada do jogo orange, do repositório de atividades
5 "Computer Science Unplugged". Foi entretanto profundamente alterada,
6 primeiro para o CSIRL (o meu repositório de atividades unplugged
7 <i>livres</i> para introduzir a ciência da computação, disponível em
8 http://www.loria.fr/~quinson/Mediation/SMN/) e agora para o PLM.</p>
9
10 <p>Na literatura, a forma geral deste problema é conhecida como o "Pebble
11 motion problem" (as bases podem ser conectadas por qualquer tipo de grafo e
12 a afinidade das "pebbles" com bases pode ser diferente). Outra variante
13 deste problema é o famoso jogo do 15, com um jogador por base e um tabuleiro
14 quadrado bidimensional. Mais informações sobre estes problemas encontram-se
15 na wikipédia em inglês, como sempre.</p>
16
17 <h3>Como sabe que o algoritmo simplório não vai entrar em loop nesta situação
18 inicial?</h3>
19
20 <p>Bem, simplesmente testamos todas as situações possíveis para ver quando este
21 algoritmo entra em loop e quando acha a solução correta. Verificamos que
22 funciona em todas as situações onde nenhum jogador está na casa dele
23 (existem 84 situações destas para 4 bases, a considerar as
24 simetrias). Obviamente funciona para algumas situações que não respeitam
25 este critério (como todas as situações que encontra desde uma dessas 84
26 bases até ao estado final), mas isto é outra história. Dado tal critério
27 podemos gerar situações iniciais pseudo-aleatórias para o primeiro exercício
28 para o qual o algoritmo que propomos com certeza funciona.</p>
29
30 <p>Também exploramos instâncias maiores do problema e infelizmente, não temos
31 tal critério para elas. Com 5 bases, o algoritmo entra em loop de forma
32 errada para 24 dos 1824 possíveis tabuleiros onde nenhum jogador está na
33 casa dele (que dá 1.31%). Com 6 bases, falha em 1251 dos 58860 tabuleiros
34 (2.12%). Com 7 bases, falha em 84444 dos 2633940 (3.2%). Ainda estou à
35 procura dum critério que garanta que o algoritmo não vai entrar em loop. Se
36 descobrir um, por favor avise. Idealmente, deve ser simples garantir
37 manualmente de forma que possamos usá-lo durante as nossas atividades
38 "unplugged".</p>
39
40 <h3>O que posso fazer para melhorar este universo do PLM?</h3>
41
42 <p>Como sempre, existem várias coisas que podem ser feitas no código deste
43 universo para melhorá-lo:</p>
44 <ul>
45 <li>Outras representações gráficas podem ser propostas, tais como uma linear
46 (para os exercícios existentes) ou outros (como um grid ou uma árvore, se um
47 exercício neste tipo de grafo se mostrar interessante).</li>
48 <li>Outros exercícios em outros algoritmos desta variante, ou em outras
49 variantes como o jogo do 15.</li>
50 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Basebal do arco-íris simples</h1>
3
4 <p>Hoje os buggles decidiram jogar um jogo de basebal, mas eles estão sem muita
5 sorte, na verdade. Primeiro, eles esqueceram-se das regras e... bem... eles
6 não acharam as bolas e tacos de novo. Então eles decidiram adaptar um pouco
7 as regras. Como eles não são bolas, tudo que podem fazer é correr ao redor
8 do campo, o que fazem felizes da vida: Por um período, todos os buggles
9 correram na máxima velocidade em todas as direções pelo campo.</p>
10
11 <p>Mas depois de algumas colisões eles decidiram inventar novas regras para
12 organizar o jogo um pouco: eles fizeram um time por base e dois jogadores
13 por time. Um dos times tem apenas um jogador de forma que a base deles tem
14 uma vaga. Então, os jogadores são despachados aleatoriamente entre as bases
15 e o jogo deles é encontrar a base de origem deles. O jogo como um todo para
16 quando todos os jogadores estão nas bases de origem delws. Não existe um
17 time vencedor: ou todo mundo ganha ou todo mundo perde. Na verdade, este
18 jogo é muito diferente do baseball original. A única regra que sobrou é que
19 só pode correr ao redor do campo, de uma base à próxima, sem cruzar o meio
20 do campo.</p>
21
22 <p>Agora, eles estão a pedir-lhe que lhes ajude a decidir quem se deve mover de
23 forma que cada jogador retorne à sua base de origem. Apenas um buggle pode
24 se mover por rodada, da posição dele para um espaço vazio. A distância
25 máxima que um buggle pode percorrer numa rodada é de uma base.</p>
26
27 <p>Logo, em cada turno, o espaço vazio fica numa base (digamos <code>B</code>)
28 e deve decidir que buggle vai entrar neste espaço vazio. Existem quatro
29 candidatos (dois de base <code>B-1</code> e dois da base
30 <code>B+1</code>). Na verdade, existe um quinto candidato pois o buggle que
31 está na mesma base que o espaço vazio pode mudar de posição, mas isto não
32 ajuda muito.</p>
33
34 <h3>O algoritmo simplório</h3>
35
36 <p>Neste exercício, vamos primeiramente explorar um algoritmo muito
37 simples. Para decidir qual dos quatro buggles candidatos deve entrar no
38 espaço vazio, vamos primeiro nos restringir e decidir que os buggles só
39 podem andar no sentido horário. Então, dos dois candidatos restantes,
40 escolhemos o que tem a maior distância a percorrer para alcançar a base
41 deles (no sentido horário). Clique no botão demo: isto funciona melhor, na
42 prática.</p>
43
44 <p>É difícil encontrar um algoritmo simples para este problema: Como não está
45 ordenado, busque pela base a conter os buggles candidatos: se o vazio
46 estiver na base <code>B</code>, será a base <code>B+1</code>, módulo a
47 quantidade de bases. Então, calcule a distância que cada buggle daquela base
48 ainda tem que andar para atingir a própria base (0 se já estiver na própria
49 base). Uma vez que encontra o buggle que deve entrar no vazio, simplesmente
50 use o método <code>move</code> nele e itere.</p>
51
52 <p>A principal dificuldade deve ser obter corretamente as poucas equações:
53 determinar a base próxima do espaço vazio deve ser fácil, mas determinar a
54 distância que um jogador tem que cobrir pode se revelar um pouco
55 desafiadora. Não hesite em desenhar esboços num papel para cobrir todas as
56 possibilidades. Não vai ser tão difícil no final das contas: não existem
57 tantos casos assim.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Selection Baseball</h1>
3
4 <p>O algoritmo anterior é muito agradável: é muito simples e muito rápido de
5 implementar, mas infelizmente, é também bastante errado! Em alguns casos,
6 nunca para, o que é obviamente ruim. Se não acredita, simplesmente copie e
7 cole o seu código anterior e aperte no botão executar. O primeiro mundo
8 deste exercício é uma destas situações infelizes que deixam endoidar o
9 algoritmo anterior.</p>
10
11 <p>Portanto temos que encontrar outro algoritmo, preferencialmente um que
12 funcione em todos os casos.</p>
13
14 <p>Para isto, a melhor solução é começar de um algoritmo bem conhecido ao invés
15 de tentar inventar um novo do zero como fizemos. Quando pensa um pouco sobre
16 este problema, ele pode ser muito similar a um problema de ordenação: apenas
17 se certifique de que todos os jogadores estão ordenados pelas cores deles. E
18 enquanto fazemos isto, vamos generalizar o jogo para poder ter mais de 4
19 bases.</p>
20
21 <p>Vamos adaptar o selection sort para nossa situação. As linhas grandes do
22 algoritmo se tornam "para cada base, selecione os jogadores que devem ocupar
23 esta base e garanta que eles venham às posições deles". Desta forma, vamos
24 aumentar uma área ordenada onde todos os jogadores já estão ordenados (e
25 nunca deixam de estar) enquanto a área não-ordenada se reduz.</p>
26
27 <p>Selecionar o jogador não deve ser um problema; Não hesite para definir
28 alguns métodos como <code>findPlayer()</code> ou
29 <code>findPlayerBase()</code>. Isto vai garantir que o seu código permaneça
30 entendível.</p>
31
32 <p>O aspeto mais problemático é mover os jogadores selecionados para as
33 posições deles. Para isto, tem que mover o espaço vazio à posição onde o
34 jogador está e depois mover ambos os jogadores e o espaço vazio à base que
35 estiver próxima do objetivo do jogador (provavelmente com um loop) e
36 finalmente pôr o jogador na posição correta da base favorita dele.</p>
37
38 <p>Como é comum em programação, o diabo esconde-se nos detalhes: existe um
39 conjunto de casos particulares que deve detetar e lidar corretamente, como
40 os casos onde o jogador já está na base (mas não na posição que gostaria),
41 ou quando o buraco está à direita do jogador (provavelmente quando ordena a
42 primeira base). Mas vai caçar tais coisas enquanto depurar o seu código.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>basebal multicores</h3>
3
4 <p>Este é outra variação divertida do problema da ordenação, a adaptar os
5 pricipais algoritmos de ordenação num contexto inusitado.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Rainbow Baseball</h1>
3 <p>As cores são representadas por inteiros, entre <code>0</code> e
4 <code>quantidade de bases -1</code>. O espaço vazio é representado por um
5 valor especial <code>-1</code>. A cor de cada base é o rank dela. Logo, a
6 base <code>1</code> é de cor <code>1</code>. Na interface gráfica, a base
7 <code>0</code> é a azul escura enquanto que a base <code>1</code> é a
8 fuscia.</p>
9
10 <p>Uma vez que todos os jogadores no campo estejam nas bases deles, o espaço
11 vazio deve estar na última base, ou seja, a de rank
12 <code>getBasesAmount()-1</code>.</p>
13
14 <h2>FFunções para recuperar as dimensões do mundo</h2>
15
16 <pre>[!java|c]int [/!]getBasesAmount() [!scala]:Int[/!]</pre>
17 Retorna a quantidade de bases neste campo.
18
19 <pre>[!java|c]int [/!]getPositionsAmount() [!scala]:Int[/!]</pre>
20 Retorna a quantidade de posições de jogadores por base neste campo.
21
22 <h2>Funções para recuperar o estado do mundo</h2>
23
24 <pre>[!java|c]int [/!]getHoleBase() [!scala]:Int[/!]</pre>
25 Retorna a base na qual o espaço vazio está localizado.
26
27 <pre>[!java|c]int [/!]getHolePosition() [!scala]:Int[/!]</pre>
28 Retorna a posição do espaço vazio na base dela
29
30 <pre>[!java|c]int [/!]getCorDoJogador([!java|c]int [/!]base[!scala]:Int[/!], [!java|c]int [/!]posição[!scala]:Int[/!]) [!scala]:Int[/!]</pre>
31 Retorna a cor do jogador numa dada posição.
32
33 <pre>[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]</pre>
34 Retorna se todos os jogadores em campo estão nos "home" deles.
35
36 <pre>[!java]boolean [/!][!c]int [/!]baseEstáOrdenada([!java|c]int [/!]base) [!scala]:Boolean[/!]</pre>
37 Retorna se todos os jogadores de uma dada base estão em "home".
38
39 <pre>[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]</pre>
40 Retorna true se o mundo atual estiver selecionado na interface.
41 <h2>Funções para mudar o mundo</h2>
42
43 <pre>[!java|c]void [/!]mover([!java|c]int [/!]base[!scala]:Int[/!], [!java|c]int [/!]posição[!scala]:Int[/!])</pre>
44 Move um dado jogador para um espaço vazio. Vai levantar uma
45 IllegalArgumentException se o jogador especificado não estiver próximo do
46 espaço vazio (no máximo a uma base de distância).
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Algoritmos de Ordenação</h1>
3
4 Esta lição permite a experimentação com alguns algoritmos de ordenação
5 clássicos (e algumas variações menos comuns deles). E temos um duplo
6 objetivo: pode primeiro compreender melhor a ideia destes algoritmos a
7 escrever eles por si só. Mas mesmo se não codificar os algoritmos, pode usar
8 o modo de demonstração para organizar "corridas" entre os algoritmos para
9 experimentar na prática o que significam diferentes complexidades
10 assintóticas.
11
12 <p>Mais exercícios estão previstos para o futuro, sobre os algoritmos de
13 ordenação recursivos (como o QuickSort e o MergeSort) ou a usar outros
14 micromundos para aplicar estes algoritmos a outros contextos.</p>
15
16 <h3>O que posso fazer para melhorar este universo do PLM?</h3>
17
18 <p>Como sempre, existem várias coisas que podem ser feitas no código deste
19 universo para melhorá-lo:</p>
20 <ul>
21 <li>Outras representações gráficas podem ser propostas, como aquelas
22 apresentadas em <a href="http://sorting.at/">http://sorting.at/</a>.</li>
23 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>BubbleSort</h1>
3
4 <p>Bem-vindo ao universo da ordenação. Ele permite que experimente os
5 algoritmos de ordenação existentes. A lista de "buildins" que pode usar nos
6 seus algoritmos está disponível na documentação de referência do mundo
7 ("Ajuda"-&gt;"Sobre este mundo").</p>
8
9 <p>Não é suficiente ordenar a array para passar nos exercícios. A sua solução
10 deve seguir estritamente o comportamento esperado em cada exercício. Isto é
11 reforçado a verificar que o seu algoritmo precisa da mesma quantidade de
12 operações de escrita e leitura para ordenar a array. </p>
13
14 <p>Quando seu algoritmo divergge das expectativas, entender a diferença entre o
15 seu código e a solução esperada pode ser muito difícil. Para ajudar neste
16 processo, é possível explorar graficamente a história do seu algoritmo de
17 ordenação. Alterne à visão Objetivo e use o menu contextual (clique com o
18 botão direito) para alternar da visão do estado atual para a visão do
19 histórico dele.</p>
20
21 <p>A visão do histórico é um pouco bagunçada à primeira vista, mas na verdade é
22 bem simples: o tempo anda da esquerda para a direita neste gráfico e cada
23 linha é uma célula da sua array. As linhas curvas que navegam entre linhas
24 representam um certo valor de um dado. Quando duas linhas se cruzam,
25 significa que dois valores foram alternados agora; uma bifurcação numa linha
26 representa uma cópia de valor; quando um valor é magenta e seguido de uma
27 interrogação (?), foi lido a usar getValue(); Se o valor é vermelho e
28 seguido de uma exclamação (!), foi escrito com setValor().</p>
29
30 <h2>Primeira tentativa no BubbleSort</h2>
31
32 <p>O primeiro algoritmo de ordenação é o mais simples: Bubble sort consiste em
33 progressivamente mover o menor elemento da array, como se fossem bolhas de
34 ar a subir à superfície de um líquido. O algoritmo percorre a array e
35 compara qualquer par de elementos adjacentes. Se dois elementos adjacentes
36 estiverem fora de ordem, eles são alternados. Quando a array estiver
37 completamente percorrida, a operação começa de novo do começo. Quando nenhum
38 elemento for ordenado após uma passagem completa, significa que a array está
39 completamente ordenada: e o algoritmo pode parar. Bubble sort é estudado
40 por causa da simplicidade dele, mas quase nunca é usado na prática por causa
41 do baixo desempenho dele (O(n^2) em média).</p>
42
43 <div class="tip" id="tip-1" alt="Mostrar Dica (Pseudo-código)">
44 <p>O pseudo-código do algoritmo BubbleSort é o seguinte:</p>
45 <pre>faça:
46 Para cada i em [0,len-2]
47 Se a célula i e i+1 devem ser alternadas, alterne
48 enquanto algo foi alternado na última passagem
49 </pre>
50 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>BubbleSort (take 2)</h1>
3
4 <p>Se olhar atentamente ao comportamento do BubbleSort, uma primeira e fácil
5 otimização aparece: depois de uma travesia, o último elemento da array é o
6 maior de todos, pois a travessia moveu-o para cima como uma bolha à posição
7 dele. Mais geralmente, depois de N travessias, sabemos que os últimos N
8 elementos da array já estão ordenados. Portanto, não é necessário
9 compará-los de novo durante travessias subsequentes. Por agora, vamos ter
10 tantas travessias quantos elementos na array.</p>
11
12 <div class="tip" id="tip-2" alt="Mostrar Dica (Pseudo-código)">
13 <p>O pseudo-código do algoritmo BubbleSort2 é o seguinte:</p>
14 <pre>Para todo i em [len-2,0] (a percorrer do maior ao menor)
15 Para todo j em [0, i]
16 Se células j e j+1 devem ser trocadas, troque
17 </pre>
18 </div>
19
20 <p>Quando rodamos este algoritmo, desaponta bastante ver que executa cerca de
21 na mesma velocidade que a versão básica do BubbleSort. Isto é um elemento
22 gráfico apenas já que apenas mudanças de valores são representadas
23 graficamente. Como esta variação evita algumas comparações inúteis, ela faz
24 a mesma quantidade de trocas que a versão básica. É, portanto, bastante
25 lógico que a interface gráfica desenhe esta versão no mesmo ritmo que a
26 versão básica. Mas as estatísticas da quantidade de leituras mostram que
27 economizamos cerca de um quarto das leituras, o que não é nada mal.</p>
28
29 <p>Do ponto de vista da complexidade asimtótica, não existe nenhuma diferença:
30 Esta variação ainda é O(n^2) no caso médio (nosso ganho é apenas no termo
31 constante, ignorado quando se está a calcular a complexidade asimtótica).</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>BubbleSort (take 3)</h1>
3
4 <p>Vamos agora reintroduzir a pequena otimização que fizemos no passo anterior:
5 se uma passagem não troca nenhum elemento, significa que a array já está
6 ordenada. Neste caso, vamos parar todo o processo de ordenação.</p>
7
8 <p>
9 [!java|python|c]Para isto, simplesmente use a palavra-chave
10 <code>break</code>, que interrompe o loop atual. Cuidado, se tem vários
11 loops aninhados, isto só vai ter efeito no mais interno.[/!] [!scala]Para
12 isto, simplesmente saia da função atual a chamar <code>return</code> sem
13 nenhum valor associado.[/!]
14 </p>
15
16 <div class="tip" id="tip-3" alt="Se quiser, esta dica mostra o pseudo-código.">
17 <p></p>
18 <pre>para todo i em [len-2,0] (a percorrer do maior ao menor)
19 Para todo j em [0, i]
20 Se células j e j+1 devem ser trocadas, troque
21 Se ao percorrer j não fez nenhuma troca, pare o loop
22 </pre>
23 </div>
24
25 <p>Esta otimização é ainda mais desapontadora: ela só dá um ganho de alguns
26 porcento sobre o BubbleSort2 no total de leituras.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>CocktailSort</h1>
3
4 <p>Para melhorar ainda mais o algoritmo BubbleSort, precisamos ver
5 comportamente dele bem de perto. Pode perceber que os elementos grandes se
6 movem bem rápido enquanto os pequenos se movem lentamente para os destinos
7 dele. Eles são então tradicionalmente chamados de "coelhos" e "tartarugas"
8 respectivamente para valores grandes e rápidos e valores pequenos e lentos.</p>
9
10 <p>Para ajudar as tartarugas a se mover rápido, o cocktail sort percorre
11 alternativamente a array da direita para a esquerda e da esquerda para a
12 direita. Aqui está o pseudo-código:</p>
13
14 <pre>
15 Do
16 For all i in [0,len-2], do:
17 if i and i+1 must be swapped, do it
18 For all i in [len-2,0] (downward), do:
19 if i and i+1 must be swapped, do it
20 while at least one of the traversal swapped an element
21 </pre>
22
23 <p>Podemos perceber que cocktail sort alcança a mesma quantidade de trocas que
24 o bubble sort, mas melhora levemente na quantidade de leituras. Entretanto,
25 é ainda pior que o BubbleSort2 neste assunto.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>CocktailSort (take 2)</h1>
3
4 <p>Vamos agora aplicar ao CocktailSort a mesma otimização que o BubbleSort2 faz
5 no BubbleSort. Devemos lembrar que os limites da parte do array que não está
6 ordenada ainda e percorrer ela alternativamente da esquerda para a direita e
7 da diretia para a esquerda:</p>
8 <pre>
9 beg=0; end=len-2
10 do
11 For all Pour i in [beg,end], do:
12 If cells i and i+1 must be swapped, do it
13 end -= 1 (this means end = end - 1)
14 For all Pour i in [beg,end] (downwards), do:
15 If cells i and i+1 must be swapped, do it
16 beg += 1 (this means beg = beg + 1)
17 while at least one of the traversal swapped an element
18 </pre>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>CocktailSort (3o tempo)</h1>
3
4 <p>Mesmo se a complexidade assintótica de CocktailSort2 for a mesma do
5 BubbleSort, que parece melhor, na prática. É até mesmo possível melhorar um
6 pouco mais a pará-lo na primeira rodada que não encontrar nada para
7 alternar, se realizar a rodada para baixo. Da mesma forma, podemos parar se
8 a rodada para cima encontrar algo para alternar, mas a rodada para baixo
9 não.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>CombSort</h1>
3
4 <p>Vimos que CocktailSort melhora um pouco as coisas para as tartarugas
5 (p.ex. pequenos valores próximos do fim da array), mas ainda é possível
6 fazer melhor. ComboSort vem-les fornecer um atalho: ao invés de comparar
7 valores adjacentes, comparamos valores separados por um intervalo ("gap")
8 maior que 1. Desta forma, as tartarugas vão percorrer <i>gap</i> células em
9 cada passagem. Naturalmente, temos que aplicar o algoritmo com distâncias
10 decrescentes e terminar com <i>gap=1</i> para garantir que a array está
11 corretamente ordenada ao final. Escolher a distância correta e como
12 diminuí-la é uma questão difícil, mas na prática, dividir por 1.3 depois de
13 cada passagem leva a uma boa performance. Aqui está o pseudo-código
14 correspondente:</p>
15
16 <pre>
17 gap = len;
18 do
19 if gap>1 then
20 gap = gap / 1.3
21 i = O
22 while i+gap &lt; len do:
23 if i and i+gap must be swapped, do it
24 increase i by one
25 while the gap is bigger than 1 or the last traversal swapped at least one pair
26 </pre>
27
28 [!scala]<p>Um detalhe perigoso é que temos que dividir o intervalo, que é um inteiro
29 (ou do tipo Int), por 1.3, que é um Double. O sistema de tipos do scala não
30 nos deixa fazer isto, por que tal discrepância normalmente significa um erro
31 de programação. Como isto não é um erro neste caso, vamos ter que converter
32 o intervalo para Double para o momento da operação e depois converter o
33 resultado de volta para Int para armazená-lo no intervalo. Isto deve ser
34 escrito desta forma:</p>
35 <pre>gap = (gap.asInstanceOf[Double] / 1.3).asInstanceOf[Int]</pre>
36 <p>Isto é meio exagerado, mas, na verdade, esta notação não é muito complexa. E
37 lembre-se que o verificador de sintaxe é o seu amigo. Ás vezes é chato e
38 irritante (como neste caso), mas frequentemente apanha bugs esquisitos que
39 seriam trabalhosos para depurar se não fosse o verificador de sintaxe. E
40 como os autores do Scala são pragmáticos, a expressão anterior pode ser
41 simplificada:</p>
42 <pre>gap = (gap.toDouble / 1.3).toInt</pre>
43 <p><code>toDouble</code> e <code>toInt</code> são apenas atalhos para as
44 expressões correspondentes <code>asInstanceOf[Double]</code> e
45 <code>asInstanceOf[Int]</code>. Não é muito genérico, mas é bem prático.</p>
46 [/!]
47
48 <p>Este algoritmo foi inventado por Wlodek Dobosiewicz em 1980 e depois
49 redescoberto e popularizado por Stephen Lacey e Richard Box, que o
50 descreveram na Byte Magazine em Abril de 1991.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>CombSort11</h1>
3
4 <p>Os autores deste algoritmo observaram que o desempenho é aumentado se nos
5 certificarmos que os últimos valores do intervalo são (11, 8, 6, 4, 3, 2, 1)
6 ao invés de (9, 6, 4, 3, 2, 1) ou (10, 7, 5, 3, 2, 1). Retrabalhe o código
7 do CombSort para garantir que apenas depois da atualização do intervalo que
8 se for 9 ou 10, devemos usar 11.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>GnomeSort</h1>
3
4 <p>O Gnome sort é similar ao insertion sort, mas os elementos são movidos de
5 poisção por uma série de trocas que se parecem com o bubble sort. O nome
6 veio do suposto comportamento que gnomos de jardim tem quando ordenam vasos
7 de flores. Aqui está uma descrição do algoritmo pelo autor dele:</p>
8
9 <p>Gnome Sort é baseado na técnica usada pelo gnomo de jardim holandês padrão
10 (em holandês: tuinkabouter). Aqui está como um gnomo de jardim ordena uma
11 fileira de potes de flores. Basicamente, procura pelo pote de flor próximo e
12 o anterior; se estão na ordem correta vai para a frente em direção ao
13 próximo pote, caso contrário troca os potes e vai para trás. Condições de
14 contorno: se não existe um pote anterior, vai para a frente; se não existe
15 um pote próximo, termina. <i>—Dick Grune</i></p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>InsertionSort</h1>
3
4 <p>
5 Este algoritmo de ordenação é muito simples de entender e escrever, mesmo se
6 não for o mais eficiente possível. A complexidade assintótica dela é O(n2),
7 mas é mais eficiente, na prática (linear no melhor caso, p.ex. quando a
8 array já está ordenada e N2/4 no caso médio).
9 </p>
10 <p>A ideia é percorrer todos os elementos da array e inserir cada um deles na
11 posição correta dele numa parte já ordenada da array. Quando olhamos num
12 elemento x, a situação é a seguinte: qualquer elemento da esquerda da array
13 já está ordenado e temos que inserir x na posição dele na array.</p>
14 <div style="text-align:center">
15 <img src="lessons/sort/basic/insertion/InsertionsortBefore.png"/>
16 </div>
17 <p>Uma vez isto feito, a situação é a seguinte:</p>
18 <div style="text-align:center">
19 <img src="lessons/sort/basic/insertion/InsertionsortAfter.png"/>
20 </div>
21 <p>O pseudo-código deste algoritmo é então o seguinte:</p>
22 <pre>For each i in [1,len-1]
23 store the value of i in a variable v
24 copy the cell i-1 into i if i-1 contains a value bigger than v
25 copy the cell i-2 into i-1 if i-2 contains a value bigger than v
26 copy the cell i-3 into i-2 if i-3 contains a value bigger than v
27 copy the cell i-4 into i-3 if i-4 contains a value bigger than v
28 ...
29 copy v into the last cell copied above
30 </pre>
31 <p>
32 Naturalmente, deve usar um loop para escrever a grande permutação dentro do
33 loop. Escrever ela desta forma deve ser na verdade ... improdutivo.
34 </p>
35 <p>Se já se perguntou o que cientistas da computação fazem nos dias de hoje,
36 aqui está uma parte da resposta: Eles melhoram algoritmos fundamentais para
37 que outras pessoas possam escrever programas eficientes.</p>
38
39 <h2>Outra variação do insertion sort</h2>
40 <p>
41 TreeSort constrói uma árvore de busca binária para ordená-la. Consegue O(n
42 log(n)) no caso médio, mas O(n^2) nos piores casos. Não vamos estudar este
43 algoritmo aqui, pois para entendê-lo temos que entender o que uma árvore
44 binária é, o que está além dos nossos objetivos atuais.
45 </p>
46 <p>Existem variações do insertion sort, tais como o PatienceSort que constrói
47 pilhas de valores e ordena cada pilha depois. Este algoritmo apresenta um
48 tempo 0(n log(n)) no pior caso e uma complexidade de espaço de
49 0(n). LibrarySort (proposto em 2004) também troca um pouco de espaço por
50 tempo já que tem uma complexidade de tempo de O(n log(n)) mas precisa
51 armazenar um pouco mais de dados.</p>
52
53 <p>A Wikipédia fornece uma descrição detalhada de cada um destes algoritmos que
54 não apresentamos aqui devido a limitações de tempo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Selection Sort</h1>
3
4 Neste exercício vamos implementar outro algoritmo clássico: selection sort.
5
6 <p>A ideia é simplesmente selecionar para cada célula da array o menor valor da
7 parte ainda não ordenada. Então para a primeira célula, levamos o menor
8 valor da array toda. Para a segunda, precisamos do segundo menor valor, que
9 é o menor valor das células ainda não ordenadas.
10
11 <p>De forma mais geral, para a célula N, procura a célula M em [N;len] a conter
12 o menor valor possível do intervalo. Então, alterna o conteúdo da célula N
13 com o da célula M.
14
15 <h2>Variações existentes</h2>
16 Outro algoritmo clássico cuja ideia é baseada na seleção de bons elementos é
17 o HeapSort, mas usa uma estrutura de dados heap que ainda não
18 vimos. Simplesmente lembre-se que o HeapSort fornece um desempenho O(n log
19 n) no pior caso, que é o motivo para ser bem interessante, na prática.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>ShellSort</h2>
3
4 Este algoritmo é batizado em homenagem ao autor dele, Donald Shell, que o
5 publicou em 1959. Seja uma aplicação da ideia do CombSort (faz com que
6 elementos que tem um longo caminho tomarem atalhos) ao insertion sort
7 (CombSort é uma variação do BubbleSort). Ao invés de comparar valores
8 adjacentes durante o insertion sort, compara valores separados por um
9 intervalo maior. Quanto maior o intervalo, mais rápido os elementos se movem
10 ao destino deles, mas também menos preciso fica o movimento. É, portanto,
11 essencial que o algoritmo vá a ser aplicado numa série de intervalos cada
12 vez menor. No último passo, quando o intervalo for 1, o InsertionSort será
13 usado, mas numa array que estará praticamente ordenada pelos passos
14 anteriores.
15
16 <p>Donald Shell propôs <code>len/2</code> como o valor inicial do intervalo e
17 ir a dividir por 2 a cada passo. O pseudo-código é o seguinte:
18 <pre>
19 gap=len/2
20 while gap>0:
21 apply InsertionSort, comparing i-gap and i, then i-2gap and i-gap, then i-3gap and i-2gap, etc.
22 </pre>
23
24 <p>Assim como no CombSort, a sequência de valores levados pelo intervalo é
25 crucial para o desempenho do Shell sort. Em alguns casos patológicos raros,
26 a sequência que usamos pode levar a um desempenho O(n^2). Outras sequências
27 foram propostas: os incrementos de Hibbard de 2k − 1 levam a uma
28 complexidade de O(n^(3/2)) em casos ruins. Incrementos de Pratt 2^i3^j levam
29 a um desempenho de O(nlog(n)log(n) nos piores casos. A existência de uma
30 sequência a levar a O(n log(n)) foi excluída por Poonen, Plaxton e
31 Suel. Graças a este desempenho, ShellSort é um candidato válido para arrays
32 de várias centenas de milhares quando corretamente implementado.</p>
33
34 <p>No nosso caso, a array é pequena demais para se beneficiar destas
35 otimizações. Se ainda assim quiser, tome o intervalo inicial como o maior
36 valor da série alvo ainda menor que o tamanho do array e depois use valores
37 decrescentes da série.</p>
38
39 <p>Um fato interessante: Determinar a melhor sequência de intervalos para o
40 shell sort se tornou um tema de pesquisa de nosso século em ciência da
41 computação. Por exemplo, um artigo de 2001 introduz a seguinte sequência,
42 que parece ser a melhor na prática para arrays de tamanho até 10^5: {1, 4,
43 10, 23, 57, 132, 301, 701, 1750} (Marcin Ciura, Best Increments for the
44 Average Case of Shellsort, 13th International Symposium on Fundamentals of
45 Computation Theory, LNCS 2001; Vol. 2138).</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Algoritmos de Ordenação</h3>
3
4 <p>Esta lição permite a experimentação com alguns algotimos de ordenação
5 clássicos (e algumas variantes menos comuns deles :)</p>
6
7 <p>Para fazer esta lição deve dominar as bases da programação.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>O problema da bandeira holandesa</h1>
3
4 <p>O seu trabalho é ordenar todas as cores da bandeira holandesa e a única
5 primitiva fornecida é trocar duas linhas dadas. Adicionalmente, não deve
6 criar quaisquer variáveis adicionais (exceto alguns índices).</p>
7
8 <p>Se pensar bem, pode ser feito em tempo linear, ondeordena uma linha a cada
9 iteração do loop. Pode dar mais uma olhada no <a
10 href="plm://lessons.sort.basic/insertion.AlgInsertionSort">insertion
11 sort</a>, do qual o Dutch Flag sort é uma variação. A principal diferença é
12 que tem 3 pontos de inserção e não apenas um...</p>
13
14 <div class="tip" id="tip-1" alt="Preciso de uma dica para começar">
15 Atravesse os seus dados, a guardar 3 índices:
16 <ul>
17 <li><code>afterBlue</code> é iniciado como 0. Certifique-se de que cada célula
18 abaixo de <code>afterBlue</code> é preenchida com elementos azuis.</li>
19 <li><code>whiteRed</code> é iniciado como size-1. Certifique-se de que cada
20 célula depois de <code>whiteRed</code> é preenchida com elementos vermelhos.</li>
21 <li><code>beforeWhite</code> é iniciado com size-1. Certifiqeu-se de que cada
22 célula depois de <code>beforeWhite</code> e antes de <code>whiteRed</code> é
23 preenchida com elementos brancos.</li>
24 </ul>
25 Observe que as células não-ordenadas ficam sempre entre
26 <code>afterBlue</code> e <code>beforeWhite</code>.<br/>
27
28 Em cada passo da sua travessia, verifique a cor da célula em
29 <code>afterBlue</code> e faça as mudanças necessárias. A condição de fim de
30 loop é quando <code>afterBlue</code> se torna maior que
31 <code>beforeWhite</code>.<br/>
32 </div>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>O problema da bandeira holandesa</h1>
3
4 <p>Este problema foi proposto primeiro por E.W Dijkstra em 1976 (no capítulo 14
5 do livro dele "A Discipline of Programming"). É uma variação clássica de
6 algoritmos de ordenação desde então. Às vezes é útil na realidade, mas se
7 tornou famosos pelas propriedades pedagógicas dele: a complexidade não é
8 trivial, mas não é muito complexo. Pode ser provados formalmente com
9 facilidade, mas não é de forma alguma trivial. </p>
10
11 <h3>O que posso fazer para melhorar este universo do PLM?</h3>
12
13 <p>Como sempre, existem várias coisas que podem ser feitas no código deste
14 universo para melhorá-lo:</p>
15 <ul>
16 <li>Uma visão temporal pode ser bem-vinda.</li>
17 <li>Outros exercícios, por exemplo com 2 cores apenas ou com mais de 3 cores,
18 podem generalizar a abordagem proposta.</li>
19 <li>Este problema pode ser resolvido recursivamente.</li>
20 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>O problema da bandeira holandesa</h3>
3
4 <p>Este é um problema de ordenação clássico, a constituir uma variação do
5 insertion sort.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>O problema da bandeira holandesa</h1>
3
4 <h2>Valores fornecidos</h2>
5
6 <p>As cores são representadas através das seguintes constantes: BLUE, WHITE e
7 RED. Pode usá-las diretamente no seu código.</p>
8
9 <h2>Funções fornecidas</h2>
10
11 <p>Este mundo é bem simples, com apenas 5 funções fornecidas. </p>
12
13 <pre>[!java|c]void [/!]alterna([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int [/!]y[!scala]:Int[/!])</pre>
14 Troca as linhas de número <code>x</code> com a de número <code>y</code>.
15
16 <pre>[!java|c]int [/!]getSize() [!scala]:Int[/!]</pre>
17 Retorna a quantidade de linhas desta bandeira.
18
19 <pre>[!java|c]int [/!]getCor([!java|c]int [/!]linha[!scala]:Int[/!]) [!scala]:Int[/!]</pre>
20 Retorna a cor da linha dada.
21
22 <pre>[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]</pre>
23 Retorna true se a bandeira estiver ordenada.
24
25 <pre>[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]</pre>
26 Retorna true se o mundo atual estiver selecionado na interface.
27
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Ordenação da panqueca</h1>
3
4 <p>O problema da ordenação da panqueca é um quebra-cabeças simples onde tem um
5 conjunto de panquecas, cada uma de tamanhos diferentes. O cozinheiro que
6 cozinha as panquecas é um pouco psicorígido: odeia quando as panquecas não
7 estão corretamente ordenadas no prato. Adora quando elas estão corretamente
8 ordenadas, com as pequenas sobre as grandes. Como todo fazedor de panquecas,
9 é mestre em virar a panqueca com a espátula. Ele pode virar a panqueca do
10 topo da pilha, ou até mesmo várias panquecas de uma vez. O problema é que
11 tem apenas um prato e a mesa está muito suja para pôr as panquecas nela,
12 mesmo temporariamente. A única operação permitida é virar algumas panquecas
13 que estão no topo da pilha.</p>
14
15 <p>O seu trabalho é ajudar este pobre coitado a ordenar a pilha dele a virar as
16 panquecas. Cada panqueca é definida pelo raio e rank dentro da pilha, onde a
17 panqueca de cima está com rank 0 e a próxima com rank 1.</p>
18
19 <p>Observe que pode brincar primeiro fisicamente com pedaços de papel ou
20 madeira para ter a ideia do problema. Esta é inclusive uma das atividades
21 que uso no meu projeto CS-IRL (computer science in real life - ciência da
22 computação na vida real) para introduzir o conceito de algoritmo para
23 completos iniciantes que querem saber da nossa ciência. Mais informações em
24 http://www.loria.fr/~quinson/Mediation/SMN/ (em francês).</p>
25
26 <p><div class="tip" id="tip-1" alt="Não compreendi. preciso de ajuda.">
27 Deve tentar primeiro mover a maior panqueca para o fundo e depois a segunda
28 maior para cima dela e depois a menor para o topo e assim por diante.
29 </div></p>
30
31 <p><div class="tip" id="tip-2" alt="A primeira dica não foi suficiente. Preciso de outra.">
32 Logo, em primeiro lugar precisa mover a maior panqueca para o fundo da
33 pilha. <br/>
34 Pode imaginar uma situação onde possa facilmente trazer esta panqueca
35 super-grande para o fundo?<br/>
36 Como pode atingir esta situação a partir da atual?
37 </div></p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Bubble Pancakes</h1>
3
4 <p>Este problema é similar ao anterior: tem que ordenar as panquecas, a menor
5 no topo e a maior embaixo, mas só pode virar-las para ordená-las.</p>
6
7 <p>O objetivo aqui é ordená-los a usar o algoritmo da bolha (bubble), onde uma
8 panqueca é movida ao fundo até encontrar uma maior que ela. Em
9 representações gráficas, parece que uma bolha ocupa o lugar do elemento e
10 move-o através da pilha. É daí que saiu o nome do algoritmo.</p>
11
12 <p>Agora, a usar panquecas torna as coisas um pouco mais difíceis de escrever,
13 pois tem que encontrar uma forma de alternar apenas duas panquecas por vez.</p>
14
15 <p><div class="tip" id="tip-1" alt="Não compreendi. preciso de ajuda.">
16 O Algoritmo da bolha consiste em navegar a pilha completa de cima para baixo
17 e a fazer uma comparação entre duas panquecas. Cada vez que a panqueca de
18 cima é maior que a de baixo, tem que alterná-las, então comparar a panqueca
19 maior que acabou de alternar com a de baixo dela e por aí vai. Tem que
20 navegar através de toda a pilha até que nenhuma troca ocorra e neste caso, a
21 pilha estará ordenada.</div>
22
23 <p><div class="tip" id="tip-2" alt="A primeira dica não foi suficiente. Preciso de outra.">
24 Se não entende o algoritmo básico bubble sort, tente os exercícios da lição
25 Algoritmos de Ordenação. Se consegue, mas não imagina uma forma de alternar
26 apenas duas panquecas por vez, pense na situação onde apenas duas panquecas
27 são alternadas por vez e encontre uma forma de chegar nesta situação.
28 </div></p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Panquecas queimadas</h1>
3
4 <p>Hard blow for the chef! As panquecas queimaram de um lado! Não há forma de
5 entregar uma pilha de panquecas com paquecas visivelmente queimadas! Tem que
6 ajudá-lo a ter certeza de que nenhuma panqueca está de cabeça pra baixo
7 enquanto ordena esta pilha.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Faster Burned Pancake Sorting</h1>
3
4 <p>O algoritmo de Gates que vimos no exercício anterior ordena rapidamente uma
5 pilha de panquecas que não estão queimadas a aumentar o tamanho dos blocos
6 de panquecas já ordenadas. Isto é muito mais rápido que o algoritmo que move
7 em cada passo a panqueca maior para o fundo das panquecas ainda não
8 ordenadas. O algoritmo de Gates ordena uma pilha de <i>n</i> panquecas em
9 menos que <i>(5n + 5)/3</i> passos no pior caso, enquanto que o algoritmo
10 simplório precisa de no máximo <i>2n</i> passos. Gates é então cerca de 3
11 vezes mais rápido no pior caso.</p>
12
13 <p>Neste exercício, vamos explorar uma adaptação da mesma ideia das panquecas
14 queimadas. Isto foi publicado primeiramente por David X. Cohen e Manuel
15 Blum. David Cohen co-fundou uns anos depois a série de TV Futurama, cheia de
16 piadas matemáticas. Definitivamente, pessoas interessantes estudaram este
17 singelo problema da panqueca...</p>
18
19 <p>O algoritmo de Cohen é um pouco mais fácil que o algoritmo de Gates já que
20 ele distingue menos casos:</p>
21
22 <p><b>Caso 1:</b> pelo menos uma panqueca está de cabeça para cima na
23 pilha. Seja <i>p</i> a maior destas panquecas. Observe que <i>p + 1</i> deve
24 portanto estar de cabeça para baixo, a menos que <i>p = n</i> (e neste caso
25 não existe a panqueca <i>p + 1</i>).</p>
26
27 <ul>
28 <li><b>Caso 1.a:</b> <i>p+1</i> é menor que <i>p</i> na pilha. <div align="center"><img src="img/cohen-1a.png"/></div><br/></li>
29 <li><b>Caso 1.b:</b> <i>p+1</i> é maior que <i>p</i> na pilha. <div align="center"><img src="img/cohen-1b.png"/></div><br/></li>
30 <li><b>Caso 1.c:</b> Não existe <i>p+1</i> pois <i>p</i> é a maior panqueca da
31 pilha, isto por que <i>p = n</i>. Se a panqueca <i>p</i> já estiver na
32 posição, não há nada a fazer. Se não, pode movê-la para o fundo da pilha em
33 duas viradas:
34 <div align="center"><img src="img/cohen-1c.png"/></div>
35
36 <b>O truque é que a panqueca <i>p</i> nunca deve ser considerada de
37 novo.</b> caso contrário, vai considerar ela de novo e de novo pois ela está
38 de cabeça pra cima e já que é a maior panqueca. Para desconsiderar-la, deve
39 se lembrar do tamanho da pilha que ainda está para ser ordenada. Qualquer
40 travessia da pilha deve então considerar apenas estas panquecas, não a mexer
41 nas que já estão posicionadas no fundo da pilha.
42 </li>
43 </ul>
44
45
46 <p><b>Caso 2:</b> Todas as panquecas estão de cabeça para baixo. De novo,
47 distinguimos dois sub-casos.</p>
48
49 <ul>
50 <li><b>Caso 2.a:</b> Existe pelo menos um <i>p</i> para o qual <i>p+1</i> é
51 maior que <i>p</i> (se existem vários destes <i>p</i>, pegue o maior).
52 <div align="center"><img src="img/cohen-2a.png"/></div><br/>
53 </li>
54 <li><b>Caso 2.b:</b> Qualquer panqueca <i>p</i> é menor que a panqueca
55 <i>p+1</i>. Neste caso, devemos ter a seguinte configuração:
56 <div align="center"><img src="img/cohen-2b.png"/></div>
57 </li>
58 </ul>
59
60 <p>Como pode ver, alcançamos um "join" em duas viradas nos casos 1 ou 2.a. Já
61 que precisamos alcançar n junções para ordenar a pilha, podemos ordenar a
62 pilha em <i>2n</i> passos se o caso 2.b não ocorrer.</p>
63
64 <p>Este caso 2.b necessita um tratamento particular já que é obviamente
65 impossível juntar duas panquecas em apenas duas viradas. Mas por sorte, uma
66 única configuração bem específica da pilha cai neste caso da figura. Podemos
67 então utilizar o algoritmo seguinte, conhecido por tirar vantagem desta
68 configuração. Este algoritmo ordena toda a pilha em exatamente <i>2n</i>
69 passos.</p>
70
71 <pre>
72 Repita n vezes
73 vire a pilha toda de n panquecas
74 Vire as (n-1) panquecas mais de cima
75 </pre>
76
77 <p>Pode parecer mágica, mas funciona de verdade, como é mostrado no exemplo
78 abaixo.</p>
79
80 <p><div align="center"><img src="img/cohen-2b-algo.png"/></div></p>
81
82 <p>Portanto, em todo caso, o algoritmo de Cohen trata de ordenar a pilha de
83 panquecas queimadas em <i>2n</i> passos em todos os casos. Uma vitória sobre
84 o algoritmo simplório para panquecas queimadas que precisa de <i>3n</i>
85 passos.</p>
86
87 <p><div class="tip" id="tip-1" alt="Não entendi direito.">
88 Não se preocupe. Este exercício é muito difícil, então tudo bem se não
89 conseguir de primeira. Adicione alguns logs relevantes ao seu código para
90 entender onde parou de funcionar corretamente. Certifique-se de usar o
91 método <code>isSelected()</code> de forma que os seus logs apenas apareçam
92 no mundo que estiver a ser exibido no momento. Em particular, pode ajudar se
93 imprimir textualmente o estado do mundo cada vez que adentrar no loop
94 principal.
95 </div></p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Ondenação de Panqueca Rápida</h1>
3
4 <p>Ao contrário de outros problemas de ordenação, a operação cara não é a
5 comparação de valores, mas virar as panquecas. Neste exercício, vamos
6 explorar outro algoritmo que tenta reduzir a quantidade de viradas da
7 pilha. O engraçado é que este algoritmo mostrado primeiro por Bill Gates,
8 antes de inventar o Windows.</p>
9
10 <p>A ideia básica é aumentar as sequências de panquecas ordenadas, não
11 necessariamente a começar do fundo. Dizemos que uma sequência de panquecas
12 ordenadas constitui um <b>bloco</b> enquanto uma panqueca que não é parte de
13 um bloco é dita <b>livre</b>. O algoritmo então considera o panqueca mais de
14 cima (de raio <code>t</code>) e busca pelas panquecas <code>t+1</code> ou
15 <code>t-1</code> (a vizinhança considerada é <code>t+o</code>). Oito casos
16 podem acontecer:</p>
17
18 <ul>
19 <li><b>Caso a</b>: tanto <code>t</code> quanto <code>t+o</code> são livres. elas
20 são então juntadas numa virada.<br/>
21 <div align="center"><img src="img/gates-a.png"/></div>
22 </li></ul>
23
24 <ul><li><b>Caso b</b>: <code>t</code> é livre e <code>t+o</code> é o primeiro de um
25 bloco. Eles são juntados numa virada.<br/>
26 <div align="center"><img src="img/gates-b.png"/></div>
27 </li></ul>
28
29 <ul>
30 <li><b>Caso c</b>: <code>t</code> é livre mas tanto <code>t-1</code> quanto
31 <code>t+1</code> são últimos elementos de blocos. Os blocos e <code>t</code>
32 são mesclados juntos em 4 viradas. Cuidado, se <code>t-1</code> ou
33 <code>t+1</code> não existir (pois <code>t</code> é 0 ou max), apenas duas
34 viradas são obrigatórias.
35 <br/>
36 <div align="center"><img src="img/gates-c.png"/></div>
37 </li></ul>
38
39 <ul>
40 <li><b>Caso d</b>: <code>t</code> está num bloco mas <code>t+o</code> é
41 livre. Eles são mesclados numa virada.<br/>
42 <div align="center"><img src="img/gates-d.png"/></div>
43 </li></ul>
44
45 <ul>
46 <li><b>Caso e</b>: <code>t</code> está num bloco e <code>t+o</code> é o primeiro
47 elemento de um bloco. Eles são mesclados numa virada.<br/>
48 <div align="center"><img src="img/gates-e.png"/></div>
49 </li></ul>
50
51 <ul><li><b>Caso f</b>: <code>t</code> está num bloco e <code>t+o</code> é o último
52 elemento de outro bloco. Eles são mesclados em 3 viradas como segue.<br/>
53 <div align="center"><img src="img/gates-f.png"/></div></li></ul>
54
55 <ul><li><b>Caso g</b>: <code>t</code> está num bloco de comprimento k+1 (o último
56 elemento é <code>t+ko</code>), <code>t+(k+1)o</code> é tanto livre ou o
57 último elemento é outro bloco. Ambos os blocos são mesclados em 2 viradas:<br/>
58 <div align="center"><img src="img/gates-g.png"/></div><br/></li></ul>
59
60 <ul><li><b>Caso h</b>: <code>t</code> está num bloco de comprimento k+1 (o último
61 elemento é <code>t+ko</code>), <code>t+(k+1)o</code> é o primeiro elemento
62 de outro bloco (a diferença com o caso g é que <code>t+(k+1)o</code> é agora
63 o <i>primeiro</i> elemento do bloco dele). Ambos os blocos são mesclados em
64 2 viradas:<br/>
65 <div align="center"><img src="img/gates-h.png"/></div>
66 </li></ul>
67
68 <ul><li><b>Caso i</b>: <code>t</code> está num bloco de comprimento <code>n</code>
69 (este bloco contém todas as panquecas). Se <code>t</code> não for 1, a pilha
70 toda destá virada. O algoritmo então pára.</li></ul>
71
72 <p>Cada iteração aumenta o tamanho dos blocos, então o algoritmo eventualmente
73 pára em todos os casos. Uma análise mais aprofundada mostrará que leva no
74 máximo <code>(5n+5)/3</code> passos para ordenar a pilha. O que é melhor que
75 o algoritmo simplório, que precisa de 2n-3 passos.</p>
76
77 <h2>É a sua vez</h2>
78 <p>Agora tem quase toda a informação necessária para implementar este algoritmo
79 por si só. Temos apenas que remover as últimas ambiguidades para garantir
80 que implemente o mesmo algoritmo que a correção. Se vários casos se aplicam
81 à sua situação, deve usar o primeiro que foi dado. Por exemplo, se tanto o
82 caso a quanto o caso b se aplicam (e.g., com <code>t-1</code> no <b>a</b> e
83 <code>t+1</code> no caso <b>b</b>), deve aplicar as viradas do caso
84 <b>a</b>. Se um dado caso se aplica tanto para <code>t+1</code> quanto para
85 <code>t-1</code>, então deve aplicá-lo a <code>t+1</code>.</p>
86
87 <p>Observe que este é de certa forma mais difícil que os outros exercícios que
88 fizemos até agora, logo não se surpreenda se precisar de mais tempo para
89 terminar. Mas não desista, pode conseguir!</p>
90
91 <p><div class="tip" id="tip-1" alt="Bem, preciso de ajuda para começar.">
92 Primeiro escreva algumas funções auxiliares tais como <code>isFirst()</code>
93 ou <code>isFree()</code>. Isto vai simplificar o seu algoritmo principal,
94 que vai poder ser escrito de forma muito similar à explicação acima com um
95 conjunto de condições if. Fatorizar o código desta forma às vezes ajuda a
96 tornar o seu código mais legível.
97 </div></p>
98
99 <p><div class="tip" id="tip-2" alt="O meu código continua a falhar e não sei como depurar-lo.">
100 Para depurar um mundo depois do outro e evitar que as mensagens de todos os
101 mundos fiquem misturadas, pode escrever a sua função de depuração apenas se
102 o método <code>isSelected()</code> retorna true. Isto acontecerá apenas para
103 a entidade que estiver selecionada na interface gráfica, que é provavelmente
104 o mundo que está a depurar no momento. Isto vai ajudar a dividir a
105 dificuldade em partes e a depurar a situção uma após a outra.<br/>
106 Em particular, escrever textualmente o estado do mundo cada vez que entrar
107 no loop principal pode ajudar.
108 </div></p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Ordenação da panqueca</h1>
3
4 <p>Esta atividade é inspirada por um problema introduzido pela primeira vez em
5 1975 por Harry Dweighter no American Mathematical Monthly. A pergunta não é
6 apenas ordenar panquecas, mas determinar <code>f(n)</code> a quantidade
7 <i>minima</i> de viradas necessárias para ordenar qualquer pilha de tamanho
8 <code>n</code>.</p>
9
10 <p>Este problema é agora famoso por que Bill Gates escreveu (com
11 C. Papadimitriou) a única publicação científica dele em 1979 neste tópico, a
12 fornecer um algoritmo mais rápido e a provar que <code>17n/16 ≤ f(n) ≤
13 (5n+5)/3</code>. Este foi a única publicação de Bill Gates antes dele
14 inventar o Windows e ficar rico.</p>
15
16 <p>Então, David X. Cohen, o inventor dos quadrinhos Futurama com muitas
17 referências matemáticas, introduziu a variante com panquecas queimadas e
18 estudou a complexidade dele com Manuel Blum em 1993.</p>
19
20 <p>Um artigo de 2011 (por L. Bulteau, G. Fertin e I. Rusu) provou que
21 determinar a quantidade mínima de voltas para ordenar a pilha é um problema
22 NP-completo. Naturalmente, o problema de ordenação da pilha não é
23 NP-completo já que pode ser resolvido em 2n-3 passos com o algoritmo ingénuo
24 e (5n+5)/3 passos com o algoritmo Gates. Isso é determinar a quantidade
25 mínima de passos que é NP.</p>
26
27 <p>Mais informações encontram-se na página da wikipédia, como sempre.</p>
28
29
30 <p>Esta atividade também é integrada ao CSIRL (o meu repositório de atividades
31 offline <i>livres</i> para introdução de ciência da computação, disponível
32 em http://www.loria.fr/~quinson/Mediation/SMN/) e pode ser interessante
33 executar as atividades offline antes de implementar estes algoritmos no PLM.</p>
34
35
36 <h3>O que posso fazer para melhorar este universo do PLM?</h3>
37
38 <p>Como sempre, existem várias coisas que podem ser feitas no código deste
39 universo para melhorá-lo:</p>
40 <ul>
41 <li>Uma visão temporal similar ao universo da ordenação pode ser útil</li>
42 <li>Outros exercícios, por exemplo sobre Roti sorting, com uma pilha de Roti que
43 tem que tocar a grelha em ambos os lados (see
44 http://en.wikipedia.org/wiki/Pancake_sorting#The_identical_pancake_stack).</li>
45 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>O problema da panqueca</h3>
3
4 <p>Ajude o pobre chef das panquecas psychorigid a ordenar a pilha de panquecas
5 dele!</p>
6
7 <p>Este problema divertido leva a algoritmos que são de certa forma mais
8 desafiadores de implmentar. Espera-se que domine as bases da programação e
9 de algoritmos de ordenação para fazer esta lição.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>PancakeWorld</h1>
3
4 <p>Este universo é bastante simples, com apenas cinco funções fornecidas.</p>
5
6 <pre>[!java|c]int [/!]getStackSize() [!scala]:Int[/!]</pre>
7 Retorna o tamanho da pilha, ou seja, a quantidade de panquecas nela.
8
9 <pre>[!java|c]int [/!]getRaioPanqueca([!java|c]int [/!]rank[!scala]:Int[/!]) [!scala]:Int[/!]</pre>
10 Retorna o raio da panqueca passado como argumento, com o rank da panqueca
11 mais acima a ser 0.
12
13 <pre>[!java]boolean [/!][!c]int [/!]panquecaDeCabeçaPraBaixo([!java|c]int [/!]rank[!scala]:Int[/!]) [!scala]:Boolean[/!]</pre>
14 Retorna se a panqueca passada como argumento está de cabeça para baixo, ou
15 seja, se o lado queimado está para cima. Como sempre, a panqueca mais acima
16 é a de rank 0.
17
18 <pre>[!java|c]void [/!]flip([!java|c]int [/!]amount[!scala]:Int[/!])</pre>
19 Vira as primeiras <code>amount</code> panquecas que compõe a pilha, do topo
20 dela.
21
22 <pre>[!java]boolean [/!][!c]int [/!]isSorted() [!scala]:Boolean[/!]</pre>
23 Retorna true se a pilha de panquecas estiver corretamente ordenada.
24
25 <pre>[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]</pre>
26 Retorna true se o mundo atual está selecionado na interface gráfica.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Os turmites</h1>
3
4 <p>Este conjunto de atividades é para brincar com formigas de Langton, que são
5 máquinas de Turing 2D. Elas constituem problemas bem simples, bons para
6 iniciantes e abrem as portas para um mundo fantástico.</p>
7
8 <p>Este mecanismo foi inventado em 1986 por Chris Langton e depois generalizado
9 em várias formas (como veremos nos próximos exercícios). Foi provado que
10 Turmites e máquinas de Turing têm o mesmo poder: Uma trajetória de formiga
11 pode ser usada para calcular qualquer circuito booleano e logo uma formiga é
12 capaz de qualquer cálculo universal. a resumir, qualquer cálculo possível
13 pode ser alcançado a usar uma turmite como aparelho computacional. Ainda
14 outro assunto fascinante...</p>
15
16 <p>formigas de Langton multicoloridas foram descobertas em 1995 por Propp et
17 Al. Outro fato divertido é que as formigas cujos nomes é uma lista de pares
18 consecutivos de letras idênticas (LL e RR) produzem padrões simétricos. Este
19 fato foi até mesmo provado formalmente.</p>
20
21 <p>Verifique a página da wikipédia correspondente, na qual este exercício é
22 inspirado, para maiores detalhes.</p>
23
24 <h3>O que posso fazer para melhorar este universo do PLM?</h3>
25
26 <p>Como sempre, existem várias coisas que podem ser feitas no código deste
27 universo para melhorá-lo:</p>
28 <ul>
29 <li>Alguns bons exercícios estão provavelmente a faltar. O exercício de criador
30 de turmite é um pouco pé-duro: podemos introduzir os padrões de uma forma
31 mais amigável.</li>
32 <li>Quem sabe não escrevemos um exercício sobre os "busy beavers"?</li>
33 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Turmites</h2>
3
4 <p>Este exercício explora uma nova forma de extender o conceito de formiga de
5 Langton. Agora, o comportamento da formiga não depende apenas da cor no
6 chão, mas também do estado interno dela (representado por um valor
7 inteiro). A ideia de transformar a formiga num autômato vem naturalmente do
8 conceito de máquina de Turing. Isto explica o nome destes novos animais, que
9 é um amálgama de <i>Turing</i> e <i>Termite</i> (se não sabe o que uma
10 máquina de Turing é, vá à wikipédia, por que é impossível ser um cientista
11 da computação de verdade sem conhecê-la).</p>
12
13 <p>Novamente, tem que simplesmente escrever o método <code>step()</code>,
14 encarregado de fazer o turmite dar um passo. Novamente, deve primeiro
15 encontrar o rank da cor do chão da célula atual na sequência de cores. Mas
16 agora, os dados de <code>rule</code> (regras) dependem tanto da cor atual
17 quanto do estado atual. A <code>rule</code> na verdade contém 3 informações
18 em cada situação: a cor que a escreve, o movimento a fazer e o valor do
19 próximo estado. Por exemplo,
20 [!java|python]rule[1][0][/!][!scala]rule(1)(0)[/!] contém as informações
21 para usar quando <code>state==1</code> e <code>color==0</code>. Em outros
22 mundos, pode recuperar a informação relativa à sua situação atual a usar
23 <code>[!java|python]rule[state][currentColor][/!][!scala]rule(state)(currentColor)[/!]</code>.</p>
24
25 <p>Cada um destes conjuntos de informações contém 3 valores. O primeiro é o
26 rank da cor para escrever no chão. O segundo é o movimento para fazer, com a
27 seguinte notação: 0=stop, 1=noturn, 2=left, 4=u-turn, 8=right. Observe que
28 se o comando é stop, não se pode mover nem para a frente neste passo (mas
29 também não pode parar o programa: os próximos passos podem fazer algo mais
30 num estado futuro). Finalmente, o terceiro inteiro é o próximo valor do
31 <code>state</code> a ir dentro da próxima iteração.</p>
32
33 <p>Uma vez que estas notações arbitrárias são de certa forma difíceis de
34 lembrar, deve definir um conjunto de constantes que deve usar no lugar dos
35 valores numéricos diretos. Os nomes deles podem ser NOTURN, LEFT, RIGHT
36 etc. [!scala]Simplesmente declare-as a usar keyword <code>val</code> no
37 lugar de <code>var</code>. Deve sempre usar <code>val</code> no lugar de
38 <code>var</code> quando possível de qualquer forma.[/!] [!java]Os
39 modificadores <code>final static</code> antes do tipo dele é a forma de
40 marcar variáveis como constantes em Java. Deve escrever, por exemplo,
41 <code>static final int NOTURN=1;</code> Desculpe pela complesxidade desta
42 notação. [/!] [!python]Por convenção, tais variáveis constantes são escritas
43 em maiúsculas no python. Tecnicamente, ainda pode modificá-las, mas isto é
44 uma má ideia.[/!] Deve escrevê-las fora de qualquer método para que elas se
45 tornem visíveis globalmente.</p>
46
47 <p>Usar tais constantes ajuda em muito a fazer o código mais legível. Compare
48 os dois blocos de código a seguir:</p>
49
50 <pre>[!java]if (rule[state][currentColor][NEXT_MOVE] == LEFT) {[/!][!python]if rule[state][currentColor][NEXT_MOVE] == LEFT:[/!][!scala]if (rule(state)(currentColor)(NEXT_MOVE) == LEFT) {[/!]
51 left()[!java];[/!]
52 [!java|scala]}[/!]</pre>
53 <p>Isto é muito mais fácil de se ler (embora seja mais longo) do que o
54 seguinte:</p>
55 <pre>[!java]if (rule[i][j][1] == 2) {[/!][!python]if rule[i][j][1] == 2:[/!][!scala]if (rule(i)(j)(1) == 2) {[/!]
56 left()[!java];[/!]
57 [!java|scala]}[/!]</pre>
58
59 [!python]<p>Finalmente, provavelmente vai escrever um ramo <code>elif</code> para a
60 condição <code>STOP</code> também. Ter um ramo <code>else</code> a mostrar
61 uma mensagem de erro tal como "unknown case" é uma boa prática: faz as suas
62 suposições sobre o seu código mais explícitas e tem uma mensagem de erro se
63 elas falharem. Quando fizer isto, o próximo problema vai ser que não tem
64 nada para fazer no caso do <code>STOP</code>, mas python não permite que
65 escreva ramos <code>elif</code> vazios. Deve usar a instrução
66 <code>pass</code> como substituto, que diz ao python que tem um ramo aqui e
67 que não faz nada.</p>[/!] [!java|scala]<p>Provavelmente deve usar uma construção [!java]switch case[/!][!scala]pattern
68 matching[/!] para manter o seu código legível. Se não se lembra o que isto
69 é, veja <a href="plm://lessons.welcome/bdr.BDR2">este exercício</a>.</p>[/!]
70
71 <p>Agora tem informação o suficiente para conseguir.</p>
72
73 <h2>Notas bibliográficas</h2>
74 <p>De acordo com a wikipédia, os turmites foram inventados independentemente no
75 final dos anos oitenta. Foi provado que turmites em geral são exatamente
76 equivalentes em capacidade a máquinas de turing uni-dimensionais com uma
77 fita infinita, pois um pode simular o outro. Isto significa que qualquer
78 programa que possa conceber pode teoricamente ser executado neste
79 aparelho...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>formiga de Langton</h2>
3
4 <p>Neste exercício, vai transformar o seu buggle numa <i>formiga de
5 Langton</i>. Estes pequenos animais artificiais são bastante interessantes
6 por que eles recebem regras simples que dependem apenas do seu ambiente
7 local e depois de um período de aparente comportamento caótico, um modelo
8 geral <i>surge</i>.</p>
9
10 <p>As regras são absolutamente triviais: para calcular qual o próximo passo,
11 verifique a cor atual do chão (a usar <code>getGroundColor()</code>). Se for
12 branco, mude para preto, vire à direita e mova uma célula. Se for preto mude
13 para branco, vire a esquerda e ande uma célula.</p>
14
15 <p>Difícil encontrar regras mais simples, não é? Bem, vamos em frente codificar
16 isto agora. Precisa completar o método <code>step()</code>, que codifica o
17 comportamento da formiga em cada passo. Vai provavelmente usar o método
18 <code>getGroundColor()</code> para recuperar a cor da célula na qual a
19 formiga está no momento. Cores úteis são nomeadas simplesmente de
20 <code>Cor.preto</code> e <code>Cor.branco</code>.</p>
21
22 [!java]
23 <p>Para comparar cores, não pode usar o símbolo de igualdade (==), pois estas
24 coisas não são valores escalares, mas objetos. Ao invés disto, precisa
25 escrever algo como o seguinte:</p>
26 <pre>
27 Cor c /* = alguma inicialização */;
28 if (c.equals(Cor.preto)) {
29 /* é igual */
30 } else {
31 /* não é igual */
32 }
33 </pre>
34 [/!]
35
36 <p>Mudar a cor do chão não é difícil, mas meio demorado: tem que mudar a cor do
37 pincel do seu buggle, baixar o pincel (para marcar a célula atual -- com
38 <code>brushDown()</code>) e levantar o pincel de novo (com
39 <code>brushUp()</code>) para evitar problemas quando o buggle se mexer. É,
40 naturalmente, livre para organizar o seu código da forma que quiser, mas
41 deve querer escrever um método <code>setGroundColor(color)</code> para
42 separar um pouco as coisas.</p>
43
44 <p>Como pode ver da execução deste exercício, o interessante neste algoritmo é
45 que depois de uns 10000 passos de comportamento relativamente caótico, a
46 formiga começa a construir um modelo regular. O surgimento deste modelo
47 regular em meio ao caos é bastante fascinante, não acha? Mova para o próximo
48 exercício para ver mais disto.</p>
49
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>formiga de Langton multicolorida</h2>
3
4 <p>Existem várias formas de extender o conceito de formiga de Langton. Neste
5 exercício, vamos explorar a primeira, a usar mais que duas cores. Ela se
6 mantem muito similar ao caso base: o comportamento em cada passo ainda
7 depende da cor do chão, mas tem mais que duas possibilidades. Pode ter mais
8 que um tipo de formiga, a depender do que decide fazer para cada cor. Por
9 exemplo, a formiga LRL recebe 3 cores. Ela vira a esquerda na primiera cor,
10 a direita na segunda e a esquerda na terceira. De acordo com esta definição,
11 a formiga básica é uma RL (já que ela vira a direita em células brancas e a
12 esquerda em pretas).</p>
13
14 <p>Algumas destas formigas desenham padrões fascinantes (alterne o mundo para
15 vê-los): LLRR constrói uma figura simétrica semelhante a uma bola, LRRRRRLLR
16 desenha um quadrado, LLRRRLRLRLLR desenha um padrão regular convolucionado
17 depois de um período de aparente caos e RRLLLRLLLRRR parece preencher uma
18 ampulheta...</p>
19
20 <p>Transformar o seu buggle numa formiga de Langton genérica não é muito
21 complicado, embora não seja totalmente trivial. Como anteriormente, tem que
22 escrever uma função <code>step</code>. Mas desta vez, ela recebe duas arrays
23 como parâmetros. A primeira define as regras para seguir a depender da cor
24 do chão enquanto a segunda dá a sequência de cores a usar. Por exemplo, a
25 formiga básica deve ter [!java]<code>{'R', 'L'}</code> e <code>{Cor.branco,
26 Cor.preto}</code>[/!] [!python]<code>['R', 'L']</code> e <code>[Cor.branco,
27 Cor.preto]</code>[/!] [!scala]<code>Array('R', 'L')</code> e
28 <code>Array(Cor.branco, Cor.preto)</code>[/!] como argumentos.</p>
29
30 <p>Em cada passo, deve então ter que aplicar o seguinte pseudo-código:</p>
31 <ul>
32 <li>Encontre a posição da cor do chão na sequência de cores;</li>
33 <li>Vire a esquerda ou direita a depender do conteúdo da array de regras nesta
34 posição;</li>
35 <li>Marque o chão com a próxima cor na sequência (a cor seguinte à última é a
36 primeira);</li>
37 <li>ande um passo para frente.</li>
38 </ul>
39
40 <p>Agora tem informação o suficiente para conseguir.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Os turmites</h3>
3 <p>Descubra as formigas de Langton, que são máquinas de Turing 2D.</p>
4
5 <p>Estas atividades são problemas bem simples, bons para iniciantes e abrema a
6 porta para um mundo fantástico.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Criar Turmites</h2>
3
4 <p>Este exercício permite que construa os seus próprios turmites. Para passar
5 neste exercício, deve simplesmente escrever um método <code>init()</code>
6 que inicializa a <code>rule</code> para usar a seguintes tabela de
7 transições (da wikipédia), configure a posição inicial em (8;33) e peça por
8 8342 passos.</p>
9
10 <table border="1" style="text-align:center">
11 <tr>
12 <th rowspan="3" colspan="2"></th>
13 <th colspan="6">Cor atual</th>
14 </tr>
15 <tr>
16 <th colspan="3">0</th>
17 <th colspan="3">1</th>
18
19 </tr>
20 <tr style="font-size:9pt">
21 <th>Escrever cor</th>
22 <th>Turn</th>
23 <th>Próximo estado</th>
24 <th>Escrever cor</th>
25 <th>Turn</th>
26 <th>Próximo estado</th>
27 </tr>
28 <tr>
29 <th rowspan="2">Estado atual</th>
30
31 <th>0</th>
32 <td>1</td>
33 <td>R</td>
34 <td>0</td>
35 <td>1</td>
36 <td>R</td>
37 <td>1</td>
38 </tr>
39 <tr>
40 <th>1</th>
41
42 <td>0</td>
43 <td>N</td>
44 <td>0</td>
45 <td>0</td>
46 <td>N</td>
47 <td>1</td>
48 </tr>
49 </table>
50
51 <p>Onde a direção para virar é <b>L</b> (90° à esquerda), <b>R</b> (90° à
52 direita), <b>N</b> (não vira) e <b>U</b> (meia-volta).</p>
53
54 <h2>Ir mais longe</h2>
55 <p>Este exercício é naturalmente uma desculpa para deixá-lo experimentar com os
56 seus próprios turmites. Sinta-se à vontade para mudar a tabela de transições
57 e a quantidade de passos por conta própria. Nesta altura, pode se interessar
58 pela biblioteca de Pegg Jr. Se encontrar novos padrões interessantes,
59 envie-os por email para que eles possam integrar a lista! </p>
60
61 <p>Adicionalmente, a wikipédia está a precisar desesperadamente de alguns
62 turmites coloridos bem apresentáveis: apenas os preto e branco estão
63 descritos. Deveria considerar a possibilidade de enviar as suas criações
64 diretamente à enciclopédia livre.</p>
65
66 <p>Aqui estão alguns turmites de 2 cores, extraídos de
67 http://demonstrations.wolfram.com/Turmites/ [!python|scala]Eles não foram
68 escritos a usar o sintaxe de [!thelang], mas convertê-los não deve ser
69 difícil.[/!]</p>
70
71 <pre>
72 {{{1, RIGHT , 0}, {0, LEFT , 0}}} # 1: formiga de Langton
73 {{{1, RIGHT , 0}, {0, NOTURN, 0}}} # 2: contador binário
74 {{{0, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 3: (triâgulo preenchido)
75 {{{0, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {0, NOTURN, 1}}} # 4: espiral numa caixa
76 {{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 5: espiral stripe-filled
77 {{{0, RIGHT , 1}, {0, LEFT , 0}}, {{1, LEFT , 1}, {1, NOTURN, 0}}} # 6: pirâmide inclinada
78 {{{0, RIGHT , 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {1, LEFT , 0}}} # 7: ilha contoured
79 {{{0, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {0, RIGHT , 1}}} # 8: woven placemat
80 {{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {1, LEFT , 0}}} # 9: floco de neve
81 {{{1, LEFT , 0}, {0, NOTURN, 1}}, {{0, LEFT , 0}, {0, LEFT , 1}}} # 10: construtor de cidades lento
82 {{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 0}, {0, LEFT , 1}}} # 11: framed computer art
83 {{{1, LEFT , 0}, {1, RIGHT , 1}}, {{0, RIGHT , 1}, {1, LEFT , 0}}} # 12: balloon bursting (makes a spreading highway)
84 {{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 13: makes a horizontal highway
85 {{{1, LEFT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 1}, {1, RIGHT , 0}}} # 14: makes a 45 degree highway
86 {{{1, LEFT , 1}, {0, LEFT , 1}}, {{1, RIGHT , 1}, {0, LEFT , 0}}} # 15: makes a 45 degree highway
87 {{{1, LEFT , 1}, {0, NOTURN, 0}}, {{1, NOTURN, 0}, {1, RIGHT , 0}}} # 16: spiral in a filled box
88 {{{1, LEFT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 17: glaciers
89 {{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 18: golden rectangle!
90 {{{1, LEFT , 1}, {1, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 19: fizzy spill
91 {{{1, LEFT , 1}, {1, RIGHT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 20: nested cabinets
92 {{{1, NOTURN, 1}, {0, LEFT , 1}}, {{1, RIGHT , 0}, {1, NOTURN, 1}}} # 21: (cross)
93 {{{1, NOTURN, 1}, {0, NOTURN, 0}}, {{0, RIGHT , 0}, {1, LEFT , 0}}} # 22: saw-tipped growth
94 {{{1, NOTURN, 1}, {0, NOTURN, 1}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 23: curves in blocks growth
95 {{{1, NOTURN, 1}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 0}}} # 24: textured growth
96 {{{1, NOTURN, 1}, {0, RIGHT , 1}}, {{1, LEFT , 0}, {1, RIGHT , 0}}} # 25: (diamond growth)
97 {{{1, NOTURN, 1}, {1, LEFT , 0}}, {{1, RIGHT , 1}, {0, NOTURN, 0}}} # 26: coiled rope
98 {{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, NOTURN, 1}}} # 27: (growth)
99 {{{1, RIGHT , 0}, {0, LEFT , 1}}, {{1, LEFT , 0}, {0, RIGHT , 1}}} # 28: (square spiral)
100 {{{1, RIGHT , 0}, {1, RIGHT , 1}}, {{0, NOTURN, 0}, {0, NOTURN, 1}}} # 29: loopy growth with holes
101 {{{1, RIGHT , 1}, {0, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 0}}} # 30: Lanton's Ant drawn with squares
102 {{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, LEFT , 1}, {1, LEFT , 0}}} # 31: growth with curves and blocks
103 {{{1, RIGHT , 1}, {0, RIGHT , 0}}, {{0, NOTURN, 0}, {1, RIGHT , 1}}} # 32: distracted spiral builder
104 {{{1, RIGHT , 1}, {0, RIGHT , 1}}, {{1, NOTURN, 0}, {1, NOTURN, 1}}} # 33: cauliflower stalk (45 deg highway)
105 {{{1, RIGHT , 1}, {1, LEFT , 1}}, {{1, RIGHT , 1}, {0, RIGHT , 0}}} # 34: worm trails (eventually turns cyclic!)
106 {{{1, RIGHT , 1}, {1, NOTURN, 0}}, {{1, NOTURN, 0}, {0, NOTURN, 1}}} # 35: eventually makes a two-way highway!
107 {{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, NOTURN, 0}, {0, NOTURN, 0}}} # 36: almost symmetric mould bloom
108 {{{1, RIGHT , 1}, {1, RIGHT , 0}}, {{0, RIGHT , 0}, {1, NOTURN, 1}}} # 37: makes a 1 in 2 gradient highway
109 {{{1, RIGHT , 1}, {1, RIGHT , 1}}, {{1, LEFT , 1}, {0, RIGHT , 0}}} # 38: immediately makes a 1 in 3 highway
110 {{{0, RIGHT , 1}, {1, RIGHT , 1}}, {{0, LEFT , 2}, {0, LEFT , 0}}, {{1, RIGHT , 2}, {1, LEFT , 0}}} # 39: squares and diagonals growth
111 {{{1, LEFT , 1}, {0, NOTURN, 0}}, {{0, RIGHT , 2}, {1, LEFT , 0}}, {{1, RIGHT , 1}, {1, NOTURN, 0}}} # 40: streak at approx. an 8.1 in 1 gradient
112 {{{1, LEFT , 1}, {0, NOTURN, 2}}, {{0, RIGHT , 2}, {1, NOTURN, 1}}, {{1, RIGHT , 1}, {1, NOTURN, 0}}} # 41: streak at approx. a 1.14 in 1 gradient
113 {{{1, LEFT , 1}, {1, LEFT , 1}}, {{1, NOTURN, 0}, {0, NOTURN, 2}}, {{0, LEFT , 1}, {1, NOTURN, 1}}} # 42: maze-like growth
114 {{{1, LEFT , 2}, {0, RIGHT , 0}}, {{1, LEFT , 0}, {0, RIGHT , 0}}, {{0, LEFT , 0}, {0, LEFT , 1}}} # 43: growth by cornices
115 {{{1, RIGHT , 0}, {0, RIGHT , 2}}, {{0, LEFT , 0}, {0, RIGHT , 0}}, {{0, NOTURN, 1}, {1, LEFT , 0}}} # 44: makes a 1 in 7 highway
116 {{{1, RIGHT , 1}, {0, LEFT , 0}}, {{1, RIGHT , 2}, {0, NOTURN, 0}}, {{1, LEFT , 0}, {0, LEFT , 0}}} # 45: makes a 4 in 1 highway
117 </pre>
118
119 <p>Formigas de Langton podem não compartilhar do poder de expressão dos
120 turmites, mas ainda assim são fascinantes. Pode experimentar elas a usar o
121 método initLangton(), fornecido no seu template, que permite construir uma
122 tabela de transição do nome da formiga de Langton. Pequenas mudanças na
123 formiga podem resultar em grandes mudanças. Por exemplo, "RRL" parece não
124 levar a nenhum padrão, mesmo após um milhão de passos, mas "RLL" começa a
125 construir um padrão de estrada muito simples depois de menos de 100 passos!</p>
126
127 <p>Muitas das formigas de Langton constróem estradas: RL, claro, mas também
128 RLRLRLLRLR (em cerca de 2500 passos). O comportamento caótico das formigas
129 antes da estrada pode ser bastante curto (como no caso RLL que precisa de
130 apenas 100 passos para convergir) ou muito longo, como LLLLLLRRLRRR que
131 parece caótico até mais de 500.000 de passos antes de contruir a estrada, ou
132 até mesmo RRLLLRRRLRRR que precisa de 1.170.000 para começar a
133 convergir. Umas são estreitas e outras bem largas, como em RRLRLLRLRR
134 (200,000 passos). Esta formiga é também notável pois é meio quadrada mesmo
135 antes da estrada começar, enquanto que as outras não exibem nada de especial
136 antes da estrada.<p>
137
138 <p>Algumas formiga preenchem setores sólidos, como RRLLLRLLLRRR(16,000 passos),
139 RRLLLRLLLRRR (30,000 passos), RRLLLRRRRRLR (125,000 passos) ou RRLRLLRRRRRR
140 (20,000 passos). Algumas preenchem até mesmo todo o plano (RRLRR depois de
141 3000 passos). algumas das minhas favoritas são aquelas onde as formigas
142 parecem ricochetear desntro de uma caixa que vai a ficar maior em cada
143 batida, como LRRRRRLLR (30,000 passos). LRRRRLLLRRR é ainda mais
144 impressionante pois as ricocheteadas dantro da caixa são regulares e também
145 por que ela converge mais rapidamente o comportamento estável dele (15,000
146 passos são suficientes).</p>
147
148 <p>Finalmente, algumas formigas fazem padrões simplesmente artísticos. Pode
149 verificar este vídeo com alguns deles:
150 http://www.youtube.com/watch?v=1X-gtr4pEBU. Se quiser convertê-los em
151 código, tem que transladar um caractere: por exemplo, aquele descrito no
152 minuto 3:42 não será RRLRLRLLRL, mas sim RLRLRLLRLR (o primeiro movimento
153 visível deve ser lido como o último).</p>
154
155 <p>Como pode ver ao explorar o conjunto de turmites acima, elas não são tão
156 coloridas quanto as formigas, mas isto pode ser por que poucas cores são o
157 suficientes para exibir comportamentos complexos. Por exemplo, existe uma
158 classe específica de turmites chamada <i>busy beavers</i> que são turmites
159 que escrevem várias coisas antes de parar (busy beavers normalmente são
160 máquinas de turing clássicas, mas a ideia encaixa perfeitamente em turmites
161 também). Existe um tipode competição internacional onde as pessoas tentam
162 encontrar o turmite que cobre a maior área antes de parar. A página é esta:
163 http://code.google.com/p/ruletablerepository/wiki/TwoDimensionalTuringMachines
164
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Universo dos Turmites</h1>
3
4 <p>Este universo é bastante similar ao dos buggles, mas provavelmente não vai
5 usar nenhum método dos buggles. Então, esta página apenas repacitula os
6 métodos do buggle que vai usar.</p>
7
8 <p></p>
9
10 <table border=1>
11 <tr><td><b>Virar à esquerda<br/>Virar à direita<br/>Dar meia volta<br/>Mover para a frente<br/>Mover para trás</b></td>
12 <td>[!java|c]void [/!]left()<br/>[!java|c]void [/!]right()<br/>[!java|c]void [/!]back()<br/>
13 [!java|c]void [/!][!c]stepForward()[/!][!java|python|scala]forward()[/!] ou
14 [!java|c]void [/!]forward([!java|c]int [/!]passos[!scala]:Int[/!])<br/>
15 [!java|c]void [/!][!c]stepBackward()[/!][!java|python|scala]back()[/!] ou
16 [!java|c]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])<br/></td></tr>
17
18 <tr><td><b>Obtém a cor do chão</b></td><td>[!java|c]Color [/!]getGroundColor()[!scala]:Color[/!]</td></tr>
19 </table>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Turmite universe</h1>
3
4 <p>This universe is very similar to the buggle one, but you will probably not
5 use all buggles methods. So, this page only recap the buggle methods that
6 you will use.</p>
7
8 <p></p>
9
10 <table border=1>
11 <tr><td><b>Sväng vänster<br/>Sväng höger<br/>Kör tillbaka<br/>Kör framåt<br/>Backar</b></td>
12 <td>[!java|c]void [/!]vänster()<br/>[!java|c]void [/!]höger()<br/>[!java|c]void [/!]backa()<br/>
13 [!java|c]void [/!][!c]stepForward()[/!][!java|python|scala]forward()[/!] or
14 [!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])<br/>
15 [!java|c]void [/!][!c]stepBackward()[/!][!java|python|scala]backward()[/!]
16 or [!java|c]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])<br/></td></tr>
17
18 <tr><td><b>Get the color of the ground</b></td><td>[!java|c]Color [/!]getGroundColor()[!scala]:Color[/!]</td></tr>
19 </table>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Turtle Art</h1>
3
4 <p>Desde a concepção dela nos anos 60, a tartaruga do LOGO fascinou pela
5 habilidade dela de desenhar belas figuras no computador. Este lição permite
6 que explore algumas das figuras clássicas e desenhe as suas próprias.</p>
7
8 <p>A sintaxe da linguagem é não vai ser apresentada, mas se conhece um pouco ou
9 se alguém lhe mostrar, pode tentar estes exercícios mesmo a ser um completo
10 iniciante em programação.</p>
11
12 <p>Por favor mande-nos as suas melhores contribuições para que sejam
13 adicionadas a esta galeria para inspirar os próximos utilizadores.</p>
14
15 <h3>O que posso fazer para melhorar este universo do PLM?</h3>
16
17 <p>Como sempre, existem várias coisas que podem ser feitas no código deste
18 universo para melhorá-lo:</p>
19 <ul>
20 <li>Outros exercícios devem ser adicionados. Um conjunto completo de exercícios
21 está disponível em <a
22 href="http://neoparaiso.com/logo/#sect4">http://neoparaiso.com/logo/#sect4</a>
23 ou em <a
24 href="http://billkerr2.blogspot.fr/2009/08/40-maths-shapes-challenges.html.">http://billkerr2.blogspot.fr/2009/08/40-maths-shapes-challenges.html</a>.</li>
25 <li>A faltar: os built-ins arc() e arcTo(), que desenham um arco, tanto a mover
26 ou sem mover para o final do arco.</li>
27 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Turtle Art</h3>
3 <p>Desenhe belas figuras com a tartaruga do Logo e aprenda a programar enquanto
4 brinca.</p>
5
6 <p>Deve saber a sintaxe básica da linguagem de programação que escolher, mas
7 técnicas avançadas de programação não são necessárias para fazer esta lição.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Primeiros passos</h1>
3
4 A primeira lição vai te guiar pelos primeiros passos em programação. Ela é
5 feita para iniciantes. Lista de noções vistas por exercício:
6
7 <table border=1>
8 <tr>
9 <td>&nbsp;</td>
10 <td>Instruções</td>
11 <td>Comentários</td>
12 <td>Condicionais/ Expressões</td>
13 <td>Loops while (enquanto)</td>
14 <td>Variáveis</td>
15 <td>Loops for</td>
16 <td>loops Do/While (faça/enquanto)</td>
17 <td>Métodos</td>
18 <td>Switch</td>
19 <td>Arrays</td>
20 </tr>
21
22 <tr>
23 <td>Bem-vindo ao mundo dos Buggles</td>
24 <td align="center"><img src="img/focus_intro.png" /></td>
25 <td align="center"><img src="img/focus_not.png" /></td>
26 <td align="center"><img src="img/focus_not.png" /></td>
27 <td align="center"><img src="img/focus_not.png" /></td>
28 <td align="center"><img src="img/focus_not.png" /></td>
29 <td align="center"><img src="img/focus_not.png" /></td>
30 <td align="center"><img src="img/focus_not.png" /></td>
31 <td align="center"><img src="img/focus_not.png" /></td>
32 <td align="center"><img src="img/focus_not.png" /></td>
33 <td align="center"><img src="img/focus_not.png" /></td>
34 </tr>
35
36 <tr>
37 <td>Instruções Java</td>
38 <td align="center"><img src="img/focus_intro.png" /></td>
39 <td align="center"><img src="img/focus_not.png" /></td>
40 <td align="center"><img src="img/focus_not.png" /></td>
41 <td align="center"><img src="img/focus_not.png" /></td>
42 <td align="center"><img src="img/focus_not.png" /></td>
43 <td align="center"><img src="img/focus_not.png" /></td>
44 <td align="center"><img src="img/focus_not.png" /></td>
45 <td align="center"><img src="img/focus_not.png" /></td>
46 <td align="center"><img src="img/focus_not.png" /></td>
47 <td align="center"><img src="img/focus_not.png" /></td>
48 </tr>
49
50 <tr>
51 <td>A escrever programas mais complexos</td>
52 <td align="center"><img src="img/focus_working.png" /></td>
53 <td align="center"><img src="img/focus_intro.png" /></td>
54 <td align="center"><img src="img/focus_not.png" /></td>
55 <td align="center"><img src="img/focus_not.png" /></td>
56 <td align="center"><img src="img/focus_not.png" /></td>
57 <td align="center"><img src="img/focus_not.png" /></td>
58 <td align="center"><img src="img/focus_not.png" /></td>
59 <td align="center"><img src="img/focus_not.png" /></td>
60 <td align="center"><img src="img/focus_not.png" /></td>
61 <td align="center"><img src="img/focus_not.png" /></td>
62 </tr>
63
64 <tr>
65 <td>Instruções condicionais</td>
66 <td align="center"><img src="img/focus_check.png" /></td>
67 <td align="center"><img src="img/focus_not.png" /></td>
68 <td align="center"><img src="img/focus_intro.png" /></td>
69 <td align="center"><img src="img/focus_not.png" /></td>
70 <td align="center"><img src="img/focus_not.png" /></td>
71 <td align="center"><img src="img/focus_not.png" /></td>
72 <td align="center"><img src="img/focus_not.png" /></td>
73 <td align="center"><img src="img/focus_not.png" /></td>
74 <td align="center"><img src="img/focus_not.png" /></td>
75 <td align="center"><img src="img/focus_not.png" /></td>
76 </tr>
77
78 <tr>
79 <td>Loops while (enquanto)</td>
80 <td align="center"><img src="img/focus_check.png" /></td>
81 <td align="center"><img src="img/focus_not.png" /></td>
82 <td align="center"><img src="img/focus_check.png" /></td>
83 <td align="center"><img src="img/focus_intro.png" /></td>
84 <td align="center"><img src="img/focus_not.png" /></td>
85 <td align="center"><img src="img/focus_not.png" /></td>
86 <td align="center"><img src="img/focus_not.png" /></td>
87 <td align="center"><img src="img/focus_not.png" /></td>
88 <td align="center"><img src="img/focus_not.png" /></td>
89 <td align="center"><img src="img/focus_not.png" /></td>
90 </tr>
91 <tr>
92 <td>&nbsp;</td>
93 <td>Instruções</td>
94 <td>Comentários</td>
95 <td>Condicionais/ Expressões</td>
96 <td>Loops while (enquanto)</td>
97 <td>Variáveis</td>
98 <td>Loops for</td>
99 <td>loops Do/While (faça/enquanto)</td>
100 <td>Métodos</td>
101 <td>Switch</td>
102 <td>Arrays</td>
103 </tr>
104
105 <tr>
106 <td>A procurar Baggles</td>
107 <td align="center"><img src="img/focus_check.png" /></td>
108 <td align="center"><img src="img/focus_not.png" /></td>
109 <td align="center"><img src="img/focus_check.png" /></td>
110 <td align="center"><img src="img/focus_working.png" /></td>
111 <td align="center"><img src="img/focus_not.png" /></td>
112 <td align="center"><img src="img/focus_not.png" /></td>
113 <td align="center"><img src="img/focus_not.png" /></td>
114 <td align="center"><img src="img/focus_not.png" /></td>
115 <td align="center"><img src="img/focus_not.png" /></td>
116 <td align="center"><img src="img/focus_not.png" /></td>
117 </tr>
118
119 <tr>
120 <td>A armazenar e a manipular dados</td>
121 <td align="center"><img src="img/focus_check.png" /></td>
122 <td align="center"><img src="img/focus_not.png" /></td>
123 <td align="center"><img src="img/focus_check.png" /></td>
124 <td align="center"><img src="img/focus_check.png" /></td>
125 <td align="center"><img src="img/focus_intro.png" /></td>
126 <td align="center"><img src="img/focus_not.png" /></td>
127 <td align="center"><img src="img/focus_not.png" /></td>
128 <td align="center"><img src="img/focus_not.png" /></td>
129 <td align="center"><img src="img/focus_not.png" /></td>
130 <td align="center"><img src="img/focus_not.png" /></td>
131 </tr>
132
133 <tr>
134 <td>Loops for</td>
135 <td align="center"><img src="img/focus_check.png" /></td>
136 <td align="center"><img src="img/focus_not.png" /></td>
137 <td align="center"><img src="img/focus_check.png" /></td>
138 <td align="center"><img src="img/focus_check.png" /></td>
139 <td align="center"><img src="img/focus_check.png" /></td>
140 <td align="center"><img src="img/focus_intro.png" /></td>
141 <td align="center"><img src="img/focus_not.png" /></td>
142 <td align="center"><img src="img/focus_not.png" /></td>
143 <td align="center"><img src="img/focus_not.png" /></td>
144 <td align="center"><img src="img/focus_not.png" /></td>
145 </tr>
146
147 <tr>
148 <td>Loops Do .. while (faça .. enquanto)</td>
149 <td align="center"><img src="img/focus_check.png" /></td>
150 <td align="center"><img src="img/focus_not.png" /></td>
151 <td align="center"><img src="img/focus_check.png" /></td>
152 <td align="center"><img src="img/focus_not.png" /></td>
153 <td align="center"><img src="img/focus_not.png" /></td>
154 <td align="center"><img src="img/focus_not.png" /></td>
155 <td align="center"><img src="img/focus_intro.png" /></td>
156 <td align="center"><img src="img/focus_not.png" /></td>
157 <td align="center"><img src="img/focus_not.png" /></td>
158 <td align="center"><img src="img/focus_not.png" /></td>
159 </tr>
160
161 <tr>
162 <td>Métodos</td>
163 <td align="center"><img src="img/focus_check.png" /></td>
164 <td align="center"><img src="img/focus_not.png" /></td>
165 <td align="center"><img src="img/focus_check.png" /></td>
166 <td align="center"><img src="img/focus_check.png" /></td>
167 <td align="center"><img src="img/focus_not.png" /></td>
168 <td align="center"><img src="img/focus_not.png" /></td>
169 <td align="center"><img src="img/focus_not.png" /></td>
170 <td align="center"><img src="img/focus_intro.png" /></td>
171 <td align="center"><img src="img/focus_not.png" /></td>
172 <td align="center"><img src="img/focus_not.png" /></td>
173 </tr>
174 <tr>
175 <td>&nbsp;</td>
176 <td>Instruções</td>
177 <td>Comentários</td>
178 <td>Condicionais/ Expressões</td>
179 <td>Loops while (enquanto)</td>
180 <td>Variáveis</td>
181 <td>Loops for</td>
182 <td>loops Do/While (faça/enquanto)</td>
183 <td>Métodos</td>
184 <td>Switch</td>
185 <td>Arrays</td>
186 </tr>
187 <tr>
188 <td>Construir metodicamente</td>
189 <td align="center"><img src="img/focus_check.png" /></td>
190 <td align="center"><img src="img/focus_not.png" /></td>
191 <td align="center"><img src="img/focus_not.png" /></td>
192 <td align="center"><img src="img/focus_not.png" /></td>
193 <td align="center"><img src="img/focus_not.png" /></td>
194 <td align="center"><img src="img/focus_not.png" /></td>
195 <td align="center"><img src="img/focus_not.png" /></td>
196 <td align="center"><img src="img/focus_working.png" /></td>
197 <td align="center"><img src="img/focus_not.png" /></td>
198 <td align="center"><img src="img/focus_not.png" /></td>
199 </tr>
200
201 <tr>
202 <td>Métodos a retornar um resultado</td>
203 <td align="center"><img src="img/focus_check.png" /></td>
204 <td align="center"><img src="img/focus_not.png" /></td>
205 <td align="center"><img src="img/focus_check.png" /></td>
206 <td align="center"><img src="img/focus_not.png" /></td>
207 <td align="center"><img src="img/focus_check.png" /></td>
208 <td align="center"><img src="img/focus_check.png" /></td>
209 <td align="center"><img src="img/focus_not.png" /></td>
210 <td align="center"><img src="img/focus_intro.png" /></td>
211 <td align="center"><img src="img/focus_not.png" /></td>
212 <td align="center"><img src="img/focus_not.png" /></td>
213 </tr>
214 <tr>
215 <td>Métodos com perâmetros</td>
216 <td align="center"><img src="img/focus_check.png" /></td>
217 <td align="center"><img src="img/focus_not.png" /></td>
218 <td align="center"><img src="img/focus_check.png" /></td>
219 <td align="center"><img src="img/focus_not.png" /></td>
220 <td align="center"><img src="img/focus_not.png" /></td>
221 <td align="center"><img src="img/focus_check.png" /></td>
222 <td align="center"><img src="img/focus_not.png" /></td>
223 <td align="center"><img src="img/focus_intro.png" /></td>
224 <td align="center"><img src="img/focus_not.png" /></td>
225 <td align="center"><img src="img/focus_not.png" /></td>
226 </tr>
227
228 <tr>
229 <td>Desenhar metodicamente</td>
230 <td align="center"><img src="img/focus_check.png" /></td>
231 <td align="center"><img src="img/focus_not.png" /></td>
232 <td align="center"><img src="img/focus_not.png" /></td>
233 <td align="center"><img src="img/focus_not.png" /></td>
234 <td align="center"><img src="img/focus_not.png" /></td>
235 <td align="center"><img src="img/focus_not.png" /></td>
236 <td align="center"><img src="img/focus_not.png" /></td>
237 <td align="center"><img src="img/focus_working.png" /></td>
238 <td align="center"><img src="img/focus_not.png" /></td>
239 <td align="center"><img src="img/focus_not.png" /></td>
240 </tr>
241 <tr>
242 <td>Desenhar metodicamente (apenas grande)</td>
243 <td align="center"><img src="img/focus_check.png" /></td>
244 <td align="center"><img src="img/focus_not.png" /></td>
245 <td align="center"><img src="img/focus_not.png" /></td>
246 <td align="center"><img src="img/focus_not.png" /></td>
247 <td align="center"><img src="img/focus_not.png" /></td>
248 <td align="center"><img src="img/focus_check.png" /></td>
249 <td align="center"><img src="img/focus_not.png" /></td>
250 <td align="center"><img src="img/focus_working.png" /></td>
251 <td align="center"><img src="img/focus_not.png" /></td>
252 <td align="center"><img src="img/focus_not.png" /></td>
253 </tr>
254 <tr>
255 <td>&nbsp;</td>
256 <td>Instruções</td>
257 <td>Comentários</td>
258 <td>Condicionais/ Expressões</td>
259 <td>Loops while (enquanto)</td>
260 <td>Variáveis</td>
261 <td>Loops for</td>
262 <td>loops Do/While (faça/enquanto)</td>
263 <td>Métodos</td>
264 <td>Switch</td>
265 <td>Arrays</td>
266 </tr>
267 <tr>
268 <td>Desenhar maior e maior</td>
269 <td align="center"><img src="img/focus_check.png" /></td>
270 <td align="center"><img src="img/focus_not.png" /></td>
271 <td align="center"><img src="img/focus_not.png" /></td>
272 <td align="center"><img src="img/focus_not.png" /></td>
273 <td align="center"><img src="img/focus_not.png" /></td>
274 <td align="center"><img src="img/focus_check.png" /></td>
275 <td align="center"><img src="img/focus_not.png" /></td>
276 <td align="center"><img src="img/focus_working.png" /></td>
277 <td align="center"><img src="img/focus_not.png" /></td>
278 <td align="center"><img src="img/focus_not.png" /></td>
279 </tr>
280 <tr>
281 <td>Mais padrões para desenhar</td>
282 <td align="center"><img src="img/focus_check.png" /></td>
283 <td align="center"><img src="img/focus_not.png" /></td>
284 <td align="center"><img src="img/focus_not.png" /></td>
285 <td align="center"><img src="img/focus_not.png" /></td>
286 <td align="center"><img src="img/focus_not.png" /></td>
287 <td align="center"><img src="img/focus_check.png" /></td>
288 <td align="center"><img src="img/focus_not.png" /></td>
289 <td align="center"><img src="img/focus_working.png" /></td>
290 <td align="center"><img src="img/focus_not.png" /></td>
291 <td align="center"><img src="img/focus_not.png" /></td>
292 </tr>
293
294 <tr>
295 <td>Buggle Dance Revolution</td>
296 <td align="center"><img src="img/focus_check.png" /></td>
297 <td align="center"><img src="img/focus_not.png" /></td>
298 <td align="center"><img src="img/focus_working.png" /></td>
299 <td align="center"><img src="img/focus_check.png" /></td>
300 <td align="center"><img src="img/focus_not.png" /></td>
301 <td align="center"><img src="img/focus_not.png" /></td>
302 <td align="center"><img src="img/focus_not.png" /></td>
303 <td align="center"><img src="img/focus_not.png" /></td>
304 <td align="center"><img src="img/focus_not.png" /></td>
305 <td align="center"><img src="img/focus_not.png" /></td>
306 </tr>
307
308 <tr>
309 <td>Buggle Dance Revolution 2</td>
310 <td align="center"><img src="img/focus_check.png" /></td>
311 <td align="center"><img src="img/focus_not.png" /></td>
312 <td align="center"><img src="img/focus_working.png" /></td>
313 <td align="center"><img src="img/focus_check.png" /></td>
314 <td align="center"><img src="img/focus_not.png" /></td>
315 <td align="center"><img src="img/focus_not.png" /></td>
316 <td align="center"><img src="img/focus_not.png" /></td>
317 <td align="center"><img src="img/focus_not.png" /></td>
318 <td align="center"><img src="img/focus_intro.png" /></td>
319 <td align="center"><img src="img/focus_not.png" /></td>
320 </tr>
321
322 <tr>
323 <td>Caça à lesma</td>
324 <td align="center"><img src="img/focus_check.png" /></td>
325 <td align="center"><img src="img/focus_not.png" /></td>
326 <td align="center"><img src="img/focus_check.png" /></td>
327 <td align="center"><img src="img/focus_check.png" /></td>
328 <td align="center"><img src="img/focus_not.png" /></td>
329 <td align="center"><img src="img/focus_not.png" /></td>
330 <td align="center"><img src="img/focus_not.png" /></td>
331 <td align="center"><img src="img/focus_check.png" /></td>
332 <td align="center"><img src="img/focus_not.png" /></td>
333 <td align="center"><img src="img/focus_not.png" /></td>
334 </tr>
335 <tr>
336 <td>Rastrear a lesma</td>
337 <td align="center"><img src="img/focus_check.png" /></td>
338 <td align="center"><img src="img/focus_not.png" /></td>
339 <td align="center"><img src="img/focus_check.png" /></td>
340 <td align="center"><img src="img/focus_check.png" /></td>
341 <td align="center"><img src="img/focus_not.png" /></td>
342 <td align="center"><img src="img/focus_not.png" /></td>
343 <td align="center"><img src="img/focus_not.png" /></td>
344 <td align="center"><img src="img/focus_check.png" /></td>
345 <td align="center"><img src="img/focus_not.png" /></td>
346 <td align="center"><img src="img/focus_not.png" /></td>
347 </tr>
348 <tr>
349 <td>&nbsp;</td>
350 <td>Instruções</td>
351 <td>Comentários</td>
352 <td>Condicionais/ Expressões</td>
353 <td>Loops while (enquanto)</td>
354 <td>Variáveis</td>
355 <td>Loops for</td>
356 <td>loops Do/While (faça/enquanto)</td>
357 <td>Métodos</td>
358 <td>Switch</td>
359 <td>Arrays</td>
360 </tr>
361 <tr>
362 <td>Mundo das cobras</td>
363 <td align="center"><img src="img/focus_check.png" /></td>
364 <td align="center"><img src="img/focus_not.png" /></td>
365 <td align="center"><img src="img/focus_check.png" /></td>
366 <td align="center"><img src="img/focus_check.png" /></td>
367 <td align="center"><img src="img/focus_check.png" /></td>
368 <td align="center"><img src="img/focus_not.png" /></td>
369 <td align="center"><img src="img/focus_not.png" /></td>
370 <td align="center"><img src="img/focus_check.png" /></td>
371 <td align="center"><img src="img/focus_not.png" /></td>
372 <td align="center"><img src="img/focus_not.png" /></td>
373 </tr>
374
375 <tr>
376 <td>tricô e Arrays</td>
377 <td align="center"><img src="img/focus_check.png" /></td>
378 <td align="center"><img src="img/focus_not.png" /></td>
379 <td align="center"><img src="img/focus_check.png" /></td>
380 <td align="center"><img src="img/focus_not.png" /></td>
381 <td align="center"><img src="img/focus_check.png" /></td>
382 <td align="center"><img src="img/focus_check.png" /></td>
383 <td align="center"><img src="img/focus_not.png" /></td>
384 <td align="center"><img src="img/focus_check.png" /></td>
385 <td align="center"><img src="img/focus_not.png" /></td>
386 <td align="center"><img src="img/focus_intro.png" /></td>
387 </tr>
388
389 <tr>
390 <td>tricô, arrays e módulos</td>
391 <td align="center"><img src="img/focus_check.png" /></td>
392 <td align="center"><img src="img/focus_not.png" /></td>
393 <td align="center"><img src="img/focus_check.png" /></td>
394 <td align="center"><img src="img/focus_not.png" /></td>
395 <td align="center"><img src="img/focus_check.png" /></td>
396 <td align="center"><img src="img/focus_check.png" /></td>
397 <td align="center"><img src="img/focus_not.png" /></td>
398 <td align="center"><img src="img/focus_check.png" /></td>
399 <td align="center"><img src="img/focus_not.png" /></td>
400 <td align="center"><img src="img/focus_working.png" /></td>
401 </tr>
402 <tr>
403 <td>Percorrer pelas colunas</td>
404 <td align="center"><img src="img/focus_check.png" /></td>
405 <td align="center"><img src="img/focus_not.png" /></td>
406 <td align="center"><img src="img/focus_check.png" /></td>
407 <td align="center"><img src="img/focus_check.png" /></td>
408 <td align="center"><img src="img/focus_check.png" /></td>
409 <td align="center"><img src="img/focus_not.png" /></td>
410 <td align="center"><img src="img/focus_not.png" /></td>
411 <td align="center"><img src="img/focus_check.png" /></td>
412 <td align="center"><img src="img/focus_not.png" /></td>
413 <td align="center"><img src="img/focus_working.png" /></td>
414 </tr>
415 <tr>
416 <td>Percorrer pelas linhas</td>
417 <td align="center"><img src="img/focus_check.png" /></td>
418 <td align="center"><img src="img/focus_not.png" /></td>
419 <td align="center"><img src="img/focus_check.png" /></td>
420 <td align="center"><img src="img/focus_check.png" /></td>
421 <td align="center"><img src="img/focus_check.png" /></td>
422 <td align="center"><img src="img/focus_not.png" /></td>
423 <td align="center"><img src="img/focus_not.png" /></td>
424 <td align="center"><img src="img/focus_check.png" /></td>
425 <td align="center"><img src="img/focus_not.png" /></td>
426 <td align="center"><img src="img/focus_working.png" /></td>
427 </tr>
428 <tr>
429 <td>&nbsp;</td>
430 <td>Instruções</td>
431 <td>Comentários</td>
432 <td>Condicionais/ Expressões</td>
433 <td>Loops while (enquanto)</td>
434 <td>Variáveis</td>
435 <td>Loops for</td>
436 <td>loops Do/While (faça/enquanto)</td>
437 <td>Métodos</td>
438 <td>Switch</td>
439 <td>Arrays</td>
440 </tr>
441 <tr>
442 <td>Percorrer em zig-zag</td>
443 <td align="center"><img src="img/focus_check.png" /></td>
444 <td align="center"><img src="img/focus_not.png" /></td>
445 <td align="center"><img src="img/focus_check.png" /></td>
446 <td align="center"><img src="img/focus_check.png" /></td>
447 <td align="center"><img src="img/focus_check.png" /></td>
448 <td align="center"><img src="img/focus_not.png" /></td>
449 <td align="center"><img src="img/focus_not.png" /></td>
450 <td align="center"><img src="img/focus_check.png" /></td>
451 <td align="center"><img src="img/focus_not.png" /></td>
452 <td align="center"><img src="img/focus_working.png" /></td>
453 </tr>
454 <tr>
455 <td>Percorrer na diagonal</td>
456 <td align="center"><img src="img/focus_check.png" /></td>
457 <td align="center"><img src="img/focus_not.png" /></td>
458 <td align="center"><img src="img/focus_check.png" /></td>
459 <td align="center"><img src="img/focus_check.png" /></td>
460 <td align="center"><img src="img/focus_check.png" /></td>
461 <td align="center"><img src="img/focus_not.png" /></td>
462 <td align="center"><img src="img/focus_not.png" /></td>
463 <td align="center"><img src="img/focus_check.png" /></td>
464 <td align="center"><img src="img/focus_not.png" /></td>
465 <td align="center"><img src="img/focus_working.png" /></td>
466 </tr>
467
468 <tr>
469 <td>&nbsp;</td>
470 <td>Instruções</td>
471 <td>Comentários</td>
472 <td>Condicionais/ Expressões</td>
473 <td>Loops while (enquanto)</td>
474 <td>Variáveis</td>
475 <td>Loops for</td>
476 <td>loops Do/While (faça/enquanto)</td>
477 <td>Métodos</td>
478 <td>Switch</td>
479 <td>Arrays</td>
480 </tr>
481 </table>
482
483 <h2>Significado dos símbolos</h2>
484 <table>
485 <tr>
486 <td>Introduzir o conceito</td>
487 <td align="center"><img src="img/focus_intro.png" /></td></tr>
488 <tr>
489 <td>Trabalhar no conceito</td>
490 <td align="center"><img src="img/focus_working.png" /></td></tr>
491 <tr>
492 <td>Conceito tido como dominado</td>
493 <td align="center"><img src="img/focus_check.png" /></td></tr>
494 <tr>
495 <td>Conceito não é obrigatório para o exercício</td>
496 <td align="center"><img src="img/focus_not.png" /></td></tr>
497 </table>
498
499
500
501 <h2>O que irei aprender?</h2>
502 <p>Irá aprender o básico de programação. pelo menos, irá ser apresentado aos
503 mais importantes conceitos, a permitir que leia a maioria dos algoritmos
504 simples. Não será capaz de escrever ou ler programas completos por que ainda
505 não saberá nada sobre objetos, mas irá dominar o que é chamado de
506 "programação tática", ou seja, vai dominar a sintaxe o suficiente para não
507 ter qualquer problema com ela, a permitir que foque nos problemas
508 funcamentais que quer resolver ao invés de se debater com dificuldades de
509 sintaxe.</p>
510
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Array123</h1>
3 Dada uma array de inteiros, retorna true se .. 1, 2, 3, .. aparece em algum
4 lugar da array.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Array667</h1>
3 Dada uma array de inteiros, retorna a quantidade de vezes no qual dois 6
4 estão vizinhos na array. Também conta as instâncias onde o segundo "6" é, na
5 verdade um 7.
6
7 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
8 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>ArrayCount9</h1>
3 Dada uma array de inteiros, retorna a quantidade de 9's na array.
4
5 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
6 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>ArrayFront9</h1>
3 Dada uma array de inteiros, retorna true se um dos primeiros 4 elementos na
4 array é um 9. O comprimento da array pode ser menor que 4.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>[!java|scala]Arrays[/!][!python]Lists[/!] e nós</h1>
3
4 O objetivo deste exercício é reproduzir o padrão da primeira linha nas
5 outras linhas com um deslocamento de uma célula (veja a guia Objetivo para
6 detalhes). A maior diferença entre este exercício e os outros sobre padrões
7 é que tem que ler o padrão (na primeira linha) antes de reproduzí-lo. Não
8 pode fazer de outro jeito por que o mesmo código será executado em três
9 mundos diferentes, cada um com um próprio padrão.
10
11 <p>Uma solução é ler a próxima célula e copiá-la à posição antes de voltar para
12 ler a segunda célula. Mas já que é proibido usar os métodos de
13 teletransporte de buggle para uma posição específica (<code>setPos()</code>
14 e similares), esta abordagem seria muito difícil de implementar. </p>
15
16 <p>O mais simples é armazenar a sequência de cores que constituem o padrão
17 inteiro numa [!java|scala]<b>array</b>[/!][!python]<b>list</b>[/!]. Mas
18 antes de fazer isto, devemos aprender um pouco sobre o que
19 [!java|scala]arrays[/!][!python]lists[/!] são.</p>
20
21 <h2>[!java|scala]Arrays[/!][!python]List[/!]</h2>
22
23 <p>[!java|scala]Uma array[/!][!python]Uma list[/!] é uma sequência ordenada de
24 variáveis que ficam juntas. é similar a uma estante onde em cada prateleira
25 se coloca um valor separado. Cada variável da sequência é identificada pela
26 posição dela e pode armazenar um valor específico. [!java|scala]todas as
27 células da array devem armazenar valores do mesmo tipo por que arrays são
28 homogêneas em [!thelang]. É possível burlar esta restrição a usar tipos de
29 dados <code>[!java]Object[/!][!scala]Any[/!]</code> que contenham
30 [!java]praticamente[/!] qualquer outro tipo de dados. [!java]Tipos
31 primitivos como aqueles que vimos anteriormente (int, boolean, double, char,
32 etc) não podem ser armazenados numa variável Object, mas suas contrapartidas
33 objetificadas (Integer, Boolean, Double, Char, Boolean, etc) podem.[/!]
34 Entretanto, é boa prática fazer o tipo de uma array o mais específico
35 possível, p.ex., se planea armazenar alguns inteiros na sua array, faça dela
36 uma array de inteiros, não de [!java]Object[/!][!scala]Any[/!].[/!]
37 [!python]Lists podematé mesmo misturar valores de diferentes tipos, como
38 valores inteiros em algumas células e cores em outras células.[/!]</p>
39
40 <div style="text-align:center"><img src="lessons/welcome/array/array.png"/></div>
41
42 <p>T é o nome da [!java|scala]array[/!][!python]list[/!],
43 [!java|python]T[0][/!][!scala]T(0)[/!] é o nome da primeira célula,
44 [!java|python]T[1][/!][!scala]T(1)[/!] é o nome da segunda célula,
45 [!java|python]T[2][/!][!scala]T(2)[/!] da terceira e etc. E sim, a primeira
46 célula é numerada [!java|python]T[0][/!][!scala]T(0)[/!] e a última de uma
47 [!java|scala]array[/!][!python]list[/!] de tamanho N é
48 [!java|python]T[N-1][/!][!scala]T(N-1)[/!]. Pode parecer estranho contar a
49 partir de 0 e não de 1 como normalmente, mas por motivos históricos isto
50 agora é inevitável.</p>
51
52 <h3>Uso básico</h3>
53
54 <p>Podemos usar uma variável inteira <i>i</i> para acessar com
55 [!java|python]T[i][/!][!scala]T(i)[/!] as células: quando o valor de
56 <i>i</i> é 0, [!java|python]T[i][/!][!scala]T(i)[/!] acessa
57 [!java|python]T[0][/!][!scala]T(0)[/!]; quando o valor de <i>i</i> é 10,
58 [!java|python]T[i][/!][!scala]T(i)[/!] acessa
59 [!java|python]T[10][/!][!scala]T(10)[/!]. Sizemos que <i>i</i> é o
60 <b>índice</b> em T. <code>[!java|python]T[i][/!][!scala]T(i)[/!]</code> pode
61 ser usada simplesmente como qualquer variável. Podemos configurar um novo
62 valor:</p>
63 <pre>[!java|python]T[i][/!][!scala]T(i)[/!] = 78[!java];[/!]</pre>
64
65 <p>Podemos recuperar e usar valor dele: </p>
66 <pre>x = [!java|python]T[i][/!][!scala]T(i)[/!][!java];[/!]</pre>
67
68 <p>Podemos testar este valor:</p>
69 <pre>if ([!java|python]T[i][/!][!scala]T(i)[/!] > 0) [!scala|java]{[/!][!python]:[/!]
70 [!java|scala]//[/!][!python]#[/!] instruções...
71 [!java|scala]}[/!]</pre>
72
73 <p>É muito fácil percorrer toda a [!scala|java]array[/!][!python]list[/!], por
74 exemplo para iniciar as células.</p>
75
76 <pre>[!java]for (int i = 0; i&lt;T.length; i++) {[/!][!python]for i in range(len(T)):[/!][!scala]for (i &lt;- 0 to T.length-1) {[/!]
77 [!java|python]T[i][/!][!scala]T(i)[/!] = 3[!java];[/!]
78 [!java|scala]}[/!]</pre>
79
80 <p>[!java|scala]A notação <code>T.length</code> recupera o comprimento (length)
81 da array T,[/!] [!python]A função <code>len()</code> recupera o comprimento
82 da lista T,[/!] a permitir que se construa um loop clássico facilmente.
83 [!python]Na verdade, a função <code>len()</code> é muito mais genérica e
84 pode ser usada para recuperar o comprimento de muitos objetos. Aplicada numa
85 cadeia, por exemplo, ela retorna a quantidade de caracteres na cadeia.[/!]
86 [!scala]Não se esqueça de começar em <code>0</code> e terminar em
87 <code>T.length-1</code> ao invés de ir de <code>1</code> até
88 <code>T.length</code>.[/!]</p>
89
90 <p>Se quer simplesmente iterar nos valores de T sem controlar o índice, pode
91 simplesmente escrever:</p>
92 <pre>[!java]for (int i: T) {[/!][!scala]for (i &lt;- T) {[/!][!python]for i in T:[/!]
93 ação()[!java];[/!]
94 [!java|scala]}[/!]</pre>
95 <p>[!java]Esta construção é chamada um <i>loop extendido</i> em Java. A
96 variável <i>i</i> assume todos os valores do conjunto localizado a direita
97 do dois-pontos (:), um depois do outro.[/!] [!python|scala]Isto é na verdade
98 muito similar à construção anterior. Simplesmente,
99 <code>[!python]range(n)[/!][!scala]i to j[/!]</code> retorna um conjunto de
100 inteiros sobre os quais o loop for itera. Na verdade, [!thelang] oferece
101 formas muito mais elegantes de percorrer
102 [!python]lists[/!][!scala]arrays[/!] e outras coleções de dados, mas isto
103 fica para um conjunto específico de exercícios (que ainda será escrito no
104 PLM).[/!]</p>
105
106
107 <h3>Declarar uma [!python]list[/!][!java|scala]array[/!]</h3>
108
109 [!python]
110 <p>Se sabe antecipadamente o conteúdo da sua lista, pode atribuir os valores
111 todos juntos. Ponha eles simplesmente entre colchetes e separados por
112 vírgulas como segue:</p>
113 <pre>
114 L = [1, 3, 5, 7, 9]
115 <span class="comment"># L agora é uma array de 5 valores, todos eles inteiros</span></pre>
116 <p>Por outro lado, provavelmente vai criar uma lista vazia e depois anexar-la
117 os valores separadamente:</p>
118 <pre>
119 L2 = []
120 <span class="comment"># neste momento, L2 é uma lista vazia</span>
121 L2.append(1)
122 L2.append(3)
123 L2.append(5)
124 L2.append(7)
125 L2.append(9)
126 <span class="comment"># E agora o seu conteúdo é igual ao de L, vista antes</span></pre>
127 [/!] [!java|scala]
128 <p>Para declarar uma variável chamada <b>T</b> que pode guardar uma array de
129 inteiros, deve escrever:</p>
130 <pre>[!java]int[] T;[/!][!scala]var T:Array[Int][/!]</pre>
131
132 <p>[!java]<code>int</code> significa que os elementos da array são do tipo
133 inteiro; <code>[]</code> significa que estamos a falar de uma array e
134 <code>T</code> é o nome da variável. Por motivos históricos, também pode ser
135 escrito como <code>int T[]</code> (com o [] depois do nome da variável), mas
136 como assim é menos legível, é melhor evitar esta forma.[/!] [!scala]A
137 notação <code>[Int]</code> especializa o tipo Array (que é genérico), a
138 especificar que cada célula desta array é um inteiro. Um array de booleanos
139 deve ser escrito simplesmente como <code>Array[Boolean]</code>.[/!]
140 </p>
141
142 <h3>Alocar uma array</h3>
143
144 <p>Declarar uma variável <code>T</code> que armazena uma array apenas reserva o
145 <b>nome</b> <code>T</code> para uso futuro, mas não reserva a área de
146 memória para armazenar as células. A array ainda não está inicializada: ela
147 não tem qualquer valor. O que significa
148 <code>[!java]T[4][/!][!scala]T(4)[/!]</code> se ainda não dissemos que a
149 array tem 5 células?</p>
150
151 <p>Primeiramente, temos que dar um valor a <code>T</code>:</p>
152 <pre>[!java]T = new int[10];[/!][!scala]var T = new Array[Int](10)[/!]</pre>
153
154 <p><code>new</code> (novo) significa que queremos criar algo e
155 <code>[!java]int[10][/!][!scala]Array[Int](10)[/!]</code> significa que é
156 uma array de 10 valores inteiros. Como resultado, uma array de 10 células
157 para valores inteiros é criada na memória e a variável <code>T</code> <b>faz
158 referência</b> a esta array.</p>
159
160 <p>O tamanho de uma array é fixo e não pode ser mudado depois da criação da
161 array. O tamanho de uma array <code>T</code> pode ser recuperado ao se
162 consultar a variável <code>T.length</code>.</p>
163
164 <p>Ao alocar pode especificar o tamanho com uma variável: <code>[!java]int[] T
165 = new int[i];[/!][!scala]var T = new Array[Int](i);[/!]</code> Neste caso, o
166 tamanho da array será ajustado para o valor de <code>i</code> <i>quando
167 <code>new</code> for chamado</i>. O tamanho da array ainda não pode ser
168 modificado: mesmo se a variável <code>i</code> mudar depois disto, o tamanho
169 permanece o do valor dado no momento da alocação. [!java]Além disto, é
170 proibido escrever algo como <code>int T[10];</code> no momento de declarar a
171 variável. Deve usar a instrução <code>new</code> para alocar o array, como
172 em <code>int[] T = new int[10];</code> [/!]</p>
173
174 <h4>Declaração e inicialização</h4>
175 <p>Se sabe previamente o conteúdo da sua array, pode declarar, alocar e
176 inicializar-la toda de uma vez:</p>
177 <pre>[!java]int[] T = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };[/!][!scala]var T = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)[/!]</pre>
178
179 <p>Para saber o tamanho da array para alocar, o compilador conta os valores
180 dados. Este código é equivalente a:</p>
181 <pre>[!java]int[] T = new int[10];
182 T[0] = 1;
183 T[1] = 2;
184 ...
185 T[9] = 10;[/!][!scala]var T = new Array[Int](10);
186 T(0) = 1
187 T(1) = 2
188 ...
189 T(9) = 10[/!]</pre>
190
191 <p>também é equivalente a:</p>
192 <pre>[!java]int[] T = new int[10];
193 for (int i=0; i&lt;T.length; i++) {
194 T[i] = i+1;
195 }[/!][!scala]var T = new Array[Int](10);
196 for (i &lt;- 0 to T.length-1) {
197 T(i) = i+1
198 }[/!]</pre>
199
200
201 <!-- end of java|scala. python comes back -->
202 [/!]
203
204 <h3>[!python]Lists[/!][!scala|java]Arrays[/!] e parâmetros de métodos</h3>
205 <p>Não há nenhum problema em passar uma [!python]list[/!][!java|scala]array[/!]
206 para um método como parâmetro. Este método pode então usar este parâmetro
207 como se fosse definido localmente:</p>
208 <pre>[!java]boolean has42First(int[] array) {
209 return array[0] == 42;
210 }[/!][!python]def has42First(list):
211 return list[0] == 42[/!][!scala]def has42First(array:Array[Int]):Boolean = {
212 return array(0) == 42
213 }[/!]</pre>
214
215 <p>No lado de quem invoca também é bastante simples:</p>
216 <pre>[!java]int[] tab = new int[10];[/!][!scala]var tab = new Array[Int] (10)[/!][!python]tab = [1, 3, 5, 7, 9][/!]
217 [!java|scala]<span class="comment">// inicialização de valores omitida</span>
218 [/!]if (has42First(tab))[!java|scala] {[/!][!python]:[/!]
219 <span class="comment">[!java|scala]//[/!][!python]#[/!] faz algo</span>
220 [!java|scala]}[/!]</pre>
221
222 [!java]
223 <p>Se quer alocar e inicializar o array de uma vez só, é um pouco mais
224 complicado pois o compilador terá que saber o tipo do parâmetro queestá a
225 criar. Para isto, use a seguinte construção (feia):</p>
226 <pre>if (has42First( new int[] {1, 3, 5, 7, 9} ) {
227 <span class="comment">// faz algo</span>
228 }</pre>
229 [/!]
230
231 <p>Métodos também podem retornar [!java|scala]arrays[/!][!python]lists[/!] como
232 resultado sem nenhuma complicação. Aqui está um método que retorna uma
233 [!java|scala]array[/!][!python]list[/!] do tamanho pedido, preenchido com
234 42s.</p>
235
236 <pre>[!java]int[] fill42(int size) {
237 int[] res = new int[size];
238 for (int i=0; i&lt;size; i++)
239 res[i] = 42;
240 return res;
241 }[/!][!scala]def fill42(size:Int):Array[Int] = {
242 var res = new Array[int] (size)
243 for (i &lt;- 0 to size -1) {
244 res(i) = 42;
245 }
246 return res;
247 }[/!][!python]def fill42(size):
248 res = []
249 for i in range(size):
250 res.append(42)
251 return res[/!]</pre>
252
253 <h2>Objetivo deste exercício</h2>
254
255 <p>Finalmente! Depois desta longa explicação, podemos voltar ao exercício.</p>
256 <p>A sua missão é bastante simples, na verdade. O seu código deve guardar o
257 padrão de cores observado na primeira linha numa
258 [!java|scala]array[/!][!python]list[/!]. [!python]O mais fácil é criar uma
259 lista vazia e depois usar <code>append()</code>para adicionar as cores uma
260 por uma à medida que for a ler elas (com <code>getGroundColor()</code>).[/!]
261 [!java|scala]Para isto, deve declarar e alocar uma array de
262 <code>Cor</code>. Mas atencção, existem vários mundos, de diferentes
263 tamanhos; use <code>getWorldHeight()</code> para recuperar o tamanho do
264 mundo atual. Uma que a array esteja alocada, preencha ela a ler a cor do
265 chão em cada um dos pontos (com <code>getGroundColor()</code>).[/!]</p>
266
267 <p>Uma vez que conseguiu ler e gravar o padrão na primeira linha, tem que
268 reaplicar o padrão nas outras linhas, por exemplo a executar
269 <code>getWorldHeight()</code> vezes um método escrito especificamente para
270 isto.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>[!java|scala]Arrays[/!][!python]Lists[/!], Nós e Módulos</h1>
3
4 <p>Este exercício é similar ao anterior: tem que reproduzir o padrão de cores
5 da primeira célula para as outras.</p>
6
7 <p>A primeira diferença é que o mundo é cercado de muros: portanto tem que
8 modificar levemente a sua trajetória para garantir que o buggle não bata num
9 muro. O jeito mais simples é manipular a primeira célula fora do loop
10 <code>for</code> e fazer apenas <code>getWorldHeight()-1</code> passos no
11 loop.</p>
12
13 <p>A outra diferença é que o deslocamento para aplicar entre as colunas não é
14 fixo, mas está escrito na primeira célula de cada coluna. Para obter a
15 informação como um inteiro, podemos usar:</p>
16
17 <pre>[!java]int deslocamento = Integer.parseInt(readMessage())[/!][!python]deslocamento = int( readMessage() )[/!][!scala]val deslocamento = readMessage().toInt[/!]</pre>
18
19 <p><code>readMessage()</code> obtém a mensagem no chão como uma
20 [!java|scala]String[/!][!python]string[/!], enquanto
21 <code>[!java]Integer.parseInt(str)[/!][!scala]str.toInt[/!][!python]int(str)[/!]</code>
22 transforma a cadeia <code>str</code> num inteiro ao <i>ler</i> ela.</p>
23
24 <p>Então, para escolher a cor certa, o mais fácil é usar o operador
25 <code>%</code> (operador módulo). Por exemplo, <code>(i + 5) % tam</code>
26 serve para recuperar a <code>i</code>-ésima célula de uma array de tamanho
27 <code>tam</code> com um deslocamento de <code>5</code>.</p>
28
29 <p>Agora é consigo.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>sequência de Golomb</h1>
3
4 A sequência de Golomb é uma sequência de inteiros não decrescente onde a(n)
5 é a quantidade de vezes que n ocorre na sequência, com a(1) = 1.
6
7 <p>Como a(1)=1, significa que 1 ocorre apenas uma vez na sequência, então a(2)
8 deve ser diferente. Uma vez que a sequência é não-decrescente, a(2) deve ser
9 maior que 1. Como a(2)>1, o dígito 2 deve aparecer mais de uma vez na
10 sequência. Logo, a(2)=2.</p>
11
12 <p>Como a(2)=2, existem duas ocorrências de 2 na sequência, logo sabemos o
13 valor de a(3). E assim por diante para os outros valores da sequência.</p>
14
15 <p>Escreva uma função que calcule o N-ésimo elemento da sequência.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Has271</h1>
3 <p>Dada uma array de inteiros, retorne true se ela contém um padrão 2, 7, 1 --
4 um valor, seguido dele mais 5, seguinte dele menos 1. Então, 2,7,1 é um
5 exemplo deste padrão pois 7 é 5+2 e 1 é 2-1. 3,8,2 é outro exemplo.</p>
6
7 <p>Acicionalmente, o 271 "counts even" se o "1" difere por 2 ou menos do valor
8 correto.</p>
9
10 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
11 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Ilha dos Buggles</h1>
3
4 Acaba de receber as anotações de viagem da sua tia velha que atravessou o
5 país das Ilhas dos Buggles. Ela escreveu a altitude a cada quilômetro
6 durante a viagem, a resultar numa sequência de números como segue.
7
8 <pre>0 0 1 1 2 2 1 1 0 1 2 2 1 1 0</pre>
9
10 <p>Aqui está um corte das ilhas por este caminho:</p>
11
12 <pre>
13 /***\ /*\ &lt;-- 2 metros acima do nível do mar
14 /***********\ /*******\ &lt;-- 1 metro acima do nível do mar
15 *************************** &lt;-- nível do mar
16 | | | | | | | | | | | | | |
17 0 0 1 1 2 2 1 1 0 1 2 1 1 0 &lt;-- altitude em cada ponto
18 </pre>
19
20 <p>Este exemplo é constituído de quatro níveis de ilhas:</p>
21
22 <ul>
23 <li>1 1 2 2 1 1 (a ilha da esquerda)</li>
24 <li>2 2 (o topo da montanha da ilha da esquerda)</li>
25 <li>1 2 1 1 (a ilha da direita)</li>
26 <li>2 (a montanha da direita)</li>
27 </ul>
28
29 <p>Isto também pode ser visualizado desta forma:</p>
30
31 <pre>0 0(1 1(2 2)1 1)0(1(2)1 1)0</pre>
32
33 <p>Poderia escrever um pequeno programa que calculasse a quantidade de níveis
34 numa dada sequência de altitudes? Na verdade, existem uma solução iterativa
35 e uma recursiva para este problema.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>NenhumaTripla</h1>
3 Dada uma array de inteiros, digamos que uma tripla é um valor que aparece 3
4 vezes seguidas na array. Retorne true se a array não contém nenhuma tripla.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Valor médio</h1>
3
4
5 <p>O objetivo deste exercício é calcular o valor médio dos valores inteiros
6 armazenados numa array.</p>
7
8 <p>Tem que preencher o corpo do método <code>average()</code> que leva como
9 parâmetro a array de inteiros da qual calcula e retorna o valor médio. Por
10 favor note que este método deve retornar um inteiro.</p>
11
12 <p>para calcular o valor médio de um inteiro, é necessário percorrer toda a
13 array e calcular a soma de todos os valores (logo, precisa de uma variável
14 para armazenar este valor temporário) e por fim dividir esta soma pelo
15 tamanho da array.</p>
16
17 <p class="Java">Em Java, pode obter o tamanho de uma array <code>minhaarray</code> ao
18 consultar o atributo <code>length</code> (tamanho) dele (em outras palavras,
19 <code>minhaarray.length</code>). Observe que não existe parêntesis depois do
20 <code>length</code>.</p>
21
22 <p class="python">Em python, recuperar o tamanho de uma array <code>minhaarray</code> é tão
23 fácil como chamar <code>len(myarray)</code>.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Máximo e Mínimo</h1>
3
4 Neste exercício, deve retornar a diferença entre o máximo (p.ex., o maior
5 valor da array) e o mínimo (p.ex., o menor valor). O valor retornado é então
6 um número positivo. Mas atenção, só pode percorrer o array uma vez para
7 obter todas as informações de que necessita.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>ìndice do valor máximo</h1>
3
4 <p>Neste exercício, deve calcular o índice da célula da tab a conter o maior
5 valor.</p>
6
7 <p>Para isto, complete o método <code>indexOfMaximum()</code>. O parâmetro dele
8 é a array para explorar. Caso a array contenha o valor procurado várias
9 vezes, deve retornar o índice da primeira ocorrência.</p>
10
11 <p>Para resolver este exercício, deve varrer a array completamente. Para cada
12 valor, se for maior que o maior até o momento, este passa a ser o novo maior
13 e guarda o valor e a posição dele. Precisa de 2 variáveis adicionais; o
14 valor inicial do maior pode ser o valor da primeira célula.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Procurar por um dado valor</h1>
3
4 <p>O objetivo deste exercício é procurar a célula de um dado valor e retornar a
5 posição dela.</p>
6
7 <p>Para isto, deve preencher o método <code>indexOf()</code>, cujos parâmetros
8 são a array a ser explorada e o valor a ser procurado. Se o valor
9 <code>lookingFor</code> não está na array <code>tab</code>, o método deve
10 retornar -1.</p>
11
12 <p>A ideia do algoritmo é varrer toda a array, a verificar o valor de cada
13 célula. Se for o valor procurado, deve retornar o índice da célula que está
14 a ser verificada.</p>
15
16 <p>Lembre-se que os índices começam com 0 e não com 1. Logo, se houverem 3
17 células, os índices delas serão 0, 1 e 2. Não vai haver nenhuma célula
18 numerada com 3.</p>
19
20 <p class="Java">Lembre-se também que a quantidade de células numa array pode ser recuperada
21 a usar o atributo <code>length</code>. Portanto, se a sua array é chamada
22 <code>tab</code>, o tamanho dela será recuperado como
23 <code>tab.length</code>. Observe que não existe um () depois de
24 <code>length</code>. Um atributo é como uma variável dentro de outro objeto
25 (no caso, a array).</p>
26 <p class="Java">Logo, o último valor de uma array é dado por <code>tab[tab.length -
27 1]</code>.</p>
28
29 <p class="python">Lembre-se também que a quantidade de células numa array pode ser recuperada
30 com a função <code>len()</code>. Logo, se a sua array é chamada
31 <code>tab</code>, o tamanho dela pode ser recuperado como
32 <code>len(tab)</code>.</p>
33
34 <p class="python">Logo, o último valor de uma array é dado por <code>tab[ len(tab) -
35 1]</code>.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Valor maximal</h1>
3
4 <p>Neste exercício, deve calcular o valor maximal contido numa array. Para
5 isto, preencha o método <code>maximum()</code>, cujo parâmetro é a array
6 para explorar.</p>
7
8 <p>Para calcular este valor, percorra o parâmetro todo. Para cada valor, se for
9 maior que o maior valor até o momento, deve gravar este valor em algum lugar
10 para lembrar dele mais tarde. Vai precisar então de uma variável adicional,
11 que pode ser iniciada para o valor da primeira célula do array.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Ocorrência de um valor</h1>
3
4 <p>Neste exercício, deve calcular a quantidade de ocorrências de um dado valor
5 numa array (ou seja, a quantidade de tempo que este valor aparece na
6 array). Para isto, preencha o método <code>occurrences()</code>, que retorna
7 a quantidade de ocorrências de <code>lookingFor</code> em <code>tab</code>.</p>
8
9 <p>Para calcular este valor, simplesmente percorra a array a contar a
10 quantidade de células a conter o valor procurado. Vai precisar de uma
11 variável adicional para isso.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Segundo Maior Valor</h1>
3
4 <p>Neste exercício, deve calcular o segundo valor maximal contido numa array,
5 ou seja o valor que se torna máximo se remover cada instância do máximo
6 atual da array.</p>
7
8 <p>Como normalmente, deve obter informações em apenas uma passagem pela
9 array. Pode assumir que o segundo maior valor "actual" existe (existe pelo
10 menos dois valores distintos na array) e que todos os valores na array são
11 maiores que [!python] -100000000.[/!]
12 [!java|scala]<code>Integer.MIN_VALUE</code> (que é o menor inteiro
13 representável que existe em [!thelang]).[/!]</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Próximo de 10</h1>
3 <p>Dados dois valores int, retorne o valor que for mais próximo do 10 ou
4 retorne 0 no caso de um empate. [!java|scala]Note que Math.abs(n) retorna o
5 valor absoluto de um número.[/!] [!python]Note que math.fabs(n) retorna o
6 valor absoluto de um número. Esta função só pode ser usada se importar o
7 módulo math.[/!]</p>
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Contar Adolescentes</h1>
3 <p>Diremos que um número é "adolescente" se estiver no intervalo 13..19
4 inclusive. Dados 4 valores int, retorne a quantidade de adolescentes.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Diferença 21</h1>
3 Dado um int n, retorne a diferença absoluta entre n e 21, exceto que retorna
4 a diferença absoluta, se n for maior que 21.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Tem Adolescente</h1>
3 Diremos que um número é "adolescente" se está entre 13..19 inclusive. dados
4 3 valores int, retorne true se 1 ou mais deles são adolescentes.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Frio Quente</h1>
3 Dadas duas temperaturas, retorne true se uma é menor que 0 e a outra é maior
4 que 100.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>In [10;20]</h1>
3 Dados 2 valores int, retorne true se qualquer um deles estiver no intervalo
4 10..20 inclusive.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>In [30;50]</h1>
3 Dados 2 valores int, retorne true se estão ambos no intervalo 30..40
4 inclusive, ou se eles estão ambos no intervalo 40..50 inclusive.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Último Dígito</h1>
3 Dados dois valores int não negativos, retorne true se têm o mesmo dígito
4 final, como com 27 e 57. Note que o operador % "mod" calcula os restos, pois
5 17 % 10 é 7.
6
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://javabat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Lone Teen</h1>
3 Diremos que um número é "adolescente" se está no intervalo entre 13..19
4 inclusive. Dados 2 valores, retorne true se um ou o outro é adolescente, mas
5 não ambos.
6
7 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
8 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Boolean fun</h1>
3
4 <p>Operações booleanas são algumas das mais básicas tarefas na
5 programação. Enquanto não puder escrever um teste booleano não muito simples
6 em menos de um minuto, provavelmente terá dificuldades em escrever programas
7 no mundo real.</p>
8
9 <p>É por isto que esta lição fornece vários exercícios deste tipo, de forma que
10 fique treinado nisto.</p>
11
12 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
13 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Makes 10</h1>
3 Dados 2 inteiros, a e b, retorne true se um deles é 10 ou se a a soma deles
4 é 10.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Max1020</h1>
3 <p>Dados 2 valores int positivos, retorne o maior valor que está no intervalo
4 10..20 inclusive, ou retorne 0 se nenhum dos dois estiver neste intervalo.</p>
5
6 [!scala]<p>Observe que Math.max(Int,Int):Int e Math.min(Int,Int):Int retornam o máximo
7 e o mínimo de dois inteiros</p>[/!]
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>MonkeyTrouble</h1>
3
4 Temos dois macacos, a e b, e os parâmetros aSmile e bSmile indicam se cada
5 um está a sorrir. Teremos problemas se os dois estiverem a sorrir ou nenhum
6 deles estiver a sorrir. Retorne true se estivermos com problemas.
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Near Hundred</h1>
3 <p>Dado um int n, retorna true se estiver entre 10 a 100 ou
4 200. [!java|scala]Note que Math.abs(n) retorna o valor absoluto de um
5 número.[/!] [!python]Note que math.fabs(n) retorna o valor absoluto de um
6 número. Esta função só pode ser usada se importar o módulo math.[/!]</p>
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Parot Trouble</h1>
3
4 Temos um papagaio que fala alto. O parâmetro "hora" é a hora atual no
5 intervalo 0..23. Estamos com problemas se o papagaio fala e a hora for antes
6 de 7 ou depois de 20. Retorne true se estivermos com problemas.
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Positivo Negativo</h1>
3 Dados 2 valores int, retorne true se um é negativo e o outro é positivo. A
4 menos que o negativo seja true, neste caso ambos devem ser negativos.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>SleepDay</h1>
3
4 O parâmetro dia da semana é true se estivermos num dia de semana e o
5 parâmetro vacation (férias) é true se estivermos de férias. Dormimos de
6 manhã se não for dia de semana ou se estivermos de férias. Retorne true se
7 dormimos de manhã.
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Soma dupla</h1>
3 Dados dois valores int, retorne a soma deles. A menos que dois valores sejam
4 os mesmos, neste caso retorne o dobro da soma dele.
5
6 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
7 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Despertador</h1>
3 Dado o dia da semana, codificado da seguinte forma: 0=Domingo, 1=Segunda,
4 2=Terça, ... 6=Sábado e um booleano férias a indicar se estamos de férias,
5 retorne uma cadeia de caracteres da forma "7:00" que indica a que horas
6 devemos tocar o despertador. Nos dias da semana, devemos acordar às 7h e nos
7 finais de semana às 10h. Durante as férias, devemos acordar às 10h e nos
8 finais de semana desligar o despertador.
9
10
11 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
12 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>secretária eletrônica</h1>
3 O seu telemóvel toca. Retorne true se deve atender. Normalmente responde,
4 exceto de manhã, quando só a sua mãe lhe liga. De qualquer forma, se estiver
5 a dormir, não responde.
6
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>bilhete azul</h1>
3 Tem um bilhete de loteria azul, com os inteiros a, b e c. Eles fazem três
4 pares que chamaremos de ab, bc e ac. Considere a soma dos números de cada
5 par. Se a soma de um dos pares vale exatamente 10, o resultado é 10. Senão,
6 se a soma ab vale exatamente 10 mais que bc ou ac, o resultado é 5. Senão, o
7 resultado é 0.
8
9
10 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
11 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Radar de velocidade</h1>
3 Está a conduzir um pouco rápido demais e um guarda o para. Escreva o código
4 para calcular o resultado, codificado na forma de um inteiro: 0=sem multa,
5 1=multa leve, 2=multa pesada. Se a velocidade é inferior a 60, o resultado é
6 0. Se a velocidade está entre 61 e 80 (inclusive), o resultado é 1. Se a
7 velocidade é 81 ou maior, o resultado é 2. Estes casos são para dias que não
8 são o seu aniversário. No seu dia de aniversário a sua velocidade pode ser 5
9 maior em todos os casos.
10
11
12 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
13 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Festa dos charutos</h1>
3 Quando os esquilos fazem uma festa, eles gostam de ter charutos. Uma festa
4 de esquilos é boa quando a quantidade de charutos está entre 40 e 60
5 (inclusive). A menos que seja finais de semana, onde não há limite superior
6 para a quantidade de charutos. Retorne true se a festa foi um sucesso.
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Encontro elegante</h1>
3 Você e o seu par estão a tentar conseguir uma mesa no restaurante. O
4 parâmetro "you" (você) é o nível de elegância das suas roupas, no intervalo
5 0..10 e "date" (par) é o nível de elegância do seu par. O resultado da
6 tentativa de obter uma mesa é codificado como um valor inteiro com 0=no
7 (não), 1=maybe (talvez), 2=yes (sim). Se um de vocês está muito elegante, 8
8 ou mais, o resultado é 2 (yes). Com uma exceção: se um dos dois tem um
9 estilo de 2 ou menos o resultado é 0 (no). Caso contrário o resultado é 1
10 (maybe).
11
12
13 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
14 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Fizz Buzz</h1>
3 <p>De acordo com a Wikipedia, Fizz buzz é um jogo de "group word" para crianças
4 para ensinar divisão. Os jogadores jogam em turnos numéricos que vão a
5 aumentar, a substituir qualquer número divisível por três com a palavra
6 "Fizz" e qualquer número divisível por cinco com a palavra "Buzz". Qualquer
7 número que é divisível tanto por 3 quanto por 5 é substituído pela cadeia
8 "Fizz Buzz". </p>
9
10 <p>números que não são substituídos são simplesmente retornados como uma cadeia
11 [!java|scala]O eito mais fácil é usar esta construção em [!thelang]:
12 <code>""+a</code>[/!] [!python]A função <code>str(a)</code> transforma um
13 inteiro <code>a</code> numa cadeia.[/!]
14 </p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>bilhete verde</h1>
3 Tem um bilhete de loteria verde, com os inteiros a, b e c inscritos nele. Se
4 os números são todos diferentes uns dos outros, o resultado é 0. Se todos os
5 números são idênticos, o resultado é 20. Se dois dos números são os mesmos,
6 o resultado é 10.
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>De 1 a 10</h1>
3 Seja um número n, retorne true se n está no intervalo [1..10]. Exceto se
4 "outsideMode" é true e neste caso retorne true se o número é menor ou igual
5 a 1, ou maior ou igual a 10.
6
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Na ordem</h1>
3 Dados três inteiros, a b c, retorne true se b é maior que a, e c é maior que
4 b. Entretanto, com a exceção que se "bOk" é true, b não precisa ser maior
5 que a.
6
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Em ordem crescente</h1>
3 Dados três inteiros, a b c, retorne true se estão em ordem estritamente
4 crescente, como 2 5 11, ou 5 6 7, mas não 6 5 7 ou 5 5 7. Entretanto, com a
5 exceção de se "equalOk" for true, igualdade é permitida, como 5 5 7 ou 5 5
6 5.
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Último dígito 2</h1>
3 Dados três inteiros, a b c, retorne true se dois ou mais deles têm o mesmo
4 último dígito. Os inteiros são não negativos. Nota: o operador % "mod"
5 calcula o resto, p.ex. 17 % 10 é 7.
6
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Menor por 10</h1>
3 Dados três inteiros, a b c, retorne true se um deles é 10 ou menor que um
4 dos outros.
5
6
7 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
8 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>(mais) diversão com booleanos</h1>
3
4 <p>Uma ótima introdução a este tipo está disponível em:
5 http://codingbat.com/doc/java-if-boolean-logic.html</p>
6
7 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
8 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>MaxMod5</h1>
3 Sejam dois valores inteiros, retorne o maior dos dois. Entretanto, se os
4 dois valores possuem o mesmo resto quando divididos por 5, retorne o menor
5 dos dois. Entretanto, em todo caso, se os dois valores forem iguais, retorne
6 0. Nota: o operador % "mod" calcula o resto, p.ex. 7 % 5 é 2.
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Próximo de dez</h1>
3 Dado um inteiro positivo "num", retorne true se num estiver dentro de 2 de
4 um múltiplo de 10. Nota: ( a % b ) é o resto da divisão de a por b, assim (7
5 % 5) é 2.
6
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Bilhete vermelho</h1>
3 Tem um bilhete de loteria vermelho com três inteiros a, b e c. Cada um com o
4 valor 0, 1, ou 2. Se todos têm o valor 2, o resultado é 10. Senão, se eles
5 são iguais, o resultado é 5. Senão, e se b e c são diferentes de a, o
6 resultado é 1. Senão, o resultado é 0.
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>dígitos compartilhados</h1>
3 Dados dois inteiros, cada um no intervalo 10..99, retorne true se existe um
4 dígito que aparece nos dois números, como 2 em 12 e 23. (Nota: divisão,
5 p.ex. n/10, retorna o dígito à esquerda e % "mod" n%10 retorna o dígito a
6 direita.)
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://javabat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Soma de inteiros</h1>
3 Dados 2 inteiros, a e b, retorne a soma deles. Entretanto, somas no
4 intervalo 10..19 inclusive, são proibidas. Neste caso, simplesmente retorne
5 20.
6
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Jogo do Esquilo</h1>
3 Os esquilos em Palo Alto passam a maior parte do dia a jogar. Em particular,
4 eles jogam se a temperatura está entre 60 e 90 °F (inclusive). A menos que
5 seja verão e neste caso o limite superior é de 100 ao invés de 90. Seja uma
6 temperatura inteira e um isSummer (éVerão) booleano. Retorne true se eles
7 jogam e false caso contrário.
8
9
10 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
11 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Festa do chá</h1>
3 Estamos a ter uma festa com chá e doces. Retorne o resultado inteiro da
4 festa codificado como 0=ruim, 1=bom, ou 2=excelente. Uma festa é boa (1) se
5 o chá e os doces são pelo menos 5. Entretanto, se tanto os doces como o chá
6 forem pelo menos o dobro do outro, a festa é excelente (2). Entretanto, em
7 todo caso, se tanto o chá quanto os doces forem menos que 5, a festa é
8 sempre ruim (0).
9
10
11 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
12 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Soma de adolescentes</h1>
3 Dados dois números inteiros (a e b), retorne a soma deles. Entretanto, os
4 valores adolescentes no intervalo 13..19 são particularmente
5 sortudos. Portanto, se um dos números for um adolescente, retorne
6 simplesmente 19.
7
8
9 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
10 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Dois como um</h1>
3 Dados três inteiros a, b e c, retorne true se é possível adicionar dois
4 deles e o resultado ser o terceiro.
5
6
7 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
8 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Sem dobros</h1>
3 Retorne a soma das rolagens de dois dados de 6 lados. Entretanto, se
4 noDoubles é true e os dois dados derem o mesmo valor, incremente um dos
5 dados para o valor seguinte, e volte a 1 se o valor for 6.
6
7
8 <p>Este exercício foi convertido para o PLM do excelente sítio de exercícios
9 http://codingbat.com/</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Buggle Dance Revolution (BDR)</h2>
3
4 <p>Depois destas corridas, é hora de festejar! Para isto, vamos ensinar os
5 buggles a jogar Dance Revolution, este jogo amado por alguns estudantes: O
6 jogador tem que mover os pés num carpete de acordo com as instruções
7 apresentadas no ecrã e seguir a música. Mas antes disto, temos alguns
8 detalhes para estudar primeiro.</p>
9
10 [!java|scala|c]
11 <h3>Condicionais sem colchetes</h3>
12 <p>
13 Existe um detalhe que omitimos sobre a sintaxe do condicional: se um ramo
14 contém apenas uma instrução, então o colchetes se torna opcional. Portanto,
15 estes dois pedaços de código são equivalentes:</p>
16
17 <pre>if (<b>condição</b>) {
18 <b>oQueFazerSeACondiçãoÉVerdadeira();</b>
19 } else {
20 <b>oQueFazerCasoContrário();</b>
21 }</pre>
22 <pre>if (<b>condição</b>)
23 <b>oQueFazerSeACondiçãoÉVerdadeira();</b>
24 else
25 <b>oQueFazerCasoContrário();</b></pre>
26
27 <p>Na verdade, pode fazer o mesmo em corpos de loop que se reduzem a apenas uma
28 instrução. Mas cuidado, isto torna-se perigoso se cadeiar as instruções
29 <tt>if</tt> como a seguir: </p>
30 <pre>if (isOverBaggle())
31 if (x == 5)
32 left();
33 else // Não escreva desta forma, é enganoso!
34 right();
35 [!c]stepForward();[/!][!java|scala]forward();[/!]</pre>
36
37 <p>Pensa que <code>right()</code> se refere ao primeiro <code>if</code> e será
38 executado quando <code>isOverBaggle()</code> retorna false, mas, na verdade,
39 refere-se ao segundo <code>if</code> e será executado quando
40 <code>isOverBaggle()</code> retorna true e <code>x != 5</code>. Sim, apesar
41 da indentação, o buggle entende o código anterior da seguinte forma:</p>
42
43 <pre>if (isOverBaggle())
44 if (x == 5)
45 left();
46 else
47 right();
48 [!c]stepForward();[/!][!java|scala]forward();[/!]</pre>
49
50 <p>Em [!thelang] o computador conecta um ramo <tt>else</tt> ao <tt>if</tt> mais
51 próximo. Se o achar ambíguo, deve adicionar mais aspas do que estritamente
52 necessário. Os computadores nem sequer olham para a indentação em
53 [!thelang]. O código anterior pode até ser escrito da seguinte forma e levar
54 ao mesmo resultado.</p>
55
56 <pre>if (isOverBaggle()) if (x == 5) left(); else right(); [!c]stepForward();[/!][!java|scala]forward();[/!]</pre>
57
58 <p>Mas para humanos, <b>realmente é melhor indentar o seu código
59 corretamente</b>. Por exemplo, se quer que um professor reveja ou mesmo
60 avalie o seu código, se quer reutilizar o seu próprio código mais tarde, ou
61 mesmo se precisa depurá-lo. Isso é certo: precisa escrever um código legível
62 para o seu próprio conforto.</p> [/!]
63
64 <h3>Encadear condicionais</h3>
65
66 <p>Algumas vezes quer perguntar o buggle algo similar a:</p>
67 <pre>se está a chover, leve um guarda-chuva;
68 se não e se está quente, leve uma garrafa de água;
69 se não e se hoje é 4 de Julho, leve uma bandeira dos estados unidos</pre>
70
71 <p>A armadilha é que queremos que pelo menos uma destas ações sejam feitas. É
72 como dizer, se está a chover num 4 de Julho quente, não queremos que o
73 buggle vá para fora com um guarda-chuva, água e um bandeira, mas
74 simplesmente com um guarda-chuva. O código seguinte está, então, ERRADO.</p>
75
76 <pre>[!scala|c|java]if (chuvoso())
77 pegueGuarda-Chuva();
78 if (quente())
79 pegueAgua();
80 if (hoje4Julho())
81 pegueBandeira();[/!][!python]if aChover():
82 pegueGuarda-Chuva()
83 if quente():
84 pegueAgua()
85 if hoje4Julho():
86 pegueBandeira()[/!]</pre>
87
88
89 <p>Na verdade, já que as condições são calculadas uma depois da outra, existe
90 um risco de que vá sair no die 4 de Julho num dia chuvoso. Na verdade,
91 devemos usar algo como isto para garantir que uma vez que encontremos a
92 condição verdadeira, não passemos às próximas.</p>
93
94 <pre>[!java|scala|c]if (chuvoso()) {
95 levarGuardaChuva();
96 } else {
97 if (diaQuente()) {
98 levarAgua();
99 } else {
100 if (jogoDaCopa()) {
101 levarBandeira();
102 }
103 }
104 }[/!][!python]if chuvoso():
105 levarGuardaChuva()
106 else:
107 if diaQuente():
108 levarAgua()
109 else:
110 if jogoDaCopa():
111 levarBandeira()[/!]</pre>
112
113
114 <p>Infelizmente, tal cascata de condicionais é bastante difícil de ler. É
115 melhor [!java|scala|c]omitir as chaves para as assertivas
116 <tt>else</tt>. Algumas linguagens até mesmo introduzem uma construção
117 específica para estes <tt>else if</tt>, mas não [!thelang].[/!]
118 [!python]mudar os sub-blocos a usar a palavra-chave <code>elif</code> para
119 marcar explicitamente estes ramos "else if".[/!]
120 </p>
121
122 <pre>[!c|java|scala]if (chuvoso()) {
123 levarGuardaChuva();
124 } else if (diaQuente()) {
125 levarAgua();
126 } else if (jogoDaCopa()) {
127 levarBandeira();
128 }[/!][!python]if chuvoso():
129 levarGuardaChuva()
130 elif diaQuente():
131 levarAgua()
132 elif jogoDaCopa():
133 levarBandeira()[/!]</pre>
134
135 <h3>Grafitagem no mundo dos Buggles</h3>
136
137 <p>Os buggles podem grafitar no chão do mundo deles. Para isto, use os quatro
138 métodos seguintes:</p>
139
140 <ul>
141 <li><code>[!c]int[/!][!java]boolean[/!]
142 isOverMessage()[!scala]:Boolean[/!]</code>: returns
143 <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> se e somente se
144 existe uma mensagem no chão.</li>
145 <li><code>[!c]char*[/!][!java]String[/!] readMessage()[!scala]:
146 String[/!]</code>: retorna a mensagem lida no chão (ou uma cadeia vazia se
147 não há nada escrito).</li>
148 <li><code>[!java|c]void[/!] escreverMensagem([!c]char*[/!][!java]String
149 [/!]msg[!scala]: String[/!])</code>: escreve a mensagem especificada no
150 chão. Se já existe uma mensagem no chão, a nova é adicionada no final da
151 mensagem existente.</li>
152 <li><code>[!java|c]void [/!]clearMessage()</code>: limpa o que está escrito no
153 chão.</li>
154 </ul>
155
156
157 <h3>Objetivo do exercício</h3>O objetivo é então organizar um jogo de BDR entre os buggles a ensinar eles
158 a se mover de acordo com as instruções escritas no chão. Estas instruções
159 são mensagens escritas no chão, com o seguinte significado:
160
161 <table border="1">
162 <tr><td>Mensagem</td>
163 <td>O que fazer</td>
164 <td>Mnemônico</td></tr>
165
166 <tr><td>[!java|c]'R'[/!][!scala|python]"R"[/!]</td><td>Vire a direita (R de right) e mova um passo a frente</td><td>Direita</td></tr>
167 <tr><td>[!java|c]'L'[/!][!scala|python]"L"[/!]</td><td>Vire a esquerda e mova um passo a frente</td><td>Esquerda</td></tr>
168 <tr><td>[!java|c]'I'[/!][!scala|python]"I"[/!]</td><td>Vire para trás (meia-volta) e mova um passo a frente</td><td>Inversa</td></tr>
169
170 <tr><td>[!java|c]'A'[/!][!scala|python]"A"[/!]</td><td>Mova um passo a frente</td><td>Primeira letra do alfabeto</td></tr>
171 <tr><td>[!java|c]'B'[/!][!scala|python]"B"[/!]</td><td>Mova dois passos a frente</td><td>Segunda letra do alfabeto</td></tr>
172 <tr><td>[!java|c]'C'[/!][!scala|python]"C"[/!]</td><td>Mova três passos a frente</td><td>Terceira letra do alfabeto</td></tr>
173
174 <tr><td>[!java|c]'Z'[/!][!scala|python]"Z"[/!]</td><td>Mova um passo para trás</td><td>última letra do alfabeto</td></tr>
175 <tr><td>[!java|c]'Y'[/!][!scala|python]"Y"[/!]</td><td>Mova dois passos para trás</td><td>penúltima letra do alfabeto</td></tr>
176 <tr><td>[!java|c]'X'[/!][!scala|python]"X"[/!]</td><td>Mova três passos para trás</td><td>Antepenúltima letra do alfabeto</td></tr>
177 <tr><td><i>(qualquer outra coisa)</i></td><td>Parar de dançar.</td><td></td></tr>
178 </table>
179
180 <h3>Indicações</h3>
181
182 Este exercício pode parecer um pouco complexo à primeira vista, mas ele vem
183 a resumir a informação na tabela numa sequência de condicionais.
184
185 <p>Tem que se manter a dançar enquanto houverem passos de dança para fazer,
186 p.ex., enquanto estivermos numa célula cujo conteúdo esteja contido na
187 tabela. a forma mais fácil de fazer isto é a usar uma variável booleana
188 (<code>terminou</code>) como condição de término para o loop
189 <code>while</code>. Ela deve ser iniciada como
190 <code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code> e trocada
191 para <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> assim que
192 o buggle encontre uma célula com um valor não descrito na tabela. Assim, o
193 loop pára e o programa termina. </p>
194
195 [!java|c]
196 <p>Outro detalhe é que detetar se cadeias são iguais é um pouco chato em
197 Java. Então, usamos o <code>char getIndication[!c]Bdr[/!]()</code> ao invés
198 do <code>[!java]String[/!][!c]char*[/!] readMessage()</code>. Este método,
199 conhecido apenas pelos buggles deste exercício, retorna o primeiro caractere
200 da mensagem escrita no chão (ou ' ' -- o caractere para espaço -- se não tem
201 nada escrito). Ele ativa que se trabalhe com caracteres ao invés de cadeias,
202 que é muito mais simples em [!thelang].</p>
203 [/!]
204
205 <h3>Dicas</h3>
206
207 Se não entendeu por que o buggle não fez os passos esperados, tente
208 adicionar <code>brushDown()</code> no seu método. Isto pede ao buggle para
209 abaixar um pincel a deixar um rastro por onde passar. Isto pode ajudá-lo a
210 entender a trajetória dele, mas não se esqueça de remover esta chamada
211 quando quiser testar se o seu código é uma solução válida para o exercício:
212 pode fazer o buggle dançar, mas não pichar a pista de dança.
213
214 <p>Quando seu programa finalmente funcionar, vá ao próximo exercício.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Buggle Dance Revolution 2 (BDR2)</h2>
3
4 [!java|scala|c]
5 <p>BDR é legal, mas um pouco caótico. Primeiro, os buggles balançam em todas as
6 direções, o que faz com que o código que tenha que escrever para fazê-los se
7 mover seja um pouco difícil de ler. Apresentamos agora um novo mundo DBR
8 onde os buggles dançam num suave círculo. Vamos aproveitar esta
9 tranquilidade para limpar um pouco nosso código graças a novas construções
10 que vamos introduzir.</p>
11
12 <h3>[!java|c]condicionais <code>switch</code>[/!][!scala]busca de padrões[/!]</h3>
13
14 <p>A parte mais difícil do código anterior é comn certeza a cascata de
15 condicionais. Em algum ponto do seu código, certamente tem algo como isto:</p>
16
17 <pre>if ([!java|c]getIndicação() == 'R'[/!][!scala]lerMensagem() == "R"[/!]) {
18 right();
19 [!c]stepForward()[/!][!java|scala]forward()[/!];
20 } else if ([!java|c]getIndicação() == 'L'[/!][!scala]lerMensagem() == "L"[/!]) {
21 left();
22 [!c]stepForward()[/!][!java|scala]forward()[/!];
23 } else if ([!java|c]getIndicação() == 'I'[/!][!scala]lerMensagem() == "I"[/!]) {
24 back();
25 [!c]stepForward()[/!][!java|scala]forward()[/!];
26 <span class="comment">/* other else if */</span>
27 } else {
28 terminou = [!c]1[/!][!java|scala]true[/!];
29 }
30 </pre>
31
32 <p>Quando revisa este código, não fica claro à primeira vista que é
33 simplesmente a escolha entre quatro ramos a depender do valor de
34 [!java|c]getIndicação()[/!][!scala]lerMensagem()[/!]. Para melhorar ele,
35 vamos usar uma construção [!java|c]<code>switch</code>, que na sintaxe de
36 Java é o seguinte:[/!] [!scala] de busca de padrões, que é bastante poderosa
37 e generaliza muito o <code>if</code>. É com certeza uma das maiores
38 vantagens de Scala quando comparada com linguagens como Java ou python. E
39 nem é tão nova assim, já que outras linguagens como OCaml e Haskell já tem
40 esta funcionalidade há muito tempo. É bem fixe![/!]</p>
41 [/!] [!java|c]
42 <pre>
43 switch (<b>expression</b>) {
44 case <b>firstValue</b>:
45 <b>whatToDoIfExpressionEqualsFirstValue();</b>
46 break;
47 case <b>secondValue</b>:
48 <b>whatToDoIfExpressionEqualsSecondValue();</b>
49 break;
50 case <b>thirdValue</b>:
51 <b>whatToDoIfExpressionEqualsThirdValue();</b>
52 break;
53 /* as much similar cases as you want */
54 default:
55 <b>whatToDoIfExpressionDoesNotEqualsAnySeenValues();</b>
56 }</pre>
57
58 <p>Observe que cada ramo de um <tt>switch</tt> deve terminar com um
59 <code>break</code>. se esquecer dele, a máquina continua e executa o próximo
60 ramo na lista depois do ramo para o qual pulou. Existem na verdade uns
61 <b>raros</b> casos onde este comportamento é útil.</p>
62
63 <p>É então possível reescrever o código do BDR anterior numa forma mais clara a
64 usar a construção <tt>switch</tt>:</p>
65
66 <pre>switch (getIndicação()) {
67 case 'R':
68 right();
69 [!c]stepForward()[/!][!java]forward()[/!];
70 break;
71 case 'L':
72 left();
73 [!c]stepForward()[/!][!java]forward()[/!];
74 break;
75 case 'I':
76 back();
77 [!c]stepForward()[/!][!java]forward()[/!];
78 break;
79 default:
80 return;
81 }</pre>
82 [/!] [!scala]
83 <pre><i>expressão</i> <b>match</b> {
84 <b>case</b> <i>um valor possível</i> <b>=></b> instruções
85 <b>case</b> <i>um outro valor</i> <b>=></b> outras instruções
86 <b>case</b> <i>mais outro valor</i> <b>=></b> e outras instruções
87 <b>case _ =></b> instruções padrão
88 }
89 </pre>
90 <p>A espressão fornecida antes da palavra-chave <code>match</code> e os ramos
91 seguintes são avaliados um após o outro até encontrarmos um cujo valor
92 fornecido entre <code>case</code> e <code>=&gt</code> seja igual ao valor da
93 expressão. O símbolo <code>_</code> age como um coringa, logo o ramo
94 <code>_</code> <i>sempre</i> casa. Aqui está um exemplo de onde uma variável
95 <code>name</code> casa.</p>
96 <pre>name match {
97 case "Martin" => println("Oi Martin, como vai?")
98 case "Gerald" => println("Oi Gerald! como está?")
99 case _ => println("Olá estranho.")
100 }</pre>
101
102 <p>é possível ter mais que uma instrução por ramo e mesclar ramos quando os
103 valores são separados por um símbolo | .</p>
104 <pre>name match {
105 case "Martin" | "Gerald" => println("Oi "+name+", como está?"); openTheDoor()
106 case _ => println("Oi estranho. Favor não passar."); lockTheDoor()
107 }</pre>
108
109 <p>Sempre pode adicionar guardas aos seus ramos. São condições adicionais que
110 devem ser respeitadas para que o ramo seja aplicado. São úteis se quiser
111 corresponder com intervalos de valores, como a seguir.</p>
112 <pre>age match {
113 case i if i&lt;10 => println("Oi menino!")
114 case i if i&lt;20 => println("Oi cara!")
115 case i if i&lt;30 => println("Oi, meu caro")
116 case _ => println("Oi senhor")
117 }</pre>
118 <p>Observe que não há necessidade de verificar se o valor é maior que 10 na
119 segunda linha por que o primeiro ramo "foi verificado". Então, se o segundo
120 ramo está a ser verificado, o primeiro não aprovou.</p>
121
122 <p>Finalmente, é possível também aprovar várias variáveis de uma vez!</p>
123 <pre>(x,y) match {
124 case (0,0) => println("Esta é a origem")
125 case (_,0) => println("nas ordenadas")
126 case (0,_) => println("nas abscissas")
127 case (_,_) => println("algum ponto qualquer")
128 }</pre>
129
130 <p>Disse que reconhecimentod e padrões em scala é muito poderoso! Adoro esta
131 funcionalidade!</p>
132 [/!]
133
134 <h3>Objetivo do exercício</h3>
135 <p>[!java|scala|c]"Aplique" a melhoria que acabamos de ver para reescrever o
136 seu código do buggle com os seguintes passos de dança. [/!] [!python]Vamos
137 ensinar um novo passo de dança aos buggles. É um pouco mais complexo mas na
138 verdade vai ficar mais legal. Apesar disto, é a mesma história de
139 sempre.[/!] Observe que nósagora vamos subir seis células num passo de
140 dança.</p>
141
142 <table border="1">
143 <tr><td>Mensagem</td>
144 <td>O que fazer</td></tr>
145
146 <tr><td>[!java|c]'R'[/!][!scala|python]"R"[/!]</td><td>Vire a direita (R de right) e mova um passo a frente</td></tr>
147 <tr><td>[!java|c]'L'[/!][!scala|python]"L"[/!]</td><td>Vire a esquerda e mova um passo a frente</td></tr>
148 <tr><td>[!java|c]'I'[/!][!scala|python]"I"[/!]</td><td>Vire e dê um passo para frente</td></tr>
149
150 <tr><td>[!java|c]'A'[/!][!scala|python]"A"[/!]</td><td>Mova um passo a frente</td></tr>
151 <tr><td>[!java|c]'B'[/!][!scala|python]"B"[/!]</td><td>Mova dois passos a frente</td></tr>
152 <tr><td>[!java|c]'C'[/!][!scala|python]"C"[/!]</td><td>Mova três passos a frente</td></tr>
153 <tr><td>[!java|c]'D'[/!][!scala|python]"D"[/!]</td><td>Mova quantro passos para frente</td></tr>
154 <tr><td>[!java|c]'E'[/!][!scala|python]"E"[/!]</td><td>Mova cinco passos para frente</td></tr>
155 <tr><td>[!java|c]'F'[/!][!scala|python]"F"[/!]</td><td>Mova seis passos para frente</td></tr>
156
157 <tr><td>[!java|c]'Z'[/!][!scala|python]"Z"[/!]</td><td>Mova um passo para trás</td></tr>
158 <tr><td>[!java|c]'Y'[/!][!scala|python]"Y"[/!]</td><td>Mova dois passos para trás</td></tr>
159 <tr><td>[!java|c]'X'[/!][!scala|python]"X"[/!]</td><td>Mova três passos para trás</td></tr>
160 <tr><td>[!java|c]'W'[/!][!scala|python]"W"[/!]</td><td>Mova quatro passos para trás</td></tr>
161 <tr><td>[!java|c]'V'[/!][!scala|python]"V"[/!]</td><td>Mova cinco passos para trás</td></tr>
162 <tr><td>[!java|c]'U'[/!][!scala|python]"U"[/!]</td><td>Mova seis passos para trás</td></tr>
163 <tr><td><i>(qualquer outra coisa)</i></td><td>Parar de dançar.</td></tr>
164
165 </table>
166
167 <p>Quando seu programa funcionar de novo, vá ao próximo exercício.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Instruções condicionais</h2>
3
4 Programas feitos simplesmente de um conjunto de instruções similares ao do
5 exercício anterior são bastante chatos. Sempre fazem a mesma coisa e não
6 reagem a condições externas. Um <b>condicional</b> faz o programa se adaptar
7 a fazer coisas do tipo <i>se está a chover, leve um guarda-chuva</i>.
8
9 <p>A sintaxe de [!thelang] é a seguinte:</p>
10
11 <pre>[!java|scala|c]if (<b>condição</b>) {
12 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue();</b>
13 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue();</b>
14 }[/!][!python]if <b>condição</b>:
15 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTrue()</b>
16 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNextIfTrue()</b>[/!]
17 <b>whatToDoAnyway()[!java|c];[/!]</b></pre>
18
19 <p>Se a condição for verdade, o código do próximo bloco será executado e então
20 o resto do código continua. Se a condição for falsa, o próximo bloco é
21 ignorado e a execução continua depois disto. O bloco condicional pode conter
22 várias instruções, pode até mesmo conter outros testes, com os próprios
23 sub-testes dele.</p>
24
25 <p>Neste exemplo, as instruções <code>whatToDoIfTrue()</code> e
26 <code>whatToDoNextIfTrue()</code> serão executadas se e somente se a
27 condição for verdadeira, mas a instrução <code>whatToDoAnyway()</code> vai
28 ser executada se a condição for verdadeira ou não.
29 </p>
30
31 <p>Em [!thelang], os blocos de código são [!java|scala|c]envolvidos entre
32 chaves: um { abre o bloco e um } fecha-o. Espaços em branco não são
33 importantes[/!][!java|c].[/!][!scala], uma vez que as suas instruções ainda
34 estejam separadas com um ponto-e-vírgula ou um fim-de-linha.[/!]
35 [!java|scala|c]Ainda assim é muito importante indentar corretamente o seu
36 código para mantê-lo legível.[/!] [!python]marcados pela indentação: todas
37 as linhas que estiverem um pouco deslocadas para a direita com espaços
38 pertencem ao bloco. Frequentemente se usam 4 espaços para indentação, mas
39 funciona se usar mais ou menos espaços. A resumir, quaisquer linhas do bloco
40 devem usar a mesma quantidade de espaços. O fim do bloco de código Python
41 não é marcado por nenhum caractere específico. Indentar linhas começa um
42 bloco e parar de indentar termina o bloco. Não se esqueça do dois-pontos (:)
43 no final da linha do <code>if</code>, python precisa dele para saber que um
44 novo bloco vai começar. O fato de que python se baseia em indentação para
45 delimitar blocos é uma ótima propriedade para iniciantes: vai forçá-lo a
46 aderir a padrões de apresentação de código estritos.[/!] É muito fácil se
47 perder no seu próprio código se não for corretamente indentado, então
48 precisa deixá-lo bem-arrumado para que trabalhar nele continue a ser
49 agradável e produtivo.</p>
50
51
52 <p class="python">Todas as indentações de um dado bloco devem ser consistentes e não é
53 possível cortar um bloco. os dois códigos a seguir estão incorretos e devem
54 resultar em erro.</p>
55 <pre class="python">if <b>condição</b>:
56 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>
57 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span class="comment"># um espaço a mais </span>
58 <b>whatToDoAnyway()</b>
59 </pre>
60 <pre class="python">se <b>condição</b>:
61 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDo()</b>
62 <b>whatToDoAnyway()</b>
63 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoNext()</b> <span class="comment"># este bloco não está condicionado a uma linha de condição</span>
64 </pre>
65
66 <p>A condição deve ser uma expressão
67 <code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code>. O
68 bloco interno do código será executado se a expressão for calculada como
69 <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> e será ignorado
70 se for
71 <code>[!c]0[/!][!java|scala]false[/!][!python]False[/!]</code>.
72 [!python|scala|java]<code>[!java|scala]true[/!][!python]True[/!]</code> e
73 <code>[!java|scala]false[/!][!python]False[/!]</code> são valores constantes
74 definidos por [!thelang] diretamente, assim como 0 ou 1 na matemática.[/!]</p>
75
76 <p>A condição pode ser uma variável
77 <code>[!c]int[/!][!java]boolean[/!][!scala|python]Boolean[/!]</code> (vamos
78 voltar a falar de variáveis num próximo exercício, não se preocupe) ou um
79 teste aritmético, como <code>x == 5</code>, que verifica se o valor atual de
80 <code>x</code> é 5, ou algo como <b>!=</b> (a verificar inequação, ou seja,
81 a retornar [!c]1[/!][!java|scala]true[/!][!python]True[/!] apenas se o lado
82 esquerdo é diferente do lado direito), <b>&lt;</b> (menor que), <b>&gt;</b>
83 (maior que), <b>&lt;=</b> (menor ou igual a), <b>&gt;=</b> (maior ou igual
84 a).</p>
85
86 <p>Cuidado com um erro clássico, que é verificar a igualdade da variável a usar
87 = no lugar de ==. Ainda bem que o
88 [!java|scala|c]compilador[/!][!python]interpretador[/!] detecta este
89 problema na maior parte das vezes, mas às vezes passa (como quando está a
90 atribuir valor a uma variável
91 [!c]int[/!][!java|python|scala]booleana[/!]). Então é bom ter cuidado...</p>
92
93 <p>A condição pode também ser uma chamada para alguns métodos particulares que
94 retornam booleano. Por exemplo, o método <code>isFacingWall()</code> do
95 buggle retorna [!c]1[/!][!java|python|scala]true[/!] se o buggle está a
96 olhar para uma parede e false caso contrário.</p>
97
98 <p>Finalmente, uma condição pode ser composta de várias sub-condições
99 conectadas por operadores booleanos:</p>
100 <ul>
101 <li><code>cond1 [!java|scala|c]&&[/!][!python]and[/!] cond2</code> é true quando
102 <tt>cond1</tt> <b>e</b> <tt>cond2</tt> são ambos trues (se <tt>cond1</tt> é
103 false, <tt>cond2</tt> não é nem sequer calculado pois sabe-se previamente
104 que a conjunção das duas proposições não pode ser verdadeira).</li>
105 <li><code>cond1 [!java|scala|c]||[/!][!python]or[/!] cond2</code> é true se
106 <tt>cond1</tt> <b>ou</b> <tt>cond2</tt> é true (se <tt>cond1</tt> é true,
107 <tt>cond2</tt> não é nem sequer calculada pois já se sabe que a disjunção de
108 ambas as proposições não pode ser verdadeira).</li>
109 <li><code>[!java|scala|c]![/!][!python]not [/!]cond</code> é verdadeira se
110 <tt>cond</tt> é falsa.</li>
111 <li>Quando a expressão se torna complicada, é melhor adicionar parêntesis para
112 forçar a ordem de cálculo. Não hesite em adicionar mais parêntesis para
113 remover ambiguidades que apareçam na expressão.</li>
114 </ul>
115
116 <p>Por fim, é possível especificar o que fazer quando a condição é falsa a usar
117 a seguinte sintaxe. Neste caso, a instrução <code>oQueFazerSeForFalso</code>
118 será executada apenas se a condição for falsa.</p>
119 <pre>[!java|scala|c]if (<b>condição</b>) {
120 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue();</b>
121 } else {
122 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse();</b>
123 }[/!][!python]if (<b>condição</b>):
124 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfTheConditionIsTrue()</b>
125 else:
126 &nbsp;&nbsp;&nbsp;&nbsp;<b>whatToDoIfItsFalse()</b>[/!]</pre>
127
128 <p class="Python">Não se esqueça do dois-pontos (:) depois do else, indica que um novo bloco
129 está a começar.</p>
130
131 <h3>Objetivo do exercício</h3><a name="Objectives"/> Se o buggle está de cara para uma parede, deve mover
132 um passo para trás. Se não, deve mover um passo para frente. Para detetar se
133 está de cara para uma parede, simplesmente use a função pré-fabricada
134 <code>isFacingWall()</code>, que todos os buggles entendem.
135
136 <p>Este exercício é um pouco diferente: o seu código tem que funcionar para
137 vários buggles, cada um a começar numa posição diferente. O mesmo código
138 será executado para cada um deles.</p>
139
140 <p>Quando o seu programa funcionar, vá ao próximo exercício, que está escondido
141 numa sub-árvore da janela de seleção.</p>
3535 messages cryptiques. Vous verrez, avec un peu d'entraînement, vous vous y
3636 habituerez.</p>
3737
38 <h3>Mais c'est du [!thelang] !</h3>
39 Actuellement, la PLM est configurée pour traiter des programmes en
40 [!thelang], mais elle peut aussi gérer des programmes en [!java]Python ou
41 Scala[/!][!scala]Java ou Python[/!][!python]Java ou Scala[/!]. Pour changer,
42 cliquez sur l'icône du langage tout en bas à droite ou utilisez le menu
43 <tt>Langage/Ordinateur</tt>.
3232 in those cryptic messages. You will see, with a bit of habit, we get
3333 used to it.</p>
3434
35 <h3>But that's [!thelang]!</h3>
36 Currently, the PLM is configured to accept [!thelang] programs, but it
37 can also accept [!java]Python or Scala[/!][!scala]Java or Python[/!][!python]Java or Scala[/!] programs.
38 Either click on the language icon at the very bottom right of the
39 window, or head to the <tt>Language/Computer</tt> menu item to change
40 it.
3232 to solve your issue is written somewhere in those cryptic messages. You will
3333 see, with a bit of habit, we get used to it.</p>
3434
35 <h3>But that's [!thelang]!</h3>
36 Currently, the PLM is configured to accept [!thelang] programs, but it can
37 also accept [!java]Python or Scala[/!][!scala]Java or
38 Python[/!][!python]Java or Scala[/!] programs. Either click on the language
39 icon at the very bottom right of the window, or head to the
40 <tt>Language/Computer</tt> menu item to change it.
0
1
2 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
3 <h2>Bem-vindo ao PLM</h2>
4
5 <p>O objectivo deste primeiro exercício é instruir o seu buggle para avançar um
6 passo. Alterne entre as vistas à direita para mais informações. O
7 <i>Mundo</i> retrata o mundo como é agora, enquanto o <i>Objetivo</i>
8 retrata o que deve obter.</p>
9
10 <h3>O meu <i>buggle</i>? O que é?</h3>
11
12 <p>Os buggles são pequenos animais que obedecem todas as suas
13 ordens. Atualmente, deve usar a linguagem de programação [!thelang/] para
14 isso, mas pode mudar a linguagem a partir do menu, ou a clicar no ícone na
15 barra de estado.</p>
16
17 <h3>Como proceder?</h3>
18
19 <p>Escreva o seu programa no painel "Código". Deve ser lido da seguinte forma:</p>
20 <pre>[!java|scala|python]forward()[!java];[/!][/!][!c]stepForward();[/!]</pre>
21 [!java|c]<p>Não se esqueça do <code>;</code> final que diz ao compilador que a instrução
22 está encerrada (sim, o computador é tão bobo que não consegue
23 <i>adivinhar</i> coisas óbvias como isto).</p>[/!]
24
25 <p>Quando feito, clique em Executar para executar o seu código.</p>
26
27 <p>Se o seu código contém erros, tudo bem: até os programadores talentosos
28 lutam com o seu código. O computador exibirá mensagens de erro na consola
29 para o ajudar a corrigi-los. Estas mensagens podem parecer assustadoras à
30 primeira vista, mas não entre em pânico. O compilador é apenas de alguma
31 forma limitado nas suas habilidades de comunicação, mas não é mau. Se olhar
32 mais de perto, a solução para resolver o seu problema está escrita em algum
33 lugar nessas mensagens crípticas. Verá, com um pouco de hábito, que nos
34 acostumamos a isso.</p>
35
36 <h3>Mas isso é [!thelang]!</h3>
37 Atualmente, o PLM está configurado para aceitar programas [!thelang], mas
38 também pode aceitar programas [!java]Python ou Scala[/!][!scala]Java ou
39 Python[/!][!python]Java ou Scala[/!]. Clique no ícone da linguagem no canto
40 inferior direito da janela, ou vá para o item de menu
41 <tt>Language/Computer</tt> para mudá-lo.
3232 to solve your issue is written somewhere in those cryptic messages. You will
3333 see, with a bit of habit, we get used to it.</p>
3434
35 <h3>But that's [!thelang]!</h3>
36 Currently, the PLM is configured to accept [!thelang] programs, but it can
37 also accept [!java]Python or Scala[/!][!scala]Java or
38 Python[/!][!python]Java or Scala[/!] programs. Either click on the language
39 icon at the very bottom right of the window, or head to the
40 <tt>Language/Computer</tt> menu item to change it.
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Instruções</h2>
3
4 Parabéns! Acaba de escrever o seu primeiro programa! Agora captou a ideia:
5 programar é nada mais que dar instruções simples ao computador, que as
6 realiza cegamente. A maior dificuldade é explicar tudo para algo tão idiota
7 quanto um computador...
8
9 <p>O nosso segundo programa vai ser um pouco mais complicado, mas não muito. O
10 objetivo do seu buggle é simplesmente desenhar uma casa (uma caixa) e
11 esconder-se dentro dela. Confira o mundo objetivo para ver exatamente o que
12 isso significa.</p>
13
14 <p>Para isso, vai precisar de <code>forward()</code>, <code>left()</code> e
15 <code>right()</code>. Use o seu pincel para marcar o chão enquanto
16 anda. Comece a marcar o chão com <code>brushDown()</code> e pare com
17 <code>brushUp()</code> depois (por exemplo, para entrar na sua casa sem
18 marcar o chão).</p>
19
20 <h3>O que exatamente é um programa?</h3>
21
22 <p>Os programas são principalmente conjuntos de chamadas de métodos, que não
23 são mais que uma lista de ordens simples dadas à máquina. É como uma receita
24 que diz <i>Derreter os pedaços de chocolate, adicionar açúcar, esfriar a
25 mistura e servir</i>. [!thelang] quer ter as instruções separadas por
26 ponto-e-virgula (;)[!python|scala] ou por novas linhas[/!], seguidas de
27 parênteses. A nossa pequena receita seria assim escrita da seguinte
28 forma[!python|scala] (também pode adicionar ponto-e-virgula no final das
29 linhas, mas isso não é obrigatório)[/!].</p>
30
31 <pre>
32 meltTheChocolatePieces()[!java|c];[/!]
33 addSugar()[!java|c];[/!]
34 coolMix()[!java|c];[/!]
35 serve()[!java|c];[/!]
36 </pre>
37
38 <p>Não escreva tudo numa só linha, mesmo que o computador o aceite
39 [!python|scala](desde que não omita ponto-e-virgulas)[/!]. Esta é uma
40 <b>péssima idéia</b>, que dificulta a legibilidade. <i>Programas devem ser
41 escritos para pessoas as lerem e apenas incidentalmente para as máquinas
42 executarem,</i> como disse Harold Abelson.</p>
43
44 <p>Há um conjunto limitado de instruções que os buggles entendem e
45 eventualmente aprenderemos a definir novas instruções. Por enquanto, existe
46 um método para cada botão do painel de controle interativo. Para alcançar o
47 mesmo efeito que o botão <b>forward</b> (a fazer o buggle mover um passo à
48 frente), precisa escrever o seguinte no editor: </p>
49
50 <pre>[!java|scala|python]forward()[!java];[/!][/!][!c]stepForward();[/!]</pre>
51 <p>Da mesma forma, para obter o mesmo efeito que os botões
52 <b>[!java|scala|python]recuar[/!][!c]recuarUmPasso[/!]</b>, <b>esquerda</b>
53 e <b>direita</b>, precisa respetivamente:</p>
54 <pre>
55 backward()[!java|c];[/!]
56 left()[!java|c];[/!]
57 right()[!java|c];[/!]
58 </pre>
59
60 <p>O botão <b>marcar</b> é diferente, pois corresponde a dois métodos: o
61 primeiro move a caneta para cima e o segundo move a caneta para baixo.</p>
62 <pre>
63 brushUp()[!java|c];[/!]
64 brushDown()[!java|c];[/!]
65 </pre>
66
67 <p>O buggle tem outros métodos, que estão no menu "Ajuda/sobre este mundo" e
68 serão introduzidos quando forem necessários.</p>
69
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>A escrever programas mais complexos</h2>
3 Agora que sabemos como desenhar coisas no tabuleiro, vamos aproveitar esta
4 habilidade e desenhar um belo G (Veja o painel de Objetivo para detalhes).
5
6 <p>Quando escreve um programa bem complexo, por vezes é útil <b>adicionar
7 comentários</b> para simplificar uma posterior revisão do código. Aqui, por
8 exemplo, é fácil se perder no processo de desenho e podeadicionar
9 comentários como <i>barra vertical desenhada</i> ou <i>terminei de desenhar
10 o G. hora de voltar para posição inicial</i>. Comentar o seu código é quase
11 obrigatório se (ou mais alguém) quiser lê-lo depois, embora comentar demais
12 (a descrever coisas óbvias) é ruim pois as ideias importantes se perdem no
13 meio do ruído.</p>
14
15 <p>Existem [!java]três[/!][!python|scala|c]dois[/!] tipos de comentários em
16 [!thelang], que instruem o
17 [!java|scala|c]compilador[/!][!python]interpretador[/!] a não ler o texto
18 que adiciona para humanos:</p>
19
20 <ul>
21 <li><b>Comentários de uma única linha</b>. Quando o
22 [!java|scala|c]compilador[/!][!python]interpretador[/!] encontra o símbolo
23 [!java|scala|c]//[/!][!python]#[/!], ignora o resto da linha.</li>
24 <li><b>Comentários em várias linhas</b>. O
25 [!java|scala|c]compilador[/!][!python]interpretador[/!] ignora tudo entre
26 [!java|scala|c]os símbolos /* e */ mesmo quando eles são postos em linhas
27 diferentes.[/!] [!python]uma linha a comaçar com ''' até a próxima linha
28 terminado com '''.[/!]</li>
29 </ul>
30
31 <pre>
32 methodCallReadByThe[!java|scala|c]Compiler[/!][!python]Interpreter[/!]()[!java|c];[/!] <span class="comment">[!java|scala|c]//[/!][!python]#[/!] tudo isto é ignorado</span>
33 otherCall()[!java|c];[/!] [!java|scala|c]<span class="comment">/* Isto também </span>
34 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="comment"> é ignorado */</span>[/!]
35 [!python]<span class="comment">''' Isto também</span>
36 <span class="comment">é ignorado '''</span>[/!]
37 yetAnotherCall()[!java|c];[/!]
38 </pre>
39 <p class="Java">Existe um terceiro tipo de comentário em Java, entre /** e */, que é lido
40 por um programa específico chamado JavaDoc para gerar automaticamente a
41 documentação a explicar como usar o código. Estes comentários devem seguir
42 um formalismo bem preciso.</p>
43
44 <p class="Python">Os comentários de várias linhas são frequentemente usados para documentar
45 como usar o código, enquanto os outros são usados para descrever como este
46 código funciona.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Loops Do .. while (faça .. enquanto)</h2>
3
4 <p>Algumas células do mundo são amarelas, mas o seu buggle não pode ficar sobre
5 estas células. Escreva o código necessário para mover para a frente até que
6 o chão fique branco. Para isto use o método fornecido
7 <code>isGroundWhite()</code>.</p>
8
9 <p>O truque é que a maioria dos buggles deste mundo ficam sobre o chão amarelo
10 que eles não gostam. é por isto que eles estão em pânico e cada buggle
11 "rushes" uma célula para a frente, mesmo aqueles que não estavam numa célula
12 amarela no começo. Em outras palavras, mesmo se o chão for branco na
13 primeira célula, ainda vai mover para a próxima célula.</p>
14
15 <p>A ideia geral é fazer algo como: </p>
16 <pre>Mover para a frente até estar numa célula branca</pre>
17
18 <p>A coisa mais difícil é que queremos executar o corpo do loop uma vez, mesmo
19 se já estivermos numa célula branca. Isto é fácil a duplicar o código do
20 loop'antes do loop em si, mas esta é uma má ideia: diplicação de código é um
21 hábito <b>muito</b> ruim e deve evitar isto <b>sempre</b>.</p>
22
23 <p>Duplicação de código faz da manutenção de código um pesadelo rapidamente: é
24 fdifícil ler o código e o leitor tem que garantir que nenhuma pequena
25 diferença exista entre as versões. Depurar o código se torna difícil, pois
26 os bugs devem ser consertados em todas as versões. Na verdade, cada
27 modificação do código se torna difícil. Então, na verdade, deve
28 <b>sempre</b> se esforçar para não duplicar o seu código sempre que
29 possível. Mas a boa notícia é que sempre pode...</p>
30
31 <h3>A executar o corpo do loop pelo menos uma vez</h3>
32 [!python]
33 <p>Algumas linguagens tem construções específicas para isto, mas não a
34 linguagem Python. Sem problemas, podemos fazer isto nós mesmos! Uma boa
35 forma é ter uma variável dedicada a indicar se estamos a entrar no loop a
36 primeira vez ou não, como segue.</p>
37 <pre>primeiraVez = True
38 while primeiraVez or (outras condições):
39 primeiraVez = False
40 (corpo do loop)
41 </pre>
42
43 <p>Quando <code>primeiraVez</code> é true, o corpo do loop é executado mesmo se
44 as outras condições digam o contrário. uma vez que o loop tenha sido
45 executado uma vez, esta variável vira false e nunca mais impacta na decisão
46 de entrar ou não no loop.</p>
47 [/!] [!java|scala|c]
48 <p>Num loop <tt>while</tt>, a condição é calculada antes de qualquer coisa e se
49 for falsa, o corpo do loop nunca é executado. Algumas vezes (mas não muito
50 frequentemente), pode preferir que o corpo do loop seja executado pelo menos
51 uma vez, mesmo se a condição seja inicialmente falsa. Para isto, uma
52 variação do loop <tt>while</tt> é usada, com a seguinte sintaxe em
53 [!thelang]. [!java|c]Não se esqueça do ponto-e-vírgula (;) depois da
54 condição, que é obrigatório.[/!]
55
56 <pre>do {
57 <b>ação()</b>[!java];[/!]
58 } while (<b>condição</b>)[!java];[/!]</pre></p>
59 [/!]
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Trilhas de buggles</h2>
3
4 <p>O seu buggle perdeu-se num estranho labirinto e deve ajudá-lo a achar a
5 saída que está representada em laranja. Não pode simplesmente explicar o
6 caminho para a saída com algo do tipo
7 <code>right();forward();forward();forward()</code> por que tem que gravar
8 dois buggles ao mesmo tempo, que estão presos em mundos similares, mas não
9 iguais. Pode alternar para o outro mundo a usar o combobox acima da
10 representação do mundo (onde está escrito 'Floresta Fechada' agora) e
11 selecionar a outra entrada (que deve ler 'Floresta Mais Fechada').</p>
12
13 <p>A boa nova é que o caminho para a saída está desenhado no chão. Como pode
14 ver, o mundo é feito de vários corredores, com baggles no chão. Depois de
15 cada corredor, deve virar à esquerda se o corredor tiver três baggels ou
16 mais e virar a direita se tiver apenas 2 ou menos baggles.</p>
17
18 <p>Deve contar exatamente 5 células por corredor, de intersecção a
19 intersecção. Considere na sua contagem a intersecção terminar o corredor,
20 mas não a intersecção antes do corredor.</p>
21
22 <p>Logo, a forma geral do seu código deve ser algo como "enquanto não encontrar
23 a saída, escolha o próximo corredor para decidir se vira à esqueda ou à
24 direita na próxima intersecção". Pode determinar se está na célula de saída
25 (que é laranja) com o método <code>exitReached()</code> fornecido.</p>
26
27 <p>Para entrar num corredor, tem que simplesmente correr de uma intersecção
28 para outra enquanto conta os baggles que vê no seu caminho. Isto é fácil:
29 existem 5 passos em cada corredor, de forma que um simples loop
30 <code>for</code> resolve.</p>
31
32
33 <p><div class="tip" id="tip-1" alt="Não consigo imaginar como contar os baggles que vejo.">
34 Precisa de uma variável que é inicializada em 0 e incrementada cada vez que
35 vê um baggle no chão. Uma variável usada desta forma é frequentemente
36 chamada de <i>contador</i>.<br/><br/>
37 Não se esqueça de resetar o seu contador para 0 no começo de cada corredor!
38 </div></p>
39
40 <p>Ah, e quando chegar na saída, não se esqueça de dar um passo a mais para
41 sair de fato do labirinto!</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Mais rastros de buggles</h2>
3
4 <p>Uau! O seu buggle perdeu-se novamente no mesmo tipo de labirinto, mas desta
5 vez, os corredores nem sempre são do mesmo tamanho. Porque não há como saber
6 a comprimento do corredor antes de tomá-lo, um <code>for</code> não será
7 mais suficiente. Ao invés disso, terá que mudar o seu loop interno para usar
8 um loop <code>while</code>, a usar o método <code>crossing()</code> que diz
9 se o seu buggle está atualmente numa intersecção.</p>
10
11 <p>A complexidade adicional é que no início de um corredor, obviamente está num
12 cruzamento, mas ainda quer seguir. [!java|scala|c]Para isso, o mais fácil é
13 usar um loop <code>do / while</code> em vez de um loop regular
14 <code>while</code> para mover até a próxima intersecção.[/!] [!python]Para
15 isso, use uma variável adicional para indicar se já entrou no corredor, como
16 a seguir. Isto assegurará que execute o corpo do loop pelo menos uma vez
17 (quando <code>firstTime</code> for true) antes de usarmos o valor retornado
18 por <code>crossing()</code> para determinar se devemos continuar ou não.[/!]</p>
19
20 [!python]
21 <pre>primeiraVez = True
22 while primeiraVez or not crossing():
23 primeiraVez = False
24 (corpo do loop)
25 </pre>
26 [/!]
27
28 <p>Com esse novo truque, o seu buggle deve sair desse labirinto muito
29 facilmente.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Treinar o Buggle</h2>
3
4 <p>Hoje o seu buggle quer fazer exercício seriamente: quer correr até tocar
5 fogo na trilha! Os super-sapatos deles são perfeitos para correr loucamente,
6 mas infelizmente, podem estragar seriamente a trilha a longo prazo...</p>
7
8 <p>O seu objetivo é percorrer a trilha 10 vezes, não importa o que
9 aconteça. Mesmo se a trilha "suffers", <b>TEM MESMO</b> que fazer esta
10 corrida. Lembre-se, a triha tem quatro lados, cada lado com oito
11 passos. Agora vá e mostre-lhe o que os seus super-sapatos podem fazer.</p>
12
13 <p>Não tem que fazer nada de particular com respeito às cores: os seus sapatos
14 vão fazer isto para si. Apenas corra!</p>
15
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Treinamento ao ar livre do Buggle</h2>
3
4 <p>Bem, nosso último treino teve um probleminha. A trilha tocou fogo e fomos
5 banidos de lá. Desta vez, nosso buggle decidiu praticar ao ar livre, no meio
6 da floresta, com os sapatos velhos deles. O problema é que tem que ser
7 cuidadoso para não cair na água. A trilha onde corre é estreita: "One side
8 is now" 4 passos para a frente, 2 passos para a esquerda, 4 passos para a
9 direita, 2 passos para a direita, 4 passos para a esquerda, "and you want to
10 run 7 around".</p>
11
12 <p>Putz, correr na grama destrói a grama também! Então dê apenas 7 voltas no
13 jardim e depois vá ao próximo exercício antes que alguém perceba o estrago
14 que fez...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Loops for</h2>
3
4 <p>loops 'while' são bem adaptados a situações onde precise realizar uma ação
5 enquanto uma condição se mantém verdadeira, mas são menos preparados para
6 realizar uma ação numa quantidade predeterminada. Por exemplo, quando nos
7 quisemos mover <code>quantidadeDePassos</code> para trás num exercício
8 anterior, tivemos que criar uma nova variável, inicializar ela e mover para
9 trás enquanto aumentávamos esta variável até ela se tornar igual a
10 <code>quantidadeDePassos</code>.</p>
11
12 <p>Em tais situações, loops <code>for</code> se tornam úteis. As sintaxes delas
13 são as seguintes:</p>
14 <pre>[!java|c]for (<b>inicialização</b>; <b>condição</b>; <b>incremento</b>) {
15 <b>ação</b>();
16 }[/!][!python]for <b>variável</b> in <b>sequência-de-valores</b>:
17 <b>ação</b>()[/!][!scala] for (<b>variável</b> &lt;- <b>primeiroValor</b> to <b>últimoValor</b>) {
18 <b>ação</b>();
19 }[/!]</pre>
20
21 <p>Por exemplo, para repetir o corpo do loop <code>n</code> vezes, [!python] é
22 útil usar a instrução <code>range(n)</code> para gerar a sequência de n
23 valores inteiros de 0 a n-1.[/!] [!java|scala|c] deve escrever:[/!]</p>
24 <pre>[!java]for (int iterador=0; iterador&lt;n; iterador++) {
25 <b>ação</b>();
26 }[/!][!c]int iterador;
27 for (iterador=0; iterador&lt;n; iterador++) {
28 <b>ação</b>();
29 }[/!][!python]for <b>iterador</b> in <b>range(n)</b>:
30 <b>ação</b>()[/!][!scala] for (<b>iterador</b> &lt;- <b>1</b> to <b>n</b>) {
31 <b>ação</b>();
32 }[/!]</pre>
33
34 <p>Este código é então equivalente ao seguinte do ponto de vista do
35 computador. Do ponto de vista do programador, uma forma ou outra pode ser
36 mais difícil ou mais fácil de ler, a depender da situação. Deve escolher
37 sabiamente em qual situação usar um loop for ou um loop while. O seu
38 objetivo principal deve ser manter o seu código simples e fácil de ler, para
39 garantir que o seu dia seja agradável e produtivo.
40 </p>
41 <pre>[!java|c]int iterador = 0;
42 while (iterador &lt; n) {
43 &nbsp;&nbsp;&nbsp;&nbsp;<b>ação</b>();
44 &nbsp;&nbsp;&nbsp;&nbsp;<b>iterador++</b>;
45 }[/!][!python]iterador=0
46 while iterador &lt; n:
47 ação()
48 iterador = iterador + 1[/!][!scala]
49 var iterador = 1
50 while (iterador &lt;= n) {
51 <b>ação</b>()
52 iterador = iterador + 1
53 }[/!]</pre>
54
55 <p>Neste caso, o loop <code>for</code> é fácil de ler, não acha?</p>
56
57 [!java|c]
58 <p>É possível construir loops <tt>for</tt> mais avançados já que qualquer
59 instrução válida pode ser usada como inicialização, condição e instrução de
60 incrementação. O exemplo seguinte é um pouco extremo, pois não existe
61 necessidade para um corpo de loop mover um buggle para frente até alcançar a
62 parede, mas funciona bem: todo o trabalho é feito nas instruções de condição
63 e incremento.</p>
64
65 <pre>for (; !isFacingWall() ; forward()) {
66 <span class="comment">/* nada no corpo do loop */</span>
67 }
68 <span class="comment">/* o buggle agora está de cara para uma parede */</span></pre>
69 [/!] [!scala]
70 <p>Se quer aninhar vários loops, pode fazer-lo numa linha no Scala. Isto
71 significa que os dois blocos seguintes são equivalentes:</p>
72 <pre>for (iterador1 &lt;- 1 to n) {
73 for (iterador2 &lt;- 1 to m) {
74 ações()
75 }
76 }</pre>
77 <pre>for (iterador1 &lt;- 1 to n; iterador2 &lt;- 1 to m) { <span class="comment">// Simplesmente separe as duas condições de loop com um ponto-e-vírgula</span>
78 ações()
79 }</pre>
80 [/!]
81
82 <h3>Objetivo do exercício</h3>
83 <p> Agora tem que refazer o mesmo exercício de antes (mover para frente até
84 estar sobre um baggle, pegá-lo, mover para trás até a localização original,
85 soltar o baggle), mas a usar um loop <code>for</code> no lugar de um loop
86 <code>while</code> para mover de volta ao local inicial.</p>
87
88 <p>Uma vez feito, pode seguir ao próximo exercício.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Uma escadaria para o Céu</h2>
3
4 <p>O seu buggle está um pouco deprimido hoje, mas está em frente de uma escada
5 mágica: ela leva diretamente ao paraíso e cada vez que anda nela, belas
6 cores surgem de todos os lados.</p>
7
8 <p>O seu objetivo é subir a escada, um passo de cada vez. Primeiro "devise" as
9 quatro instruções que tem que dar ao buggle para subir um degrau e então
10 ponha-a num loop para subir toda a escada.</p>
11
12 <p>Antes disto, ande um pouco para a frente para alcançar a escada e
13 certifique-se de estar na situação certa para que o que o loop faz seja
14 feito corretamente. E uma vez alcançado o Céu, dê uns passos no seu novo
15 lar. Enquanto isto, deve apenas seguir o seu caminho, as cores aparecem
16 automagicamente.</p>
17
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>A procurar Baggles</h2>
3 <p>O mundo dos buggles pode algumas vezes conter alguns <i>baggles</i>, que são
4 pequenos biscoitos que os buggles podem carregar de um ponto a outro. Para
5 isto, eles têm que usar métodos específicos como <code>isOverBaggle(),
6 isCarryingBaggle(), pickupBaggle()</code> ou
7 <code>pickupBaggle()</code>. Verifique a documentação deles em "Ajuda/Sobre
8 este mundo" para mais detalhes.</p>
9
10 <h3>Objetivo do exercício</h3>
11
12 <p>Deixe cada buggle encontrar o baggle dele por adaptar o código que escreveu
13 no exercício anterior (copie e cole o que fez antes se quiser).</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Loops while (enquanto)</h2>
3
4 <p>Além dos condicionais, outra construção bem útil é a habilidade de repetir
5 uma ação enquanto uma condição específica não acontece. Um loop 'while' é
6 usado para isto, com a seguinte sintaxe.</p>
7
8 <pre>[!java|scala|c]while (<b>condição</b>) {
9 &nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>;
10 }[/!][!python]while <b>condição</b>:
11 &nbsp;&nbsp;&nbsp;&nbsp;<b>action()</b>[/!]</pre>
12
13 <p>O bloco interno é então executado várias e várias vezes, enquanto a condição
14 se mantiver verdadeira. Mais especificamente, o buggle testa o valor da
15 condição. Se for falsa, ignora o bloco e continua abaixo. Se for verdadeira,
16 executa o bloco. Depois disto, testa a condição. Se agora for falsa (por
17 exemplo, porque os movimentos do bloco nos deixaram de cara à parede), agora
18 ignora o bloco e continua. Se ainda for true, executa o bloco e reavalia a
19 condição. Faz isto enquanto a condição se mantém verdadeira.</p>
20
21 <p>Naturalmente, se a ação escolhida não modifica o valor da condição, o buggle
22 vai fazer a ação infinitamente. O botão <b>stop</b> na interface se torna
23 útil nestes casos. Para testar isto, pode tentar digitar o seguinte código
24 no editor:</p>
25
26 <pre>[!java|scala]while (true) {
27 &nbsp;&nbsp;&nbsp;&nbsp;left();
28 }[/!][!c]while (1) {
29 &nbsp;&nbsp;&nbsp;&nbsp;left();
30 }[/!][!python]while True:
31 &nbsp;&nbsp;&nbsp;&nbsp;left()[/!]</pre>
32
33 <p>Isto vai fazer o buggle virar à esquerda enquanto
34 <code>[!c]1[/!][!java|scala]true[/!][!python]True[/!]</code> permanecer true
35 (ou seja, infinitamente), ou até que pare manualmente a usar o botão parar.</p>
36
37 <h3>Objetivo do exercício</h3>
38 Agora tem que escrever algum código para os seus buggles se moverem para a
39 frente até que eles encontrem uma parede. A ideia é então fazer algo assim:
40
41 <pre>Enquanto não estiver de cara para uma parede, faça:
42 &nbsp;&nbsp;moveForward()</pre>
43
44 <p>Procure na documentação (em "Ajuda/Sobre este mundo") para a lista completa
45 dos métodos dos buggles.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Métodos com perâmetros</h2>
3
4 <p>Não está cansado de escrever o mesmo código várias vezes para se mover uma
5 certa quantidade de passos? Por outro lado, escrever <tt>forward2()</tt>,
6 <tt>forward3()</tt>, <tt>forward4()</tt>, assim como <tt>backward2()</tt>,
7 <tt>backward3()</tt>, <tt>backward4()</tt> e etc também não ajudam, para
8 dizer o mínimo.</p>
9
10 <p>Felizmente, é possível passar <b>parâmetros</b> para os seus métodos. Tem
11 que especificar o tipo e nome entre parêntesis depois do nome do
12 método. Então, pode usá-los no corpo do método como se eles fossem variáveis
13 definidas lá e com valores iniciais que o "caller" especificou.</p>
14
15 <pre>[!java|c]double [/!]dividirPorDois([!java|c]double [/!]x[!scala]: Double[/!])[!scala]: Double =[/!] [!java|scala|c]{[/!][!python]:[/!]
16 return x / 2[!java|c];[/!]
17 [!scala|java|c]}[/!]</pre>
18
19 <p>Como o "caller", deve especificar o valor inicial destas "variáveis" entre
20 parêntesis na chamada.</p>
21 <pre>[!java|c]double [/!][!scala]val [/!]result = dividirPorDois(3.14)[!java|c];[/!]</pre>
22
23 <p>Se quiser vários parâmetros, precisa separar-os com vírgulas (,) tanto na
24 declaração quanto na chamada.</p>
25
26 <pre>[!java|c]double dividir(double x, double y) {[/!]
27 [!scala]def dividir(x:Double, y:Double): Double = {[/!]
28 [!python]def dividir(x, y):[/!]
29 return x / y[!java|c];[/!]
30 [!java|scala|c]}[/!]</pre>
31 <pre>[!java|c]double res = dividir(3.14 , 1.5);[/!]
32 [!scala]val res = dividir(3.14 , 1.5)[/!]
33 [!python]res = dividir(3.14 , 1.5)[/!]</pre>
34
35 [!java|scala]
36 <p>Em [!thelang], pode declarar vários métodos de mesmo nome desde que eles não
37 tenham a mesma <b>assinatura</b>, ou seja, a mesma quantidade e tipo de
38 parâmetros.</p>
39
40 <pre>[!java]double max(double x, double y)[/!][!scala]def max(x:Double, y:Double): Double =[/!] {
41 if (x > y) {
42 return x;
43 }
44 return y;
45 }[!java]int max(int x, int y)[/!][!scala]def max(x:Int, y:Int): Int =[/!] {
46 if (x > y) {
47 return x;
48 }
49 return y;
50 }
51 [!java]int max(int x, int y; int z)[/!][!scala]def max(x:Int, y:Int, z:Int): Int =[/!] {
52 if (x > y && x > z) {
53 return x;
54 }
55 if (y > z) {
56 return y;
57 }
58 return z;
59 }</pre>
60
61 <p>Observe que omitimos os ramos <tt>else</tt> de cada <tt>if</tt>. Isto
62 funciona de qualquer jeito por que um <tt>return</tt> interrompe a execução
63 do método. Se chegarmos à última linha de
64 <code>[!java]max(int,int)[/!][!scala]max(Int,Int):Int[/!]</code>, vamos
65 saber que <code>x&lt;=y</code> por que de outra forma, o <tt>return</tt> da
66 linha 2 deveria ter parado a execução.</p>
67 <!-- introduce default value for parameters in Python language -->
68 [/!]
69
70
71
72 <h3>Objetivo do exercício</h3>
73 <p>Agora vai ter que escrever um método <code> [!java|c]mover(int
74 contaPassos,[!java]boolean[/!][!c]int[/!] forward)[/!]
75 [!scala]mover(contaPassos: Int,forward: Boolean)[/!]
76 [!python]mover(contaPassos,forward)[/!] </code> que move para a frente
77 <code>contaPassos</code> passos se <code>forward</code> for true e move para
78 trás a mesmas quantidade de passos se o booleano for false.</p>
79
80 <p>Desta vez existe apenas um mundo mas sete buggles, todos a compartilhar o
81 mesmo código. Este código não deve te dar muito trabalho para escrever, na
82 verdade.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Métodos</h2>
3
4 <p>
5 Vamos agora escrever nossos próprios métodos. Isto é como extender o
6 vocabulário do buggle a ensinar novos truques.
7 </p>
8 <p>Por exemplo, vimos num exercício anterior como pedir ao buggle para apanhar
9 o baggle à frente dele e trazê-lo de volta. Se existem vários baggles no
10 tabuleiro e se queremos trazê-los todos à linha de baixo, tem que repetir
11 este código várias vezes, ou incluí-lo num loop. Em qualquer caso, deve
12 evitar duplicar o seu código para mantê-lo agradável de ler e fácil de
13 entender. Será melhor se o buggle puder obedecer uma ordem
14 <code>goAndGet()()</code> assim como entende uma
15 <code>[!c]stepForward()[/!][!scala|java|python]forward()[/!]</code>.</p>
16
17 <h3>Definir métodos</h3>
18
19 <p>A sintaxe de [!thelang] para escrever um método simples chamado
20 <code>goAndGet()</code> é a seguinte:</p>
21 <pre>[!java|c]void goAndGet()() {[/!][!python]def goAndGet()():[/!][!scala]def goAndGet()() {[/!]
22 ações()[!java|c];[/!]
23 ações()[!java|c];[/!]
24 eMaisAções()[!java|c];[/!]
25 [!java|scala|c]}[/!]</pre>
26
27 <p>O corpo do método [!java|scala](entre chaves)[/!][!python](o bloco
28 indentado)[/!] será executado quando chamarmos o método mais tarde (ou seja,
29 quando escrevermos <code>goAndGet()()</code> em algum lugar do código). Este
30 corpo do método pode conter tantas instruções quantas quiser e as
31 construções que quisermos (for, while, if, etc). [!java]A palavra-chave
32 <code>void</code> significa que este método não retorna qualquer
33 resultado. Por exemplo, o método <code>isOverBaggle()</code> retorna um
34 resultado, que é um booleano a indicar se o buggle está ou não localizado
35 sobre um baggle. Vamos em breve aprender a definir tais métodos também. Por
36 agora, apenas escreva <code>void</code> neste local.[/!]
37 </p>
38
39 <h3>Documentar métodos</h3>
40
41 <p>Deve esforçar-se para documentar o seu código para mantê-lo legível. Quando
42 escreve código, fica claro o objetivo e as limitações, mas na maioria das
43 vezes, isto é esquecido. Rapidamente esquecerá dos detalhes de cada método
44 específico e vai chegar o dia em que ficará feliz em ler a documentação. No
45 exemplo seguinte, usamos o formalismo específico de
46 [!java]javadoc[/!][!scala]scaladoc[/!][!python]pydoc[/!], um programa que
47 extrai a documentação do código-fonte de [!thelang] e produz páginas html. A
48 principal vantagem é que permite que a documentação fique junto ao
49 código. Então, quando mudar o código, tem menos chances de esquecer de
50 atualizar a documentação.</p>
51
52 <p>comentários em [!java|scala][!java]javadoc[/!][!scala]scaladoc[/!] começam
53 com a marca <code>/**</code> (com dois asteriscos). Eles devem ser postos
54 exatamente antes do método que documentam para a ferramenta
55 encontrá-los.[/!] [!python]comentários pydoc devem ser postos no começo do
56 corpo do método de forma que a ferramenta possa encontrá-los. Eles devem ser
57 postos entre <code>"""</code>, que marcam cadeias multilinhas em python.[/!]
58 A primeira linha deve ser uma breve descrição do que o método faz enquanto
59 as linhas subsequentes devem fornecer qualquer detalhes importantes sobre o
60 método.</p>
61
62 <pre>[!java|scala]/**
63 * Força, recupera o baggle em frente do buggle e traz de volta
64 *
65 * Não verifica se tem paredes, então cuidado para não chamá-lo quando paredes estiverem presentes.
66 */[/!]
67 [!java]void goAndGet()() {[/!]
68 [!scala]def goAndGet()() {[/!]
69 [!python]def goAndGet()():
70 """Vai, recupera o baggle em frente do buggle e traz de volta.
71
72 Não verifica se tem paredes, então cuidado para não o chamar quando uma parede estiver presente."""[/!]
73 ações()[!java];[/!]
74 to()[!java];[/!]
75 do()[!java];[/!]
76 [!java|scala]}[/!]</pre>
77
78 <h3>Convenções de nomes</h3>
79 <p>A maioria das linguagens de programação proíbe o uso de espaços em
80 indentificadores de métodos e variáveis (=seus nomes). Letras acentuadas
81 são algumas vezes permitidas (como em [!thelang]), mas elas geram problemas
82 de portabilidade entre sistemas operacionais e devem ser evitadas sempre que
83 possível.</p>
84
85 <p>Entre todas as linguagens de programação, existem duas convenções para
86 nomear variáveis e métodos. A primeira, consiste em concatenar todas as
87 palavras com apenas a primeria letra de cada palavra em maiúscula. "vai e
88 apanha" torna-se goAndGet(). Isto é chamado "CamelCase" por que
89 identificadores escritos desta forma parecem graficamente com as costas de
90 um camelo. A outra convenção, chamada "snake_case", é escrever todas as
91 palavras em minúsculas, separadas com sublinhados (_). "vai e apanha" se
92 torna vai_e_apanha().</p>
93
94 <p>Que convenção usar é o tópico de discussões acaloradas entre programadores,
95 mas cada linguagem de programação tem os próprios hábitos deles. Em Python,
96 Perl e C, o snake_case é normalmente usado para métodos e variáveis. Java e
97 Scala preferemo lowerCamelCase (só a primeira letra inicial é minúscula)
98 para isto.</p>
99 <p>A convenção CamelCase é sempre usada no PLM por que este programa foi
100 escrito em Java, então mantivemos o hábito quando inserimos novas
101 linguagens. Mas o fato de os vínculos Python do PLM usarem CamelCase e não
102 snake_case é considerado um bug que será corrigido em algum lançamento
103 futuro.</p>
104
105 <h3>Objetivo do exercício</h3>
106 <p>O objetivo deste exercício é escrever um método chamado
107 <code>goAndGet()()</code> que faça a mesma coisa que foi feita num exercício
108 anterior (vai para a frente até estar sobre um baggle, apanha-o, vai para
109 trás até a posição inicial e solta o baggle).</p>
110
111 <p>Este exercício é um pouco diferente por que não vai precisar escrever todo o
112 código executado pelo buggle. Ao invés disto, deve apenas escrever um método
113 que será chamado automagicamente quando clica em <b>Iniciar</b>. O seu
114 buggle vai chamar o seu método <code>goAndGet()()</code> em cada linha, até
115 que o baggle seja encontrado. [!python|scala]O código para isto já está
116 pronto no método <code>goAndGet()()</code>, mas provavelmente não vai mudar
117 isto. [/!] [!java]Não precisa escrever o código chamado
118 <code>goAndGet()()</code>. Já está lá automaticamente, mesmo se não possa
119 vê-lo.[/!]</p>
120
121 <p>Mas para isto funcionar, tem na verdade que escrever este método
122 <code>goAndGet()</code> agora.</p>
123
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Construir metodicamente</h2>
3
4 Agora queremos ensinar ao buggle como construir uma casa de cachorro. A
5 abordagem simplória consiste em escrever diretamente o código necessário
6 como segue. Isto funciona por que o buggle deste exercício deixa um caminho
7 vermelho à medida em que anda.
8
9 <pre>[!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
10 [!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
11 left()[!java|c];[/!]
12 [!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
13 [!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
14 left()[!java|c];[/!]
15 [!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
16 [!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
17 left()[!java|c];[/!]
18 [!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
19 [!c]stepForward()[/!][!python|java|scala]forward()[/!][!java|c];[/!]
20 left()[!java|c];[/!]</pre>
21
22 <p>Vai ficar mais difícil se tivermos que desenhar duas casas de cachorro:
23 teremos que reescrever o mesmo código duas vezes, o que não é muito
24 prático. Quando o código se torna um pouco longo como este, torna-se fácil
25 ver por que insistimos já tem um tempinho namais pura maldade que duplicação
26 de código representa. Na verdade, imagine um erro que se infiltrou no código
27 que copiou para vários lugares, vai ter que corrigir várias vezes. E ai de
28 se esquercer de corrigir num destes lugares.</p>
29
30 <p>Existe até um nome para esta boa prática de programação: DRY/SPOT, que em
31 inglês significa "Don't Repeat Yourself / Single Point Of Truth" (não se
32 repita/ponto único de confiança). A última parte significa que cada
33 informação deve ser escrita em apenas um local do seu programa para evitar
34 que diferentes locais fiquem desincronizados quando modificar o código.</p>
35
36 <p>Portanto, vamos aplicar este bom princípio de programação e <b>fatorizar o
37 nosso código</b>, p.ex. escrevê-lo apenas uma vez, por exemplo num
38 método. Pode ir até mais longe a fatorizar o corpo do método com um loop
39 <code>for</code>, como visto anteriormente. Se o faz corretamente (o que se
40 espera), dá para usar o método <code>left()</code> apenas uma vez.</p>
41
42 <h3>Objetivo do exercício</h3>
43 <p>O objetivo deste exercício é escrever um método chamado
44 <code>casaDeCachorro</code> que faz a mesma coisa que o código acima, mas
45 com um loop for para mantê-lo curto. O buggle vai chamar a sua criação para
46 construir várias casas de cachorro neste mundo. </p>
47
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Vitrine de flores</h2>
3
4 <p>Uau! isto não é mais um potinho! É uma grande vitrine de flores! O seu
5 buggle mal pode esperar para começar a florir este belo lugar. Deve ajudá-lo
6 a não bater nas paredes...</p>
7
8 <p>PS: a cor recentemente usada é <code>Cor.AZUL</code>.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Vaso de Flores</h2>
3
4 <p>O seu buggle decidiu plantar umas flores no pote onde vive. Tem que ajudá-lo
5 a reproduzir o desenho dos sonhos dele (verifique a guia "Objetivo" para ver
6 o sonho).</p>
7
8 <p>Para isso, tem que escrever um método <code>growFlowers()</code> que não
9 toma nenhum parâmetro e não retorna nenhum resultado. Provavelmente poderia
10 fazê-lo sem definir este método, mas isto é parte da atribuição.</p>
11
12 <p>Além disso, deve tentar decompor este desenho complexo em sub-passos para
13 que o seu código permaneça curto e fácil de ler. Um método para desenhar uma
14 flor da cor passada no parâmetro parece um bom começo, mas provavelmente não
15 é suficiente.</p>
16
17 <p>Para sua informação, este desenho usa cinco cores que estão listadas
18 abaixo. [!java|scala|c]o tipo de dados destas constantes é
19 <code>Cor</code>, que naturalmente descreve uma cor particular.[/!]</p>
20
21 <ul>
22 <li><code>[!scala|java|python]Cor.[/!]VERMELHO</code></li>
23 <li><code>[!scala|java|python]Cor.[/!]ROSA</code></li>
24 <li><code>[!scala|java|python]Cor.[/!]CIANO</code></li>
25 <li><code>[!scala|java|python]Cor.[/!]LARANJA</code></li>
26 <li><code>[!scala|java|python]Cor.[/!]VERDE</code></li>
27 <li><code>[!scala|java|python]Cor.[/!]AMARELO</code></li>
28 </ul>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Desenho colorido</h2>
3
4 Neste exercício, vamos reproduzir o desenho geométrico que pode ver na guia
5 "Objetivo".
6
7 <p>O seu objetivo (aqui e em qualquer programa bem escrito) é escrever o código
8 mais simples possível. Para isto, tem que decompor o seu trabalho em
9 sub-passos e escrever métodos específicos para cada sub-passo.</p>
10
11 <p>Se observar cuidadosamente a figura para pintar, é constituída de quatro
12 partes a descrever um tipo de V a usar uma cor diferente. Uma decomposição
13 possível é escrever um método responsável por pintar um V de uma cor
14 específica a partir da posição atual. O protótipo dela pode ser:</p>
15 <pre>[!java|c]void [/!]fazerV([!java|c]Cor [/!]c[!scala]: Cor[/!])[!python] <span class="comment"># parâmetro c é do tipo Cor</span>[/!]</pre>
16
17 <p>O tipo de dados <code>Cor</code> descreve obviamente uma cor particular. O
18 seu código provavelmente vai chamar <code>fazerV</code> com os seguintes
19 argumentos (uma cor diferente para cada chamada):</p>
20 <ul>
21 <li>[!java|scala|python]Cor.[/!]AMARELO</li>
22 <li>[!java|scala|python]Cor.[/!]VERMELHO</li>
23 <li>[!java|scala|python]Cor.[/!]AZUL</li>
24 <li>[!java|scala|python]Cor.[/!]VERDE</li>
25 </ul>
26
27 <p>Em <code>makeV()</code>, deve usar o método <code>setBrushColor()</code>
28 (pré-definido no buggle) para mudar a cor do pincel do buggle, assim como
29 <code>brushUp()</code> e <code>brushDown()</code> para mudar a posição do
30 pincel.</p>
31
32 <p>É recomendável escrever o código do <code>makeV()</code> de forma que deixe
33 o buggle na posição ao próximo V.</p>
34
35 [!java|scala]
36 <p>Agora é a sua vez. Tenho certeza de que pode imaginar os outros métodos
37 necessários para manter o seu código simples e agradável de ler. Complete o
38 método <code>run()</code> que será chamado automaticamente (uma vez).
39 [!java]a palavra-chave <code>public</code> significa mais ou menos que todo
40 o mundo pode chamar este método, o que é bom, pois a infraestrutura do PLM
41 chama-o diretamente.[/!] </p>
42 [/!]
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Um desenho colorido maior</h2>
3
4 Como pode imaginar, vai ter que reproduzir o desenho geométrico descrito na
5 guia "Objetivos". Como pode ver, é até maior do que o anterior.
6
7 <p>Agora tem que declarar ainda mais métodos para usar as repetições de padrões
8 e fatorizar o seu código. Outra soução é <i>parametrizar</i> as suas funções
9 para reusar o código que escreveu previamente a mudar o tamanho.</p>
10
11 <p>É asua vez...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Outro padrão colorido</h2>
3
4 Aqui está outro exercício onde tem que reproduzir o padrão fornecido na guia
5 "Objetivo".
6
7 <p>Este é um pouco mais difícil do que o anterior. Procure por padrões de
8 repetição, mesmo se a cor mudar e escreva um método a desenhar cada um
9 deles.</p>
10
11 <p>Boa Sorte!</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Desenhar metodicamente</h2>
3
4 Neste exercício, vamos reproduzir o desenho geométrico que pode ver na guia
5 "Objetivo".
6
7 <p>O seu objetivo (aqui e em qualquer programa bem escrito) é escrever o código
8 mais simples possível. Para isto, tem que decompor o seu trabalho em
9 sub-passos e escrever métodos específicos para cada sub-passo.</p>
10
11 <p>Se observar cuidadosamente a figura que tem que desenhar, ela é constituída
12 de quatro partes a descrever um V. Uma decomposição possível é escrever um
13 método responsável por escrever um V a partir da posição atual. O protótipo
14 dele pode ser: <code>[!java|c]void [/!]makeV()</code></p>
15
16 <p>Neste método, deve usar os métodos <code>brushUp()</code> e
17 <code>brushDown()</code> para marcar o chão (se quiser, faça um método só
18 para isto). É uma decisão inteligente escrever <code>makeV()</code> para pôr
19 o buggle diretamente em posição ao próximo V.</p>
20
21 <p>É a sua vez. O seu código não deve ser maior que 4 linhas (sem contar
22 <code>fazerV</code>)...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Desenhar metodicamente (apenas grande)</h2>
3
4 Vamos agora reproduzir um desenho geométrico ainda maior. Novamente,pode ver
5 o modelo a clicar na guia "Objetivo".
6
7 <p>Pode naturalmente reutilizar todo o código que digitou em exercícios
8 anteriores (selecione o outro exercício, faça Ctrl-C, volte para o código
9 deste exercício e faça Ctrl-V).</p>
10
11 <p>Mas quer manter o seu código tão simples quanto possível. Para isto, defina
12 novos métodos para lidar simplesmente com as repetições no padrão. Por
13 exemplo, um método <code>makePattern()</code> a fazer o padrão do exemplo
14 anterior parece ser uma boa ideia (mas pode não ser o suficiente).</p>
15
16 <p>Por que não tentar? O método do código principal não deve levar mais de 2
17 linhas (incluindo o loop for)</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Desenhar maior e maior</h2>
3
4 Como pode imaginar, vai ter que reproduzir o desenho geométrico descrito na
5 guia "Objetivos". Como pode ver, é até maior do que o anterior.
6
7 <p>Portanto tem que declarar até mais métodos para usar as repetições do padrão
8 e fatorar o seu código. É a sua vez...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Funções</h2>
3
4 <p>Frequentemente, vai escrever um método que calcula algum valor e o
5 retorna. Métodos a retornar resultados são chamados <b>funções</b>. Escrever
6 uma função não é realmente mais difícil do que escrever um simples método.
7 [!java|c]Simplesmente tem que especificar o tipo de dados do resultado
8 esperado entes do nome da função (onde previamente tínhamos
9 <code>void</code>).[/!] [!scala]Simplesmente tem que adicionar um
10 dois-pontos (:) depois do parêntesis e escrever o tipo de dados que a função
11 dele vai retornar e adicionar um símbolo de igualdade (=). Esta sintaxe é na
12 verdade mais próxima de definir uma variável, com o tipo dela, do que na
13 verdade escrever uma função.[/!] Pode usar a instrução <code>return</code>
14 em qualquer lugar do corpo da sua função para especificar que o cálculo foi
15 feito (a função não continuará a ser executada) e que o resultado é o valor
16 que acompanha a palavra-chave <code>return</code>.</p>
17
18 <pre>[!java|c]double pi() {[/!][!scala]def pi(): Double = {[/!][!python]def pi():[/!]
19 return 3.14159[!java|c];[/!]
20 [!java|scala|c]}[/!]</pre>
21
22 <p>Na verdade, também pode usar a palavra-chave <code>return</code> em métodos
23 que não retornam qualquer resultado, para interromper o cálculo. Obviamente
24 que nestes casos não passa nenhum valor para retornar.</p>
25
26 <p>É possível ter várias instruções <code>return</code> em várias ramificações
27 de um condicional. De fato, é proibido ter um caminho de execução no corpo
28 da função sem nenhum <code>return</code>, ou escrever algum código depois da
29 instrução <code>return</code>. Na verdade, se a máquina alcança o fim da
30 função sem encontrar qualquer <code>return</code>, ela não sabe o real valor
31 que deve retornar a quem chamou a função. Além disto, o <code>return</code>
32 interrompe imediatamente a execução da função (por que se preocupar a olhar
33 além quando sabe o resultado da função?). Então, se existe algum código
34 depois de um <code>return</code>, deve ser um erro e o compilador irá te
35 alertar disto.</p>
36
37 <pre>[!java|scala|c][!java]boolean [/!][!c]int [/!][!scala]def [/!]isFrontFree()[!scala]:Boolean =[/!] {
38 if (isFacingWall() == [!java|scala]true[/!][!c]1[/!]) {
39 return [!java|scala]false[/!][!c]0[/!];
40 <span class="comment">/* proibido pôr código aqui */</span>
41 } else {
42 return [!java|scala]true[/!][!c]1[/!];
43 <span class="comment">/* nem aqui */</span>
44 }
45 <span class="comment">/* e nem mesmo aqui. desista */</span>
46 }[/!][!python]def livreEmFrente():
47 if isFacingWall() == True:
48 return False
49 <span class="comment"># proibido pôr código aqui</span>
50 else
51 return True
52 <span class="comment"># nem aqui</span>
53 <span class="comment"># e nem mesmo aqui, desista</span>[/!]</pre>
54
55 <h3>Objetivo do exercício</h3>Vai mais uma vez escrever uma função que o buggle vai usar. O nome dela deve
56 ser <code>temBaggle</code> e retorna um valor booleano a indicar se a linha
57 na frente do buggle contém um baggle ou não. O buggle vai usar isto para
58 buscar a primeira linha a conter um baggle e parar nela.
59
60 <p>A forma fácil de fazer esta função é usar uma variável booleana chamada
61 <code>baggleAvistado</code> a indicar se vimos ou não um baggle até o
62 momento. O valor inicial é
63 '[!python]False[/!][!scala|java]false[/!][!c]0[/!]'.</p>
64
65 <p>Então mova 6 passos para frente (o mundo contém 7 células e já estamos numa
66 delas). Para cada célula, se ela contiver um baggle, vamos guardar true em
67 <code>baggleVisto</code> (e se não, vamos simplesmente andar para frente).</p>
68
69 <p>No final, vamos nos mover 6 passos para trás e retornar o valor de
70 <code>baggleVisto</code> para quem chamou o método.</p>
71
72 <p>Observe que o buggle usado fornece código oculto que irá chamar a sua função
73 <code>haveBaggle</code> em cada coluna, movendo automaticamente entre
74 colunas. Portanto, é muito importante que a sua função
75 <code>haveBaggle</code> não tenha nenhum efeito colateral: a posição (e
76 orientação) no final do seu código deve ser a observada no início deste
77 código. Ela moverá entre elas para buscar a baggle, mas volta para o início
78 da coluna.</p>
79
80 <p>Além disso, este exercício é um pouco diferente, pois existem dois mundos
81 iniciais, cada um com um objetivo específico. O seu código deve funcionar
82 para cada um deles. Observe que o menu de rolagem de seleção de mundos (logo
83 abaixo do controle deslizante de velocidade) permite mudar o mundo
84 observado. </p>
85
86 <p>Quando a sua função <code>temBaggle</code> funcionar, siga ao próximo
87 exercício.</p>
88
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Caça à lesma</h2>
3
4 <p>Agora que o seu método <code>isFacingTrail()</code> está a funcionar, é hora
5 de escrever o código para organizar a festa da caçada. Copie-e-cole o seu
6 código do exercício anterior e complete o método <code>hunt()</code>.</p>
7
8 <p>Seguir uma trilha não é difícil: avance até ter a trilha à sua frente. Se
9 não houver trilha mais trilha à sua frente, verifique se o restante da
10 trilha está à sua esquerda ou à sua direita e vá nesta direção.</p>
11
12 <p>Para garantir que não misture o caminho de onde veio com o para aonde vai, o
13 fácil é apagar o caminho por onde passa. Use o método
14 <code>brushDown()</code> para abaixar o seu pincel e marcar o chão e
15 <code>brushUp()</code> para levantá-lo de novo.</p>
16
17 <p>Finalmente, não se esqueça de capturar a sua presa quando encontrá-la (a
18 usar <code>pickupBaggle()</code>).</p>
19
20
21 <h3>Objetivo do exercício</h3>
22 <a name="Objetivos"> Complete o método <code>hunt()</code>. Não gostaria de
23 copiar o método <code>isFacingTrail()</code> que escreveu no exercício
24 anterior?</a>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Lesmas e Caracóis</h2>
3
4 <p>Iuhu! Desta vez, o seu buggle encontrou trilhas com muitas presas! No
5 primeiro mundo, era uma bela lesma deliciosa (que deixava um rastro rosa) e
6 no segundo mundo, uma grande e o caracol gordo que esperava o seu buggle no
7 final do rastro laranja.</p>
8
9 <p>Tem que copiar/colar o seu código de novo e mudá-lo de forma que os seus
10 métodos fiquem com a cor do rastro para seguir como um parâmetro. E mesmo
11 assim, o seu código deve funcionar como antes.</p>
12
13 <p>Cuidado para não seguir pistas falsas! O método <code>hunt()</code> recebe
14 um parâmetro para dizer que cor seguir (e não é o mesmo em todos os
15 mundos). Adicione um parâmetro ao seu método <code>isFacingTrail()</code>
16 para apenas seguir a cor requisitada, pois as outras cores vão levar a
17 becos...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Rastrear a lesma</h2>
3 <p>
4 O seu buggle está super-feliz! Acabou de encontrar o rastro verde e úmido,
5 certamente deixado por um apetitosa e grande lesma. No final dele, o buggle
6 tem certeza de que vai se divertir com est deliciosa lesma (representada por
7 um baggle).
8 </p>
9
10 <p>Para atingir esse objetivo, teve que escrever um método
11 <tt>isFacingTrail</tt> que será chamado automaticamente pelo buggle a cada
12 passo. O seu método deve retornar [!python]True[/!][!java|scala]true[/!] se
13 estiver diante de uma célula verde, ou
14 [!python]False[/!][!java|scala]false[/!] se não estiver. Claro, se
15 estivermos de frente para uma parede, deve retornar false sem esbarrar
16 nela. Deve ter certeza de que este método não tem <b>efeitos colaterais</b>,
17 ou seja, que não muda o estado do buggle chamado nem do mundo dele.</p>
18
19 <p>A sua ferramenta para este objetivo é o <code>getGroundColor()</code> que
20 retorna a cor da célula atual. Simplesmente vá à célula que quer testar e
21 execute esta função. [!java]Não pode testar se esta cor é igual a
22 <code>Cor.verde</code> com um símbolo de <code>==</code> mas sim escrever
23 algo como <code>getGroundColor().equals(Cor.verde)</code>. Isto acontece por
24 que verde é um <i>objeto</i> em Java e <code>.equals()</code> é a forma de
25 testar igualdade entre objetos Java.[/!] [!python|scala]Então tem que testar
26 se a cor retornada é igual ao valor <code>Cor.verde</code>, que representa
27 verde.[/!]</p>
28
29 <h3>Objetivo do exercício</h3>
30 <p>Complete o método <code>isFacingTrail()</code> (que será chamado
31 automaticamente).</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h3>Primeiros passos</h3>
3 <p>Esta primeira lição vai guiar-lo pelos primeiros passos em programação. Ela
4 foi feita para iniciantes.</p>
5
6 <p>Se está perdido, venha para esta lição que ela irá te ensinar as bases da
7 programação.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Perdido em Moria</h2>
3
4 <p>Os seus buggles ficaram presos nas minas de Moria! Algumas pedras estão a
5 bloquear a saída e terá que limpar o seu caminho para a saída. Bem, é claro
6 que são apenas baggles e pode simplesmente sair a andar, mas será mais fácil
7 programar os buggles de forma que mova estas "pedras" do que convencer-los
8 que ele pode sair a andar facilmente sem resolver o problema. Anões podem
9 ser bem teimosos...</p>
10
11 <p>Bem, tem que encontrar o primeiro baggle a bloquear a saída (simplemente
12 ande para o leste até que esteja sobre um baggle), leve-o e mova para o
13 outro lado do túnel (ande para o oeste enquanto ainda não estiver sobre um
14 baggle e depois mova-se de volta um passo para o leste e solte o seu baggle)
15 e repita até encontrar a saída (ou seja, a parede com o muro para o lado
16 leste). Depois disto, mova-se para fora como no mundo objetivo. São só mais
17 uns passos.</p>
18
19 <p>Para piorar ainda mais as coisas, tem que escrever um programa que funcione
20 para qualquer buggle, mesmo se escrever um programa específico para cada um
21 deles for mais fácil. Parece que usar loops <code>while</code> é a única
22 solução para mover os buggles corretamente.</p>
23
24 <p>Quando conseguir escapar desta armadilha, poderá avançar para o próximo
25 exercício. Este exercício é um pouco mais complexo, então também pode
26 esperar e voltar mais tarde se não o conseguir agora mesmo.</p>
27
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Mundo das cobras</h2>
3
4 <p>Agora vamos ensinar o buggle a explorar o mundo dele. A posição inicial dele
5 é o canto inferior esquerdo e deve visitar todas as células até o topo (a
6 colorir o chão onde passa. O loop principal do seu código é algo assim:</p>
7 <pre>
8 abaixe o pincel
9 enquanto não chegar na posição final
10 se mova como uma cobra
11 </pre>
12
13 <p>Então temos que escrever dois métodos específicos: o primeiro retorna um
14 booleano a indicar se estamos numa posição final enquanto o segundo um
15 "snake step" para frente.</p>
16
17 <p>Chegamos na posição final se e apenas se ambas as condições são verdadeiras:</p>
18 <ul>
19 <li>Estamos de frente para uma parede</li>
20 <li>Existe uma parede no norte do buggle. Então, se o buggle está a olhar para o
21 leste, deve verificar se existe uma parede à esquerda e se o buggle está a
22 olhar para o oeste, deve verificar do lado direito.<br/>
23 Podemos obter a direção atual do buggle a usar o <code>getDirection()</code>
24 e sabemos se ele está a apontar para o leste a usar <code>getDirection() ==
25 [!scala|python|java]Direção.[/!]LESTE</code> (OESTE para oeste).<br/>
26 Para verificar, não tem mágica: tem que virar o buggle e verificar em
27 seguida se está a olhar para uma parede.</li>
28 </ul>
29
30 <p>Então, um passo de cobra pode ser conseguido a mover um passo para a frente
31 se não estivermos de cara para a parede e a mover para a linha acima caso
32 contrário (p.ex., se olha para o oeste e está de cara para uma parede, tem
33 que virar a direita, andar e virar a direita).</p>
34
35 <p>Dica: o loop principal do seu código deve continuar enquanto a função de
36 teste retorna false. Existem duas formas de fazer isto:</p>
37 <pre>while (testingFunction() == [!c]0) {[/!][!java|scala]false) {[/!][!python]False):[/!]</pre>
38 <p>[!python]Pode preferir escrever como:[/!] [!java|scala|c]Já que a marca de
39 exclamação (!) denota a negação booleana em [!thelang], pode escrever
40 como:[/!]</p>
41 <pre>while ([!java|scala|c]![/!][!python]not [/!]testingFunction())[!java|scala|c] {[/!][!python]:[/!]</pre>
42
43 <p>É asua vez...</p>
44
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Percorrer pelas colunas</h2>
3
4 <p>O objetivo desta série de exercícios é fazer o buggle percorrer o mundo
5 dele. Deve numerar as células por onde passa para mostrar a ordem do
6 caminho.</p>
7
8 <p>O loop principal do seu código deve ser algo como:</p>
9 <pre>
10 enquanto não estiver na posição final
11 vá à próxima posição
12 rotule a célula com um número
13 </pre>
14
15 <p>Ao contrário dos exercícios que vimos até agora, não vamos usar os métodos
16 <code>forward()</code>, <code>recuar()</code> e similares. Ao invés disto,
17 vamos calcular as coordenadas da próxima posição de buggle e usar o método
18 <code>setPos(x, y)</code> para <i>teletransportar</i> o buggle diretamente
19 para esta posição. Por exemplo, <code>setPos(3, 5)</code> teletransporta o
20 buggle à célula onde x=3 e y=5.</p>
21
22 <p>A sua primeira tarefa é escrever uma função booleana a indicar se o buggle
23 alcançou a posição final ou não, ou seja, se alcançou o canto inferior
24 direito do mundo. Para isto, pode usar <code>getWorldWidth()</code> e
25 <code>getWorldHeight()</code> que retornam respetivamente a largura e altura
26 do mundo. O seu teste deve comparar a posição atual do buggle (que pode
27 acessar com <code>getX()</code> e <code>getY()</code>) com as dimensões do
28 mundo.<br/>
29 Cuidado, a primeira linha e coluna são numeradas com 0 e não com 1 e o ponto
30 (0,0) fica no canto superior esquerdo. Isto pode parecer estranho, mas é bem
31 comum em ciência da computação.</p>
32
33 <p>Então, tem que escrever o código para alcançar a próxima posição. Neste
34 exercício, tem que percorrer o mundo linha após linha. Logo, se está no
35 fundo de uma linha, tem que mover ao topo da próxima, caso contrário tem que
36 mover à célula abaixo.</p>
37
38 <p>Neste ponto, pode lançar o seu programa para verificar se o buggle percorre
39 corretamente o mundo na ordem esperada e que pára quando tem que parar. Use
40 oo botão <b>stop</b> se o buggle não parar corretamente.</p>
41
42 <p>Agora é hora de escrever os números das células. Para isto, vai precisar de
43 um contador a iniciar em zero no começo do seu código e incrementar de um em
44 cada passo (por exemplo com <code>counter += 1;</code>). Então, terá que
45 usar <code>writeMessage()</code> para escrever o valor no chão.
46 </p>
47
48 <p>Provavelmente vai precisar escrever o primeiro [!java|scala|c]ou último
49 [/!]valor fora do loop principal [!java|scala|c], a depender se prefere usar
50 um <code>while</code> ou um <code>do/while</code>[/!].</p>
51
52 <p>É asua vez...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Percorrer na diagonal</h2>
3
4 <p>Agora é para atravessar o mundo uma diagonal depois da outra. Dê uma olhada
5 no mundo objetivo para maiores detalhes quanto à ordem a percorrer pedida.</p>
6
7 <p>Pode ser útil usar uma variável inteira <code>diag</code> a guardar o número
8 da diagonal que está a atravessar.</p>
9
10 <p>É asua vez...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Percorrer pelas linhas</h2>
3
4 Mais uma vez terá que deixar o buggle percorrer o mundo a numerar as células
5 no caminho, mas o objetivo do exercício é escrever uma linha transversal. A
6 maioria do código que escreveu para exercícios anteriores continua útil
7 aqui. Simplesmente, o método a calcular as coordenadas da próxima posição do
8 buggle tem que ser atualizado corretamente: se estiver a direita de uma
9 linha, terá que ir ao começo da próxima. Senão, terá que ir à célula da
10 direita.
11
12 <p>É asua vez...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Percorrer em zig-zag</h2>
3
4 Desta vez, vai ter que fazer um zigzag no caminho para cima. Dê uma olhada
5 no mundo objetivo para mais detalhes da ordem a percorrer pedida.
6
7 <p>É asua vez...</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>Ande quatro bases</h2>
3
4 <p>Hoje é um grande dia para os buggles: a grande corrida dos Buggles
5 começou. Esta é uma competição tradicional na qual jovens buggles mostram o
6 valor deles para a tribo. Tanto força quanto inteligência são exercitados:
7 tem que correr, mas parar assim que alcançar o quarto baggle. Por favor,
8 ajude os buggles a se moverem para frente enquanto conta os baggles e
9 determina quando parar.</p>
10
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>A corrida dos quatro meios</h2>
3
4 <p>Chegamos ao segundo dia da grande corrida dos Buggles. Como antes, tem que
5 correr até alcançar a célula certa para parar. Mas desta vez, tem que
6 alcançar a célula onde a quantidade de baggles que viu é o dobro da
7 quantidade de células laranjas mais 1. Em outras palavras, a seguinte
8 condição deve se tornar verdadeira <code>2 * baggles = célulasLaranjas +
9 1</code>.</p>
10
11 <p>Pode determinar quando está sobre uma célula laranja com o método
12 <code>isOverOrange()</code>.</p>
13
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h2>A armazenar e a manipular dados</h2>
3 <p>Os programas que escrevemos até agora não tem um ponto fundamental da
4 computação. Na verdade, é sobre processar <b>dados</b> através de
5 <b>instruções</b> específicas. No mundo dos buggles, os dados principais
6 estão escondidos atrás de uma representação gráfica, mas isto não é motivo
7 para nunca manipular alguns dados explicitamente. </p>
8
9 <h3>Dados em [!thelang]</h3>
10 <p>Num programa, pode usar vários <i>tipos</i> de dados, tais como números
11 inteiros ou cadeias de caracteres, ou caracteres. Se quiser usar um dado
12 várias vezes, precisa armazená-la numa <i>variável</i>, que é uma célula de
13 memória a conter um valor: põe o seu dado (digamos o valor '5') na variável
14 (digamos 'comprimento') e pode recuperá-la mais tarde quando precisar
15 dela. Isto é muito similar a uma caixa com o rótulo 'presente' na qual pode
16 pôr alguma coisa, como um perfume "Channel N°5". </p>
17
18 <h3>Declaração de variáveis</h3>
19
20 <p><b>Declarar</b> (ie, criar) uma variável em [!thelang], é muito
21 simples. Simplesmente escreve [!java]o tipo dele, um espaço e o nome da
22 variável.[/!] [!scala]a palavra-chave <code>var</code>, o nome da variável,
23 um dois-pontos (:) e o tipo da variável, um sinal de igualdade (=) e um
24 valor inicial.[/!] [!python]o nome da variável, um sinal de igual (=) e um
25 valor inicial.[/!] O nome da variável é o rótulo para recuperar ela
26 depois[!python].[/!] [!java|scala] enquanto o tipo é o tipo de dado que a
27 variável aceita guardar.[/!] É proibido usar espaços em nomes de
28 variáveis. Pode nomear uma variável <code>quantidadeDePassos</code> se
29 quiser, mas <code>quantidade de passos</code> não é um nome válidos.
30 </p>
31
32 [!c|java]
33 <p>Então, para criar uma variável chamada <b>x</b> para guardar inteiros, deve
34 escrever:</p>
35 <pre>int x;</pre>
36 <p>Se quiser, pode especificar o valor inicial da variável a adicionar um
37 símbolo de igual (=) seguido do valor depois da declaração.</p>
38 <pre>int x=5;</pre>
39 [/!] [!python]
40 <p>Então se quiser que a variável tenha o valor inicial de 5, deve digitar: </p>
41 <pre>x = 5</pre>
42 [/!] [!scala]
43 <p>Logo, para criar uma variável chamada <b>x</b> que vai guardar inteiros e
44 com 42 como valor inicial, deve escrever:</p>
45 <pre>var x:Int = 42</pre>
46 <p>Na maioria dos casos, o compilador é capaz de adivinhar o tipo da variável
47 baseado no valor inicial e pode omitir o tipo:</p>
48 <pre>var x = 42</pre>
49 <p>Ainda tem que especificar se usa alguns valores genéricos como uma
50 inicialização, tais como o valor muito especial <code>null</code>, cujo tipo
51 parece ser ambíguo. Mesmo quando o tipo é claro, ainda pode especificar o
52 tipo se preferir. Portanto, se quiser que a variável contenha 5 como valor
53 inicial, deve digitar: </p>
54 <pre>var x: Int = 5 <span class="comment">// Posso definir o tipo se quiser</span>
55 var y = 10 <span class="comment">// ou posso omitir o tipo se preferir</span></pre>
56 [/!] [!java|scala|c]
57 <p>Como pode ver, as variáveis são <b>tipadas</b> em [!thelang], que significa
58 que elas são de certa forma especializadas: Uma dada variável pode armazenar
59 apenas dados de um tipo; nem pense em guardar números numa variável que é
60 feita para letras! Dizemos que a linguagem [!thelang] é <b>estaticamente
61 tipada</b>.</p>
62 <p>Outras linguages (como Python) são menos charas e permitem que guarde
63 qualquer tipo de dado em qualquer variável, sem restrições (estas linguagens
64 são ditas <b>dinamicamente tipadas</b>). Parecem mais fáceis à primeira
65 vista, mas este tipo de restrição permite que o compilador perceba mais
66 erros de lógica para você, o que é bom. Num certo sentido, Python é mais
67 fácil de escrever mas os erros surgem com mais frequencia do que em
68 [!thelang].</p>
69 <p>Aqui estão alguns dos tipos em [!thelang]:</p>
70 <ul>
71 <li><b>[!java|c]int[/!][!scala]Int[/!]</b>, para inteiros;</li>
72 <li><b>[!java|c]double[/!][!scala]Double[/!]</b>, para números com vírgula;</li>
73 <li><b>[!c]int[/!][!java]boolean[/!][!scala]Boolean[/!]</b>, para booleanos, que
74 são valores ou [!c]1[/!][!java|scala]true[/!] ou
75 [!c]0[/!][!java|scala]false[/!];</li>
76 <li><b>[!c]char*[/!][!java|scala]String[/!]</b>, para cadeias de caracteres.</li>
77 </ul>
78 [/!] [!python]
79 <p>Como pode ver, as variáveis não são <b>digitadas</b> em Python, o que
80 significa que elas não são especializadas em nenhum tipo de dado. Uma
81 determinada variável armazena qualquer tipo de dado de um determinado tipo:
82 pode armazenar um número numa variável e, mais tarde, armazenar um número na
83 mesma variável. Os valores ainda são digitados, mas não a variável. Diz-se
84 que Python é de <b>tipagem dinâmica</b>.</p>
85 <p>Outras linguagens (como Java, Scala ou C), são muito mais exigentes e
86 impedem que misture tipos de dados numa certa variável (dizemos que elas são
87 <b>esticamente tipadas</b>). Isto parece inconveniente à primeira vista, mas
88 este tipo de restrição permite que o compilador capture mais erros de lógica
89 para você, o que também é bom. Num certo sentido, Python é mais fácil de
90 escrever mas erros podem surgir mais facilmente.</p>
91 [/!]
92
93
94 <p class="scala">Se sabe que o valor da sua "variável" nunca vai mudar (eg quando ela contém
95 o tamanho do ecrã ou outro valor constante), então deve fazer dela um
96 <b>valor</b> ao invés de uma variável. Simplesmente mude a palavra-chave
97 <code>var</code> para <code>val</code>. O compilador pode então verificar as
98 suas ações e capturar o seu erro quando inadvertidamente modificar o
99 valor. Mais interessante ainda, o compilador pode produzir código mais
100 rápido em alguns casos.</p>
101
102 <p>Variáveis funcionam muito parecido com cadeias, números com vírgula e
103 valores booleanos.</p>
104
105 <pre class="c">char* nome = "Martin Quinson";
106 double altura=1.77; <span class="comment">// em metros</span>
107 int casado=1;<span class="comment">// 1 significa "verdadeiro"; false é 0</span></pre>
108
109
110 <pre class="java">Cadeia nome = "Martin Quinson";
111 double altura=1.77; <span class="comment">// em metros</span>
112 boolean casado=true;<span class="comment">// o contrário se escreve "false"</span></pre>
113
114 <pre class="scala">val nome:String = "Martin Quinson"; <span class="comment">// isto não pode ser modificado (é um valor)</span>
115 var altura: Double = 1.77; <span class="comment">// em metros</span>
116 var casado = true; <span class="comment">// o contrário se escreve "false"</span>
117 <span class="comment">// Scala sabe que 'true' é um valor Booleano, não precisa repetir</span></pre>
118
119 <pre class="python">firstName = "Martin"
120 lastName = 'Quinson' <span class="comment"># aspas e aspas simples funcionam aqui</span>
121 frase = "uma gota d'água é sempre melhor que nada" <span class="comment"># uma aspas simples entre aspas duplas vale</span>
122 altura=1.77 <span class="comment"># em metros</span>
123 casado=True <span class="comment"># o contrário se escreve "False"</span></pre>
124
125 <h3>Atribuições</h3>
126
127 <p>Uma vez que a sua variável está declarada, pode lhe <b>atribuir</b> um novo
128 valor mais tarde no programa. Isto é bem fácil:</p>
129 <pre>x = 3[!java|c];[/!]</pre>
130
131 <p>À esquerda do símbolo de igual pode pôr uma expressão aritmética a conter
132 constantes, variáveis e operações.</p>
133
134 <pre>x = 3 + 2[!java|c];[/!]
135 x = 3 * x[!java|c];[/!]
136 [!java|scala|python]saudação = "Oi "+nome[!java];[/!] <span class="comment">[!python]#[/!][!scala|java]//[/!] + é (também) a operação para concatenar (ie, para juntar) cadeias[/!]</span></pre>
137
138 <h3>Objetivo do exercício</h3>
139 Agora vamos fazer exercícios mais desafiantes, certo? O objetivo agora é
140 mover para a frente até encontrar um baggle, apanhar-lo e mover para trás
141 até a localização inicial antes de sotar o baggle.
142
143 <h3>Como fazer isto?</h3>
144 <p>Para resolver este problema, tem que decompor-lo em sub-partes menores. Por
145 exemplo, pode fazer os passos seguintes:
146 <ol>
147 <li>Mover para a frente até se pôr sobre um baggle</li>
148 <li>Apanhar o baggle</li>
149 <li>Mover para trás a mesma quantidade de passos que deu no primeiro passo</li>
150 <li>Soltar o baggle de novo</li>
151 </ol></p>
152
153 <p>Naturalmente, é impossível dar a quantidade certa de passos para trás no
154 passo 3 se não contou a quantidade de passos dados na primeira fase. Pode
155 usar uma variável para isto, que pode ser chamada
156 <code>quantidadeDePassos</code>.</p>
157
158 <p>Crie uma variável inteira antes da fase 1, inicie ela com 0 e a cada vez que
159 der um passo para frente, incremente ela de um (<code>quantidadeDePassos =
160 quantidadeDePassos + 1;</code>[!java] ou <code>quantidadeDePassos++;</code>,
161 ambas as sintaxes são equivalentes[/!]). Tais variáveis que obtèm cada
162 valor de um dado intervalo são normalmente chamadas de <b>stepper</b>.</p>
163
164 [!python|scala]
165 <p>Se conhece Java ou outras linguagens, provavelmente vai tentar usar o
166 operador <code>++</code> para incrementar a variável, mas isto não é
167 permitido em [!thelang]. Isto é por que seria difícil definir este operador
168 para todos os tipos de dados. Por exemplo, o que faria ++ quando aplicado a
169 um valor complexo ou a uma cadeia? O problema não ocorre em Java, pois
170 <code>int</code> não é um objeto e sim um tipo primitivo. (se não conhece o
171 <code>++</code>, simplesmente ignore este parágrafo: fnão existe em
172 [!thelang])</p>
173 [/!]
174
175 <p>Então, a fase 3 consiste em simplesmente criar uma nova variável inteira
176 <code>passosDados</code> iniciada como 0 e dar um passos para trás enquanto
177 <code>passosDados</code> não for igual a <code>quantidadeDePassos</code>, a
178 aumentar <code>passosDados</code> a cada vez. O operador <code>!=</code>
179 deve ser usado para testar a inequação (quando um valor NÃO É igual).</p>
180
181 <p>Agora é a sua vez!</p>
+0
-24
src/plm/core/javafx/PLM.java less more
0 package plm.core.javafx;
1
2 import javafx.application.Application;
3 import javafx.scene.Group;
4 import javafx.scene.layout.VBox;
5 import javafx.scene.web.WebView;
6 import javafx.scene.Scene;
7 import javafx.stage.Stage;
8
9 public class PLM extends Application {
10 @Override
11 public void start(Stage primaryStage) throws Exception {
12 WebView webView = new WebView();
13
14 webView.getEngine().load("http://google.com");
15
16 VBox vBox = new VBox(webView);
17 Scene scene = new Scene(vBox, 960, 600);
18
19 primaryStage.setScene(scene);
20 primaryStage.show();
21
22 }
23 }
9393 private Lesson currentLesson;
9494 private Lecture lastExercise;
9595
96 public static final String [][] humanLangs = { {"English","en"}, {"Français","fr"}, {"Italiano","it"}, {"Português brasileiro", "pt_BR"}, {"Українська", "uk"}, {"中文", "zh"} };
96 public static final String [][] humanLangs = { {"English","en"}, {"Français","fr"}, {"Italiano","it"}, {"Português", "pt"}, {"Português brasileiro", "pt_BR"}, {"Svenska", "sv"}, {"Українська", "uk"}, {"中文", "zh"} };
9797
9898 public static final ProgrammingLanguage JAVA = new LangJava();
9999 public static final ProgrammingLanguage PYTHON = new LangPython();
+0
-6
src/plm/core/model/lesson/ExerciseSheet.java less more
0 package plm.core.model.lesson;
1
2 /** Part of the exercise that is shared between all users */
3 public class ExerciseSheet {
4
5 }
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>BatWorld</h1>
3
4 <p>Este mundo é um ambiente de testes simplista largamente inspirado no
5 http://codingbat.com criado por Nick Parlente.</p>
6
7 <p>Os exercícios são bem curtos e têm como objetivo melhorar as habilidades de
8 programação tática dos estudantes. Isto significa que irá ser apresentado a
9 uma longa lista de pequenos exercícios sobre coisas simples. A ideia é
10 treinar estes aspectos simples até que eles fiquem automáticos para si.</p>
11
12 <p>Ao contrário dos outros mundos, o "BatWorld" não fornece qualquer abstração
13 ou visualização legal. Tem simplesmente que preencher uma função, que é
14 chamada com um conjunto de parâmetros e é isto.</p>
15
16 <p>Para mais informações, deve consultar a documentação do CodingBat.com, que
17 contém por exemplo uma documentação sobre operadores booleanos bem útil:
18 http://codingbat.com/doc/ifboolean.html</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>BuggleWorld</h1>
3 Este mundo foi inventado por Lyn Turbak, na Wellesley College. Está cheio de
4 Buggles, pequenos animais que entendem ordens simples e oferece numerosas
5 possiblidades de interação com o mundo: apanhar e soltar objetos, pintar o
6 chão, bater em paredes, etc.
7
8 <h2>Métodos que os buggles entendem</h2>
9 <table border=1>
10 <tr><td colspan=2 align=center><b>A mover</b><br/> (Veja também a nota sobre exceções, abaixo)</td></tr>
11 <tr><td><b>Virar à esquerda<br/>Virar à direita<br/>Dar meia volta<br/>Mover para a frente<br/>Mover para trás</b></td>
12 <td>[!java|c]void [/!]left()<br/>
13 [!java|c]void [/!]right()<br/>
14 [!java|c]void [/!]back()<br/>
15 [!java|c]void [/!][!python|java|scala]forward()[/!][!c]stepForward()[/!] or
16 [!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])<br/>
17 [!java|c]void [/!][!python|java|scala]backward()[/!][!c]stepBackward()[/!]
18 or [!java]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])<br/></td></tr>
19 <tr><td><b>Obter coordenada X<br/>Obter coordenada Y<br/>Ajustar coordenada X<br/>Ajustar coordenada Y<br/>Ajustar posição</b></td>
20 <td>[!java|c]int [/!]getX()[!scala]:Int[/!]<br/>
21 [!java|c]int [/!]getY()[!scala]:Int[/!]<br/>
22 [!java|c]void [/!]setX([!java|c]int [/!]x[!scala]:Int[/!])<br/>
23 [!java|c]void [/!]setY([!java|c]int [/!]y[!scala]:Int[/!])<br/>
24 [!java|c]void [/!]setPos([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int
25 [/!]y[!scala]:Int[/!])</td></tr>
26 <tr><td colspan=2>Observe que o ponto (0,0) está no canto superior esquerdo, o que é comum em
27 ciência da computação.</td></tr>
28
29 <tr><td colspan=2 align=center><b>Informações sobre o buggle</b></td></tr>
30 <tr><td><b>Obter a cor do corpo<br/>Ajustar a cor do corpo</b></td>
31 <td>[!java|c]Color [/!]getBodyColor()[!scala]:Color[/!]<br/>
32 [!java|c]void [/!]setCorDoCorpo([!java|c]Cor [/!]c[!scala]:Cor[/!])</td></tr>
33 <tr><td><b>Procura por uma parede à frente<br/>Procura por uma parede atrás</b></td>
34 <td>[!java]boolean [/!][!c]int [/!]isFacingWall()[!scala]:Boolean[/!]<br/>
35 [!java]boolean [/!][!c]int [/!]isBackingWall()[!scala]:Boolean[/!]</td></tr>
36 <tr><td><b>Obter direção<br/>Ajustar direção</b><br/>direções válidas são:</td>
37 <td>[!java|c]Direction [/!]getDirection()[!scala]:Direction[/!]<br/>
38 [!java|c]void [/!]ajustaDireção([!java|c]Direção
39 [/!]dir[!scala]:Direção[/!])<br/>
40 [!scala|java|python]Direção.[/!]NORTE,
41 [!scala|java|python]Direção.[/!]LESTE, [!scala|java|python]Direção.[/!]SUL e
42 [!scala|java|python]Direção.[/!]OESTE</td></tr>
43 <tr><td>Verifica se o buggle está atualmente <b>selecionado na interface</b></td>
44 <td>[!java]boolean [/!][!c]int [/!]isSelected()[!scala]:Boolean[/!]</td></tr>
45
46 <tr><td colspan=2 align=center><b>Sobre o pincel</b></td></tr>
47 <tr><td><b>Abaixar pincel<br/>Levantar pincel<br/>Obter a posição do pincel</td>
48 <td>[!java|c]void [/!]brushUp()<br/>
49 [!java|c]void [/!]brushDown()<br/>
50 [!java]boolean [/!][!c]int [/!]isBrushDown()[!scala]:Boolean[/!]</td></tr>
51 <tr><td><b>Muda a cor do pincel<br/>Obtém a cor do pincel</b></td>
52 <td>[!java|c]void [/!]setCorDoPincel([!java|c]Color [/!]c[!scala]:Color[/!])<br/>
53 [!java|c]Color [/!]getBrushColor()[!scala]:Color[/!]</td></tr>
54
55 <tr><td colspan=2 align=center><b>A interagir com o mundo</b></td></tr>
56 <tr><td><b>Obtém a cor do chão</b></td>
57 <td>[!java|c]Color [/!]getGroundColor()[!scala]:Color[/!]</td></tr>
58
59 <tr><td><b>Procura por um "baggle" no chão<br/>Procura por um "baggle" na bolsa<br/>Apanhar um "baggle"<br/>Solta um "baggle"</b><br/>
60 (veja a nota sobre exceções)</td>
61 <td>[!java]boolean [/!][!c]int [/!]isOverBaggle()[!scala]:Boolean[/!]<br/>
62 [!java]boolean [/!][!c]int [/!]isCarryingBaggle()[!scala]:Boolean[/!]<br/>
63 [!java]void [/!]pickupBaggle()<br/>
64 [!java]void [/!]dropBaggle()<br/>
65 &nbsp;</td></tr>
66
67 <tr><td><b>Procura por uma mensagem<br/>Adiciona uma mensagem<br/>Lê a mensagem<br/>Apaga a mensagem</b></td>
68 <td>[!java]boolean [/!][!c]int [/!]isOverMessage()[!scala]:Boolean[/!]<br/>
69 [!java]void [/!]escreverMensagem([!java]String [/!][!c]char*
70 [/!]msg[!scala]:String[/!])<br/>
71 [!java]String [/!][!c]char* [/!]readMessage()[!scala]:String[/!]<br/>
72 [!java]void [/!]clearMessage()</td></tr>
73 </table>
74
75 <h2>Cores válidas</h2>
76 <table border=1>
77 <tr><td>Nome</td><td>Cor</td></tr>
78 <tr><td>[!scala|java|python]Cor.[/!]black</td> <td BGCOLOR="#000000">&nbsp;</td></tr>
79 <tr><td>[!scala|java|python]Cor.[/!]azul</td> <td BGCOLOR="#0000FF">&nbsp;</td></tr>
80 <tr><td>[!scala|java|python]Cor.[/!]ciano</td> <td BGCOLOR="#00FFFF">&nbsp;</td></tr>
81 <tr><td>[!scala|java|python]Cor.[/!]cinzentoEscuro</td> <td BGCOLOR="#404040">&nbsp;</td></tr>
82 <tr><td>[!scala|java|python]Cor.[/!]cinzento</td> <td BGCOLOR="#808080">&nbsp;</td></tr>
83 <tr><td>[!scala|java|python]Cor.[/!]verde</td> <td BGCOLOR="#00FF00">&nbsp;</td></tr>
84 <tr><td>[!scala|java|python]Cor.[/!]cinzentoClaro</td><td BGCOLOR="#C0C0C0">&nbsp;</td></tr>
85 <tr><td>[!scala|java|python]Cor.[/!]magenta</td> <td BGCOLOR="#FF00FF">&nbsp;</td></tr>
86 <tr><td>[!scala|java|python]Cor.[/!]laranja</td> <td BGCOLOR="#FFC800">&nbsp;</td></tr>
87 <tr><td>[!scala|java|python]Cor.[/!]rosa</td> <td BGCOLOR="#FFAFAF">&nbsp;</td></tr>
88 <tr><td>[!scala|java|python]Cor.[/!]vermelho</td> <td BGCOLOR="#FF0000">&nbsp;</td></tr>
89 <tr><td>[!scala|java|python]Cor.[/!]branco</td> <td BGCOLOR="#FFFFFF">&nbsp;</td></tr>
90 <tr><td>[!scala|java|python]Cor.[/!]amarelo</td> <td BGCOLOR="#FFFF00">&nbsp;</td></tr>
91 </table>
92
93 <h2>Nota sobre exceções</h2>
94 Buggles normais lançam uma exceção BuggleWallException se os pede atravessar
95 uma parede. Lançam uma exceção NoBaggleUnderBuggleException se os pede
96 tirar um "baggle" de uma célula vazia, ou uma exceção
97 AlreadyHaveBaggleException se eles já carregam um "baggle". Tentar soltar
98 um "baggle" numa célula que já contém outro lança uma exceção
99 AlreadyHaveBaggleException. Soltar um "baggle" quando não tem nenhum lança
100 uma DontHaveBaggleException.
101 <p>SimpleBuggles (ie, aqueles usados nos primeiros exercícios) exibem uma
102 mensagem de erro num problema de forma que não precise saber o que é uma
103 exceção.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>BuggleWorld</h1>
3 This world was invented by Lyn Turbak, at Wellesley College. It is full of
4 Buggles, little animals understanding simple orders, and offers numerous
5 possibilities of interaction with the world: taking or dropping objects,
6 paint the ground, hit walls, etc.
7
8 <h2>Methods understood by buggles</h2>
9 <table border=1>
10 <tr><td colspan=2 align=center><b>Flyttar</b><br/> (See also the note on exceptions, below)</td></tr>
11 <tr><td><b>Sväng vänster<br/>Sväng höger<br/>Kör tillbaka<br/>Kör framåt<br/>Backar</b></td>
12 <td>[!java|c]void [/!]vänster()<br/>
13 [!java|c]void [/!]höger()<br/>
14 [!java|c]void [/!]backa()<br/>
15 [!java|c]void [/!][!python|java|scala]forward()[/!][!c]stepForward()[/!] or
16 [!java|c]void [/!]forward([!java|c]int [/!]steps[!scala]:Int[/!])<br/>
17 [!java|c]void [/!][!python|java|scala]backward()[/!][!c]stepBackward()[/!]
18 or [!java]void [/!]backward([!java|c]int [/!]steps[!scala]:Int[/!])<br/></td></tr>
19 <tr><td><b>Get X coordinate<br/>Hämta Y-koordinat<br/>Set X coordinate<br/>Set Y coordinate<br/>Ställ in plats</b></td>
20 <td>[!java|c]int [/!]getX()[!scala]:Int[/!]<br/>
21 [!java|c]int [/!]getY()[!scala]:Int[/!]<br/>
22 [!java|c]void [/!]setX([!java|c]int [/!]x[!scala]:Int[/!])<br/>
23 [!java|c]void [/!]setY([!java|c]int [/!]y[!scala]:Int[/!])<br/>
24 [!java|c]void [/!]setPos([!java|c]int [/!]x[!scala]:Int[/!], [!java|c]int
25 [/!]y[!scala]:Int[/!])</td></tr>
26 <tr><td colspan=2>Note that the point (0,0) is on the top left corner, as it is often the case
27 in Computer Science.</td></tr>
28
29 <tr><td colspan=2 align=center><b>Information on the buggle</b></td></tr>
30 <tr><td><b>Get the color of the body<br/>Set the color of the body</b></td>
31 <td>[!java|c]Color [/!]getBodyColor()[!scala]:Color[/!]<br/>
32 [!java|c]void [/!]setBodyColor([!java|c]Color [/!]c[!scala]:Color[/!])</td></tr>
33 <tr><td><b>Look for a wall forward<br/>Look for a wall backward</b></td>
34 <td>[!java]boolean [/!][!c]int [/!]isFacingWall()[!scala]:Boolean[/!]<br/>
35 [!java]boolean [/!][!c]int [/!]isBackingWall()[!scala]:Boolean[/!]</td></tr>
36 <tr><td><b>Get heading<br/>Set heading</b><br/>valid directions are:</td>
37 <td>[!java|c]Direction [/!]getDirection()[!scala]:Direction[/!]<br/>
38 [!java|c]void [/!]setDirection([!java|c]Direction
39 [/!]dir[!scala]:Direction[/!])<br/>
40 [!scala|java|python]Direction.[/!]NORTH,
41 [!scala|java|python]Direction.[/!]EAST,
42 [!scala|java|python]Direction.[/!]SOUTH and
43 [!scala|java|python]Direction.[/!]WEST</td></tr>
44 <tr><td>Check whether the buggle is currently <b>selected in the interface</b></td>
45 <td>[!java]boolean [/!][!c]int [/!]isSelected()[!scala]:Boolean[/!]</td></tr>
46
47 <tr><td colspan=2 align=center><b>About the brush</b></td></tr>
48 <tr><td><b>Brush down<br/>Brush up<br/>Get brush position</b></td>
49 <td>[!java|c]void [/!]brushUp()<br/>
50 [!java|c]void [/!]brushDown()<br/>
51 [!java]boolean [/!][!c]int [/!]isBrushDown()[!scala]:Boolean[/!]</td></tr>
52 <tr><td><b>Change the brush color<br/>Get the color of the brush</b></td>
53 <td>[!java|c]void [/!]setBrushColor([!java|c]Color [/!]c[!scala]:Color[/!])<br/>
54 [!java|c]Color [/!]getBrushColor()[!scala]:Color[/!]</td></tr>
55
56 <tr><td colspan=2 align=center><b>Interacting with the world</b></td></tr>
57 <tr><td><b>Get the color of the ground</b></td>
58 <td>[!java|c]Color [/!]getGroundColor()[!scala]:Color[/!]</td></tr>
59
60 <tr><td><b>Look for a baggle on the ground<br/>Look for a baggle in bag<br/>Pickup a baggle<br/>Drop a baggle</b><br/>
61 (see the note on exceptions)</td>
62 <td>[!java]boolean [/!][!c]int [/!]isOverBaggle()[!scala]:Boolean[/!]<br/>
63 [!java]boolean [/!][!c]int [/!]isCarryingBaggle()[!scala]:Boolean[/!]<br/>
64 [!java]void [/!]pickupBaggle()<br/>
65 [!java]void [/!]dropBaggle()<br/>
66 &nbsp;</td></tr>
67
68 <tr><td><b>Look for a message<br/>Add a message<br/>Read the message<br/>Erase the message</b></td>
69 <td>[!java]boolean [/!][!c]int [/!]isOverMessage()[!scala]:Boolean[/!]<br/>
70 [!java]void [/!]writeMessage([!java]String [/!][!c]char*
71 [/!]msg[!scala]:String[/!])<br/>
72 [!java]String [/!][!c]char* [/!]readMessage()[!scala]:String[/!]<br/>
73 [!java]void [/!]clearMessage()</td></tr>
74 </table>
75
76 <h2>Valid colors</h2>
77 <table border=1>
78 <tr><td>Name</td><td>Color</td></tr>
79 <tr><td>[!scala|java|python]Color.[/!]black</td> <td BGCOLOR="#000000">&nbsp;</td></tr>
80 <tr><td>[!scala|java|python]Color.[/!]blue</td> <td BGCOLOR="#0000FF">&nbsp;</td></tr>
81 <tr><td>[!scala|java|python]Color.[/!]cyan</td> <td BGCOLOR="#00FFFF">&nbsp;</td></tr>
82 <tr><td>[!scala|java|python]Color.[/!]darkGray</td> <td BGCOLOR="#404040">&nbsp;</td></tr>
83 <tr><td>[!scala|java|python]Color.[/!]gray</td> <td BGCOLOR="#808080">&nbsp;</td></tr>
84 <tr><td>[!scala|java|python]Color.[/!]green</td> <td BGCOLOR="#00FF00">&nbsp;</td></tr>
85 <tr><td>[!scala|java|python]Color.[/!]lightGray</td><td BGCOLOR="#C0C0C0">&nbsp;</td></tr>
86 <tr><td>[!scala|java|python]Color.[/!]magenta</td> <td BGCOLOR="#FF00FF">&nbsp;</td></tr>
87 <tr><td>[!scala|java|python]Color.[/!]orange</td> <td BGCOLOR="#FFC800">&nbsp;</td></tr>
88 <tr><td>[!scala|java|python]Color.[/!]pink</td> <td BGCOLOR="#FFAFAF">&nbsp;</td></tr>
89 <tr><td>[!scala|java|python]Color.[/!]red</td> <td BGCOLOR="#FF0000">&nbsp;</td></tr>
90 <tr><td>[!scala|java|python]Color.[/!]white</td> <td BGCOLOR="#FFFFFF">&nbsp;</td></tr>
91 <tr><td>[!scala|java|python]Color.[/!]yellow</td> <td BGCOLOR="#FFFF00">&nbsp;</td></tr>
92 </table>
93
94 <h2>Note on exceptions</h2>
95 Regular buggles throw a BuggleWallException exception if you ask them to
96 traverse a wall. They throw a NoBaggleUnderBuggleException exception if you
97 ask them to pickup a baggle from an empty cell, or a
98 AlreadyHaveBaggleException exception if they already carry a baggle. Trying
99 to drop a baggle on a cell already containing one throws an
100 AlreadyHaveBaggleException exception. Dropping a baggle when you have none
101 throws a DontHaveBaggleException.
102 <p>SimpleBuggles (ie, the one used in first exercises) display an error message
103 on problem so that you don't need to know what an exception is.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>Mundo da ordenação </h1>
3 Este mundo fornece ferramentas para experimentar com algoritmos de
4 ordenação. Pode ser usado de duas formas diferentes: a primeira é
5 naturalmente para escrever os algoritmos de ordenação necessários. Mas
6 também é possível simplesmente usar o modo de demonstração de cada exercício
7 para observar o comportamento de algoritmos de ordenação. Isto ajuda a
8 entender as diferenças entre cada um deles.
9
10 <h2>Métodos disponíveis para algoritmos de ordenação</h2>
11 <table border=1>
12 <tr><td><b>Método</b></td><td><b>Ação</b></td><td><b>Custo</b></td></tr>
13 <tr><td>[!java|c]int [/!]getValueCount() [!scala]:Int[/!]</td>
14 <td>Retorna a quantidade de valores na array</td><td>nenhum</td></tr>
15
16 <tr><td>[!java]boolean [/!][!c]int [/!]éMenor([!java|c]int [/!]i[!scala]:Int[/!],
17 [!java|c]int [/!]j[!scala]:Int[/!]) [!scala]:Boolean[/!]</td>
18 <td>Retorna true se o conteúdo da célula i é estritamente menor que o da célula
19 j</td><td>duas leituras</td></tr>
20 <tr><td>[!java]boolean [/!][!c]int [/!]éMenorQue([!java|c]int [/!]i[!scala]:Int[/!],
21 [!java|c]int [/!]value[!scala]:Int[/!])[!scala] :Boolean[/!]</td>
22 <td>Retorna true se o conteúdo da célula i é estritamente menor que
23 <code>valor</code></td><td>uma leitura</td></tr>
24
25 <tr><td>[!java|c]void [/!]alternar([!java|c]int [/!]i[!scala]:Int[/!], [!java|c]int
26 [/!]j[!scala]:Int[/!])</td>
27 <td>Alterna ("swap") o conteúdo da célula i com o da célula j</td><td>duas escritas, duas leituras</td></tr>
28 <tr><td>[!java|c]void [/!]copia([!java|c]int [/!]de[!scala]:Int[/!], [!java|c]int
29 [/!]para[!scala]:Int[/!])</td>
30 <td>Copia o conteúdo da célula 'de' para a célula 'para'</td><td>uma leitura, uuma escrita</td></tr>
31
32 <tr><td>[!java|c]int [/!]getValor([!java|c]int [/!]idx[!scala]:Int[/!])</td>
33 <td>Retorna o valor da célula idx</td><td>uma leitura</td></tr>
34 <tr><td>[!java|c]void [/!]setValor([!java|c]int [/!]idx[!scala]:Int[/!],
35 [!java|c]int [/!]valor[!scala]:Int[/!])</td>
36 <td>Coloca na célula 'idx' o <code>valor</code> </td><td>uma escrita</td></tr>
37
38 <tr><td>[!java]boolean [/!][!c]int [/!]isSelected() [!scala]:Boolean[/!]</td>
39 <td>Retorna true se o mundo atual está selecionado na interface gráfica.</td><td>nenhum</td></tr>
40
41 </table>
42
43 <h2>Visão do histórico</h2>
44 <p>É suficiente ordenar a array para resolver os exercícios. A sua solução deve
45 seguir estritamente o comportamento esperado em cada exercício. Isto é
46 reforçado a verificar que o seu algoritmo precisa da mesma quantidade de
47 operações de leitura e escrita para ordenar a array. Quando estas
48 quantidades não coincidem, compreender a diferença entre o seu código e a
49 solução esperada pode se mostrar bem difícil.</p>
50
51 <p>Para ajudar neste processo, é possível explorar graficamente o histórico do
52 algoritmo de ordenação. Alternar à visão Objetivo e usar o menu de contexto
53 (clique com botão direito) para alternar da visão do estado atual à visão do
54 histórico.</p>
55
56 <p>A visão do histórico é um pouco bagunçada à primeira vista, mas na verdade é
57 bem simples: o tempo anda da esquerda para a direita neste gráfico e cada
58 linha é uma célula da sua array. As linhas curvas que navegam entre linhas
59 representam um certo valor de um dado. Quando duas linhas se cruzam,
60 significa que dois valores foram alternados agora; uma bifurcação numa linha
61 representa uma cópia de valor; quando um valor é magenta e seguido de uma
62 interrogação (?), foi lido a usar getValue(); Se o valor é vermelho e
63 seguido de uma exclamação (!), foi escrito com setValor().</p>
64
65 <p>Esta visão, inspirada por Aldo Cortesi, se mostra muito útil para entender o
66 comportamento interno de algoritmos de ordenação.</p>
0
1 <!-- Please don't translate this file but l10n/missions/plm.pot (see https://github.com/oster/PLM/wiki/Working-on-translations) -->
2 <h1>O universo das tartarugas</h1>
3
4 <p>Esta é uma adaptação do LOGO para o Programmer's Learning Machine.</p>
5
6 <p>É diretamente inspirado no trabalho do matemático Seymour Papert nos anos
7 60. Inspirado no psicólogo suíço Jean Piaget, apresentou um método de ensino
8 chamado LOGO para ensinar programação para crianças pequenas. O mundo é
9 cheio de tartarugas que deixam um rastro de tinta por onde passam e que
10 obedecem a comandos simples.</p>
11
12 <h2>Funções para mover a tartaruga</h2>
13
14 <pre>[!java|c]void [/!]avançar([!java|c]double [/!]passos[!scala]:Double[/!])
15 [!java|c]void [/!]recuar([!java|c]double [/!]passos[!scala]:Double[/!])</pre>
16 Move para frente e para trás na quantidade de passos pedidos.
17
18 <pre>[!java|c]void [/!]direita([!java|c]double [/!]ângulo[!scala]:Double[/!])
19 [!java|c]void [/!]esquerda([!java|c]double [/!]ângulo[!scala]:Double[/!])</pre>
20 Vira à esquerda ou à direita um dado ângulo (em graus).
21
22 <pre>[!java|c]double [/!]getX()[!scala]:Double[/!]
23 [!java|c]double [/!]getY()[!scala]:Double[/!]</pre>
24 Retorna a posição atual da tartaruga. Observe que o ponto (0,0) está no
25 canto superior esquerdo, como é comum na ciência da computação.
26
27 <pre>[!java|c]void [/!]setX([!java|c]double [/!]x[!scala]:Double[/!])
28 [!java|c]void [/!]setY([!java|c]double [/!]y[!scala]:Double[/!])
29 [!java|c]void [/!]setPos([!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double [/!]y[!scala]:Double[/!])</pre>
30 Teletransporta a tartaruga para uma nova posição (sem deixar rastros).
31
32 <pre>[!java|c]void [/!]moverPara([!java|c]double [/!]x[!scala]:Double[/!], [!java|c]double [/!]y[!scala]:Double[/!])</pre>
33 Move a tartaruga para uma nova posição.
34
35 <pre>[!java|c]void [/!]círculo([!java|c]double [/!]raio[!scala]:Double[/!])</pre>
36 Desenha um círculo de raio especificado com o centro na tartaruga.
37
38 <pre>[!java|c]void [/!]hide()</pre>
39 Esconde a tartaruga.
40
41 <pre>[!java|c]void [/!]show()</pre>
42 Mostra novamente a tartaruga.
43
44 <pre>[!java]boolean [/!][!c]int [/!]isVisible()[!scala]:Boolean[/!]</pre>
45 Retorna se a tartaruga é visível ou não.
46
47 <pre>[!java|c]void [/!]clear()</pre>
48 Remove todos os rastros do papel.
49
50 <pre>[!java|c]double [/!]getHeading()[!scala]:Double[/!]</pre>
51 Retorna a direção atual da tartaruga (em graus).
52
53 <pre>[!java|c]void [/!]setDireção([!java|c]double [/!]ângulo[!scala]:Double[/!])</pre>
54 Ajusta uma nova direção para a tartaruga (em graus).
55
56 <h2>Funções da caneta</h2>
57
58 <pre>[!java|c]void [/!]penUp()</pre>
59 Levanta a caneta (tartarugas têm canetas, não pinceis, como os buggles). A
60 tartaruga não vai deixar nenhum rastro durante os seus passos seguintes.
61
62 <pre>[!java|c]void [/!]penDown()</pre>
63 Abaixa a caneta. A tartaruga vai deixar um rastro nos próximos movimentos.
64
65 <pre>[!java]boolean [/!][!c]int [/!]isPenDown()[!scala]:Boolean[/!]</pre>
66 Retorna a posição atual da caneta como um booleano.
67
68 <pre>[!java|c]Color [/!]getColor()[!scala]:Color[/!]</pre>
69 Retorna a cor atual da caneta.
70
71 <pre>[!java|c]void [/!]setCor([!java|c]Cor [/!]cor[!scala]:Cor[/!])</pre>
72 Muda a cor da caneta.
73
74 <h2>Outras funções</h2>
75
76 <pre>[!java]boolean [/!][!c]int [/!]isSelected()[!scala]:Boolean[/!]</pre>
77 Retorna se a tartaruga atual está selecionada na interface gráfica.
78
79 <h2>Cores válidas</h2>
80 <table border=1>
81 <tr><td>Nome</td><td>Cor</td></tr>
82 <tr><td>[!scala|java|python]Cor.[/!]black</td> <td BGCOLOR="#000000">&nbsp;</td></tr>
83 <tr><td>[!scala|java|python]Cor.[/!]azul</td> <td BGCOLOR="#0000FF">&nbsp;</td></tr>
84 <tr><td>[!scala|java|python]Cor.[/!]ciano</td> <td BGCOLOR="#00FFFF">&nbsp;</td></tr>
85 <tr><td>[!scala|java|python]Cor.[/!]cinzentoEscuro</td> <td BGCOLOR="#404040">&nbsp;</td></tr>
86 <tr><td>[!scala|java|python]Cor.[/!]cinzento</td> <td BGCOLOR="#808080">&nbsp;</td></tr>
87 <tr><td>[!scala|java|python]Cor.[/!]verde</td> <td BGCOLOR="#00FF00">&nbsp;</td></tr>
88 <tr><td>[!scala|java|python]Cor.[/!]cinzentoClaro</td><td BGCOLOR="#C0C0C0">&nbsp;</td></tr>
89 <tr><td>[!scala|java|python]Cor.[/!]magenta</td> <td BGCOLOR="#FF00FF">&nbsp;</td></tr>
90 <tr><td>[!scala|java|python]Cor.[/!]laranja</td> <td BGCOLOR="#FFC800">&nbsp;</td></tr>
91 <tr><td>[!scala|java|python]Cor.[/!]rosa</td> <td BGCOLOR="#FFAFAF">&nbsp;</td></tr>
92 <tr><td>[!scala|java|python]Cor.[/!]vermelho</td> <td BGCOLOR="#FF0000">&nbsp;</td></tr>
93 <tr><td>[!scala|java|python]Cor.[/!]branco</td> <td BGCOLOR="#FFFFFF">&nbsp;</td></tr>
94 <tr><td>[!scala|java|python]Cor.[/!]amarelo</td> <td BGCOLOR="#FFFF00">&nbsp;</td></tr>
95 </table>
96