Posts

complexity theory - Is the complement of the language CLIQUE element of NP? -

i'm studying np class , 1 of slides mentions: it seems verifying not present more difficult verifying present. ______ _________ hence, clique (complement) , subsetsum (complement) not members of np. was ever proved, whether complement of clique element of np? also, have proof? this open problem, actually! complexity class co-np consists of complements of problems in np . it's unknown whether np = co-np right now, , many people suspect answer no. just clique np -complete, complement of clique co-np -complete. (more generally, complement of np -complete problem co-np -complete). there's theorem if co-np -complete problem in np , co-np = np ,which huge theoretical breakthrough. if you're interested in learning more this, check out the wikipedia article on co-np , around online more resources.

c++ - Can I use an enum in a constructor for a class? -

i trying make class , inside of class want define enum called type. can use enum defined constructor class? if so, how access outside of class? class type { public: enum ttype { black, white, gray }; type(ttype type, std::string value); ~type(); ... this code doesn't give me errors when try create instance of class in class gives me error because black not defined: type piece(black, value); is there special way , still have ttype class constructor type class? first time using enums don't know how work exactly. yes can: type piece(type::black, value); enum ttype in scope of class type , have use scope resolution when accessing outside type 's body , member functions.

python - Merging txt files matchs conditions -

i have list of files in txt format in python in app this: ['pr00-1.txt', '900-2.txt', 'pr00-2.txt', '900-1.txt', 'pr900-3.txt', '00-3.txt'] i'm trying merge 00 files ['pr00-1.txt', 'pr00-2.txt', '00-3.txt'] in 1 00.txt file. same 900 files , on regardless on pr or -*.txt , * number. tried using split it's not helping. any idea how it? i think want. find 00 files regular expression open 00.txt , write files it. note solution isn't generalized xx pattern, , fails if 1 of files doesn't exist. i'll leave rest you. import re open('00.txt.', 'w') outfile: filenames = ['pr00-1.txt', '900-2.txt', 'pr00-2.txt', '900-1.txt', 'pr900-3.txt', '00-3.txt'] filename in filenames: match = re.search(r'(^|[^0-9])00.*.txt', filename) if (match): open(filename) infile: ...

python - Using a class field in another fields -

i have field in class depends on field in same class have problem code: class myclass(models.model): nation = [('sp', 'spain'), ('fr', 'france')] nationality = models.charfield(max_length=2, choices=nation) first_name = models.charfield(max_length=2, choices=name) i want put name = [('ro', 'rodrigo'), ('ra', 'raquel')] if nation = spain , name = [('lu', 'luis'), ('ch', 'chantal')] if nation = france. how can that? thanks! i think want change view user sees. have above underlying db model wrong place sort of feature. in addition (assuming web application), need in javascript, can change set of allowed names user changes nationality field.

c# - Control animation and execute script when animation ends -

Image
my project military fps , i'm having problems animations. i have 3 different weapons, 1 animator controller each 1 , every weapon has "enter" , "leave" animation. cs, cod, etc... i need know when "leave" animation ends disable gameobject, enable other 1 , play "enter" animation. i tryed this: http://answers.unity3d.com/questions/362629/how-can-i-check-if-an-animation-is-being-played-or.html without sucess. i'll leave here print of animator controller, hierarchy , script, if u need more details, need say. animator controller of weapon number 1 all transitions "sair" (leave animation) have trigger (ak47_sair) , transition "extit" state have trigger ("ak47_saircontrolador") on code, when press 2 (change weapon number 2) want transition. this hierarchy, script attached "jogador". with actual code, disable tha ak47 gameobject when leave animation still playing. using unit...

language extension - How to customize comment block characters in visual studio code? -

i created language extension visual studio code , change comment block characters couldn't find way so.. has done or know how it? ok, figured out problem. there 2 ways can change comment blocks: 1 - config file i dont know why it's not in docs (or @ least couldn't find it) there optional property pass object inside contributes.languages array in package.json named configuration . the description found on vs code source code: a relative path file containing configuration options language. on files can create object 1 , it's gonna overwrite default comment characters { "comments": { "linecomment": "//", "blockcomment": [ "<!--", "-->" ] } } you can see properties on api references: https://code.visualstudio.com/docs/extensionapi/vscode-api#commentrule note: comment block command triggered different shortcut. can overwrite though (in general or specific lang...

c# - Dynamically specifying lambda function parameters -

suppose have following line of code: context.load(itemcollection, item => item.include(i => i["title"], => i["name"])); is there way can dynamically specify parameters item.include() function instead of hard-coding them above? i ideally allow users select properties want retrieve of object such title , name , description , etc. fyi, here clientcontext.load function. function coming microsoft.sharepoint.client.dll public void load<t>(t clientobject, params expression<func<t, object>>[] retrievals) t : clientobject { if ((object) clientobject == null) throw new argumentnullexception("clientobject"); clientaction.checkactionparameterincontext(this, (object) clientobject); dataretrieval.load<t>(clientobject, retrievals); } i don't have necessary setup test it, work? string[] keys = ...; context.load( itemcollection , item => item .include(keys ...