Advertisement
Aikiro42

Rain's Task

Nov 25th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. from random import random
  2.  
  3. VALUE = 1
  4. BIN_OP = 2
  5. FN = 3
  6. ASS = 4
  7. DOT = 5
  8.  
  9. # Code formats
  10. code_format = {
  11.     VALUE: '{}',
  12.     BIN_OP: '{} {} {}',
  13.     FN: '{}({})',
  14.     ASS: '{} = {}',
  15.     DOT: '{}.{}'
  16. }
  17.  
  18. # Binary Operations
  19. bin_ops = [
  20.     '+',
  21.     '-',
  22.     '*',
  23.     '/',
  24.     '%',
  25.     '//',
  26.     '**',
  27. ]
  28.  
  29. # I recommend that you add more words to this array
  30. # Preferably technical terms like "Abstraction" or "Parser" or hackerman stuff idk lol
  31. code_dictionary = [
  32.     'thingy',
  33.     'var',
  34.     'foo',
  35.     'bar',
  36.     'something'
  37. ]
  38.  
  39.  
  40. def generate_random_int(min_int, max_int):
  41.     return min_int + (random() * (max_int - min_int))
  42.  
  43.  
  44. something = None
  45.  
  46.  
  47. # Complete this recursive function
  48. # Replace <something> with what it should return - a string.
  49. # Hint 1: You'll be calling generate_random_int() a lot
  50. # Hint 2: Work your way inside out.
  51. def generate_code(nest_depth: int):
  52.     if nest_depth <= 1:
  53.         # Return a value (int, float, bool) or a variable ()
  54.         return something
  55.     else:
  56.         # if-elif statements depending on the generated random number
  57.         return something
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement