I find it hard implementing a function which replaces the 'chars' with the alphabetically corresponding 'periodic table' element

convert recursive to iterative using stack
recursion java
tail recursion
recursive function
recursion vs iteration
how to write a shell in c using fork() and execv()
making your own linux shell in c
how to create your own shell in linux
from random import choice, choices, randint


def periodic_table_word_char(word):
    chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    periodic_table = ['Ac','Ag','Al','Am','Ar','As','At','Au','B','Ba','Be','Bh','Bi','Bk','Br','C','Ca','Cd','Ce','Cf','Cl','Cm','Cn','Co','Cr','Cs','Cu','Db','Ds','Dy','Er','Es','Eu','F','Fe','Fl','Fm','Fr','Ga','Gd','Ge','H ','He ','Hf','Hg','Ho','Hs','I','In','Ir','K','Kr','La','Li','Lr','Lu','Lv','Mc','Md','Mg','Mn','Mo','Mt','N','Na','Nb','Nd','Ne','Nh','Ni','No','Np','O','Og','Os','P','Pa','Pb','Pd','Pm','Po','Pr','Pt','Pu','Ra','Rb','Re','Rf','Rg','Rh','Rn','Ru','S','Sb','Sc','Se','Sg','Si','Sm','Sn ','Sr','Ta','Tb','Tc','Te','Th','Ti','Tl','Tm','Ts','U','V','W','Xe','Y','Yb','Zn','Zr']

    #word_modified = word.replace(chars, periodic_table)

The above is a sort of idea I had, but I don't know how to implement it right so the character is replaced alphabetically by the element in the 'periodic_table'

    print(word_modified)


if __name__ == '__main__':
    w = input("Enter any word:")
    periodic_table_word_char(w)

You need a one-to-many mapping, so use a dictionary that maps each character to all the elements that start with that character. Then you can make a random choice among the values a character maps to.

Example:

import random
table = {'a': (1,2,3), 'b': (4,5), 'c': (6,7,8)}
for c in "aaabbbc":
    print(random.choice(table[c]))

Boundary Elements: Implementation and Analysis of Advanced , as in the Section 3.1 but with Treplaced by [0,2T and k replaced by the identity mapping. For [0,27] The finite element basis function p' is given over {t}_1, t'll] by p'(s) = p(s/hl – k) with {-n if |s|< 1 g(s) 0 else, (22) (cf. It is not hard to see (cf. DataCleanUp() Function Implementation in MS SQL Server We have been getting questions at Transact-SQL forum several times to remove unwanted characters from string. So i have decided to write a DataCleanUp function which replaces the unwanted character from String. DataCleanUp ( String1, InvalidCharacters)

You could do something like this:

import random
random.seed(42)


periodic_table = ['Ac', 'Ag', 'Al', 'Am', 'Ar', 'As', 'At', 'Au', 'B', 'Ba', 'Be', 'Bh', 'Bi', 'Bk', 'Br', 'C',
                  'Ca', 'Cd', 'Ce', 'Cf', 'Cl', 'Cm', 'Cn', 'Co', 'Cr', 'Cs', 'Cu', 'Db', 'Ds', 'Dy', 'Er', 'Es',
                  'Eu', 'F', 'Fe', 'Fl', 'Fm', 'Fr', 'Ga', 'Gd', 'Ge', 'H ', 'He ', 'Hf', 'Hg', 'Ho', 'Hs', 'I',
                  'In', 'Ir', 'K', 'Kr', 'La', 'Li', 'Lr', 'Lu', 'Lv', 'Mc', 'Md', 'Mg', 'Mn', 'Mo', 'Mt', 'N',
                  'Na', 'Nb', 'Nd', 'Ne', 'Nh', 'Ni', 'No', 'Np', 'O', 'Og', 'Os', 'P', 'Pa', 'Pb', 'Pd', 'Pm',
                  'Po', 'Pr', 'Pt', 'Pu', 'Ra', 'Rb', 'Re', 'Rf', 'Rg', 'Rh', 'Rn', 'Ru', 'S', 'Sb', 'Sc', 'Se',
                  'Sg', 'Si', 'Sm', 'Sn ', 'Sr', 'Ta', 'Tb', 'Tc', 'Te', 'Th', 'Ti', 'Tl', 'Tm', 'Ts', 'U', 'V',
                  'W', 'Xe', 'Y', 'Yb', 'Zn', 'Zr']

to_element = {}
for element in periodic_table:
    to_element.setdefault(element[0].lower(), []).append(element)

def periodic_table_word_char(word):
    return ''.join(random.choice(to_element.get(c, [c])) for c in word)


result = periodic_table_word_char('agriculture')
print(result)

Output

AgGaRgICeULaTsURnEr

The idea is that to_element is a mapping from letters to elements, then you can use that mapping to choose the corresponding elements for each letter.

Advances in Artificial Life: 8th European Conference, ECAL 2005, , 7.1 Difficult Rows and Favoured Errors Experiments were run on the 1-bit adder, For each favoured error, a new truth table was formed by replacing the ablated functions, evolution was able to find a smaller circuit which implemented the  Find and replace functions handle find and replace operations. They cover basic functionality, such as finding the next instance of a search pattern, and complex replacement operations that require no user interaction. Finds the next instance of the search string that was specified previously by

building on molbdnilo

import random
table = {'a': (1,2,3), 'b': (4,5), 'c': (6,7,8)}
ns = ''
for c in "aaabbbc":
    ns+=str(random.choice(table[c]))

print(ns)

Fuzzy Databases: Modeling, Design and Implementation: Modeling, , Data: Traditional database and fuzzy metaknowledge base (see Chapter V). Summarizing, the translation function replaces the fuzzy attributes of the SELECT​  In this session today we will be implementing find and replace functionality in php.Here we will be creating a form which will have an text area , search box , replace box and an find and replace button . For implementing find and replace functionality in php follow the steps given below : First of …

So, I think the best way to do this is to actually create a list of lists, where each sublist has elements that start with the same letter. As in:

periodic_table = [ ["Ac", "Ag", "Al", "Am", "Ar", "As", "At", "Au"], ["B", "Ba", "Be", "Bh", "Bi", "Bk", "Br"], ... ]

Since you have a mapping of letters to first letters of elements already, you know how to index into the outer list (alphabetical ordering). So, if you wanted all elements that started with "A", you could do

elementsStartingWithA = periodic_table[0]

Then you need to generate a random number between 0 and the length of your smaller list, and exchange the letter you're looking up your function's input with the corresponding random string value from the smaller list. So, if your input word was the article a and your randomly generated index into elementsStartingWithA was the integer 3, you'd return the string Am.

Agile Virtual Enterprises: Implementation and Management Support: , Thus, auction trading functions add the functionality of straight auctions and Exchange e-markets also can be of help to find hard-to-find parts, or parts that are  The easiest way to do that is to pass all the arguments to a helper function which does the shifting. That way the shifts will be local to that function call and won't modify the top-level script arguments. (Functions get their own $1, $2, etc.) – John Kugelman Feb 25 '15 at 14:31

Microsoft Interview Question: Implement a Find-Replace func , Implement a Find-Replace function given a string of text. , search string, and replace string. Also a seemingly simple question became very difficult and complex  I try to code my own version of replace but it doesn't work. I hope somebody can help me out. It only replaces the first char!. Why I don't use the public string.replace function? Well I love implementing string functions :-). I coded another function for replacing chars in a word and this function works! Thank you for any help Use:

Chilton Tractor & Implement Journal, factory or service station or replace with a new one. \Vhen installing a new fibre lever, care should be taken to see that the spring is The function of an impulse starter is to facilitate easy starting of the tractor engine with a minimum of effort. The REPLACE function is one way to quickly correct this situation as shown in the example in the image above. This is especially true when long columns of imported data need correcting since it is possible to use the fill handle or copy and paste to copy the REPLACE function to multiple cells in the worksheet.

Farm Implement News, The speaker explained the origin and functions of the federal reserve banks, that deep cultivation with a six-shovel cultivator might be hard on the horses, If the superintendent of the schools is incompetent or lazy, see that he is replaced. Recursion is not hard: a step-by-step walkthrough of this useful programming technique. I’m going to say this right off the bat. Do you know the events that happen upon function invocation? No? Then that’s where we will start. Function invocation. When we call a function, an execution context gets placed on the execution stack.

Comments
  • what is the correspondence between items in chars and in periodic_table? The second has much more elements.
  • Trying to understand the problem, are you trying to make it so that the user could input 'a' and get back 'Ac'?
  • Also why are you importing all those functions from random?
  • the imports were there because of initial ideas, the idea i have is for a 'filter' that replaces a character i.e. 'a' with Au or As or Ag. Would be cool if it could choose it depending on more than one word i.e. the word 'agriculture' being replaced with 'AgRhICuLiTiURhEr' based on the periodic table
  • So you want to replace the letter with a random element that stars with that letter?