GithubHelp home page GithubHelp logo

noops-challenge / fizzbot Goto Github PK

View Code? Open in Web Editor NEW
45.0 7.0 123.0 12 KB

Fizzbot has questions for you... so many questions. A FizzBuzz API for you to play with.

Home Page: https://noopschallenge.com/challenges/fizzbot

Ruby 29.75% Python 70.25%
fizzbuzz

fizzbot's Introduction

Meet the Fizzbot

Fizzbot

Dear candidate.

Thank you for your interest.

Here at Noops Headquarters we receive a number of applications for positions in our world-class software development organization.

Unfortunately, we are very busy cooking up new challenges, so we cannot personally repond to each application.

API

Get started at https://api.noopschallenge.com/fizzbot โ€” but do it quickly!

We don't have time for slowpokes around here, and we will grade you on how fast you can solve this challenge.

Fizzbot will give you a series of questions. Solve each one by GETting the question from the provided url and then POSTing the answer back to the same url.

Fizzbot will give you a 200 response if you are correct, and a 400 response if you need to try again. Learn more about HTTP status codes.

Answering a question correctly will give you the path to the next question. When you answer all of the questions correctly, Fizzbot will grade your performance. If you're not happy with your grade, you can always try again to get a better score.

Read the API documentation for more information.

Starters

Get started with Python or Ruby using the included scripts, or start from scratch.

Python

Here are two interactive interactive starter kits, made for Python 3 and Python 2.

Learn how to install Python.

Ruby

This example shows how you might write a bot that can solve the fizzbot challenge automatically.

Check out the Ruby script and try to beat Fizzbot at its own game.

Learn how to install ruby.

Other languages

Do you have a favorite language? We'd love to see your solution.

More about Fizzbot and all of the other Noops here: https://noopschallenge.com/challenges/fizzbot

fizzbot's People

Contributors

daneah avatar davidmfoley avatar doolittle avatar quentinms avatar tomasroj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fizzbot's Issues

fizz3.py errors on run

Output on running the program:

----------------------------------------------------------------------
*** GET /fizzbot
Traceback (most recent call last):
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1016, in _send_output
    self.send(msg)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 956, in send
    self.connect()
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 928, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\socket.py", line 727, in create_connection
    raise err
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\aadibajpai\Desktop\fizz.py", line 76, in <module>
    if __name__ == '__main__': main()
  File "C:\Users\aadibajpai\Desktop\fizz.py", line 74, in main
    question_url = do_question(domain, question_url)
  File "C:\Users\aadibajpai\Desktop\fizz.py", line 60, in do_question
    request = urllib.request.urlopen( ('%s%s' % (domain, question_url)) )
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 525, in open
    response = self._open(req, data)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 543, in _open
    '_open', req)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 1345, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "C:\Users\aadibajpai\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

Not sure how to fix.

Favorite Programming Language incorrect answer

The following request gives me an error:
curl -X POST -d {"answer":"python"} https://api.noopschallenge.com/fizzbot/questions/1

{"message":"Please provide an answer that is a string.","result":"incorrect"}

But I have followed the example response:
"exampleResponse":{"answer":"COBOL"}

What am I missing here?

No access through browser request

The noops API is blocking POST requests made from javascript through the browser. POST request seem to be allowed but the mandatory pre-flight OPTIONS request is not allowed by the server. The following headers are returned by the API:

access-control-allow-methods: GET,HEAD,PUT,PATCH,POST,DELETE
access-control-allow-origin: *

chromenetwork

chromelog

I am making the request as follows:

axios.post(url, options, {
        headers: {
          'Content-type': 'application/application/json',
        },
      }).then(response => {
        console.log(response)
      })

Is there any way to include OPTIONS requests in the allowed methods?

500 Internal server error when posting answer

$ http -v POST https://api.noopschallenge.com/fizzbot/questions/MAGNBflYDdufbSDrUX_sTvZ8MwgPXZ-kQU__q4pP8H4 answer:='[1,2,"Fizz",4,"Buzz","Fizz",7,8,"Fizz","Buzz",11,"Fizz",13,14,"FizzBuzz"]'
POST /fizzbot/questions/MAGNBflYDdufbSDrUX_sTvZ8MwgPXZ-kQU__q4pP8H4 HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 99
Content-Type: application/json
Host: api.noopschallenge.com
User-Agent: HTTPie/1.0.2

{
    "answer": [
        1,
        2,
        "Fizz",
        4,
        "Buzz",
        "Fizz",
        7,
        8,
        "Fizz",
        "Buzz",
        11,
        "Fizz",
        13,
        14,
        "FizzBuzz"
    ]
}

HTTP/1.1 500 Internal Server Error
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 45
Content-Type: application/json; charset=utf-8
Date: Wed, 19 Jun 2019 21:06:30 GMT
ETag: W/"2d-rNKQTDvGLnuBDl7snD1HaRm3E1Q"
Vary: Accept-Encoding
X-Powered-By: Express
cache-control: private, max-age:0

{
    "message": "actual.charAt is not a function"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.