Skip to content

Instantly share code, notes, and snippets.

@yuheiomori
Created August 16, 2014 04:34
Show Gist options
  • Save yuheiomori/8e2333c06c2b5328de6f to your computer and use it in GitHub Desktop.
Save yuheiomori/8e2333c06c2b5328de6f to your computer and use it in GitHub Desktop.
Roller Coaster (CodeEval) in Python 3.x
# coding=utf-8
import sys
def main():
with open(sys.argv[1], "r") as f:
for line in f:
upper_flg = True
for s in line:
if s.isalpha():
if upper_flg:
sys.stdout.write(s.upper())
else:
sys.stdout.write(s.lower())
upper_flg = not upper_flg
else:
sys.stdout.write(s)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment