Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 849

PLEASE HELP WITH THIS CODING PROBLEM!

by cyphur23719 - 11 March, 2022 - 07:06 PM
This post is by a banned member (cyphur23719) - Unhide
213
Posts
5
Threads
3 Years of service
#1
You are in process of developing a new language with the help of alphabets, numbers, and special characters. You can decide your own sequence of these characters (alphabets, numbers, and special characters) while creating a new language.
Suppose you have created a language sequence as something like "lkahgfswetimncx96345@#) (" and if the user enters any string like "Philacodist 2021" then your code should generate a new word with the help your new sequence by considering the rules mentioned below:
  • If a character in the string is not present in your sequence, then it should eliminate the character from the new word.
  • If that character is present in your sequence, then it should print as it is, but its position in the final word will be different. For e.g. in the example above, h is a part of the language sequence and so are i, l, a, c, s and t. The final new word that will be substitute of "Philacodist 2021" given the sequence "lkahgfswetimncx96345@#) (" is "lahstiic". This example should make it clear, how a matching character should be processed.
  • The sequence should not have characters repeating itself. If any character is repeated in the language sequence, then output should display "New language Error".
  • Alphabets are not case sensitive i.e. you can match the string with sequence in a case-insensitive manner.
  • Space is not a character, so include it in the same place as that in the string that is to be translated.
Examples 
Input
palskdjfieuryt93516247oh
Philacodist 2021
 
Output
palsdiitoh 122
 
Explanation-
On comparison of string with sequence, we find there is no character 'c' in the sequence, so we removed it from the string to be converted. Based on language sequence the characters are arranged to form a new generated word.

TIME LIMIT :- 1sec

Can use:- C/C++/Java/PHP/Python/C#

Need it ASAP please!
This post is by a banned member (UberFuck) - Unhide
UberFuck  
Godlike
1.557
Posts
375
Threads
5 Years of service
#2
Here's your homework kid...
 
Code:
# patternStr = 'lkahgfswetimncx96345@#'
patternStr = 'palskdjfieuryt93516247oh'
inputStr = 'Philacodist 2021'


def processWord(word:str):
    output, prevChar = '', ''
    for s in patternStr:
        for c in word.lower():
            if c == prevChar:
                raise ValueError('sorry, you're a dumbass')
            elif c == s:
                output += s
            prevChar = c
    return output

words = [processWord(s) for s in inputStr.split(' ')]
print(' '.join(words))
This post is by a banned member (cyphur23719) - Unhide
213
Posts
5
Threads
3 Years of service
#3
(11 March, 2022 - 09:27 PM)foxegado Wrote: Show More
Here's your homework kid...
 
Code:
# patternStr = 'lkahgfswetimncx96345@#'
patternStr = 'palskdjfieuryt93516247oh'
inputStr = 'Philacodist 2021'


def processWord(word:str):
    output, prevChar = '', ''
    for s in patternStr:
        for c in word.lower():
            if c == prevChar:
                raise ValueError('sorry, you're a dumbass')
            elif c == s:
                output += s
            prevChar = c
    return output

words = [processWord(s) for s in inputStr.split(' ')]
print(' '.join(words))

thanks bro...I need to take user input tho for the new language sequence and the given word...could you include that too please in your code
This post is by a banned member (UberFuck) - Unhide
UberFuck  
Godlike
1.557
Posts
375
Threads
5 Years of service
#4
(11 March, 2022 - 09:39 PM)cyphur23719 Wrote: Show More
(11 March, 2022 - 09:27 PM)foxegado Wrote: Show More
Here's your homework kid...
 
Code:
# patternStr = 'lkahgfswetimncx96345@#'
patternStr = 'palskdjfieuryt93516247oh'
inputStr = 'Philacodist 2021'


def processWord(word:str):
    output, prevChar = '', ''
    for s in patternStr:
        for c in word.lower():
            if c == prevChar:
                raise ValueError('sorry, you're a dumbass')
            elif c == s:
                output += s
            prevChar = c
    return output

words = [processWord(s) for s in inputStr.split(' ')]
print(' '.join(words))

thanks bro...I need to take user input tho for the new language sequence and the given word...could you include that too please in your code
Code:
patternStr = input('Enter your gay language: ')
inputStr = input('Enter the words you want turned gay: ')


def processWord(word:str):
    output, prevChar = '', ''
    for s in patternStr:
        for c in word.lower():
            if c == prevChar:
                raise ValueError('sorry, you are a dumbass')
            elif c == s:
                output += s
            prevChar = c
    return output

words = [processWord(s) for s in inputStr.split(' ')]
print('Thanks fag, here\'s your new word: ' + ' '.join(words))
This post is by a banned member (cyphur23719) - Unhide
213
Posts
5
Threads
3 Years of service
#5
(11 March, 2022 - 09:47 PM)foxegado Wrote: Show More
(11 March, 2022 - 09:39 PM)cyphur23719 Wrote: Show More
(11 March, 2022 - 09:27 PM)foxegado Wrote: Show More
Here's your homework kid...
 
Code:
# patternStr = 'lkahgfswetimncx96345@#'
patternStr = 'palskdjfieuryt93516247oh'
inputStr = 'Philacodist 2021'


def processWord(word:str):
    output, prevChar = '', ''
    for s in patternStr:
        for c in word.lower():
            if c == prevChar:
                raise ValueError('sorry, you're a dumbass')
            elif c == s:
                output += s
            prevChar = c
    return output

words = [processWord(s) for s in inputStr.split(' ')]
print(' '.join(words))

thanks bro...I need to take user input tho for the new language sequence and the given word...could you include that too please in your code
Code:
patternStr = input('Enter your gay language: ')
inputStr = input('Enter the words you want turned gay: ')


def processWord(word:str):
    output, prevChar = '', ''
    for s in patternStr:
        for c in word.lower():
            if c == prevChar:
                raise ValueError('sorry, you are a dumbass')
            elif c == s:
                output += s
            prevChar = c
    return output

words = [processWord(s) for s in inputStr.split(' ')]
print('Thanks fag, here\'s your new word: ' + ' '.join(words))

Thank you sooo much bro...can you help with this one too pleasee...last one I swear lol https://cracked.io/Thread-Need-help-with...lp-me-ASAP

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)