Daily Challenge #69

So, today’s daily challenge is from me.

It will be very simple. Today, you will have to make a procedure that asks for one input.

It has to be a string!

The procedure should do:

  • know which is the first and the last number
  • then keep the first and last number, but
  • make all the other letters in between randomly posed again.

See examples:

Hope you will have fun koding!

Yoshi :stuck_out_tongue_winking_eye:

PS: your inputs for me:

"example", “test”, “LOL” and "Me"

PPS:
And yes, I know the creator.kodular site is down but let’s hope it will be ready for us soon!
Creator not working
:smiling_face_with_three_hearts: :innocent:

I don’t really understand

1 Like

See examples please.

Is “3” means point 3?

1 Like

Yes, silly me. Will edit it. :unamused:

I finally did it, but mine is extremely complicated cuz I don’t know how to simplify it.

It is really complicated but it worked.

1 Like

That’s all, but for the Solution, I will mark the one as Solutio that has the fewest. So, for now, yours. :wink:

So according to your instructions one possible solution could also be the word “example”. The procedure will keep the first and last letters the same and all the between will be in random places. In that case the random places happens to create the same word as given. Correct?

1 Like

Your answer…

My solution

Python:

import random

n = input()

def randomizeLetters(x):
    if len(x)>2:
        newList = list(x)
        newList.pop(0)
        newList.pop(-1)
        random.shuffle(newList)
        return newList
    else:
        return ""

def listToString(listQ):
    output = ""
    for elem in listQ:
        output+=elem
    return output


if len(n)<2:print("ERROR")
else:print(n[0]+listToString(randomizeLetters(n))+n[-1])

Kodular

3 Likes

What’s with these?

:rofl: :wink:

Anyway, I see it’s right. Nice!

Actually this is my first time doing daily challenge, feeling excited! :laughing:

What does your procedure return for “2323”?

23
Um… the return is quite strange

Should return an error.

That’s actually two procedures :rofl:

Of course, I could’ve put it in one, which would make the blocks amount much less, but I wanted so people can understand what I am doing step-by-step.

1 Like

I know that’s why I put :rofl:. It’s a joke.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.