choice

python -> combinations of numbers and letters

為{幸葍}努か 提交于 2019-12-01 01:43:43
#!/usr/bin/python import random lower_a = ['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'] upper_a = ['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'] num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] all = [] all = " ".join("".join(lower_a) + "".join(upper_a) + "".join(num)) all = all.split() x = 1 c = 1 while x < 10: y = [] for i in range(c): a = random.choice(all) y.append(a) print "".join(y) x += 1 c += 1 what i have now

Sampling without replacement from a given non-uniform distribution in TensorFlow

萝らか妹 提交于 2019-12-01 00:41:47
问题 I'm looking for something similar to numpy.random.choice(range(3),replacement=False,size=2,p=[0.1,0.2,0.7]) in TensorFlow. The closest Op to it seems to be tf.multinomial(tf.log(p)) which takes logits as input but it can't sample without replacement. Is there any other way to do sampling from a non-uniform distribution in TensorFlow? Thanks. 回答1: You could just use tf.py_func to wrap numpy.random.choice and make it available as a TensorFlow op: a = tf.placeholder(tf.float32) size = tf

Random weighted selection of an event [duplicate]

拟墨画扇 提交于 2019-11-30 19:32:59
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Generating random results by weight in PHP? i have made a database in which i store the name and the link of rss feeds.i have made the rss reader and everything is ok till now.I want to make a news scroller which will show the articles of the feeds.But i want to give to the feeds some weight values in order every feed to be selected according to its importance for me and automatically when a feed is selected

Symfony2 how to render Checkboxes?

梦想的初衷 提交于 2019-11-30 15:49:14
I have a formbuilder form with a multiple choice list of countries. When I render them on my form like this: {{ form_widget(edit_form.countries) }} They appear like this: <input type="checkbox" name="..." value="AD" /><label for="...">Andorra</label> <input type="checkbox" name="..." value="AE" /><label for="...">United Arab Emirates</label> <input type="checkbox" name="..." value="AF" /><label for="...">Afghanistan</label> I would like each option displayed on it's own line in the browser, instead of all in a row. How can I inject html around or between the options? Or is there a CSS method

Batch file 'choice' command's errorlevel returns 0

大憨熊 提交于 2019-11-30 14:20:47
I'm trying to create a batch file that performs different 'choice' command based on the version of Windows being executed on. The choice command's syntax is different between Windows 7 and Windows XP. Choice command returns a 1 for Y and 2 for N. The following command returns the correct error level: Windows 7: choice /t 5 /d Y /m "Do you want to automatically shutdown the computer afterwards " echo %errorlevel% if '%errorlevel%'=='1' set Shutdown=T if '%errorlevel%'=='2' set Shutdown=F Windows XP: choice /t:Y,5 "Do you want to automatically shutdown the computer afterwards " echo %ERRORLEVEL%

Symfony2 how to render Checkboxes?

自闭症网瘾萝莉.ら 提交于 2019-11-29 22:55:36
问题 I have a formbuilder form with a multiple choice list of countries. When I render them on my form like this: {{ form_widget(edit_form.countries) }} They appear like this: <input type="checkbox" name="..." value="AD" /><label for="...">Andorra</label> <input type="checkbox" name="..." value="AE" /><label for="...">United Arab Emirates</label> <input type="checkbox" name="..." value="AF" /><label for="...">Afghanistan</label> I would like each option displayed on it's own line in the browser,

How to use special characters in choice command - Batch File

痴心易碎 提交于 2019-11-29 16:03:20
I would like to add special characters like < | into my choice command, how can I do that? Here's my old code: CHOICE /C ABCDEFGHIJKLMNOPQRSTUVWXYZ0134567928 /N /M "Press 8 ...." and I would like it to be something like : CHOICE /C `~,.<>?ABCDEFGHIJKLMNOPQRSTUVWXYZ0134567928 /N /M "Press 8 ...." Any help will be appreciated, thanks. EDIT: Since some of you may ask why do I need so many choice, I'm here to answer. It is because pressing an invalid choice would give you an annoying beep that I would not like. Therefore I asked this question. The CHOICE command only allows alpha-numeric

Timeout for user decision in windows batch file

╄→гoц情女王★ 提交于 2019-11-29 07:30:37
I wrote a simple .bat file that asks the user a yes/ no question at one point. Now I want to add a timeout - lets say 10s - to it. Is there an easy way to do it? My source so far: SET /P ANSWER=Do you want it (Y/N)? IF /i {%ANSWER%}=={y} GOTO :yes IF /i {%ANSWER%}=={yes} GOTO :yes GOTO :no :yes @echo Yeah, it will be done. GOTO :continue :no @echo Nope, it will not happen. GOTO :continue :continue @echo And on we go This depends on version of windows your running. Different ones run different things. You can try some of the following: timeout 10 ping 0.0.0.0 -n 1 -w 10000 > nul If those fail

What versions of Swift are supported by what versions of Xcode?

雨燕双飞 提交于 2019-11-29 07:06:09
问题 I develop apps in Swift for a living. I enjoy the language and follow it as closely as I can. Yet, still, certain facts slip through, whether by me being blindsided, or by Apple being very quiet about them. Today, I discovered that Swift 3.3 and 3.4 exist. I was under the assumption that 3.2 was the last version of 3, for use in migrating to 4, 4.2, and 5. This misconception is mostly due to the fact that Swift.org, the official Git repo, and Xcode Release Notes don't mention them at all . So

django model CharField: max_length does not work?

拥有回忆 提交于 2019-11-28 12:02:11
I'm trying to make a field with limited choices: Action_Types=( ('0','foo'), ('1','bar'), ) class Foo(models.Model): myAction=models.CharField(max_length=1,choices=Action_Types) def __unicode__(self): return '%d %s'%(self.pk,self.myAction) However, when I was trying to insert content violating the rules, it succeeded without any error or warning messages (with "manage.py shell"). It seems any text of any length can be put into this field. I'm using SQLite3 as the backend. Is it supposed to be like that? Or if I missed something? SQLite does not enforce the length of a VARCHAR. From the SQLite