GITLAB

Miguel Barão / perguntations

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 1
  • Merge Requests 0
  • Wiki
  • perguntations
  • demo
  • correct-question.py
  • a54bd1fd   - corrected bugs in demo/ files. ... Browse Code »
    - textarea, text and text_regex now remember last answer on practice
      mode.
    Miguel Barao
    2015-05-29 18:30:50 +0100  
correct-question.py 301 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/env python3.4

import re
import sys

s = sys.stdin.read()

# set of words converted to lowercase lowercase
answer = set(re.findall(r'[\w]+', s.lower()))

# correct set of colors
rgb_colors = set(['red', 'green', 'blue'])

if answer == rgb_colors:
    print(1.0)
else:
    print(0.0)
exit(0)