Best Python code snippet using ATX
pattern.py
Source:pattern.py
...19"""20from math import ceil #for multi-output rounding21#Any items related to infrastructure (building the pattern tree, etc.).22pattern_tree = []23def build_tree(mat_name, quantity, indent):24 pattern_tree.append({'name':mat_name, 'quan':quantity, 'indent':indent})25#Only patterns below here.26"""27def ?(quantity=1, indent=0):28 build_tree("?", quantity, indent)29 indent += 130 ?(quantity, indent)31 ?(ceil(quantity/?.0), indent)32"""33def archaic_rune(quantity=1, indent=0):34 build_tree("Archaic Rune", quantity, indent)35def basic_writings(quantity=1, indent=0):36 build_tree("Basic Writings", quantity, indent)37def basic_reference(quantity=1, indent=0):38 build_tree("Basic Reference", quantity, indent)39def basic_rune(quantity=1, indent=0):40 build_tree("Basic Rune", quantity, indent)41def minor_etching(quantity=1, indent=0):42 build_tree("Minor Etching", quantity, indent)43def superb_etching(quantity=1, indent=0):44 build_tree("Superb Etching", quantity, indent)45def basic_parchment(quantity=1, indent=0):46 build_tree("Basic Parchment", quantity, indent)47def primitive_writings(quantity=1, indent=0):48 build_tree("Primitive Writings", quantity, indent)49def ancient_book(quantity=1, indent=0):50 build_tree("Ancient Book", quantity, indent)51def aged_etching(quantity=1, indent=0):52 build_tree("Aged Etching", quantity, indent)53def primitive_reference(quantity=1, indent=0):54 build_tree("Primitive Reference", quantity, indent)55def primitive_rune(quantity=1, indent=0):56 build_tree("Primitive Rune", quantity, indent)57def primitive_parchment(quantity=1, indent=0):58 build_tree("Primitive Parchment", quantity, indent)59 60def aged_writings(quantity=1, indent=0):61 build_tree("Aged Writings", quantity, indent)62def intricate_etching(quantity=1, indent=0):63 build_tree("Intricate Etching", quantity, indent)64def aged_reference(quantity=1, indent=0):65 build_tree("Aged Reference", quantity, indent)66def elemental_rune(quantity=1, indent=0):67 build_tree("Elemental Rune", quantity, indent)68def elemental_parchment(quantity=1, indent=0):69 build_tree("Elemental Parchment", quantity, indent)70def ancient_etching(quantity=1, indent=0):71 build_tree("Ancient Etching", quantity, indent)72def pristine_writings(quantity=1, indent=0):73 build_tree("Pristine Writings", quantity, indent)74def complex_etching(quantity=1, indent=0):75 build_tree("Complex Etching", quantity, indent)76def pristine_reference(quantity=1, indent=0):77 build_tree("Pristine Reference", quantity, indent)78def pristine_rune(quantity=1, indent=0):79 build_tree("Pristine Rune", quantity, indent)80def preserved_parchment(quantity=1, indent=0):81 build_tree("Preserved Parchment", quantity, indent)82def primeval_writings(quantity=1, indent=0):83 build_tree("Primeval Writings", quantity, indent)84def elaborate_etching(quantity=1, indent=0):85 build_tree("Elaborate Etching", quantity, indent)86def primeval_reference(quantity=1, indent=0):87 build_tree("Primeval Reference", quantity, indent)88def primeval_rune(quantity=1, indent=0):89 build_tree("Primeval Rune", quantity, indent)90def primeval_parchment(quantity=1, indent=0):91 build_tree("Primeval Parchment", quantity, indent)92def sharkwood(quantity=1, indent=0):93 build_tree("Sharkwood", quantity, indent)94def walnut(quantity=1, indent=0):95 build_tree("Walnut", quantity, indent)96def dark_cherry(quantity=1, indent=0):97 build_tree("Dark Cherry", quantity, indent)98def eel(quantity=1, indent=0):99 build_tree("Eel", quantity, indent)100def pike(quantity=1, indent=0):101 build_tree("Pike", quantity, indent)102def trout(quantity=1, indent=0):103 build_tree("Trout", quantity, indent)104def salmon(quantity=1, indent=0):105 build_tree("Salmon", quantity, indent)106def delvrak(quantity=1, indent=0):107 build_tree("Delvrak", quantity, indent)108def gilgrash(quantity=1, indent=0):109 build_tree("Gilgrash", quantity, indent)110def pickerel(quantity=1, indent=0):111 build_tree("Pickerel", quantity, indent)112def sunray(quantity=1, indent=0):113 build_tree("Sunray", quantity, indent)114def fire_goby(quantity=1, indent=0):115 build_tree("Fire Goby", quantity, indent)116def shadow_fish(quantity=1, indent=0):117 build_tree("Shadow Fish", quantity, indent)118def halibut(quantity=1, indent=0):119 build_tree("Halibut", quantity, indent)120def flounder(quantity=1, indent=0):121 build_tree("Flounder", quantity, indent)122def catfish(quantity=1, indent=0):123 build_tree("Catfish", quantity, indent)124def perch(quantity=1, indent=0):125 build_tree("Perch", quantity, indent)126def rockfish(quantity=1, indent=0):127 build_tree("Rockfish", quantity, indent)128def lancetail(quantity=1, indent=0):129 build_tree("Lancetail", quantity, indent)130def spiny_piranha(quantity=1, indent=0):131 build_tree("Spiny Piranha", quantity, indent)132def mackerel(quantity=1, indent=0):133 build_tree("Mackerel", quantity, indent)134def trunkfish(quantity=1, indent=0):135 build_tree("Trunkfish", quantity, indent)136def lionfish(quantity=1, indent=0):137 build_tree("Lionfish", quantity, indent)138def ghostfish(quantity=1, indent=0):139 build_tree("Ghostfish", quantity, indent)140def herring(quantity=1, indent=0):141 build_tree("Herring", quantity, indent)142def icefish(quantity=1, indent=0):143 build_tree("Icefish", quantity, indent)144def angelfish(quantity=1, indent=0):145 build_tree("Angelfish", quantity, indent)146def fangtooth(quantity=1, indent=0):147 build_tree("Fangtooth", quantity, indent)148def goldenbush(quantity=1, indent=0):149 build_tree("Goldebush", quantity, indent)150def pixieroot(quantity=1, indent=0):151 build_tree("Pixieroot", quantity, indent)152def apple(quantity=1, indent=0):153 build_tree("Apple", quantity, indent)154def large_egg(quantity=1, indent=0):155 build_tree("Large Egg", quantity, indent)156def spiritherb(quantity=1, indent=0):157 build_tree("Spiritherb", quantity, indent)158def gorethistle(quantity=1, indent=0):159 build_tree("Gorethistle", quantity, indent)160def waterberry(quantity=1, indent=0):161 build_tree("Waterberry", quantity, indent)162def dogweed(quantity=1, indent=0):163 build_tree("Dogweed", quantity, indent)164def sandcreeper(quantity=1, indent=0):165 build_tree("Sandcreeper", quantity, indent)166def moonbeard(quantity=1, indent=0):167 build_tree("Moonbeard", quantity, indent)168def phantomlilly(quantity=1, indent=0):169 build_tree("Phantomlilly", quantity, indent)170def orange(quantity=1, indent=0):171 build_tree("Orange", quantity, indent)172def dark_honey(quantity=1, indent=0):173 build_tree("Dark Honey", quantity, indent)174def dark_cotton(quantity=1, indent=0):175 build_tree("Dark Cotton", quantity, indent)176def arcaneleaf(quantity=1, indent=0):177 build_tree("Arcaneleaf", quantity, indent)178def wolfsbane(quantity=1, indent=0):179 build_tree("Wolfsbane", quantity, indent)180def ladyslipper(quantity=1, indent=0):181 build_tree("Ladyslipper", quantity, indent)182def banana(quantity=1, indent=0):183 build_tree("Banana", quantity, indent)184def giant_egg(quantity=1, indent=0):185 build_tree("Giant Egg", quantity, indent)186def liontail(quantity=1, indent=0):187 build_tree("Liontail", quantity, indent)188def devilweed(quantity=1, indent=0):189 build_tree("Devilweed", quantity, indent)190def ghoulweed(quantity=1, indent=0):191 build_tree("Ghoulweed", quantity, indent)192def spiderfoot(quantity=1, indent=0):193 build_tree("Spiderfoot", quantity, indent)194def vilegourd(quantity=1, indent=0):195 build_tree("Vilegourd", quantity, indent)196def apricot(quantity=1, indent=0):197 build_tree("Apricot", quantity, indent)198def devilpetal(quantity=1, indent=0):199 build_tree("Devilpetal", quantity, indent)200def medusaroot(quantity=1, indent=0):201 build_tree("Medusaroot", quantity, indent)202def ghostshroom(quantity=1, indent=0):203 build_tree("Ghostshroom", quantity, indent)204def clay(quantity=1, indent=0):205 build_tree("Clay", quantity, indent)206def cobalt_ore(quantity=1, indent=0):207 build_tree("Cobalt Ore", quantity, indent)208def fire_clay(quantity=1, indent=0):209 build_tree("Fire Clay", quantity, indent)210def garnet(quantity=1, indent=0):211 build_tree("Garnet", quantity, indent)212def blackened_stone(quantity=1, indent=0):213 build_tree("Blackened Stone", quantity, indent)214def amber(quantity=1, indent=0):215 build_tree("Amber", quantity, indent)216def lava_rock(quantity=1, indent=0):217 build_tree("Lava Rock", quantity, indent)218def moonstone(quantity=1, indent=0):219 build_tree("Moonstone", quantity, indent)220def bloodstone_ore(quantity=1, indent=0):221 build_tree("Bloodstone Ore", quantity, indent)222def amethyst(quantity=1, indent=0):223 build_tree("Amethyst", quantity, indent)224def kaolinite(quantity=1, indent=0):225 build_tree("Kaolinite", quantity, indent)226def flame_pearl(quantity=1, indent=0):227 build_tree("Flame Pearl", quantity, indent)228def basalt(quantity=1, indent=0):229 build_tree("Basalt", quantity, indent)230def adamantite_ore(quantity=1, indent=0):231 build_tree("Adamantite Ore", quantity, indent)232def clear_opal(quantity=1, indent=0):233 build_tree("Clear Opal", quantity, indent)234def sun_opal(quantity=1, indent=0):235 build_tree("Sun Opal", quantity, indent)236def earthen_clay(quantity=1, indent=0):237 build_tree("Earthen Clay", quantity, indent)238def hard_clay_mixture(quantity=1, indent=0):239 build_tree("Hard Clay Mixture", quantity, indent)240 indent += 1241 shale_rock(quantity*10, indent)242 hard_clay(quantity*6, indent)243def hard_clay(quantity=1, indent=0):244 build_tree("Hard Clay", quantity, indent)245def iron_poweder(quantity=1, indent=0):246 build_tree("Iron Powder", quantity, indent)247 indent += 1248 shale_rock(ceil(quantity/3.0), indent)249 iron_ore(ceil(quantity/3.0), indent)250def kingsflower_buff_superior(quantity=1, indent=0):251 build_tree("Kingsflower Buff (Superior+)", quantity, indent)252 indent += 1253 angelflower(quantity*2, indent)254 kingsbloom_oil(quantity*3, indent)255def silver_maple_handle(quantity=1, indent=0):256 build_tree("Silver Maple Handle", quantity, indent)257 indent += 1258 silver_maple(quantity*5, indent)259def silver_maple(quantity=1, indent=0):260 build_tree("Silver Maple", quantity, indent)261def wild_cherry_handle(quantity=1, indent=0):262 build_tree("Wild Cherry Handle", quantity, indent)263 indent += 1264 wild_cherry(quantity*2, indent)265def wild_cherry(quantity=1, indent=0):266 build_tree("Wild Cherry", quantity, indent)267def cotton(quantity=1, indent=0):268 build_tree("Cotton", quantity, indent)269def cotton_yarn(quantity=1, indent=0):270 build_tree("Cotton Yarn", quantity, indent)271 indent += 1272 cotton(quantity*5, indent)273def grilled_shrimp(quantity=1, indent=0):274 build_tree("Grilled Shrimp", quantity, indent)275 indent += 1276 shrimp(quantity*2, indent)277def shrimp(quantity=1, indent=0):278 build_tree("Shrimp", quantity, indent)279def common_random_enchant(quantity=1, indent=0):280 build_tree("Common Random Enchant", quantity, indent)281 indent += 1282 simple_dust(quantity*4, indent)283def superior_feet_enchant(quantity=1, indent=0):284 build_tree("Superior Feet Enchant", quantity, indent)285 indent += 1286 simple_dust(quantity*2, indent)287 arcane_powder(quantity, indent)288def random_superior_enchant(quantity=1, indent=0):289 build_tree("?", quantity, indent)290 indent += 1291 simple_dust(quantity*3, indent)292 arcane_powder(quantity*3, indent)293def kingsbloom_curse_superior(quantity=1, indent=0):294 build_tree("Kingsbloom Curse (Superior+)", quantity, indent)295 indent += 1296 egg(quantity, indent)297 kingsbloom_oil(quantity*5, indent)298def angel_dragon_toxin(quantity=1, indent=0):299 build_tree("Angel Dragon Toxin", quantity, indent)300 indent += 1301 shadow_essence(quantity, indent)302 dragontear_oil(quantity, indent)303 angelflower_oil(quantity*3, indent)304def shadow_essence(quantity=1, indent=0):305 build_tree("Shadow Essence", quantity, indent)306def angelflower_oil(quantity=1, indent=0):307 build_tree("Angelflower Oil", quantity, indent)308 indent += 1309 angelflower(quantity*5, indent)310def kingsbloom_oil(quantity=1, indent=0):311 build_tree("Kingsbloom Oil", quantity, indent)312 indent += 1313 kingsbloom(quantity*5, indent)314def iridium_ore(quantity=1, indent=0):315 build_tree("Iridium Ore", quantity, indent)316def quartz(quantity=1, indent=0):317 build_tree("Quartz", quantity, indent)318def iridium_bar(quantity=1, indent=0):319 build_tree("Iridium Bar", quantity, indent)320 indent += 1321 iridium_ore(quantity, indent)322 quartz(quantity*2, indent)323def iridium_nail(quantity=1, indent=0):324 build_tree("Iridium Nail", quantity, indent)325 indent += 1326 iridium_bar(ceil(quantity/15.0), indent)327def small_hemlock_building(quantity=1, indent=0):328 build_tree("Small Hemlock Building", quantity, indent)329 indent += 1330 hemlock_wall(quantity*4, indent)331 hemlock_roof(quantity, indent)332 hemlock_lumber(quantity*30, indent)333 iridium_nail(quantity*90, indent)334def hemlock_roof(quantity=1, indent=0):335 build_tree("Hemlock Roof", quantity, indent)336 indent += 1337 hemlock_lumber(quantity*100, indent)338 iridium_nail(quantity*220, indent)339 hemlock_shingle(quantity*340, indent)340def hemlock_shingle(quantity=1, indent=0):341 build_tree("Hemlock Shingle", quantity, indent)342 indent += 1343 hemlock(ceil(quantity/5.0), indent)344def hemlock_wall(quantity=1, indent=0):345 build_tree("Hemlock Wall", quantity, indent)346 indent += 1347 hemlock_lumber(quantity*100, indent)348 iridium_nail(quantity*180, indent)349def hemlock_lumber(quantity=1, indent=0):350 build_tree("Hemlock Lumber", quantity, indent)351 indent += 1352 hemlock(quantity, indent)353def hemlock(quantity=1, indent=0):354 build_tree("Hemlock", quantity, indent)355def copper_band(quantity=1, indent=0):356 build_tree("Copper Band", quantity, indent)357 indent += 1358 copper_powder(quantity*4, indent)359 pure_copper(quantity*2, indent)360def copper_powder(quantity=1, indent=0):361 build_tree("Copper Powder", quantity, indent)362 indent += 1363 copper_ore(ceil(quantity/3.0), indent)364 stone(ceil(quantity/3.0), indent)365def copper_bar(quantity=1, indent=0):366 build_tree("Copper Bar", quantity, indent)367 indent += 1368 copper_ore(quantity, indent)369 stone(quantity, indent)370def pure_copper(quantity=1, indent=0):371 build_tree("Pure Copper", quantity, indent)372 indent += 1373 copper_bar(8*quantity, indent)374def copper_ore(quantity=1, indent=0):375 build_tree("Copper Ore", quantity, indent)376def stone(quantity=1, indent=0):377 build_tree("Stone", quantity, indent)378def hemlock_container(quantity=1, indent=0):379 build_tree("Hemlock Container", quantity, indent)380 indent += 1381 iridium_nail(quantity*60, indent)382 hemlock_lumber(quantity*12, indent)383 hemlock_wall(quantity*6, indent)384def aspen_lumber(quantity=1, indent=0):385 build_tree("Aspen Lumber", quantity, indent)386 indent += 1387 bigtooth_aspen(quantity, indent)388def bigtooth_aspen(quantity=1, indent=0):389 build_tree("Bigtooth Aspen", quantity, indent)390def chromium_ore(quantity=1, indent=0):391 build_tree("Chromium Ore", quantity, indent)392def marble(quantity=1, indent=0):393 build_tree("Marble", quantity, indent)394def chromium_bar(quantity=1, indent=0):395 build_tree("Chromium Bar", quantity, indent)396 indent += 1397 chromium_ore(quantity, indent)398 marble(quantity*2, indent)399def chromium_nail(quantity=1, indent=0):400 build_tree("Chromium Nail", quantity, indent)401 indent += 1402 chromium_bar(ceil(quantity/15.0), indent)403def pine_lumber(quantity=1, indent=0):404 build_tree("Pine Lumber", quantity, indent)405 indent += 1406 white_pine(quantity, indent)407def white_pine(quantity=1, indent=0):408 build_tree("White Pine", quantity, indent)409def milkweed_line(quantity=1, indent=0):410 build_tree("Milkweed Line", quantity, indent)411 indent += 1412 milkweed(quantity*3, indent)413def milkweed(quantity=1, indent=0):414 build_tree("Milkweed", quantity, indent)415def smooth_birch_rod(quantity=1, indent=0):416 build_tree("Smooth Birch Rod", quantity, indent)417 indent += 1418 rough_birch_rod(quantity*2, indent)419 horsetail_sandpaper(quantity, indent)420def rough_birch_rod(quantity=1, indent=0):421 build_tree("Rough Birch Rod", quantity, indent)422 indent += 1423 light_birch(quantity*6, indent)424def light_birch(quantity=1, indent=0):425 build_tree("Light Birch", quantity, indent)426def horsetail_sandpaper(quantity=1, indent=0):427 build_tree("Horsetail Sandpaper", quantity, indent)428 indent += 1429 horsetail(ceil(quantity/3.0), indent)430def horsetail(quantity=1, indent=0):431 build_tree("Horsetail", quantity, indent)432def medium_pine_wall(quantity=1, indent=0):433 build_tree("Medium Pine Wall] x %d", quantity, indent)434 indent += 1435 aspen_lumber(quantity*35, indent)436 chromium_nail(quantity*200, indent)437 pine_lumber(quantity*50, indent)438def pine_container_wall(quantity=1, indent=0):439 build_tree("Pine Container Wall", quantity, indent)440 indent += 1441 chromium_nail(quantity*160, indent)442 pine_lumber(quantity*65, indent)443def pine_guild_container(quantity=1, indent=0):444 build_tree("Pine Guild Container", quantity, indent)445 indent += 1446 aspen_lumber(quantity*16, indent)447 chromium_nail(quantity*40, indent)448 medium_pine_wall(quantity*2, indent)449 pine_container_wall(quantity*4, indent)450def iron_nail(quantity=1, indent=0):451 build_tree("Iron Nail", quantity, indent)452 indent += 1453 iron_bar(ceil(quantity/15.0), indent)454def iron_bar(quantity=1, indent=0):455 build_tree("Iron Bar", quantity, indent)456 indent += 1457 iron_ore(quantity, indent)458 shale_rock(quantity, indent)459def iron_ore(quantity=1, indent=0):460 build_tree("Iron Ore", quantity, indent)461def shale_rock(quantity=1, indent=0):462 build_tree("Shale Rock", quantity, indent)463def pine_shingle(quantity=1, indent=0):464 build_tree("Pine Shingle", quantity, indent)465 indent += 1466 white_pine(ceil(quantity/5.0), indent)467def pine_guild_roof(quantity=1, indent=0):468 build_tree("Pine Guild Roof", quantity, indent)469 indent += 1470 black_ash(quantity*10, indent)471 iron_nail(quantity*1500, indent)472 limestone(quantity*220, indent)473 pine_shingle(quantity*1250, indent)474def black_ash(quantity=1, indent=0):475 build_tree("Black Ash", quantity, indent)476def limestone(quantity=1, indent=0):477 build_tree("Limestone", quantity, indent)478def pine_guild_wall(quantity=1, indent=0):479 build_tree("Pine Guild Wall", quantity, indent)480 indent += 1481 iron_nail(quantity*900, indent)482 limestone(quantity*120, indent)483 pine_lumber(quantity*250, indent)484def base_guild_wing_pine(quantity=1, indent=0):485 build_tree("Base Guild Wing (Pine)", quantity, indent)486 indent += 1487 aspen_lumber(quantity*14, indent)488 iron_nail(quantity*80, indent)489 pine_guild_roof(quantity, indent)490 pine_guild_wall(quantity*3, indent)491def pine_building_roof(quantity=1, indent=0):492 build_tree("Pine Building Roof", quantity, indent)493 indent += 1494 pine_lumber(quantity*60, indent)495 chromium_nail(quantity*200, indent)496 pine_shingle(quantity*300, indent)497def vendor_room(quantity=1, indent=0):498 build_tree("Vendor Room", quantity, indent)499 indent += 1500 iron_nail(quantity*100, indent)501 aspen_lumber(quantity*25, indent)502 pine_building_roof(quantity, indent)503 medium_pine_wall(quantity*3, indent)504def pine_building_wall(quantity=1, indent=0):505 build_tree("Pine Building Wall", quantity, indent)506 indent += 1507 chromium_nail(quantity*160, indent)508 pine_lumber(quantity*75, indent)509def polished_small_gem(quantity=1, indent=0):510 build_tree("Polished Small Gem", quantity, indent)511 indent += 1512 small_gem(quantity, indent)513 copper_powder(quantity*2, indent)514def small_gem(quantity=1, indent=0):515 build_tree("Small Gem", quantity, indent)516def polished_large_gem(quantity=1, indent=0):517 build_tree("Polished Large Gem", quantity, indent)518 indent += 1519 large_gem(quantity, indent)520 copper_powder(quantity*6, indent)521def large_gem(quantity=1, indent=0):522 build_tree("Large Gem", quantity, indent)523 indent += 1524 stone(quantity, indent)525 small_gem(quantity*3, indent)526def polished_large_agate(quantity=1, indent=0):527 build_tree("Polished Large Agate", quantity, indent)528 indent += 1529 copper_powder(quantity*6, indent)530 large_agate(quantity, indent)531def large_agate(quantity=1, indent=0):532 build_tree("Large Agate", quantity, indent)533 indent += 1534 stone(quantity*1, indent)535 agate(quantity*3, indent)536def agate(quantity=1, indent=0):537 build_tree("Agate", quantity, indent)538def enchanting_study(quantity=1, indent=0):539 build_tree("Enchanting Study", quantity, indent)540 indent += 1541 ancient_essence(quantity*16, indent)542 iron_nail(quantity*90, indent)543 aspen_lumber(quantity*35, indent)544 pine_building_wall(quantity, indent)545 pine_building_roof(quantity, indent)546 medium_pine_wall(quantity*2, indent)547def ancient_essence(quantity=1, indent=0):548 build_tree("Ancient Essence", quantity, indent)549def inscription_library(quantity=1, indent=0):550 build_tree("Inscription Library", quantity, indent)551 indent += 1552 iron_nail(quantity*90, indent)553 ancient_book(quantity*10, indent)554 archaic_rune(quantity*10, indent)555 aspen_lumber(quantity*35, indent)556 pine_building_wall(quantity, indent)557 pine_building_roof(quantity, indent)558 medium_pine_wall(quantity*2, indent)559def reinforced_pine_wall(quantity=1, indent=0):560 build_tree("Reinforced Pine Wall", quantity, indent)561 indent += 1562 limestone(quantity*160, indent)563 black_ash(quantity, indent)564 iron_nail(quantity*300, indent)565 pine_lumber(quantity*160, indent)566def alchemy_lab(quantity=1, indent=0):567 build_tree("Alchemy Lab", quantity, indent)568 indent += 1569 ancientbloom(quantity*20, indent)570 iron_nail(quantity*90, indent)571 aspen_lumber(quantity*30, indent)572 pine_building_wall(quantity, indent)573 pine_building_roof(quantity, indent)574 medium_pine_wall(quantity*2, indent)575def ancientbloom(quantity=1, indent=0):576 build_tree("Ancientbloom", quantity, indent)577def workshop(quantity=1, indent=0):578 build_tree("Workshop", quantity, indent)579 indent += 1580 black_ash(quantity*10, indent)581 iron_nail(quantity*100, indent)582 aspen_lumber(quantity*10, indent)583 pine_building_roof(quantity, indent)584 reinforced_pine_wall(quantity*3, indent)585def blacksmith(quantity=1, indent=0):586 build_tree("Blacksmith", quantity, indent)587 indent += 1588 golemite_ore(quantity*10, indent)589 iron_nail(quantity*100, indent)590 aspen_lumber(quantity*10, indent)591 pine_building_roof(quantity, indent)592 reinforced_pine_wall(quantity*3, indent)593def golemite_ore(quantity=1, indent=0):594 build_tree("Golemite Ore", quantity, indent)595def cedar_lumber(quantity=1, indent=0):596 build_tree("Cedar Lumber", quantity, indent)597 indent += 1598 red_cedar(ceil(quantity/2.0), indent)599def red_cedar(quantity=1, indent=0):600 build_tree("Red Cedar", quantity, indent)601def black_spruce_lumber(quantity=1, indent=0):602 build_tree("Black Spruce Lumber", quantity, indent)603 indent += 1604 black_spruce(ceil(quantity/2.0), indent)605def black_spruce(quantity=1, indent=0):606 build_tree("Black Spruce", quantity, indent)607def medium_cedar_wall(quantity=1, indent=0):608 build_tree("Medium Cedar Wall", quantity, indent)609 indent += 1610 iron_nail(quantity*180, indent)611 black_spruce_lumber(quantity*24, indent)612 cedar_lumber(quantity*130, indent)613def medium_cedar_container(quantity=1, indent=0):614 build_tree("Medium Cedar Container", quantity, indent)615 indent += 1616 iron_nail(quantity*60, indent)617 cedar_lumber(quantity*24, indent)618 medium_cedar_wall(quantity*6, indent)619def guild_hall_bank(quantity=1, indent=0):620 build_tree("Guild Hall Bank", quantity, indent)621 indent += 1622 iron_nail(quantity*100, indent)623 medium_cedar_container(quantity*4, indent)624 aspen_lumber(quantity*14, indent)625 pine_building_roof(quantity, indent)626 reinforced_pine_wall(quantity*3, indent)627def huge_gem(quantity=1, indent=0):628 build_tree("Huge Gem", quantity, indent)629 indent += 1630 large_gem(quantity*3, indent)631 stone(quantity*6, indent)632def copper_ring_common(quantity=1, indent=0):633 build_tree("Copper Ring (Common+)", quantity, indent)634 indent += 1635 huge_gem(quantity, indent)636 copper_band(quantity, indent)637def tin_bar(quantity=1, indent=0):638 build_tree("Tin Bar", quantity, indent)639 indent += 1640 sandstone(quantity, indent)641 tin_ore(quantity, indent)642def sandstone(quantity=1, indent=0):643 build_tree("Sandstone", quantity, indent)644def tin_ore(quantity=1, indent=0):645 build_tree("Tin Ore]x%d", quantity, indent)646def thick_iron_bar(quantity=1, indent=0):647 build_tree("Thick Iron Bar", quantity, indent)648 indent += 1649 shale_rock(quantity*5, indent)650 iron_bar(quantity*5, indent)651def golemite_bar(quantity=1, indent=0):652 build_tree("Golemite Bar", quantity, indent)653 indent += 1654 copper_bar(quantity*2, indent)655 golemite_ore(quantity*3, indent)656 tin_bar(quantity*4, indent)657 iron_bar(quantity*4, indent)658def cast_iron_pot(quantity=1, indent=0):659 build_tree("Cast Iron Pot", quantity, indent)660 indent += 1661 thick_iron_bar(quantity*10, indent)662 golemite_bar(quantity*2, indent)663def birch_lumber(quantity=1, indent=0):664 build_tree("Birch Lumber", quantity, indent)665 indent += 1666 light_birch(ceil(quantity/2.0), indent)667def copper_nail(quantity=1, indent=0):668 build_tree("Copper Nail", quantity, indent)669 indent += 1670 copper_bar(ceil(quantity/15.0), indent)671def birch_container_wall(quantity=1, indent=0):672 build_tree("Birch Container Wall", quantity, indent)673 indent += 1674 birch_lumber(quantity*60, indent)675 copper_nail(quantity*200, indent)676def small_birch_container(quantity=1, indent=0):677 build_tree("Small Birch Container", quantity, indent)678 indent += 1679 birch_container_wall(quantity*6, indent)680 birch_lumber(quantity*16, indent)681 copper_nail(quantity*30, indent)682def cooking_hall(quantity=1, indent=0):683 build_tree("Cooking Hall", quantity, indent)684 indent += 1685 iron_nail(quantity*60, indent)686 aspen_lumber(quantity*30, indent)687 pine_building_wall(quantity, indent)688 pine_building_roof(quantity, indent)689 medium_pine_wall(quantity*2, indent)690 cast_iron_pot(quantity*4, indent)691def large_citrine(quantity=1, indent=0):692 build_tree("Large Citrine", quantity, indent)693 indent += 1694 shale_rock(quantity*2, indent)695 citrine(quantity*3, indent)696def citrine(quantity=1, indent=0):697 build_tree("Citrine", quantity, indent)698def huge_citrine(quantity=1, indent=0):699 build_tree("Huge Citrine", quantity, indent)700 indent += 1701 shale_rock(quantity*6, indent)702 large_citrine(quantity*3, indent)703def huge_malachite(quantity=1, indent=0):704 build_tree("Huge Malachite", quantity, indent)705 indent += 1706 slate(quantity*6, indent)707 large_malachite(quantity*3, indent)708def large_malachite(quantity=1, indent=0):709 build_tree("Large Malachite", quantity, indent)710 indent += 1711 slate(quantity*2, indent)712 malachite(quantity*3, indent)713def malachite(quantity=1, indent=0):714 build_tree("Malachite", quantity, indent)715def slate(quantity=1, indent=0):716 build_tree("Slate", quantity, indent)717def jewelry_room(quantity=1, indent=0):718 build_tree("Jewelry Room", quantity, indent)719 indent += 1720 iron_nail(quantity*100, indent)721 huge_citrine(quantity*3, indent)722 huge_malachite(quantity*5, indent)723 aspen_lumber(quantity*10, indent)724 pine_building_wall(quantity, indent)725 pine_building_roof(quantity, indent)726 reinforced_pine_wall(quantity*2, indent)727def party_cake(quantity=1, indent=0):728 build_tree("Party Cake", quantity, indent)729 indent += 1730 rosemary(quantity*50, indent)731 salt(quantity*12, indent)732 honey(quantity*15, indent)733 flax(quantity*25, indent)734def rosemary(quantity=1, indent=0):735 build_tree("Rosemary", quantity, indent)736def salt(quantity=1, indent=0):737 build_tree("Salt", quantity, indent)738def honey(quantity=1, indent=0):739 build_tree("Honey", quantity, indent)740def flax(quantity=1, indent=0):741 build_tree("Flax", quantity, indent)742def basic_book(quantity=1, indent=0):743 build_tree("Basic Book", quantity, indent)744 indent += 1745 midnight_ink(quantity*3, indent)746 basic_chapter(quantity*5, indent)747def midnight_ink(quantity=1, indent=0):748 build_tree("Midnight Ink", quantity, indent)749 indent += 1750 midnight_berry(ceil((quantity*3)/4.0), indent)751 squid(ceil(quantity/4.0), indent)752 egg(ceil((quantity*2)/4.0), indent)753 honey(ceil(quantity/4.0), indent)754def basic_chapter(quantity=1, indent=0):755 build_tree("Basic Chapter", quantity, indent)756 indent += 1757 basic_writings(quantity*7, indent)758 midnight_ink(quantity*2, indent)759def midnight_berry(quantity=1, indent=0):760 build_tree("Midnight Berry", quantity, indent)761def squid(quantity=1, indent=0):762 build_tree("Squid", quantity, indent)763def egg(quantity=1, indent=0):764 build_tree("Egg", quantity, indent)765def basic_reference_book(quantity=1, indent=0):766 build_tree("Basic Reference Book", quantity, indent)767 indent += 1768 midnight_ink(quantity*2, indent)769 basic_book(quantity, indent)770 basic_reference(quantity*6, indent)771def basic_formation(quantity=1, indent=0):772 build_tree("Basic Formation", quantity, indent)773 indent += 1774 basic_rune(quantity*3, indent)775 minor_etching(quantity*5, indent)776def basic_markings(quantity=1, indent=0):777 build_tree("Basic Markings", quantity, indent)778 indent += 1779 superb_etching(quantity, indent)780 basic_formation(quantity, indent)781def rough_parchment(quantity=1, indent=0):782 build_tree("Rough Parchment", quantity, indent)783 indent += 1784 basic_parchment(quantity*3, indent)785def common_weapon_enchant(quantity=1, indent=0):786 build_tree("Common Weapon Enchant", quantity, indent)787 indent += 1788 simple_dust(quantity*4, indent)789def simple_dust(quantity=1, indent=0):790 build_tree("Simple Dust", quantity, indent)791def weapon_enchant_rare(quantity=1, indent=0):792 build_tree("Weapon Enchant (Rare+)", quantity, indent)793 indent += 1794 arcane_powder(quantity*4, indent)795 mystic_essence(quantity*4, indent)796def arcane_powder(quantity=1, indent=0):797 build_tree("Arcane Powder", quantity, indent)798def mystic_essence(quantity=1, indent=0):799 build_tree("Mystic Essence", quantity, indent)800def dragontear_oil(quantity=1, indent=0):801 build_tree("Dragontear Oil", quantity, indent)802 indent += 1803 dragontear(quantity*4, indent)804def dragontear(quantity=1, indent=0):805 build_tree("Dragontear", quantity, indent)806def ancientbloom_oil(quantity=1, indent=0):807 build_tree("Ancientbloom Oil", quantity, indent)808 indent += 1809 ancientbloom(quantity*4, indent)810def kingsbloom(quantity=1, indent=0):811 build_tree("Kingsbloom", quantity, indent)812def angelflower(quantity=1, indent=0):...
bst_tests.py
Source:bst_tests.py
...4"""Tests for linked_list.py"""5class TestTree(unittest.TestCase):6 def test_insert(self):7 alist = []8 tree = build_tree(alist)9 tree[8] = 'black'10 self.assertEqual('black', tree.val)11 self.assertEqual(8, tree.key)12 self.assertEqual(tree.left, None)13 tree[5] = 'yellow'14 tree[20] = 'blue'15 self.assertEqual((8, 5, 20, None, None), (tree.key, tree.left.key,16 tree.right.key, tree.left.left, tree.right.right))17 self.assertEqual(('black', 'yellow', 'blue', None, None), (tree.val, tree.left.val,18 tree.right.val, tree.left.left, tree.right.right))19 def test_contains(self):20 alist = [(8, 'black'), (5, 'yellow'), (20, 'blue')]21 tree = build_tree(alist)22 self.assertFalse(30 in tree)23 self.assertTrue(20 in tree)24 alist = []25 tree = build_tree(alist)26 self.assertFalse(8 in tree)27 def test_size(self):28 alist = [(8, 'black'), (5, 'yellow'), (20, 'blue')]29 tree = build_tree(alist)30 self.assertEqual(tree.size, 3)31 tree[40] = 'brown'32 self.assertEqual(tree.size, 4)33 alist = []34 tree = build_tree(alist)35 self.assertEqual(tree.size, 0)36 def test_height(self):37 alist = [(8, 'black'), (5, 'yellow'), (20, 'blue')]38 tree = build_tree(alist)39 self.assertEqual(tree.height(), 1)40 tree[40] = 'brown'41 self.assertEqual(tree.height(), 2)42 tree[50] = 'orange'43 tree[80] = 'green'44 self.assertEqual(tree.height(), 4)45 tree[6] = 'white'46 self.assertEqual(tree.height(), 4)47 alist = []48 tree = build_tree(alist)49 self.assertEqual(tree.height(), -1)50 def test_get_balance_factor(self):51 alist = [(8, 'black'), (5, 'yellow'), (20, 'blue')]52 tree = build_tree(alist)53 self.assertEqual(tree.get_balance_factor(), 0)54 tree[40] = 'brown'55 self.assertEqual(tree.get_balance_factor(), -1)56 tree[3] = 'orange'57 tree[2] = 'green'58 self.assertEqual(tree.get_balance_factor(), 1)59 def test_in_order(self):60 alist = [(8, 'black'), (5, 'yellow'),61 (20, 'blue'), (15, 'brown'),62 (3, 'orange'), (2, 'green'),63 (6, 'white'), (25, 'gold')]64 tree = build_tree(alist)65 self.assertListEqual(list(tree.in_order()), [(2, 'green'),66 (3, 'orange'),67 (5, 'yellow'),68 (6, 'white'),69 (8, 'black'),70 (15, 'brown'),71 (20, 'blue'),72 (25, 'gold')])73 alist = []74 tree = build_tree(alist)75 self.assertListEqual(list(tree.in_order()), [])76 def test_pre_order(self):77 alist = [(8, 'black'), (5, 'yellow'),78 (20, 'blue'), (15, 'brown'),79 (3, 'orange'), (2, 'green'),80 (6, 'white'), (25, 'gold')]81 tree = build_tree(alist)82 self.assertListEqual(list(tree.pre_order()), [(8, 'black'),83 (5, 'yellow'),84 (3, 'orange'),85 (2, 'green'),86 (6, 'white'),87 (20, 'blue'),88 (15, 'brown'),89 (25, 'gold')])90 def test_post_order(self):91 alist = [(8, 'black'), (5, 'yellow'),92 (20, 'blue'), (15, 'brown'),93 (3, 'orange'), (2, 'green'),94 (6, 'white'), (25, 'gold')]95 tree = build_tree(alist)96 self.assertListEqual(list(tree.post_order()), [(2, 'green'),97 (3, 'orange'),98 (6, 'white'),99 (5, 'yellow'),100 (15, 'brown'),101 (25, 'gold'),102 (20, 'blue'),103 (8, 'black')])104 def test_breadth_first(self):105 alist = [(8, 'black'), (5, 'yellow'),106 (20, 'blue'), (15, 'brown'),107 (3, 'orange'), (2, 'green'),108 (6, 'white'), (25, 'gold')]109 tree = build_tree(alist)110 self.assertListEqual(list(tree.breadth_first()),111 [(8, 'black'),112 (5, 'yellow'),113 (20, 'blue'),114 (3, 'orange'),115 (6, 'white'),116 (15, 'brown'),117 (25, 'gold'),118 (2, 'green')])119 def test_rm_node(self):120 # no descendants121 alist = [(8, 'black'), (5, 'yellow'), (20, 'blue')]122 tree = build_tree(alist)123 del tree[20]124 self.assertListEqual(list(tree.in_order()),125 [(5, 'yellow'), (8, 'black')])126 # one descendant127 alist = [(8, 'black'), (5, 'yellow'), (20, 'blue'), (25, 'gold')]128 tree = build_tree(alist)129 del tree[20]130 self.assertListEqual(list(tree.in_order()),131 [(5, 'yellow'), (8, 'black'), (25, 'gold')])132 # two descendants133 alist = [(8, 'black'), (5, 'yellow'),134 (20, 'blue'), (25, 'gold'),135 (15, 'brown')]136 tree = build_tree(alist)137 del tree[20]138 self.assertListEqual(list(tree.in_order()),139 [(5, 'yellow'), (8, 'black'),140 (15, 'brown'), (25, 'gold')])141def build_tree(alist):142 new_tree = Tree()143 for i in alist:144 new_tree[i[0]] = i[1]145 return new_tree146if __name__ == "__main__":...
problem_644.py
Source:problem_644.py
...13 res.append(self.right.data)14 return res15 def __repr__(self):16 return str(self.data)17def build_tree(*args: Any, size: int = -1, start: int = 0) -> Optional[BinaryNode]:18 if size < 0:19 size = len(args)20 if start >= size or args[start] is None:21 return None22 root = BinaryNode(args[start])23 root.left = build_tree(*args, size=size, start=2 * start + 1)24 root.right = build_tree(*args, size=size, start=2 * start + 2)25 return root26# O(n)27def unival_vs_all_subtrees(root: BinaryNode) -> (int, int):28 if root is None:29 return 0, 030 all_unival_num, all_subtree_num = map(add, unival_vs_all_subtrees(root.left), unival_vs_all_subtrees(root.right))31 is_unival = all_unival_num == all_subtree_num and all(v == root.data for v in root.children_data())32 return all_unival_num + is_unival, all_subtree_num + 133# Basic positive cases34assert unival_vs_all_subtrees(build_tree('A')) == (1, 1)35assert unival_vs_all_subtrees(build_tree('A', 'A')) == (2, 2)36assert unival_vs_all_subtrees(build_tree('A', None, 'A')) == (2, 2)37assert unival_vs_all_subtrees(build_tree('A', 'A', 'A')) == (3, 3)38# Basic negative cases39assert unival_vs_all_subtrees(build_tree('A', 'B')) == (1, 2)40assert unival_vs_all_subtrees(build_tree('A', None, 'B')) == (1, 2)41assert unival_vs_all_subtrees(build_tree('A', 'B', 'A')) == (2, 3)42assert unival_vs_all_subtrees(build_tree('A', 'A', 'B')) == (2, 3)43# Nonadjacent values44assert unival_vs_all_subtrees(build_tree('B', 'B', 'B', 'A', None, None, None, 'A', 'A')) == (4, 6)45# Acceptance cases46assert unival_vs_all_subtrees(build_tree(0, 1, 0, None, None, 1, 0, None, None, None, None, 1, 1)) == (5, 7)47assert unival_vs_all_subtrees(build_tree(5, 1, 5, 5, 5, None, 5)) == (4, 6)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!