scramble

Puzzle Solving: Finding All Words Within a Larger Word in PHP

最后都变了- 提交于 2019-11-28 05:38:40
问题 So I have a database of words between 3 and 20 characters long. I want to code something in PHP that finds all of the smaller words that are contained within a larger word. For example, in the word "inward" there are the words "rain", "win", "rid", etc. At first I thought about adding a field to the Words tables (Words3 through Words20, denoting the number of letters in the words), something like "LetterCount"... for example, "rally" would be represented as 10000000000200000100000010: 1

Are there any ways to scramble strings in python?

与世无争的帅哥 提交于 2019-11-27 06:49:28
问题 I'm writing a program and I need to scramble the letters of string s from a list in python. For instance I have a list of string s like: l = ['foo', 'biology', 'sequence'] And I want something like this: l = ['ofo', 'lbyoogil', 'qceeenus'] What is the best way to do it? Thanks for your help! 回答1: Python has batteries included.. >>> from random import shuffle >>> def shuffle_word(word): ... word = list(word) ... shuffle(word) ... return ''.join(word) A list comprehension is an easy way to