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.
  • Hackerrank Home
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Implementation
  4. Encryption
  5. Discussions

Encryption

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1110 Discussions, By:

votes

Please Login in order to post a comment

  • Schuetzl
    6 years ago+ 57 comments

    I see a lot of people in the discussions are using a 2d array, did anyone else solve it by simply iterating through the input string? Is there a difference in efficiency? All of my submissions were 0.09s of quicker (using Java). Is there a better way to do it?

    59|
    Permalink
    View more Comments..
  • samar5yadav
    5 years ago+ 10 comments
    import math
    s=input()
    sm=s.replace(" ","")
    r=math.floor(math.sqrt(len(sm)))
    c=math.ceil(math.sqrt(len(sm)))
    for i in range(c):
        print(sm[i::c],end=" ")
    

    short and sweet. that's why you gotta love python

    58|
    Permalink
    View more Comments..
  • saurabh_jasper
    4 years ago+ 19 comments

    image

    image

    why is this happening?

    23|
    Permalink
    View more Comments..
  • sujithvm
    6 years ago+ 12 comments

    http://ideone.com/1zvv4T

    This is the solution i submitted. Can anyone please tell me why ideone is giving correct answer for TestCase 1 and Hackerrank is giving a different answer. No difference in code

    TestCase : feedthedog
    Ideone output : fto ehg ee dd
    Hackerrank editor output : fto ehg ee
    
    11|
    Permalink
    View more Comments..
  • yashzawar2000
    1 year ago+ 1 comment
    def encryption(s):
        c = math.ceil(math.sqrt(len(s)))
    
        p = ' '.join(map(lambda x: s[x::c], range(c)))
    
        return p
    
    10|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature