zoukankan      html  css  js  c++  java
  • HackerRank

    So fun! It connects algorithm(regex) with real world usages!

    So basically speaking, C:pointer syntax, #includescanf ypedef; Java: importpublic class syntax ry-catch syntax; Python: def syntaxspecial print syntax.

    And BTW, if you are working on regex problems with Python, this is god-sent: http://pythex.org/

    import re
    
    import io
    import sys
    input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
    
    s = input_stream.readlines()
    s = "
    ".join(s)
    
    pc = '([^/]*[a-zA-Z]+w*|typedef|#include|scanf)'
    pj = '(imports+|publics+class|catchs*[(].*?[)]|System.)'
    pp = '(prints+[w"]+|[(][[]["sw,]+[]][)]|defs+[w]+[(])'
    
    mc = re.findall(pc, s)
    mj = re.findall(pj, s)
    mp = re.findall(pp, s)
    
    bc = len(mc) > 0
    bj = len(mj) > 0
    bp = len(mp) > 0
    if bc:
        print ("C")
    if bj:
        print ("Java")
    if bp:
        print ("Python")
  • 相关阅读:
    文章参考
    选择标识符(identifier)
    linux常见命令2
    Django框架之MVT(1)
    Tornado入门二
    2.Flask-jinjia2模板
    JQuery扩展和事件
    JQuery文档操作
    Jquery学习
    Jquery属性操作(入门二)
  • 原文地址:https://www.cnblogs.com/tonix/p/4548199.html
Copyright © 2011-2022 走看看