Python Forum
Need help with this coding puzzle
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with this coding puzzle
#1
# Here is the problem (and the solution is supposedly hidden in the Python code!)

# Your friend has recommended that you go eat at this restaurant, insisting that they have amazing pasta. When you arrive, you realize that it's not # just amazing...it's arguably the best in the world.

# The problem? Well...it's so commonly requested that they've had to implement a security measure to prevent everyone from ordering it. Looks like
# this is going to be more complicated than you hoped. To actually eat the pasta, you're going to have to figure out what the secret password is.

# After several minutes, your server comes up to you. Your stomach growls. Better figure that password out quickly!

# Ravioli ravioli, what is the formuoli
# Finalized 6/13/18

"""
you may or may not need this
http://www.ssec.wisc.edu/~tomw/java/unicode.html
"""
spaghetti = 0
warming = int(bin(4)[2:])

def roast(nut):
  try:
    herring = str(nut)[1]
    cracker = int(str(nut)[:2])
    barrel = int(str(nut)[0])
    for beef in range(barrel, cracker):
      nut -= cracker
    return nut == cracker
  except:
    herring = "red"
    return False

def boil(fish):
  salmon = [0]*2 + [1] * (fish - 1)
  gill = 2
  while gill ** 2 <= fish:
    if salmon[gill] == 1:
      for fin in range(2, fish//gill + 1):
        salmon[gill*fin] = 0
    gill += 1
  filet = 0
  for cod in range(fish):
    if salmon[cod] == 1:
      filet += cod
  return roast(filet)
  
def salt(crystal): #Spagetii 0
  global warming, spaghetti
  spaghetti = 1 if (crystal/warming != crystal // warming) else crystal // warming
  
def served():
  global spaghetti,warming
  spaghetti = 0
  print("The waiter asks, 'What's the secret code?'")
  while True:
    try:
      pasta = ord(input("You reply: "))
      salt(pasta)
      print(salt)
      if boil(spaghetti):
        
        break
      
      else:
        print(salt)
        print("\nThe waiter is confused.")
        print("'I'm afraid that is not the correct code.'")
        print("You're incredibly hungry, but you don't want to miss out on the opportunity for some incredible pasta.")
        print("Fortunately, the waiter seems to be inviting you to try again, so...")
        
    except:
      print(salt)
      print("\nThe waiter frowns and shakes their head.")
      print("'Sorry, that's not a valid code.  Try again.'")
      print("Whoops! After apologizing...")
      continue
  print("\nThe waiter smiles and nods.")
  print("'We'll have your pasta out right away!'")
  print("Nice! You can finally eat. While you're waiting though, you should probably input your solution into the field below.")

if __name__ == '__main__':
  served()
Reply
#2
You need to reverse-engineer the correct password. Going trough the code you will understand what it does and how it checks that password is correct
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Frog Puzzle Random To Custom MoreMoney 4 280 Mar-26-2024, 08:38 AM
Last Post: MoreMoney
  Slider puzzle captcha resolver, how do this? dw0rd1337 0 3,437 Jan-04-2021, 11:55 PM
Last Post: dw0rd1337
  I code a program to solve puzzle but i can't make it more dynamic. Shahmadhur13 5 2,683 Apr-18-2020, 10:05 AM
Last Post: Shahmadhur13
  how to program robot to pass wise man puzzle steven12341234 0 1,907 Dec-02-2018, 08:31 AM
Last Post: steven12341234

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020