# How to use up method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

day2.js

Source:day2.js

`1/*2--- Day 2: Dive! ---3Now, you need to figure out how to pilot this thing.4It seems like the submarine can take a series of commands like forward 1, down 2, or up 3:5forward X increases the horizontal position by X units.6down X increases the depth by X units.7up X decreases the depth by X units.8Note that since you're on a submarine, down and up affect your depth, and so they have the opposite result of what you might expect.9The submarine seems to already have a planned course (your puzzle input). You should probably figure out where it's going. For example:10forward 511down 512forward 813up 314down 815forward 216Your horizontal position and depth both start at 0. The steps above would then modify them as follows:17forward 5 adds 5 to your horizontal position, a total of 5.18down 5 adds 5 to your depth, resulting in a value of 5.19forward 8 adds 8 to your horizontal position, a total of 13.20up 3 decreases your depth by 3, resulting in a value of 2.21down 8 adds 8 to your depth, resulting in a value of 10.22forward 2 adds 2 to your horizontal position, a total of 15.23After following these instructions, you would have a horizontal position of 15 and a depth of 10. (Multiplying these together produces 150.)24Calculate the horizontal position and depth you would have after following the planned course. What do you get if you multiply your final horizontal position by your final depth?25 */26const puzzleInput = `27forward 228down 729down 830forward 931down 832forward 933forward 834down 335forward 836forward 537up 238down 939down 440forward 441forward 342down 843down 944forward 545down 146up 147forward 448up 549forward 250down 651forward 952forward 353forward 754down 655down 156forward 857down 358forward 159up 660down 161down 262forward 963down 764down 165down 766down 767up 568down 869forward 670up 871up 272forward 673up 174down 975forward 876forward 477up 378forward 779down 280down 881forward 582down 983up 484forward 785forward 586down 587down 588forward 389forward 290down 291up 492up 793down 894up 895forward 196up 497forward 498down 299forward 5100forward 7101down 4102forward 8103down 2104forward 5105forward 9106forward 6107forward 5108down 5109forward 4110forward 3111down 7112down 8113forward 9114forward 7115down 3116down 6117forward 4118down 7119up 9120down 8121up 7122up 3123forward 6124forward 9125down 2126down 3127down 1128down 3129forward 8130forward 3131forward 9132down 5133up 1134up 2135down 9136up 9137down 5138down 9139forward 1140down 3141down 5142down 1143forward 7144down 6145forward 7146forward 4147up 2148up 1149forward 9150down 2151down 6152down 5153down 6154forward 8155down 5156forward 1157forward 2158down 7159down 5160down 7161up 9162down 9163up 4164down 7165up 8166down 9167forward 3168down 6169down 2170forward 9171down 4172up 7173forward 3174down 5175forward 8176forward 9177down 2178up 5179forward 2180forward 9181up 5182down 2183forward 8184forward 6185down 7186down 3187forward 4188forward 3189forward 9190up 4191up 4192forward 7193up 3194forward 6195down 7196up 8197forward 2198up 1199down 6200forward 4201up 6202up 6203up 3204forward 4205forward 2206forward 5207forward 8208down 9209down 4210down 3211down 1212down 6213down 4214down 5215down 7216down 5217up 4218forward 3219down 4220down 7221down 7222down 2223forward 2224forward 9225up 6226down 3227up 9228forward 8229down 9230up 2231up 2232up 2233up 1234down 6235forward 9236forward 2237forward 2238forward 2239forward 5240up 3241down 7242down 6243down 8244up 3245up 9246down 3247forward 1248forward 7249down 7250down 1251forward 3252down 7253down 9254down 7255down 3256up 2257down 6258up 6259down 1260up 2261forward 7262up 2263down 7264up 2265down 9266down 3267forward 6268down 5269down 1270forward 5271down 2272down 6273down 1274down 3275down 3276down 5277forward 2278forward 4279forward 8280forward 6281forward 4282forward 9283up 8284down 5285forward 1286down 1287forward 1288forward 6289up 1290down 6291down 3292forward 9293forward 5294forward 4295up 3296up 7297down 2298up 4299up 2300down 1301forward 6302forward 9303forward 4304forward 2305down 8306forward 4307forward 3308up 5309down 4310forward 3311down 8312down 5313down 5314forward 1315forward 6316forward 4317forward 5318forward 9319forward 5320down 4321forward 3322forward 8323down 8324down 1325up 4326down 4327up 7328forward 2329forward 6330down 3331down 5332down 5333down 8334up 3335down 2336forward 4337forward 2338forward 4339forward 9340up 2341down 7342up 7343down 2344forward 4345up 7346forward 4347down 2348forward 7349up 2350down 3351forward 5352down 7353down 2354up 2355up 1356up 7357up 9358down 3359forward 1360forward 3361down 2362down 3363forward 6364down 7365forward 9366down 9367forward 3368forward 2369down 1370up 9371down 4372forward 4373up 4374forward 7375up 3376down 4377down 9378down 3379forward 7380down 6381down 7382down 6383up 5384forward 3385forward 9386up 2387up 4388up 9389down 2390forward 5391up 1392down 7393down 5394up 2395forward 8396down 8397up 3398forward 4399down 9400forward 6401down 9402down 5403forward 6404down 8405up 6406down 3407forward 6408forward 3409down 3410down 5411down 7412down 1413down 5414down 7415down 5416forward 3417down 2418forward 4419up 4420up 1421up 7422forward 1423forward 5424down 4425down 8426down 3427forward 4428down 3429up 7430down 6431forward 9432up 8433forward 2434forward 5435down 6436up 4437forward 8438forward 5439down 6440forward 2441down 7442forward 3443forward 1444forward 6445down 9446up 6447down 4448down 2449up 8450forward 4451down 8452forward 8453up 9454forward 7455down 6456up 9457down 4458up 6459down 4460down 3461up 7462up 4463forward 5464up 9465down 9466up 6467down 3468forward 8469down 9470forward 7471up 3472up 9473forward 8474down 3475forward 3476forward 5477down 6478forward 3479down 4480up 6481forward 3482forward 7483down 1484down 6485down 4486forward 6487up 6488down 5489down 6490down 4491up 2492down 7493down 9494down 2495down 6496forward 3497forward 4498down 5499up 5500down 5501forward 3502forward 6503down 4504down 7505up 2506forward 7507down 7508up 6509up 3510forward 9511forward 8512up 6513forward 2514down 2515forward 8516forward 4517up 6518forward 6519down 8520up 3521up 5522forward 6523up 8524down 1525down 4526up 9527forward 6528up 5529down 6530down 8531down 9532forward 5533up 3534down 7535forward 3536forward 6537down 3538down 1539down 9540up 9541down 4542down 7543forward 2544forward 4545down 7546forward 7547up 5548down 9549up 7550down 4551forward 6552down 5553forward 4554up 8555down 4556down 7557forward 3558down 6559down 1560forward 3561down 4562up 6563up 5564up 7565forward 5566down 4567forward 7568up 1569down 4570forward 4571down 2572down 6573forward 1574up 3575up 8576forward 6577forward 6578down 5579forward 7580down 6581down 8582forward 6583down 6584forward 3585forward 5586down 9587down 5588up 4589down 5590down 1591forward 1592forward 5593down 2594forward 5595forward 2596forward 5597up 3598forward 5599up 8600forward 9601forward 3602down 2603up 2604forward 7605down 5606up 1607down 3608down 7609up 2610forward 8611forward 6612forward 1613forward 6614forward 6615down 5616forward 4617down 5618forward 9619forward 7620down 7621down 7622down 9623forward 4624down 4625forward 3626down 6627forward 5628down 9629forward 6630up 7631down 3632up 4633up 4634down 1635down 2636up 5637forward 6638forward 2639down 7640up 6641up 3642down 8643forward 1644down 3645up 9646down 2647forward 6648forward 1649forward 4650up 1651down 8652down 2653down 9654down 5655forward 3656down 1657down 6658down 5659down 3660forward 1661forward 9662up 2663down 3664down 3665down 9666down 7667forward 6668forward 8669forward 4670up 7671down 2672forward 3673forward 1674up 4675forward 8676up 9677forward 8678forward 2679down 5680forward 2681down 6682down 6683down 4684forward 8685down 6686forward 2687forward 8688down 7689down 6690forward 2691down 1692down 8693forward 2694forward 9695up 6696forward 6697down 3698down 2699up 5700up 6701down 6702up 7703forward 5704forward 7705down 1706forward 7707forward 9708down 3709forward 4710forward 5711down 1712up 3713forward 2714up 5715forward 2716forward 1717down 5718down 4719down 8720up 8721forward 3722down 3723forward 4724down 6725up 8726down 5727up 2728down 1729up 3730forward 8731up 6732forward 9733up 9734down 5735forward 2736forward 9737up 6738forward 1739down 2740forward 4741forward 4742forward 1743forward 5744forward 1745forward 4746down 5747down 1748down 2749down 2750forward 7751down 7752down 7753down 4754down 7755down 4756down 3757up 7758up 1759forward 2760forward 3761down 4762down 5763forward 9764up 7765forward 6766down 1767forward 6768forward 6769forward 8770down 3771forward 2772down 6773forward 9774up 6775up 6776forward 7777down 5778down 6779up 3780down 5781up 4782forward 3783down 7784forward 9785up 1786down 1787up 6788down 3789up 2790down 5791forward 3792forward 6793down 9794down 4795forward 7796down 1797up 1798forward 3799forward 5800up 7801down 3802up 9803up 9804down 4805up 4806forward 8807up 9808down 8809forward 6810forward 4811forward 9812forward 8813down 2814forward 3815forward 2816down 3817up 1818forward 6819down 3820down 7821down 3822down 5823down 9824up 9825forward 8826forward 6827down 8828forward 3829down 4830down 2831down 9832forward 4833forward 2834up 4835forward 1836up 8837up 1838down 4839up 2840down 1841up 7842down 2843down 4844up 4845forward 2846down 3847forward 2848forward 3849down 5850forward 9851forward 7852down 1853up 3854down 3855forward 3856down 6857forward 5858up 3859up 3860up 1861forward 7862forward 1863forward 2864forward 2865down 4866up 7867forward 1868forward 1869forward 6870down 8871up 8872down 8873down 4874down 6875forward 8876forward 4877forward 5878down 2879down 3880forward 7881down 6882forward 4883forward 1884up 7885up 5886up 2887forward 1888forward 8889forward 2890up 9891forward 4892forward 5893down 2894forward 5895forward 7896down 3897forward 1898down 3899up 5900up 2901up 2902up 2903forward 4904forward 4905forward 8906forward 2907down 3908up 7909down 4910down 2911down 7912forward 2913down 2914forward 7915up 9916up 7917forward 7918forward 7919down 3920down 4921up 4922down 2923down 8924forward 4925down 1926up 6927forward 4928down 2929up 8930down 1931down 8932down 6933up 9934forward 4935up 1936down 2937down 9938down 7939down 4940down 8941down 8942up 1943down 5944up 5945down 7946up 7947forward 5948down 3949forward 7950up 5951down 3952forward 9953up 5954down 7955forward 8956forward 8957down 2958forward 7959forward 8960down 4961up 7962down 2963up 7964forward 5965down 1966down 3967forward 9968up 4969forward 6970forward 4971down 5972down 7973forward 2974forward 4975down 2976forward 1977down 5978up 2979down 8980down 1981down 4982down 8983down 6984forward 9985forward 2986forward 6987forward 4988down 1989forward 8990up 4991forward 6992down 4993forward 4994forward 3995forward 6996forward 9997forward 8998down 1999forward 51000down 81001forward 71002up 11003down 31004up 61005forward 51006forward 81007forward 81008forward 51009forward 51010forward 11011up 91012forward 71013up 31014down 21015down 41016forward 61017up 21018forward 51019up 81020forward 81021forward 21022forward 61023forward 31024up 41025forward 31026forward 6`;1027// const directionVectors = {1028// forward:[1,0],1029// down:[0,1],1030// up: [0,-1],1031// };1032// const instructions = puzzleInput.split('\n');1033// let position = [0, 0];1034// instructions.forEach((ins) => {1035// const [direction, val] = ins.split(' ');1036// if (directionVectors[direction]) {1037// const vector = directionVectors[direction].map((num) => num * parseInt(val));1038// position = [position[0] + vector[0], position[1] + vector[1]]1039// }1040// });1041// console.log(position);1042// console.log('part 1 answer is', position[0] * position[1])1043/*1044--- Part Two ---1045Based on your calculations, the planned course doesn't seem to make any sense. You find the submarine manual and discover that the process is actually slightly more complicated.1046In addition to horizontal position and depth, you'll also need to track a third value, aim, which also starts at 0. The commands also mean something entirely different than you first thought:1047down X increases your aim by X units.1048up X decreases your aim by X units.1049forward X does two things:1050It increases your horizontal position by X units.1051It increases your depth by your aim multiplied by X.1052Again note that since you're on a submarine, down and up do the opposite of what you might expect: "down" means aiming in the positive direction.1053Now, the above example does something different:1054forward 5 adds 5 to your horizontal position, a total of 5. Because your aim is 0, your depth does not change.1055down 5 adds 5 to your aim, resulting in a value of 5.1056forward 8 adds 8 to your horizontal position, a total of 13. Because your aim is 5, your depth increases by 8*5=40.1057up 3 decreases your aim by 3, resulting in a value of 2.1058down 8 adds 8 to your aim, resulting in a value of 10.1059forward 2 adds 2 to your horizontal position, a total of 15. Because your aim is 10, your depth increases by 2*10=20 to a total of 60.1060After following these new instructions, you would have a horizontal position of 15 and a depth of 60. (Multiplying these produces 900.)1061Using this new interpretation of the commands, calculate the horizontal position and depth you would have after following the planned course. What do you get if you multiply your final horizontal position by your final depth?1062*/1063const getNewPosition = (position, direction, val) => {1064 if (direction === "down") {1065 position[2] += val;1066 } else if (direction === "up") {1067 position[2] -= val;1068 } else if (direction === "forward") {1069 position[0] += val;1070 position[1] = position[1] + position[2] * val;1071 }1072 return position;1073};1074const instructions = puzzleInput.split("\n");1075let position = [0, 0, 0];1076instructions.forEach((ins) => {1077 const [direction, val] = ins.split(" ");1078 if (direction) {1079 position = getNewPosition(position, direction, parseInt(val));1080 }1081});1082console.log("part 2 answer is", position[0] * position[1]);1083// part 2 test1084// const testInput = `forward 51085// down 51086// forward 81087// up 31088// down 81089// forward 2`;1090// const instructionsTest = testInput.split('\n');1091// let positionTest = [0, 0, 0];1092// instructionsTest.forEach((ins) => {1093// const [direction, val] = ins.split(' ');1094// if (direction) {1095// positionTest = getNewPosition(positionTest, direction, parseInt(val))1096// console.log({positionTest})1097// }1098// });1099// console.log(positionTest);...`

data.js

Source:data.js

`1const data = [2 "forward 4",3 "down 9",4 "forward 2",5 "forward 2",6 "down 7",7 "up 2",8 "down 9",9 "up 8",10 "down 7",11 "down 9",12 "forward 4",13 "up 6",14 "down 2",15 "down 5",16 "down 1",17 "down 5",18 "forward 2",19 "up 4",20 "forward 2",21 "forward 3",22 "up 2",23 "forward 6",24 "up 8",25 "forward 8",26 "down 8",27 "up 8",28 "down 7",29 "down 2",30 "down 9",31 "forward 2",32 "forward 9",33 "down 4",34 "forward 8",35 "up 6",36 "down 3",37 "up 9",38 "forward 1",39 "forward 6",40 "up 3",41 "forward 8",42 "up 9",43 "forward 1",44 "down 9",45 "down 3",46 "down 7",47 "up 2",48 "up 7",49 "down 5",50 "forward 3",51 "down 1",52 "up 6",53 "down 2",54 "forward 4",55 "down 6",56 "down 8",57 "forward 2",58 "down 5",59 "forward 6",60 "down 5",61 "down 7",62 "forward 8",63 "forward 2",64 "down 9",65 "up 4",66 "forward 6",67 "forward 4",68 "up 6",69 "down 9",70 "down 7",71 "down 9",72 "forward 9",73 "forward 8",74 "down 7",75 "up 7",76 "forward 9",77 "forward 8",78 "up 1",79 "up 4",80 "down 3",81 "forward 6",82 "up 6",83 "down 2",84 "up 3",85 "down 6",86 "down 5",87 "forward 8",88 "forward 3",89 "forward 8",90 "down 4",91 "down 4",92 "down 5",93 "forward 6",94 "down 5",95 "forward 6",96 "down 2",97 "down 5",98 "up 4",99 "down 8",100 "up 5",101 "forward 5",102 "forward 6",103 "down 9",104 "up 5",105 "down 2",106 "forward 5",107 "down 7",108 "up 7",109 "down 9",110 "forward 2",111 "down 3",112 "down 3",113 "forward 8",114 "up 5",115 "up 1",116 "forward 1",117 "forward 3",118 "down 5",119 "forward 8",120 "forward 7",121 "forward 8",122 "down 5",123 "down 8",124 "up 2",125 "forward 8",126 "forward 8",127 "down 7",128 "forward 1",129 "forward 7",130 "down 6",131 "up 4",132 "forward 7",133 "forward 7",134 "down 3",135 "up 7",136 "forward 2",137 "down 7",138 "down 4",139 "forward 5",140 "down 8",141 "forward 9",142 "down 7",143 "forward 5",144 "up 6",145 "up 6",146 "down 8",147 "down 3",148 "forward 5",149 "forward 3",150 "down 8",151 "up 7",152 "forward 8",153 "up 6",154 "down 2",155 "forward 4",156 "up 3",157 "up 3",158 "down 9",159 "down 9",160 "up 1",161 "up 7",162 "forward 2",163 "down 1",164 "forward 9",165 "up 7",166 "up 6",167 "down 2",168 "down 3",169 "forward 4",170 "down 3",171 "down 3",172 "down 1",173 "forward 4",174 "forward 8",175 "forward 6",176 "forward 3",177 "up 4",178 "up 5",179 "up 4",180 "forward 1",181 "up 3",182 "down 9",183 "up 6",184 "forward 2",185 "down 5",186 "down 1",187 "forward 8",188 "forward 2",189 "down 6",190 "up 5",191 "up 3",192 "forward 7",193 "forward 2",194 "forward 7",195 "up 9",196 "forward 3",197 "up 9",198 "forward 1",199 "down 9",200 "forward 9",201 "down 3",202 "down 3",203 "down 2",204 "forward 9",205 "forward 2",206 "up 3",207 "forward 3",208 "down 7",209 "down 3",210 "forward 2",211 "forward 1",212 "forward 6",213 "up 9",214 "forward 4",215 "down 9",216 "down 8",217 "up 3",218 "up 5",219 "forward 8",220 "down 9",221 "forward 5",222 "forward 4",223 "down 5",224 "up 4",225 "forward 7",226 "forward 3",227 "down 9",228 "forward 7",229 "down 2",230 "down 7",231 "forward 3",232 "up 3",233 "forward 7",234 "down 9",235 "down 4",236 "down 8",237 "forward 8",238 "down 6",239 "forward 9",240 "forward 4",241 "up 9",242 "down 9",243 "down 6",244 "up 7",245 "up 2",246 "forward 2",247 "forward 7",248 "down 7",249 "forward 9",250 "down 6",251 "down 2",252 "forward 4",253 "forward 8",254 "down 4",255 "forward 4",256 "forward 4",257 "forward 6",258 "up 6",259 "down 9",260 "down 3",261 "down 7",262 "up 2",263 "up 2",264 "forward 4",265 "down 4",266 "forward 6",267 "down 2",268 "down 2",269 "forward 1",270 "down 1",271 "forward 7",272 "up 5",273 "forward 9",274 "forward 8",275 "down 4",276 "forward 8",277 "down 5",278 "up 4",279 "down 8",280 "forward 4",281 "forward 7",282 "down 9",283 "down 3",284 "forward 6",285 "down 6",286 "forward 6",287 "down 9",288 "down 6",289 "forward 5",290 "forward 5",291 "up 9",292 "down 9",293 "down 9",294 "down 1",295 "down 5",296 "forward 5",297 "down 7",298 "forward 3",299 "down 6",300 "forward 5",301 "forward 8",302 "down 6",303 "forward 7",304 "down 5",305 "forward 4",306 "down 4",307 "down 9",308 "forward 3",309 "down 9",310 "down 9",311 "down 1",312 "up 7",313 "forward 4",314 "up 1",315 "up 1",316 "forward 1",317 "down 9",318 "up 8",319 "down 8",320 "down 3",321 "down 7",322 "forward 4",323 "down 5",324 "down 5",325 "forward 7",326 "forward 7",327 "forward 6",328 "up 2",329 "down 4",330 "forward 8",331 "forward 3",332 "forward 3",333 "forward 2",334 "forward 4",335 "up 9",336 "up 1",337 "forward 2",338 "forward 2",339 "forward 6",340 "down 9",341 "up 8",342 "forward 4",343 "forward 5",344 "forward 4",345 "down 4",346 "down 8",347 "forward 6",348 "down 8",349 "forward 9",350 "forward 8",351 "down 1",352 "down 2",353 "forward 2",354 "up 4",355 "up 7",356 "forward 5",357 "down 7",358 "down 5",359 "down 3",360 "up 7",361 "down 4",362 "forward 8",363 "up 8",364 "down 1",365 "down 2",366 "up 6",367 "up 8",368 "forward 9",369 "down 5",370 "down 2",371 "forward 5",372 "forward 4",373 "up 6",374 "forward 7",375 "down 3",376 "up 5",377 "up 9",378 "forward 5",379 "forward 1",380 "down 6",381 "down 7",382 "forward 9",383 "down 8",384 "down 2",385 "forward 9",386 "forward 2",387 "down 3",388 "forward 9",389 "down 3",390 "down 9",391 "up 3",392 "forward 7",393 "up 2",394 "up 5",395 "forward 3",396 "down 9",397 "up 1",398 "down 2",399 "down 4",400 "down 6",401 "forward 5",402 "forward 5",403 "up 7",404 "up 3",405 "down 1",406 "down 1",407 "up 8",408 "down 4",409 "forward 1",410 "down 4",411 "down 5",412 "down 9",413 "forward 7",414 "up 2",415 "up 1",416 "down 7",417 "forward 9",418 "forward 9",419 "forward 8",420 "forward 9",421 "down 5",422 "forward 9",423 "forward 9",424 "up 9",425 "down 7",426 "down 8",427 "forward 2",428 "forward 9",429 "down 1",430 "forward 3",431 "forward 8",432 "up 4",433 "down 4",434 "forward 4",435 "forward 3",436 "down 7",437 "down 3",438 "forward 6",439 "forward 9",440 "forward 1",441 "down 2",442 "up 3",443 "down 9",444 "forward 5",445 "forward 6",446 "forward 8",447 "up 2",448 "up 1",449 "down 3",450 "up 4",451 "forward 1",452 "up 9",453 "forward 4",454 "down 1",455 "up 2",456 "down 8",457 "down 9",458 "forward 3",459 "down 2",460 "up 5",461 "forward 2",462 "down 6",463 "down 5",464 "down 8",465 "down 3",466 "down 7",467 "down 2",468 "forward 8",469 "down 9",470 "up 7",471 "down 7",472 "down 7",473 "down 7",474 "forward 4",475 "forward 1",476 "forward 9",477 "up 9",478 "forward 5",479 "forward 8",480 "forward 7",481 "forward 7",482 "down 1",483 "forward 3",484 "down 7",485 "forward 2",486 "forward 4",487 "up 7",488 "forward 1",489 "down 5",490 "forward 5",491 "forward 1",492 "down 8",493 "forward 7",494 "forward 2",495 "up 3",496 "down 1",497 "up 7",498 "down 1",499 "down 2",500 "forward 9",501 "forward 6",502 "forward 3",503 "forward 2",504 "down 4",505 "forward 7",506 "forward 7",507 "forward 5",508 "forward 7",509 "forward 2",510 "down 9",511 "down 8",512 "forward 8",513 "forward 9",514 "down 3",515 "up 7",516 "up 1",517 "down 4",518 "forward 2",519 "forward 7",520 "forward 3",521 "forward 9",522 "up 2",523 "down 3",524 "forward 4",525 "down 8",526 "down 6",527 "down 4",528 "down 6",529 "down 7",530 "forward 9",531 "down 9",532 "forward 8",533 "down 1",534 "down 1",535 "forward 1",536 "forward 1",537 "down 7",538 "down 3",539 "down 3",540 "forward 2",541 "down 7",542 "forward 8",543 "up 7",544 "down 5",545 "forward 7",546 "forward 9",547 "down 2",548 "forward 9",549 "forward 3",550 "forward 9",551 "forward 9",552 "down 3",553 "forward 1",554 "forward 7",555 "up 8",556 "forward 7",557 "forward 4",558 "forward 5",559 "forward 6",560 "down 4",561 "up 3",562 "down 5",563 "up 8",564 "up 5",565 "up 6",566 "forward 1",567 "down 1",568 "up 8",569 "down 8",570 "down 5",571 "forward 8",572 "up 9",573 "down 8",574 "forward 2",575 "up 6",576 "forward 3",577 "down 3",578 "down 8",579 "down 4",580 "forward 6",581 "forward 2",582 "down 9",583 "up 9",584 "down 2",585 "down 9",586 "up 1",587 "down 6",588 "up 2",589 "down 9",590 "forward 8",591 "forward 3",592 "forward 6",593 "down 6",594 "up 9",595 "up 8",596 "forward 4",597 "down 2",598 "forward 5",599 "up 4",600 "up 4",601 "down 5",602 "down 9",603 "forward 3",604 "down 1",605 "forward 1",606 "forward 6",607 "forward 2",608 "down 7",609 "forward 7",610 "up 5",611 "forward 2",612 "down 8",613 "forward 5",614 "down 1",615 "down 7",616 "forward 7",617 "down 4",618 "forward 7",619 "forward 2",620 "down 6",621 "forward 9",622 "forward 4",623 "up 3",624 "forward 8",625 "forward 2",626 "up 6",627 "up 3",628 "forward 9",629 "forward 4",630 "down 2",631 "forward 6",632 "down 1",633 "forward 5",634 "down 2",635 "up 1",636 "down 1",637 "forward 2",638 "forward 4",639 "down 7",640 "up 6",641 "forward 4",642 "forward 7",643 "up 8",644 "forward 3",645 "down 8",646 "forward 7",647 "down 2",648 "down 5",649 "forward 3",650 "forward 7",651 "down 5",652 "forward 2",653 "forward 8",654 "up 6",655 "forward 8",656 "down 7",657 "up 3",658 "down 2",659 "forward 2",660 "down 8",661 "down 2",662 "up 5",663 "up 1",664 "forward 6",665 "down 1",666 "forward 2",667 "down 1",668 "forward 6",669 "forward 9",670 "down 9",671 "down 8",672 "down 3",673 "forward 5",674 "forward 3",675 "down 3",676 "down 1",677 "forward 4",678 "forward 8",679 "forward 2",680 "down 7",681 "forward 9",682 "forward 4",683 "down 4",684 "forward 6",685 "down 4",686 "forward 8",687 "down 8",688 "down 2",689 "up 7",690 "down 9",691 "down 5",692 "up 4",693 "down 3",694 "up 5",695 "forward 8",696 "down 4",697 "down 6",698 "forward 1",699 "up 2",700 "down 6",701 "forward 4",702 "down 8",703 "forward 1",704 "up 7",705 "forward 6",706 "up 2",707 "forward 1",708 "down 8",709 "down 2",710 "forward 3",711 "down 3",712 "down 2",713 "up 9",714 "down 3",715 "down 4",716 "down 3",717 "forward 9",718 "down 6",719 "forward 8",720 "forward 8",721 "down 1",722 "forward 8",723 "down 5",724 "up 9",725 "up 5",726 "up 5",727 "forward 5",728 "forward 4",729 "down 7",730 "down 6",731 "forward 9",732 "up 4",733 "forward 7",734 "up 5",735 "forward 7",736 "down 5",737 "down 3",738 "forward 5",739 "down 8",740 "up 3",741 "forward 4",742 "up 2",743 "down 1",744 "down 6",745 "down 6",746 "up 3",747 "forward 5",748 "forward 8",749 "down 2",750 "forward 6",751 "down 5",752 "down 4",753 "forward 9",754 "down 6",755 "forward 6",756 "up 5",757 "forward 4",758 "forward 5",759 "forward 1",760 "up 6",761 "up 2",762 "down 8",763 "up 4",764 "up 2",765 "down 3",766 "forward 4",767 "down 5",768 "forward 8",769 "up 5",770 "forward 6",771 "forward 9",772 "down 6",773 "down 3",774 "up 3",775 "down 2",776 "up 9",777 "forward 5",778 "up 5",779 "forward 3",780 "forward 2",781 "down 5",782 "up 2",783 "down 5",784 "forward 8",785 "forward 2",786 "down 1",787 "up 2",788 "down 6",789 "up 8",790 "down 3",791 "down 2",792 "forward 2",793 "down 1",794 "forward 8",795 "forward 2",796 "up 6",797 "forward 6",798 "up 3",799 "up 8",800 "up 2",801 "up 4",802 "down 7",803 "forward 6",804 "down 3",805 "down 2",806 "forward 5",807 "down 7",808 "down 6",809 "forward 1",810 "down 4",811 "forward 4",812 "up 1",813 "down 3",814 "up 3",815 "down 4",816 "forward 1",817 "down 2",818 "forward 6",819 "down 7",820 "forward 3",821 "forward 1",822 "forward 5",823 "down 7",824 "down 9",825 "forward 7",826 "forward 2",827 "forward 7",828 "forward 8",829 "down 1",830 "down 1",831 "up 6",832 "forward 2",833 "up 7",834 "down 9",835 "up 4",836 "up 9",837 "forward 9",838 "forward 6",839 "down 3",840 "down 9",841 "forward 1",842 "forward 1",843 "up 8",844 "forward 6",845 "forward 1",846 "forward 9",847 "down 2",848 "down 1",849 "forward 2",850 "forward 9",851 "down 9",852 "down 6",853 "forward 5",854 "down 6",855 "forward 4",856 "down 3",857 "forward 1",858 "down 4",859 "up 5",860 "forward 6",861 "forward 3",862 "down 2",863 "up 3",864 "down 9",865 "down 2",866 "forward 1",867 "down 4",868 "up 2",869 "down 6",870 "forward 6",871 "forward 7",872 "forward 3",873 "forward 9",874 "up 7",875 "up 2",876 "forward 2",877 "up 2",878 "forward 1",879 "up 2",880 "forward 8",881 "forward 5",882 "down 6",883 "up 7",884 "down 4",885 "down 1",886 "up 8",887 "forward 1",888 "down 3",889 "up 8",890 "forward 8",891 "down 6",892 "down 1",893 "down 6",894 "forward 1",895 "forward 7",896 "up 3",897 "forward 6",898 "forward 1",899 "up 3",900 "down 5",901 "down 1",902 "forward 5",903 "down 5",904 "up 7",905 "up 3",906 "down 6",907 "forward 6",908 "up 7",909 "forward 5",910 "forward 2",911 "forward 1",912 "down 8",913 "forward 3",914 "down 3",915 "forward 5",916 "down 4",917 "up 4",918 "down 8",919 "down 7",920 "down 7",921 "up 9",922 "up 2",923 "down 4",924 "down 1",925 "down 4",926 "forward 9",927 "up 8",928 "up 4",929 "down 2",930 "forward 8",931 "forward 1",932 "down 2",933 "up 5",934 "down 3",935 "down 8",936 "down 8",937 "down 6",938 "down 5",939 "forward 7",940 "down 3",941 "forward 5",942 "down 6",943 "down 9",944 "down 2",945 "forward 8",946 "down 4",947 "up 2",948 "forward 4",949 "down 8",950 "down 5",951 "down 4",952 "forward 2",953 "up 3",954 "forward 4",955 "up 3",956 "down 8",957 "down 2",958 "up 8",959 "forward 4",960 "forward 6",961 "down 3",962 "forward 9",963 "forward 6",964 "forward 8",965 "forward 5",966 "forward 1",967 "forward 5",968 "down 3",969 "up 2",970 "forward 4",971 "down 4",972 "down 3",973 "forward 1",974 "forward 3",975 "forward 7",976 "forward 9",977 "down 2",978 "up 4",979 "down 3",980 "up 8",981 "forward 9",982 "down 5",983 "up 9",984 "down 1",985 "up 4",986 "forward 7",987 "forward 2",988 "forward 4",989 "up 8",990 "down 4",991 "down 1",992 "forward 8",993 "down 4",994 "down 7",995 "up 1",996 "down 3",997 "down 2",998 "forward 5",999 "up 6",1000 "down 7",1001 "forward 2",...`

input.js

Source:input.js

`1const inputData = ['forward 9',2'down 3',3'down 8',4'forward 2',5'up 3',6'forward 5',7'up 8',8'down 2',9'down 5',10'up 7',11'down 9',12'forward 4',13'up 5',14'down 9',15'forward 2',16'forward 2',17'forward 8',18'down 6',19'forward 2',20'up 9',21'up 5',22'down 2',23'forward 5',24'down 8',25'forward 3',26'up 4',27'forward 5',28'forward 7',29'down 8',30'down 6',31'up 7',32'down 3',33'forward 4',34'up 8',35'down 5',36'down 3',37'down 6',38'down 8',39'forward 1',40'forward 9',41'forward 4',42'up 7',43'down 4',44'forward 7',45'forward 3',46'forward 9',47'down 1',48'down 3',49'up 9',50'down 3',51'forward 9',52'up 6',53'up 9',54'down 8',55'up 3',56'down 1',57'up 8',58'down 8',59'down 2',60'down 4',61'down 4',62'up 3',63'down 6',64'down 1',65'down 3',66'forward 1',67'up 5',68'forward 5',69'forward 8',70'down 2',71'forward 6',72'forward 2',73'up 7',74'forward 6',75'down 8',76'forward 6',77'forward 5',78'up 9',79'forward 5',80'up 5',81'forward 9',82'down 2',83'down 4',84'down 3',85'down 8',86'forward 9',87'forward 6',88'forward 2',89'up 7',90'down 7',91'up 3',92'forward 4',93'forward 5',94'down 7',95'forward 5',96'up 9',97'forward 6',98'forward 6',99'forward 1',100'down 6',101'forward 9',102'up 2',103'down 7',104'down 8',105'down 6',106'up 5',107'down 8',108'down 8',109'forward 7',110'down 6',111'up 5',112'down 9',113'down 3',114'forward 2',115'down 4',116'forward 8',117'down 5',118'up 5',119'forward 7',120'up 2',121'up 2',122'down 4',123'forward 4',124'down 5',125'up 8',126'down 2',127'forward 4',128'down 9',129'forward 8',130'down 5',131'down 6',132'down 7',133'up 7',134'up 5',135'up 7',136'forward 7',137'forward 8',138'down 2',139'forward 3',140'down 2',141'down 7',142'down 4',143'down 2',144'forward 3',145'forward 5',146'down 3',147'down 7',148'up 7',149'down 7',150'up 5',151'forward 1',152'down 8',153'down 2',154'up 4',155'up 5',156'down 8',157'forward 9',158'down 3',159'down 9',160'forward 8',161'forward 1',162'forward 1',163'down 2',164'up 9',165'down 2',166'up 8',167'down 6',168'up 8',169'forward 7',170'down 5',171'forward 7',172'down 8',173'forward 8',174'down 7',175'up 9',176'up 2',177'up 6',178'down 5',179'down 9',180'forward 2',181'up 3',182'down 4',183'up 5',184'up 4',185'down 9',186'forward 7',187'forward 7',188'down 3',189'forward 4',190'forward 9',191'up 8',192'forward 3',193'down 1',194'forward 2',195'down 7',196'down 3',197'down 7',198'down 7',199'forward 8',200'forward 4',201'forward 7',202'up 1',203'down 4',204'up 9',205'down 2',206'down 1',207'forward 6',208'down 3',209'forward 7',210'forward 8',211'up 9',212'up 2',213'up 2',214'forward 7',215'up 2',216'up 5',217'forward 5',218'down 3',219'forward 8',220'forward 1',221'up 4',222'down 6',223'down 5',224'forward 4',225'up 9',226'forward 8',227'up 4',228'down 8',229'down 3',230'down 3',231'down 7',232'forward 2',233'forward 4',234'down 9',235'down 7',236'down 2',237'up 3',238'up 3',239'forward 8',240'forward 7',241'forward 8',242'down 5',243'up 5',244'forward 3',245'forward 6',246'up 7',247'up 1',248'forward 2',249'forward 5',250'down 5',251'forward 8',252'down 2',253'down 4',254'forward 2',255'down 7',256'down 3',257'down 5',258'forward 9',259'down 7',260'down 8',261'up 1',262'up 2',263'down 8',264'forward 7',265'forward 8',266'down 8',267'forward 5',268'up 7',269'forward 3',270'up 2',271'down 7',272'forward 1',273'down 2',274'up 7',275'up 4',276'down 2',277'forward 1',278'up 5',279'forward 2',280'up 2',281'forward 3',282'forward 9',283'forward 2',284'forward 8',285'forward 2',286'up 7',287'down 8',288'down 7',289'forward 2',290'forward 7',291'down 1',292'forward 2',293'up 1',294'up 6',295'down 3',296'down 6',297'forward 7',298'down 4',299'forward 5',300'forward 6',301'up 3',302'forward 3',303'down 6',304'forward 8',305'up 8',306'forward 4',307'down 3',308'forward 3',309'down 4',310'down 7',311'forward 9',312'forward 2',313'up 2',314'forward 8',315'down 6',316'forward 6',317'down 9',318'down 9',319'forward 8',320'down 1',321'forward 9',322'down 1',323'down 6',324'down 8',325'down 5',326'down 5',327'forward 3',328'forward 3',329'down 2',330'down 5',331'forward 9',332'down 2',333'down 8',334'down 3',335'forward 9',336'up 2',337'down 4',338'down 9',339'forward 9',340'forward 1',341'forward 5',342'up 9',343'down 1',344'down 6',345'forward 6',346'forward 5',347'forward 8',348'down 2',349'forward 8',350'down 4',351'down 2',352'down 6',353'down 6',354'up 3',355'up 8',356'forward 1',357'down 1',358'up 8',359'down 3',360'down 4',361'up 9',362'up 1',363'down 7',364'down 7',365'up 1',366'up 2',367'forward 5',368'up 8',369'forward 2',370'down 3',371'forward 1',372'up 5',373'forward 6',374'forward 2',375'down 6',376'up 2',377'forward 2',378'forward 1',379'down 3',380'forward 4',381'up 8',382'forward 5',383'down 4',384'forward 2',385'down 8',386'down 7',387'up 7',388'down 8',389'forward 1',390'down 4',391'up 9',392'down 6',393'up 6',394'up 6',395'down 2',396'forward 1',397'forward 8',398'down 6',399'up 3',400'down 7',401'forward 9',402'up 1',403'up 4',404'forward 7',405'down 7',406'forward 1',407'down 6',408'down 4',409'down 7',410'down 8',411'down 8',412'forward 4',413'down 6',414'down 6',415'down 5',416'forward 6',417'up 9',418'up 3',419'down 4',420'forward 8',421'down 7',422'forward 6',423'up 3',424'forward 1',425'forward 1',426'down 8',427'forward 7',428'forward 4',429'forward 6',430'up 1',431'forward 7',432'up 8',433'forward 2',434'forward 6',435'forward 8',436'down 9',437'down 8',438'up 9',439'up 4',440'up 2',441'forward 2',442'forward 8',443'up 2',444'forward 3',445'forward 2',446'up 2',447'up 5',448'up 8',449'forward 4',450'forward 8',451'forward 3',452'up 5',453'down 1',454'forward 2',455'down 7',456'down 8',457'forward 3',458'up 1',459'forward 5',460'forward 7',461'forward 9',462'up 7',463'forward 4',464'down 4',465'up 2',466'forward 4',467'forward 5',468'forward 3',469'up 9',470'forward 6',471'forward 8',472'down 9',473'down 1',474'forward 1',475'down 5',476'down 2',477'forward 9',478'down 2',479'up 9',480'down 1',481'forward 5',482'forward 8',483'up 2',484'forward 6',485'down 4',486'down 9',487'forward 4',488'forward 1',489'down 3',490'down 3',491'up 5',492'forward 5',493'down 6',494'forward 3',495'down 2',496'forward 8',497'down 7',498'down 2',499'down 1',500'forward 2',501'up 5',502'forward 9',503'forward 3',504'forward 5',505'down 4',506'up 7',507'forward 6',508'down 3',509'forward 1',510'forward 7',511'forward 1',512'up 4',513'down 2',514'down 7',515'up 9',516'forward 9',517'down 8',518'down 1',519'up 2',520'down 3',521'forward 7',522'down 8',523'down 5',524'down 5',525'up 8',526'forward 1',527'down 5',528'forward 8',529'up 7',530'down 1',531'forward 9',532'down 4',533'forward 8',534'forward 5',535'forward 7',536'forward 8',537'forward 3',538'up 9',539'forward 3',540'down 7',541'down 5',542'up 8',543'forward 3',544'up 6',545'forward 8',546'up 3',547'down 5',548'forward 5',549'forward 6',550'forward 4',551'forward 3',552'forward 8',553'up 9',554'forward 2',555'down 6',556'down 4',557'down 5',558'forward 7',559'down 2',560'up 5',561'forward 2',562'forward 5',563'down 9',564'forward 8',565'down 8',566'forward 6',567'down 9',568'down 7',569'up 9',570'forward 3',571'forward 3',572'up 5',573'down 2',574'forward 5',575'down 6',576'down 6',577'down 2',578'down 3',579'down 4',580'forward 7',581'up 1',582'down 7',583'forward 7',584'up 1',585'forward 3',586'up 6',587'down 7',588'down 5',589'forward 9',590'forward 2',591'down 5',592'forward 9',593'down 5',594'forward 9',595'forward 1',596'down 4',597'forward 9',598'down 5',599'forward 8',600'down 6',601'down 4',602'down 5',603'forward 9',604'down 1',605'forward 6',606'forward 9',607'down 1',608'down 1',609'up 2',610'forward 5',611'forward 3',612'down 4',613'up 8',614'forward 8',615'down 2',616'forward 3',617'forward 1',618'down 7',619'forward 6',620'forward 5',621'up 7',622'up 8',623'down 5',624'up 3',625'down 8',626'forward 6',627'forward 5',628'forward 6',629'up 1',630'up 8',631'up 7',632'down 5',633'forward 3',634'forward 9',635'up 9',636'up 4',637'up 7',638'up 8',639'forward 7',640'forward 3',641'forward 9',642'down 7',643'forward 3',644'down 6',645'forward 9',646'down 1',647'forward 3',648'down 1',649'forward 8',650'forward 7',651'down 2',652'forward 1',653'forward 6',654'forward 7',655'down 3',656'down 2',657'down 1',658'forward 7',659'forward 4',660'down 6',661'up 4',662'forward 4',663'forward 9',664'forward 3',665'down 1',666'up 2',667'down 3',668'down 5',669'forward 7',670'forward 5',671'up 1',672'down 2',673'down 3',674'down 8',675'forward 1',676'down 4',677'forward 5',678'down 5',679'up 6',680'down 6',681'down 8',682'forward 1',683'forward 9',684'up 5',685'forward 2',686'down 9',687'down 5',688'down 1',689'down 4',690'down 9',691'down 8',692'forward 2',693'forward 4',694'up 2',695'forward 3',696'down 8',697'down 5',698'up 5',699'forward 8',700'up 2',701'down 8',702'up 3',703'forward 7',704'down 7',705'forward 8',706'down 7',707'down 3',708'up 6',709'forward 5',710'up 4',711'up 5',712'forward 9',713'forward 6',714'down 9',715'forward 5',716'down 5',717'down 3',718'forward 2',719'down 1',720'up 9',721'up 8',722'down 6',723'down 1',724'forward 9',725'forward 4',726'forward 2',727'up 1',728'forward 5',729'forward 9',730'up 5',731'forward 8',732'forward 4',733'down 4',734'down 4',735'down 2',736'forward 1',737'forward 7',738'down 9',739'forward 4',740'down 5',741'down 4',742'down 7',743'down 2',744'forward 9',745'down 3',746'forward 6',747'forward 3',748'down 9',749'down 3',750'down 4',751'down 9',752'down 9',753'up 6',754'down 5',755'up 4',756'down 1',757'down 1',758'forward 9',759'forward 7',760'down 9',761'forward 4',762'down 8',763'down 7',764'forward 7',765'forward 4',766'up 2',767'up 5',768'forward 2',769'forward 7',770'down 1',771'forward 6',772'forward 6',773'forward 3',774'forward 8',775'down 2',776'up 2',777'forward 7',778'up 5',779'down 1',780'down 5',781'forward 8',782'down 6',783'forward 8',784'down 5',785'down 4',786'down 6',787'forward 5',788'down 1',789'forward 9',790'forward 8',791'up 5',792'down 6',793'forward 5',794'up 5',795'down 4',796'forward 1',797'down 2',798'down 5',799'down 3',800'forward 2',801'down 9',802'forward 1',803'forward 1',804'forward 1',805'forward 8',806'forward 2',807'down 8',808'down 6',809'up 1',810'forward 6',811'down 3',812'down 4',813'up 9',814'down 3',815'down 3',816'up 7',817'down 4',818'forward 4',819'forward 9',820'down 3',821'down 8',822'forward 5',823'down 3',824'down 6',825'down 7',826'forward 1',827'up 2',828'forward 8',829'down 1',830'down 4',831'up 9',832'forward 9',833'up 4',834'up 2',835'forward 3',836'forward 4',837'down 2',838'down 2',839'down 6',840'forward 6',841'forward 8',842'down 6',843'up 6',844'down 5',845'forward 1',846'down 4',847'up 9',848'forward 1',849'forward 3',850'down 1',851'down 4',852'up 6',853'forward 5',854'forward 6',855'up 9',856'up 9',857'down 2',858'up 6',859'forward 1',860'forward 2',861'forward 3',862'forward 3',863'forward 6',864'up 2',865'down 8',866'down 9',867'forward 7',868'up 1',869'up 3',870'down 2',871'forward 3',872'down 8',873'forward 9',874'down 3',875'forward 6',876'up 2',877'forward 7',878'down 2',879'forward 5',880'down 4',881'down 2',882'up 8',883'forward 3',884'forward 5',885'forward 9',886'forward 5',887'forward 3',888'up 9',889'down 7',890'forward 4',891'forward 2',892'forward 7',893'down 5',894'up 6',895'up 6',896'forward 8',897'down 2',898'forward 1',899'up 1',900'up 9',901'up 8',902'up 3',903'up 4',904'down 2',905'up 7',906'down 4',907'up 5',908'down 1',909'up 9',910'down 5',911'down 9',912'down 4',913'up 2',914'down 8',915'up 2',916'up 7',917'up 9',918'forward 4',919'forward 2',920'forward 1',921'forward 6',922'forward 8',923'up 5',924'forward 5',925'forward 5',926'down 4',927'up 6',928'forward 3',929'down 9',930'down 7',931'forward 4',932'down 3',933'up 1',934'forward 4',935'down 2',936'down 6',937'up 3',938'up 1',939'down 9',940'down 7',941'down 9',942'forward 3',943'forward 8',944'down 8',945'up 7',946'up 6',947'down 2',948'down 9',949'down 1',950'down 9',951'forward 6',952'up 4',953'down 3',954'forward 5',955'up 3',956'up 9',957'up 8',958'forward 6',959'down 8',960'forward 6',961'forward 6',962'forward 5',963'up 4',964'down 4',965'up 6',966'up 4',967'forward 2',968'down 5',969'forward 9',970'up 7',971'up 6',972'down 4',973'forward 7',974'forward 6',975'up 2',976'down 8',977'down 6',978'forward 5',979'up 2',980'forward 5',981'forward 1',982'up 9',983'down 8',984'forward 7',985'up 4',986'forward 8',987'down 4',988'forward 3',989'forward 3',990'down 9',991'forward 4',992'forward 9',993'up 8',994'forward 7',995'forward 3',996'forward 9',997'forward 4',998'up 3',999'forward 2',...`

part2.solution.js

Source:part2.solution.js

`1import calculateFinalPositionWithAim from "./part2.js";2console.log(3 calculateFinalPositionWithAim(`forward 84forward 35down 86forward 47down 28down 49down 810down 411down 712up 413down 614down 215forward 716down 517down 718down 519forward 820forward 421forward 322down 423forward 224up 325up 626forward 727down 428down 229forward 730up 331forward 832down 433down 634forward 335forward 936down 937down 638forward 839up 840forward 341down 842down 443forward 744forward 345up 946down 847forward 748forward 549forward 350down 151down 452forward 153down 654forward 955up 256forward 357down 258down 159up 560down 861down 762down 563down 964up 765forward 466down 967down 868down 469forward 370down 171up 872down 173down 874forward 475up 176forward 777down 678down 279forward 380down 981forward 982forward 483down 184up 685down 186up 287down 488down 989down 790forward 591down 392up 993forward 494up 595down 996forward 197forward 798forward 199down 8100forward 5101down 2102down 4103down 3104forward 4105down 9106up 7107up 1108forward 4109up 2110forward 4111forward 4112down 1113down 5114forward 6115forward 1116down 6117forward 8118forward 8119forward 6120down 3121forward 3122forward 1123forward 5124forward 7125down 5126forward 8127down 7128down 8129forward 7130forward 8131down 7132forward 7133up 2134up 9135down 1136forward 1137forward 6138up 3139up 6140down 2141down 4142forward 2143up 8144forward 5145up 9146up 5147down 2148forward 5149forward 9150up 3151forward 7152down 4153down 3154down 2155forward 9156up 4157down 7158down 1159forward 9160forward 3161up 4162forward 1163up 6164forward 5165forward 2166forward 2167down 9168forward 1169up 7170forward 3171down 1172down 5173up 8174down 5175forward 5176forward 5177down 9178up 5179forward 8180up 9181down 1182forward 1183down 7184up 3185down 9186down 9187down 5188up 6189forward 7190down 5191down 2192down 5193forward 3194forward 2195forward 9196forward 5197forward 6198up 7199up 7200forward 4201forward 2202up 4203up 6204down 8205up 9206up 5207down 8208forward 4209up 9210forward 8211forward 3212down 6213down 6214down 7215down 6216forward 7217up 5218down 2219down 5220forward 2221up 5222forward 7223down 5224up 4225up 2226forward 2227forward 9228forward 5229forward 8230up 4231forward 6232up 7233forward 5234down 2235down 3236down 8237up 2238down 2239up 1240up 7241down 1242down 6243down 9244down 7245forward 8246up 8247up 9248down 9249forward 6250forward 6251down 6252forward 3253forward 4254forward 6255forward 7256down 5257down 8258forward 7259forward 9260down 4261up 9262forward 8263down 6264down 1265down 2266forward 4267down 5268up 1269forward 1270down 6271forward 4272forward 2273forward 6274down 8275up 2276up 8277forward 3278down 6279forward 7280down 1281forward 1282forward 8283down 8284down 8285down 2286forward 8287down 4288up 8289down 6290forward 2291down 5292up 3293up 1294down 2295forward 4296up 7297forward 2298up 9299forward 1300down 5301forward 3302up 9303up 4304down 4305up 6306down 1307forward 9308up 5309forward 5310up 4311down 6312forward 2313up 6314forward 5315forward 5316down 4317up 7318forward 2319down 9320down 8321down 7322forward 4323forward 7324down 4325forward 9326up 2327forward 1328up 4329down 8330forward 9331up 2332up 5333down 7334up 6335forward 7336up 1337forward 3338down 3339down 2340down 6341down 6342forward 3343down 2344down 2345down 5346down 4347down 6348down 2349forward 7350down 6351forward 4352down 5353down 7354down 3355forward 2356forward 8357forward 1358up 6359down 8360down 4361up 5362forward 5363down 7364forward 5365forward 8366forward 7367down 8368down 5369down 3370up 2371forward 8372forward 7373down 6374up 1375down 9376down 3377down 7378down 2379forward 9380forward 2381forward 4382forward 8383forward 3384forward 2385down 3386down 8387up 7388down 7389down 1390forward 8391down 2392up 4393forward 9394down 6395forward 5396forward 8397forward 1398forward 4399down 6400down 1401down 6402forward 1403forward 7404down 3405down 3406down 1407up 2408down 6409down 5410down 6411forward 5412forward 2413forward 1414forward 8415up 5416down 2417down 9418down 9419down 5420down 3421up 6422forward 2423down 7424down 7425down 2426down 2427up 6428forward 8429forward 6430forward 4431down 1432forward 7433down 5434up 9435forward 5436down 4437down 9438up 7439forward 1440up 3441up 7442forward 6443forward 8444up 6445up 3446forward 4447up 3448down 1449forward 8450forward 1451up 3452forward 7453up 2454forward 6455forward 2456down 2457down 9458down 9459forward 1460forward 8461down 5462forward 4463forward 5464forward 5465down 9466forward 8467up 8468down 6469down 2470down 5471down 6472up 9473up 8474down 4475down 9476up 4477forward 6478forward 1479forward 3480up 4481up 3482forward 3483forward 8484down 1485down 2486down 2487forward 9488forward 4489up 2490forward 7491down 4492up 1493forward 2494forward 9495forward 8496down 4497down 7498up 7499down 1500forward 3501down 7502down 8503up 2504forward 2505forward 8506forward 4507forward 4508down 5509forward 8510down 2511up 7512down 1513up 9514up 5515down 3516forward 6517forward 2518forward 6519down 5520down 6521forward 9522up 5523up 6524down 4525down 5526up 4527down 6528down 2529down 5530down 4531forward 7532forward 6533down 8534forward 2535down 5536down 7537down 2538forward 8539forward 6540down 3541forward 4542up 6543down 9544down 3545forward 3546forward 3547down 9548up 1549up 3550forward 3551forward 6552forward 1553forward 4554forward 3555forward 3556forward 3557down 6558down 8559forward 3560down 5561forward 8562forward 3563down 4564up 3565up 1566down 7567forward 7568up 6569forward 7570down 4571down 7572up 9573down 9574forward 8575down 5576down 2577forward 9578down 3579forward 4580forward 4581forward 4582forward 6583down 1584up 5585forward 8586down 6587forward 5588up 5589up 5590down 2591down 9592down 7593up 3594up 7595up 6596forward 2597forward 6598up 9599forward 5600forward 2601up 4602down 4603down 5604forward 7605down 5606down 7607forward 3608down 6609down 1610forward 6611up 5612up 6613up 3614down 9615up 7616forward 9617down 3618forward 4619up 2620forward 9621down 2622up 2623up 5624forward 1625down 8626down 1627down 8628up 2629forward 9630forward 1631up 2632down 1633up 1634forward 2635down 7636forward 9637up 1638forward 8639down 5640down 5641down 9642forward 5643down 7644down 1645forward 9646down 5647forward 9648forward 9649down 6650down 5651down 6652forward 3653down 4654up 8655down 6656up 4657down 9658up 1659up 2660up 8661forward 6662down 7663down 4664down 9665down 3666forward 9667down 5668forward 6669down 6670forward 7671down 9672forward 2673forward 2674down 8675down 7676forward 5677down 8678forward 6679down 1680forward 6681forward 7682forward 3683forward 2684forward 1685forward 1686down 9687forward 7688up 9689down 5690forward 6691down 4692down 2693forward 4694forward 3695forward 9696down 8697down 2698forward 4699down 8700down 6701forward 9702down 7703forward 1704up 1705forward 3706down 5707down 8708up 6709forward 9710forward 4711down 2712forward 4713up 2714forward 9715down 5716down 1717down 9718forward 5719down 9720forward 1721down 9722forward 8723down 5724forward 9725forward 8726up 8727down 7728up 9729down 5730up 9731forward 7732forward 7733forward 1734up 2735up 2736forward 6737up 5738up 5739down 7740forward 2741up 8742forward 8743down 8744forward 7745forward 8746down 7747down 8748forward 4749forward 2750down 8751up 4752down 1753up 7754forward 4755forward 3756down 6757up 6758forward 6759down 1760forward 3761down 6762forward 6763up 3764up 1765up 5766down 1767up 9768down 8769forward 7770forward 9771up 2772forward 2773forward 6774up 2775up 3776forward 1777forward 2778forward 8779down 6780forward 5781down 8782forward 2783up 1784down 1785down 3786forward 9787down 6788down 1789down 6790down 6791down 6792down 1793up 6794down 6795forward 6796down 5797down 2798up 5799forward 7800down 3801forward 9802forward 2803down 2804down 1805down 9806up 3807down 2808forward 2809forward 6810down 4811up 7812up 3813up 9814forward 3815forward 8816forward 9817forward 4818forward 2819up 7820up 5821down 9822forward 1823up 1824down 7825forward 5826forward 5827down 3828forward 1829forward 6830up 8831down 4832down 2833up 2834forward 2835forward 1836down 4837up 9838down 1839down 4840down 6841forward 3842forward 7843down 4844up 8845down 6846forward 7847forward 4848up 2849down 8850forward 5851down 1852forward 7853down 1854up 6855down 9856forward 3857forward 1858up 2859up 4860forward 8861forward 1862up 8863forward 3864forward 7865up 9866up 6867up 9868down 9869down 5870forward 8871forward 7872down 5873forward 7874forward 6875forward 8876up 4877forward 6878down 6879up 8880down 7881up 8882forward 6883forward 7884down 4885forward 4886up 2887forward 9888down 6889down 2890down 8891forward 6892up 2893up 8894forward 2895down 3896forward 7897forward 6898down 9899up 1900forward 1901down 8902down 8903forward 4904forward 4905up 6906down 8907up 8908forward 1909forward 1910down 6911up 3912up 7913forward 1914forward 1915up 2916forward 2917down 4918up 8919forward 1920up 7921down 2922forward 2923down 1924forward 1925down 4926forward 4927forward 8928up 5929down 6930up 8931forward 4932down 3933up 6934forward 3935forward 4936down 5937forward 1938forward 6939forward 4940forward 1941down 7942down 4943forward 2944down 6945forward 3946down 5947forward 3948forward 4949forward 4950forward 9951down 5952forward 7953forward 7954forward 9955down 1956up 6957forward 1958down 9959forward 3960down 7961up 8962up 6963down 7964forward 2965down 9966forward 9967forward 6968down 9969forward 6970down 8971forward 1972up 6973down 1974forward 6975down 9976forward 6977forward 7978forward 3979forward 8980forward 5981forward 8982down 9983down 2984forward 3985down 3986up 4987down 4988down 3989forward 3990forward 3991down 5992forward 5993forward 1994down 9995down 3996up 7997forward 9998up 1999down 11000down 61001up 11002forward 2`)...`

part1.solution.js

Source:part1.solution.js

`1import calculateFinalPosition from "./part1.js";2console.log(3 calculateFinalPosition(`forward 84forward 35down 86forward 47down 28down 49down 810down 411down 712up 413down 614down 215forward 716down 517down 718down 519forward 820forward 421forward 322down 423forward 224up 325up 626forward 727down 428down 229forward 730up 331forward 832down 433down 634forward 335forward 936down 937down 638forward 839up 840forward 341down 842down 443forward 744forward 345up 946down 847forward 748forward 549forward 350down 151down 452forward 153down 654forward 955up 256forward 357down 258down 159up 560down 861down 762down 563down 964up 765forward 466down 967down 868down 469forward 370down 171up 872down 173down 874forward 475up 176forward 777down 678down 279forward 380down 981forward 982forward 483down 184up 685down 186up 287down 488down 989down 790forward 591down 392up 993forward 494up 595down 996forward 197forward 798forward 199down 8100forward 5101down 2102down 4103down 3104forward 4105down 9106up 7107up 1108forward 4109up 2110forward 4111forward 4112down 1113down 5114forward 6115forward 1116down 6117forward 8118forward 8119forward 6120down 3121forward 3122forward 1123forward 5124forward 7125down 5126forward 8127down 7128down 8129forward 7130forward 8131down 7132forward 7133up 2134up 9135down 1136forward 1137forward 6138up 3139up 6140down 2141down 4142forward 2143up 8144forward 5145up 9146up 5147down 2148forward 5149forward 9150up 3151forward 7152down 4153down 3154down 2155forward 9156up 4157down 7158down 1159forward 9160forward 3161up 4162forward 1163up 6164forward 5165forward 2166forward 2167down 9168forward 1169up 7170forward 3171down 1172down 5173up 8174down 5175forward 5176forward 5177down 9178up 5179forward 8180up 9181down 1182forward 1183down 7184up 3185down 9186down 9187down 5188up 6189forward 7190down 5191down 2192down 5193forward 3194forward 2195forward 9196forward 5197forward 6198up 7199up 7200forward 4201forward 2202up 4203up 6204down 8205up 9206up 5207down 8208forward 4209up 9210forward 8211forward 3212down 6213down 6214down 7215down 6216forward 7217up 5218down 2219down 5220forward 2221up 5222forward 7223down 5224up 4225up 2226forward 2227forward 9228forward 5229forward 8230up 4231forward 6232up 7233forward 5234down 2235down 3236down 8237up 2238down 2239up 1240up 7241down 1242down 6243down 9244down 7245forward 8246up 8247up 9248down 9249forward 6250forward 6251down 6252forward 3253forward 4254forward 6255forward 7256down 5257down 8258forward 7259forward 9260down 4261up 9262forward 8263down 6264down 1265down 2266forward 4267down 5268up 1269forward 1270down 6271forward 4272forward 2273forward 6274down 8275up 2276up 8277forward 3278down 6279forward 7280down 1281forward 1282forward 8283down 8284down 8285down 2286forward 8287down 4288up 8289down 6290forward 2291down 5292up 3293up 1294down 2295forward 4296up 7297forward 2298up 9299forward 1300down 5301forward 3302up 9303up 4304down 4305up 6306down 1307forward 9308up 5309forward 5310up 4311down 6312forward 2313up 6314forward 5315forward 5316down 4317up 7318forward 2319down 9320down 8321down 7322forward 4323forward 7324down 4325forward 9326up 2327forward 1328up 4329down 8330forward 9331up 2332up 5333down 7334up 6335forward 7336up 1337forward 3338down 3339down 2340down 6341down 6342forward 3343down 2344down 2345down 5346down 4347down 6348down 2349forward 7350down 6351forward 4352down 5353down 7354down 3355forward 2356forward 8357forward 1358up 6359down 8360down 4361up 5362forward 5363down 7364forward 5365forward 8366forward 7367down 8368down 5369down 3370up 2371forward 8372forward 7373down 6374up 1375down 9376down 3377down 7378down 2379forward 9380forward 2381forward 4382forward 8383forward 3384forward 2385down 3386down 8387up 7388down 7389down 1390forward 8391down 2392up 4393forward 9394down 6395forward 5396forward 8397forward 1398forward 4399down 6400down 1401down 6402forward 1403forward 7404down 3405down 3406down 1407up 2408down 6409down 5410down 6411forward 5412forward 2413forward 1414forward 8415up 5416down 2417down 9418down 9419down 5420down 3421up 6422forward 2423down 7424down 7425down 2426down 2427up 6428forward 8429forward 6430forward 4431down 1432forward 7433down 5434up 9435forward 5436down 4437down 9438up 7439forward 1440up 3441up 7442forward 6443forward 8444up 6445up 3446forward 4447up 3448down 1449forward 8450forward 1451up 3452forward 7453up 2454forward 6455forward 2456down 2457down 9458down 9459forward 1460forward 8461down 5462forward 4463forward 5464forward 5465down 9466forward 8467up 8468down 6469down 2470down 5471down 6472up 9473up 8474down 4475down 9476up 4477forward 6478forward 1479forward 3480up 4481up 3482forward 3483forward 8484down 1485down 2486down 2487forward 9488forward 4489up 2490forward 7491down 4492up 1493forward 2494forward 9495forward 8496down 4497down 7498up 7499down 1500forward 3501down 7502down 8503up 2504forward 2505forward 8506forward 4507forward 4508down 5509forward 8510down 2511up 7512down 1513up 9514up 5515down 3516forward 6517forward 2518forward 6519down 5520down 6521forward 9522up 5523up 6524down 4525down 5526up 4527down 6528down 2529down 5530down 4531forward 7532forward 6533down 8534forward 2535down 5536down 7537down 2538forward 8539forward 6540down 3541forward 4542up 6543down 9544down 3545forward 3546forward 3547down 9548up 1549up 3550forward 3551forward 6552forward 1553forward 4554forward 3555forward 3556forward 3557down 6558down 8559forward 3560down 5561forward 8562forward 3563down 4564up 3565up 1566down 7567forward 7568up 6569forward 7570down 4571down 7572up 9573down 9574forward 8575down 5576down 2577forward 9578down 3579forward 4580forward 4581forward 4582forward 6583down 1584up 5585forward 8586down 6587forward 5588up 5589up 5590down 2591down 9592down 7593up 3594up 7595up 6596forward 2597forward 6598up 9599forward 5600forward 2601up 4602down 4603down 5604forward 7605down 5606down 7607forward 3608down 6609down 1610forward 6611up 5612up 6613up 3614down 9615up 7616forward 9617down 3618forward 4619up 2620forward 9621down 2622up 2623up 5624forward 1625down 8626down 1627down 8628up 2629forward 9630forward 1631up 2632down 1633up 1634forward 2635down 7636forward 9637up 1638forward 8639down 5640down 5641down 9642forward 5643down 7644down 1645forward 9646down 5647forward 9648forward 9649down 6650down 5651down 6652forward 3653down 4654up 8655down 6656up 4657down 9658up 1659up 2660up 8661forward 6662down 7663down 4664down 9665down 3666forward 9667down 5668forward 6669down 6670forward 7671down 9672forward 2673forward 2674down 8675down 7676forward 5677down 8678forward 6679down 1680forward 6681forward 7682forward 3683forward 2684forward 1685forward 1686down 9687forward 7688up 9689down 5690forward 6691down 4692down 2693forward 4694forward 3695forward 9696down 8697down 2698forward 4699down 8700down 6701forward 9702down 7703forward 1704up 1705forward 3706down 5707down 8708up 6709forward 9710forward 4711down 2712forward 4713up 2714forward 9715down 5716down 1717down 9718forward 5719down 9720forward 1721down 9722forward 8723down 5724forward 9725forward 8726up 8727down 7728up 9729down 5730up 9731forward 7732forward 7733forward 1734up 2735up 2736forward 6737up 5738up 5739down 7740forward 2741up 8742forward 8743down 8744forward 7745forward 8746down 7747down 8748forward 4749forward 2750down 8751up 4752down 1753up 7754forward 4755forward 3756down 6757up 6758forward 6759down 1760forward 3761down 6762forward 6763up 3764up 1765up 5766down 1767up 9768down 8769forward 7770forward 9771up 2772forward 2773forward 6774up 2775up 3776forward 1777forward 2778forward 8779down 6780forward 5781down 8782forward 2783up 1784down 1785down 3786forward 9787down 6788down 1789down 6790down 6791down 6792down 1793up 6794down 6795forward 6796down 5797down 2798up 5799forward 7800down 3801forward 9802forward 2803down 2804down 1805down 9806up 3807down 2808forward 2809forward 6810down 4811up 7812up 3813up 9814forward 3815forward 8816forward 9817forward 4818forward 2819up 7820up 5821down 9822forward 1823up 1824down 7825forward 5826forward 5827down 3828forward 1829forward 6830up 8831down 4832down 2833up 2834forward 2835forward 1836down 4837up 9838down 1839down 4840down 6841forward 3842forward 7843down 4844up 8845down 6846forward 7847forward 4848up 2849down 8850forward 5851down 1852forward 7853down 1854up 6855down 9856forward 3857forward 1858up 2859up 4860forward 8861forward 1862up 8863forward 3864forward 7865up 9866up 6867up 9868down 9869down 5870forward 8871forward 7872down 5873forward 7874forward 6875forward 8876up 4877forward 6878down 6879up 8880down 7881up 8882forward 6883forward 7884down 4885forward 4886up 2887forward 9888down 6889down 2890down 8891forward 6892up 2893up 8894forward 2895down 3896forward 7897forward 6898down 9899up 1900forward 1901down 8902down 8903forward 4904forward 4905up 6906down 8907up 8908forward 1909forward 1910down 6911up 3912up 7913forward 1914forward 1915up 2916forward 2917down 4918up 8919forward 1920up 7921down 2922forward 2923down 1924forward 1925down 4926forward 4927forward 8928up 5929down 6930up 8931forward 4932down 3933up 6934forward 3935forward 4936down 5937forward 1938forward 6939forward 4940forward 1941down 7942down 4943forward 2944down 6945forward 3946down 5947forward 3948forward 4949forward 4950forward 9951down 5952forward 7953forward 7954forward 9955down 1956up 6957forward 1958down 9959forward 3960down 7961up 8962up 6963down 7964forward 2965down 9966forward 9967forward 6968down 9969forward 6970down 8971forward 1972up 6973down 1974forward 6975down 9976forward 6977forward 7978forward 3979forward 8980forward 5981forward 8982down 9983down 2984forward 3985down 3986up 4987down 4988down 3989forward 3990forward 3991down 5992forward 5993forward 1994down 9995down 3996up 7997forward 9998up 1999down 11000down 61001up 11002forward 2`)...`

SignUpController.js

Source:SignUpController.js

```1/**2 * ç¨æ·æ³¨å 3 */45var signUpCtr = avalon.define("SignUpController", function(vm){6 vm.vType = {7 userName: true,8 password: true,9 phoneNumber: true,10 verify:true,1112 userNameError: '',13 passwordError: '',14 phoneNumberError: '',15 verifyError: '',1617 userNameBlur: false,18 passwordBlur: false,19 phoneNumberBlur: false,20 verifyBlur: false21 };2223 vm.userName = '';24 vm.password = '';25 vm.repassword = '';26 vm.phoneNumber = '';27 vm.verify = '';2829 vm.agreeCheck = true;30 vm.agreeHandler = function(bool){31 signUpCtr.agreeCheck = bool;32 };333435 vm.codeText = "è·åéªè¯ç ";3637 vm.focus = null;3839 vm.focusHandler = function(target){40 signUpCtr.focus = target;41 if(target == 'password'){42 signUpCtr.vType.passwordBlur = false;43 }else if(target == 'userName'){44 signUpCtr.vType.userNameBlur = false;45 }else if(target == 'phoneNumber'){46 signUpCtr.vType.phoneNumberBlur = false;47 } else if(target == 'verify'){48 signUpCtr.vType.verifyBlur = false;49 } 5051 };5253 vm.blurHandler = function(target){54 signUpCtr.focus = '';55 if(target == 'userName'){56 signUpCtr.vType.userNameBlur = true;57 signUpCtr.userName.replace(/\s+/g, "");58 if(!signUpCtr.userName){59 signUpCtr.vType.userName = false;60 signUpCtr.vType.userNameError = 'ç¨æ·åéè¯¯';61 }else{62 signUpCtr.vType.userName = true;63 signUpCtr.vType.userNameError = '';64 }65 }else if(target == 'password'){66 signUpCtr.vType.passwordBlur = true;67 signUpCtr.password.replace(/\s+/g, "");68 if(signUpCtr.password.length >= 6 && signUpCtr.password.length <= 20){69 signUpCtr.vType.password = true;70 signUpCtr.vType.passwordError = '';71 }else{72 signUpCtr.vType.password = false;73 signUpCtr.vType.passwordError = '6-20ä½å­æ¯ææ°å­';74 }75 }76 else if(target == 'verify'){77 signUpCtr.vType.verifyBlur = true;78 if(signUpCtr.verify.length > 0){79 signUpCtr.vType.verify = true;80 signUpCtr.vType.verifyError = '';81 }else{82 signUpCtr.vType.verify = false;83 signUpCtr.vType.verifyError = 'è¯·è¾å¥éªè¯ç ';84 }85 }86 else if(target == 'phoneNumber'){87 signUpCtr.vType.phoneNumberBlur = true;88 signUpCtr.phoneNumber.replace(/\s+/g, "");89 var phoneNumberR = /^(1[3|5|7|8|][0-9]{9})\$/;90 if(phoneNumberR.test(signUpCtr.phoneNumber)){91 signUpCtr.vType.phoneNumber = true;92 signUpCtr.vType.phoneNumberError = '';93 }else{94 signUpCtr.vType.phoneNumber = false;95 signUpCtr.vType.phoneNumberError = 'è¯·å¡«åæ­£ç¡®çææºå·ç ';96 }97 }98 };99100 vm.keydown = function(e){101 if(e.keyCode == 13){102 signUpCtr.register();103 }104 };105 vm.passwordType = "password";106 vm.passwordToggle = function() {107 if(vm.passwordType == 'password'){108 vm.passwordType = 'text';109 }110 else111 vm.passwordType = 'password';112 };113114 vm.register = regHandler;115116 vm.regSuccess = false;117118 vm.sendCode = regSendCode;119120});121122var timer;123124function regSendCode(){125 signUpCtr.blurHandler('phoneNumber');126 if(signUpCtr.codeText != 'è·åéªè¯ç '){127 return;128 }129 if(!signUpCtr.vType.phoneNumber){130 return;131 }132133 var phone = {134 tel: signUpCtr.phoneNumber135 };136 signUpCtr.codeText = 59;137 var timer = setInterval(function(){138 if(signUpCtr.codeText <= 1){139 signUpCtr.codeText = 'è·åéªè¯ç ';140 clearInterval(timer);141 }else{142 signUpCtr.codeText--;143 }144 }, 1000);145146 require(['UtilController'], function(AjaxFunc){147 AjaxFunc.getAction({148 url: Global_URL['verify'],149 data: phone,150 dataType:Global_DataType,151 callback: function(result){152 Tip.alert('éªè¯ç å·²åéï¼');153 }154 })155 });156}157158159160function regHandler(){161 if(!signUpCtr.agreeCheck){162 return;163 }164 signUpCtr.blurHandler('userName');165 signUpCtr.blurHandler('phoneNumber');166 signUpCtr.blurHandler('password');167 signUpCtr.blurHandler('verify');168169 if(!signUpCtr.vType.userName ||170 !signUpCtr.vType.password ||171 !signUpCtr.vType.phoneNumber ||172 !signUpCtr.vType.verify173 ){174 return;175 }176 var user = {177 userName: signUpCtr.userName,178 pwd: signUpCtr.password,179 tel: signUpCtr.phoneNumber,180 code: signUpCtr.verify181 };182183 require(['UtilController'], function(AjaxFunc){184 AjaxFunc.getAction({185 url: Global_URL['signUp'],186 data: user,187 callback: function(result){188 if(result.errorCode!=22000){189 result.msg = result.msg || 'æ³¨åå¤±è´¥';190 alert(result.msg);191 return;192 }193 // æ³¨åæå194 location.href = '../index.html'195 }196 })197 }); ...```

listview.js

Source:listview.js

`1/**2 * TodoList3 * * æ¬ç»ä»¶éç¨scroll-view+æå¿å¤æ­æ¹æ¡4 * * å¦ä¸ç§å®ç°æ¹æ¡å¯éç¨ï¼movable-area+movable-viewæ¹æ¡5 */6const Distance = 80; //ä¸æå è½½åºåéå¼7Component({8 options: {9 addGlobalClass: true10 },11 properties: {12 mode: {//åè¡¨æ¨¡å¼ upä¸æå·æ°/downä¸æå è½½/allå¨é¨13 type: String,14 value: 'all'15 },16 upStatus: {//ä¸æå·æ°ç¶æ ''/dropä¸æå·æ°/releaseéæ¾å·æ°/loadingå è½½ä¸­17 type: String,18 value: ''19 },20 downstatus: {//ä¸æå è½½ç¶æ ''/loadingå è½½ä¸­/noMoreDataæ åå®¹21 type: String,22 value: ''23 },24 lowerThreshold: {//è·ç¦»åºé¨å¤è¿ï¼è§¦åä¸æå è½½äºä»¶25 type: Number,26 value: 5027 },28 downLoadingIcon: {29 type: String,30 value: 'ms-loading'31 },32 downLoadingText: {33 type: String,34 value: 'å è½½ä¸­...'35 },36 noMoreData: {37 type: String,38 value: 'æ²¡ææ´å¤æ°æ®äº'39 },40 },41 data: {42 upHeight: 0,//ä¸æå è½½åºåé«åº¦43 isLockUp: false,//éå®ä¸æå·æ°44 isLockDown: false,//éä½ä¸æå è½½45 },46 ready() {47 this.scrollTop = 048 },49 methods: {50 onScroll(ev) {51 const { scrollTop } = ev.detail52 this.scrollTop = scrollTop53 this.triggerEvent('onScroll', ev)54 },55 onDragStart(ev) {56 let { upStatus, isLockUp } = this.data57 if (upStatus == 'loading' && isLockUp) {58 return;59 }60 const { touches } = ev61 const touch = touches[0]62 this.pageX = touch.pageX63 this.pageY = touch.pageY64 },65 onDragMove(ev) {66 const { touches } = ev67 const touch = touches[0]68 let offsetX = touch.pageX - this.pageX69 let offsetY = touch.pageY - this.pageY70 let absOffsetX = Math.abs(offsetX)71 let absOffsetY = Math.abs(offsetY)72 let { upHeight, upStatus, isLockUp } = this.data73 if (upStatus == 'loading' && isLockUp) {74 return;75 }76 if (absOffsetY - absOffsetX > 0 && offsetY > 0 && this.scrollTop <= 0) {//çºµåä¸åä¸æ»å¨ ä¸ scroll-viewæ­£å¨é¡¶é¨77 if (absOffsetY < Distance * 0.2) {78 return79 }80 if (absOffsetY <= Distance) {//ç¬¬ä¸é¶æ®µ ä¸æå·æ°81 upHeight = absOffsetY82 upStatus = 'drop'83 } else if (Distance < absOffsetY) {//ç¬¬äºé¶æ®µ éæ¾å·æ°84 if (absOffsetY <= Distance * 2) {85 upHeight = Distance + (absOffsetY - Distance) * 0.586 } else {87 upHeight = Distance + Distance * 0.5 + (absOffsetY - Distance * 2) * 0.288 }89 upStatus = 'release'90 }91 upHeight = upHeight * 0.7 //ç§»å¨è·ç¦»è¡°å92 this.setData({93 upHeight,94 upStatus95 })96 }97 },98 onDragEnd() {99 if (this.scrollTop <= 0) {//scroll-viewæ­£å¨é¡¶é¨100 let { upHeight, upStatus, isLockUp } = this.data;101 if (upStatus == 'loading' && isLockUp) {102 return103 }104 if (upStatus == 'release') {105 upHeight = Distance106 upStatus = 'loading'107 this.onEmitUp()108 } else {109 upHeight = 0110 upStatus = ''111 }112 this.setData({113 upHeight,114 upStatus115 })116 }117 },118 lock(direction) {119 /**120 * éå®121 */122 let { isLockUp, isLockDown } = this.data123 switch (direction) {124 case 'up':125 isLockUp = true126 case 'down':127 isLockDown = true128 default:129 isLockUp = true130 isLockDown = true131 }132 this.setData({133 isLockUp,134 isLockDown135 })136 },137 unlock(direction) {138 /**139 * è§£é140 */141 let { isLockUp, isLockDown } = this.data142 switch (direction) {143 case 'up':144 isLockUp = false145 case 'down':146 isLockDown = false147 default:148 isLockUp = false149 isLockDown = false150 }151 this.setData({152 isLockUp,153 isLockDown154 })155 },156 onEmitUp(ev) {157 /**158 * ä¸æå·æ°159 */160 this.triggerEvent('onEmitUp')161 },162 setUpStatus(status = '') {163 /**164 * è®¾ç½®ä¸æå·æ°ç¶æ165 */166 this.setData({167 upStatus: status168 })169 },170 onEmitDown(ev) {171 /**172 * ä¸æå è½½äºä»¶173 */174 const { downstatus, isLockDown } = this.data175 if (downstatus == 'loading' && isLockDown) {176 return177 }178 this.triggerEvent('onEmitDown')179 },180 setDownStatus(status = '') {181 /**182 * è®¾ç½®ä¸æå è½½åºåçç¶æ183 */184 this.setData({185 downstatus: status186 })187 },188 }...`

AxisSpec.js

Source:AxisSpec.js

`1import { Cartesian4 } from "../../Source/Cesium.js";2import { Math as CesiumMath } from "../../Source/Cesium.js";3import { Matrix4 } from "../../Source/Cesium.js";4import { Axis } from "../../Source/Cesium.js";5describe("Scene/Axis", function () {6 function convertUpAxis(upAxis, transformation, expected) {7 var transformed = Matrix4.multiplyByVector(8 transformation,9 upAxis,10 new Cartesian4()11 );12 Cartesian4.normalize(transformed, transformed);13 expect(transformed).toEqualEpsilon(expected, CesiumMath.EPSILON1);14 }15 it("Convert y-up to z-up", function () {16 convertUpAxis(Cartesian4.UNIT_Y, Axis.Y_UP_TO_Z_UP, Cartesian4.UNIT_Z);17 });18 it("Convert y-up to x-up", function () {19 convertUpAxis(Cartesian4.UNIT_Y, Axis.Y_UP_TO_X_UP, Cartesian4.UNIT_X);20 });21 it("Convert z-up to x-up", function () {22 convertUpAxis(Cartesian4.UNIT_Z, Axis.Z_UP_TO_X_UP, Cartesian4.UNIT_X);23 });24 it("Convert z-up to y-up", function () {25 convertUpAxis(Cartesian4.UNIT_Z, Axis.Z_UP_TO_Y_UP, Cartesian4.UNIT_Y);26 });27 it("Convert x-up to y-up", function () {28 convertUpAxis(Cartesian4.UNIT_X, Axis.X_UP_TO_Y_UP, Cartesian4.UNIT_Y);29 });30 it("Convert x-up to z-up", function () {31 convertUpAxis(Cartesian4.UNIT_X, Axis.X_UP_TO_Z_UP, Cartesian4.UNIT_Z);32 });...`

Using AI Code Generation

`1var client = require('devicefarmer-stf-client');2var device = new client.Device({serial: '0123456789ABCDEF'});3device.up();4device.down();5device.left();6device.right();7device.tap(100, 100);8device.swipe(100, 100, 200, 200);9device.home();10device.back();11device.menu();12device.power();13device.reboot();14device.rotate(0);15device.rotate(1);16device.rotate(2);17device.rotate(3);18device.rotate(4);19device.installApp('test.apk');20device.uninstallApp('test.apk');21device.startApp('com.test', 'com.test.activity');22device.stopApp('com.test');23device.clearApp('com.test');24device.getBatteryLevel(function (err, level) {25 if (err) {26 console.log('Error: ', err);27 } else {28 console.log('Battery level: ', level);29 }30});31device.getBatteryStatus(function (err, status) {32 if (err) {33 console.log('Error: ', err);34 } else {35 console.log('Battery status: ', status);36 }37});38device.getSystemInfo(function (err, info) {39 if (err) {40 console.log('Error: ', err);41 } else {42 console.log('System info: ', info);43 }44});45device.getDisplayInfo(function (err, info) {46 if (err) {47 console.log('Error: ', err);48 } else {49 console.log('Display info: ', info);50 }51});52device.getDisplayRotation(function (err, rotation) {53 if (err) {54 console.log('Error: ', err);55 } else {56 console.log('Display rotation: ', rotation);57 }58});59device.getDisplayDensity(function (err, density) {60 if (err) {61 console.log('Error: ', err);62 } else {63 console.log('Display density: ', density);64 }65});66device.getDisplaySize(function (err, size) {67 if (err) {68 console.log('Error: ', err);69 } else {70 console.log('Display size: ', size);71 }72});73device.getDeviceTime(function (err, time) {74 if (err) {75 console.log('Error: ', err);76 } else {77 console.log('Device time: ', time);78 }79});`

Using AI Code Generation

`1var stf = require('devicefarmer-stf-client');2var client = new stf.client();3var device = new stf.device();4var up = new stf.up();5 if (err) {6 console.log(err);7 } else {8 console.log('Connected to STF server');9 }10});11device.getAvailableDevice(function(err, res) {12 if (err) {13 console.log(err);14 } else {15 console.log('Device selected');16 console.log(res.serial);17 var serial = res.serial;18 up.uploadFile(serial, 'test.txt', function(err, res) {19 if (err) {20 console.log(err);21 } else {22 console.log(res);23 }24 });25 }26});27{ success: true, message: 'File uploaded successfully' }`

Using AI Code Generation

`1var stf = require('devicefarmer-stf');2api.useUp("deviceID", function(err, data) {3 if (err) {4 console.log("error", err);5 } else {6 console.log("data", data);7 }8});9var stf = require('devicefarmer-stf');10api.useDown("deviceID", function(err, data) {11 if (err) {12 console.log("error", err);13 } else {14 console.log("data", data);15 }16});17var stf = require('devicefarmer-stf');18api.useLeft("deviceID", function(err, data) {19 if (err) {20 console.log("error", err);21 } else {22 console.log("data", data);23 }24});25var stf = require('devicefarmer-stf');26api.useRight("deviceID", function(err, data) {27 if (err) {28 console.log("error", err);29 } else {30 console.log("data", data);31 }32});33var stf = require('devicefarmer-stf');34api.useCenter("deviceID", function(err, data) {35 if (err) {36 console.log("error", err);37 } else {38 console.log("data", data);39 }40});41var stf = require('devicefarmer-stf');42api.useHome("deviceID", function(err, data) {43 if (err) {44 console.log("error", err);45 } else {46 console.log("data",`

Using AI Code Generation

`1var devicefarmer = require('devicefarmer-stf-utils');2var options = {3}4devicefarmer.up(options, function (err) {5 if (err) {6 console.log(err);7 } else {8 console.log('Device is up');9 }10});11devicefarmer.down(options, function (err) {12 if (err) {13 console.log(err);14 } else {15 console.log('Device is down');16 }17});18devicefarmer.reset(options, function (err) {19 if (err) {20 console.log(err);21 } else {22 console.log('Device is reset');23 }24});25devicefarmer.info(options, function (err, data) {26 if (err) {27 console.log(err);28 } else {29 console.log(data);30 }31});32devicefarmer.list(options, function (err, data) {33 if (err) {34 console.log(err);35 } else {36 console.log(data);37 }38});39devicefarmer.get(options, function (err, data) {40 if (err) {41 console.log(err);42 } else {43 console.log(data);44 }45});46devicefarmer.unlock(options, function (err) {47 if (err) {48 console.log(err);49 } else {50 console.log('Device is unlocked');51 }52});53devicefarmer.lock(options, function (err) {54 if (err) {55 console.log(err);56 } else {57 console.log('Device is locked');58 }59});60devicefarmer.screenshot(options, function (err, data) {61 if (err) {62 console.log(err);63 } else {64 console.log(data);65 }66});`

Using AI Code Generation

`1var devicefarmer = require('devicefarmer-stf');2var device = new devicefarmer.Device(client, 'a5b3c3b7');3var up = device.up();4up.then(function() {5 console.log('up');6});7up.catch(function(err) {8 console.log('error', err);9});10var devicefarmer = require('devicefarmer-stf');11var device = new devicefarmer.Device(client, 'a5b3c3b7');12var down = device.down();13down.then(function() {14 console.log('down');15});16down.catch(function(err) {17 console.log('error', err);18});19var devicefarmer = require('devicefarmer-stf');20var device = new devicefarmer.Device(client, 'a5b3c3b7');21var left = device.left();22left.then(function() {23 console.log('left');24});25left.catch(function(err) {26 console.log('error', err);27});28var devicefarmer = require('devicefarmer-stf');29var device = new devicefarmer.Device(client, 'a5b3c3b7');30var right = device.right();31right.then(function() {32 console.log('right');33});34right.catch(function(err) {35 console.log('error', err);36});37var devicefarmer = require('devicefarmer-stf');38var device = new devicefarmer.Device(client, 'a5b3c3b7');`

Using AI Code Generation

`1var stf = require('devicefarmer-stf');2device.up().then(function () {3 console.log('Device is up');4});5var stf = require('devicefarmer-stf');6device.down().then(function () {7 console.log('Device is down');8});9var stf = require('devicefarmer-stf');10device.reboot().then(function () {11 console.log('Device is rebooted');12});13var stf = require('devicefarmer-stf');14device.install('com.android.chrome').then(function () {15 console.log('App is installed');16});17var stf = require('devicefarmer-stf');18device.uninstall('com.android.chrome').then(function () {19 console.log('App is uninstalled');20});21var stf = require('devicefarmer-stf');22device.open('com.android.chrome').then(function () {23 console.log('App is opened');24});25var stf = require('devicefarmer-stf');26device.close('com.android.chrome').then(function () {`

Using AI Code Generation

`1var stf = require('devicefarmer-stf');2var path = require('path');3var stfObj = new stf(stfServer);4stfObj.up(device, apk, function (err, res) {5 if (err) {6 console.log(err);7 } else {8 console.log(res);9 }10});11var stf = require('devicefarmer-stf');12var stfObj = new stf(stfServer);13stfObj.up(device, apk, function (err, res) {14 if (err) {15 console.log(err);16 } else {17 console.log(res);18 }19});`

## Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.