We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Data Structures
  3. Stacks
  4. Simple Text Editor
  5. Discussions

Simple Text Editor

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • Freak_1231 3 years ago+ 0 comments

    can't get any shorter i guess

    dic={0:''};order=0;s=''
    for i in range(int(input())):
      t=[_ for _ in input().strip().split()]
      if t[0]=='1':order+=1;s+=t[1];dic[order]=s
        
      elif t[0]=='3':print(s[int(t[1])-1])
      
      elif t[0]=='2':s=s[:len(s)-int(t[1])];order+=1;dic[order]=s
      
      elif t[0]=='4':order-=1;s=dic[order]
    
    2|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature