How to use find_recipe method in autotest

Best Python code snippet using autotest_python

day14_chocolate_charts.py

Source: day14_chocolate_charts.py Github

copy

Full Screen

...15 self.scores.append(int(digit))16 self.elf1 = (1 + self.elf1 + self.scores[self.elf1]) % len(self.scores)17 self.elf2 = (1 + self.elf2 + self.scores[self.elf2]) % len(self.scores)18 # end while19 def find_recipe(self, recipe_str):20 found = False21 n_chars = len(recipe_str)22 pattern = [int(i) for i in recipe_str]23 while not found:24 new_recipe = str(self.scores[self.elf1] + self.scores[self.elf2])25 for digit in new_recipe:26 self.scores.append(int(digit))27 curr_score = self.scores[-n_chars:]28 if curr_score == pattern:29 found = True30 break31 32 self.elf1 = (1 + self.elf1 + self.scores[self.elf1]) % len(self.scores)33 self.elf2 = (1 + self.elf2 + self.scores[self.elf2]) % len(self.scores)34 return len(self.scores)-n_chars35 # end while36 def get_scores(self, start, num):37 # print(self.elf1, self.elf2)38 return "".join(map(str, self.scores[start:start+num]))39 def display_scores(self, start, num):40 # print(self.elf1, self.elf2)41 print("".join(map(str, self.scores[start:start+num])))42test = Recipes()43test.add_recipe(20)44assert (test.get_scores(9,10) == "5158916779")45test = Recipes()46assert (test.find_recipe("51589") == 9)47test = Recipes()48assert (test.find_recipe("01245") == 5)49test = Recipes()50assert (test.find_recipe("92510") == 18)51test = Recipes()52assert (test.find_recipe("59414") == 2018)53"""54Total time: 1 sec55"""56START = time.time()57part1 = Recipes()58part1.add_recipe(846601+20)59print(part1.get_scores(846601, 10))60print("Total time = {0:f} ms".format((time.time()-START)*1000))61"""62Total time: 28 secs63"""64START = time.time()65part2 = Recipes()66print(part2.find_recipe("846601"))...

Full Screen

Full Screen

views.py

Source: views.py Github

copy

Full Screen

1from django.shortcuts import render, redirect2from django.urls import reverse3from django.db.models import Q4from book_recipes.models import Recipes, Ingredients5from book_recipes.forms import RecipesFilterForms6def home(request):7 """Главная страница. Редирект на `/​recipes_list`"""8 response = redirect(reverse("recipes_list"))9 return response10def recipes_list(request):11 try:12 find_recipe = request.GET.get("find_recipe")13 except (ValueError, TypeError):14 find_recipe = None15 query = Q()16 if find_recipe:17 query.add(18 Q(pk=find_recipe), Q.AND,19 )20 recs = Recipes.objects.filter(query)21 ingrs = Ingredients.objects.all()22 filter_recipes = RecipesFilterForms()23 filter_ingredients = Ingredients.objects.values('ingredient').distinct()24 return render(request, 'book_recipes/​recipes_list.html', {"recs": recs,25 "ingrs": ingrs,26 "filter_recipes": filter_recipes,27 'filter_ingredients': filter_ingredients,28 })29def search_ingredients(request):30 recs = Recipes.objects.all()31 ingrs = Ingredients.objects.all()32 recipes_list = []33 check_ingrs = request.GET.getlist('check_ingrs')34 for check_ingr in check_ingrs:35 for ingr in ingrs:36 if ingr.ingredient==check_ingr:37 recipes_list.append(ingr.recipes_id)38 recipes_list = list(set(recipes_list))39 return render(request, 'book_recipes/​search_ingredients.html', {'check_ingrs': check_ingrs,40 "ingrs": ingrs,41 "recs": recs,42 "recipes_list": recipes_list,...

Full Screen

Full Screen

day14.py

Source: day14.py Github

copy

Full Screen

...12 s.append(next_recipe)13 i = (i + 1 + s[i]) % len(s)14 j = (j + 1 + s[j]) % len(s)15 return ''.join(str(v) for v in s[n:n+10])16def find_recipe(needle, s=None):17 if s is None:18 s = '37'19 i = 020 j = 121 while s.find(needle, -len(needle) - 2) == -1:22 si = int(s[i])23 sj = int(s[j])24 next_recipe = si + sj25 s += str(next_recipe)26 i = (i + 1 + si) % len(s)27 j = (j + 1 + sj) % len(s)28 return s.find(needle)29if __name__ == '__main__':30 from aocd.models import Puzzle31 assert get_recipes(9) == '5158916779'32 assert get_recipes(5) == '0124515891'33 assert get_recipes(18) == '9251071085'34 assert get_recipes(2018) == '5941429882'35 assert find_recipe('51589') == 936 assert find_recipe('01245') == 537 assert find_recipe('92510') == 1838 assert find_recipe('59414') == 201839 puz = Puzzle(2018, 14)40 puz.answer_a = get_recipes(int(puz.input_data))41 print(f'Part 1: {puz.answer_a}')42 puz.answer_b = find_recipe(puz.input_data)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful