Posts

python - BFS and UCS algorithms. My BFS implementation works but my UCS doesn't. Can't figure out why -

as long not mistaken, ucs same bfs difference instead of expanding shallowest node, expands node lowest path cost. (also using priorityqueue instead of queue that)so copied bfs code, created map keep track of each node's path cost , changed way items being pushed/popped in queue/priority queue. note: getsuccessors(state) returns list of triples (state, action, cost) these both of implementations: bfs: def breadthfirstsearch(problem): """search shallowest nodes in search tree first.""" queue=queue() objectqueue=queue() visited=set() actions=[] flag=0 objectmap={} actionmap={} start=problem.getstartstate() objectmap[start]=start queue.push(start) objectqueue.push(start) if problem.isgoalstate(start): return actions while queue: parent=queue.pop() object=objectqueue.pop() if parent in visited: continue visited.add(parent) if problem.isgoalst...

windows - Batch for adding suffix of several files except of batchfiles -

i found solution renaming files. did not work, added suffix after file ending like @echo off setlocal enabledelayedexpansion %%a in (*.*) ( ren "%%a" "%%a tenor 1" ) pause&exit my problem: have several filetypes in folder like: song1.mp3 song2.mp3 text1.txt text2.txt document1.pdf document2.pdf add_tenor_1.bat add_tenor_2.bat replaceblankwithunderline.bat and on. want add example files except batch files suffix "* tenor 1". song1 tenor 1.mp3 song2 tenor 1.mp3 text1 tenor 1.txt text2 tenor 1.txt document1 tenor 1.pdf document2 tenor 1.pdf add_tenor_1.bat add_tenor_2.bat replaceblankwithunderline.bat is possible use *.* in condition exception (for .bat) ? how code batch file like? another thing add suffix .txt , .pdf files example. work in 1 routine or need 1 .txt , 1 .pdf? song1.mp3 song2.mp3 text1 tenor 1.txt text2 tenor 1.txt document1 tenor 1.pdf document2 tenor 1.pdf add_tenor_1.bat add_tenor_2.bat replaceblankwithunderline.b...

Are preconditions necessary inside handler APIs that are supported by Frameworks? -

basically when spring io or other framework matter routes url handler method, injects path parameters user supplied values. public responseentity<list<datamodel>> doget(@pathvariable string param1, @pathvariable string param2) { preconditions.checknotnull(param1); preconditions.checknotnull(param2); } is practice or redundant make precondition checks on supplied params inside function shown above? the spring framework not allow injection of null values above parameters. still, handler method can invoked other parts of code (a bad practice, legit nevertheless). method can passed null values when under junit test. so having said this, there compelling case not have preconditions assertions @ top of handler api?

c++ - QT how to cross compile for Windows on linux -

good day all i need test , distibute software have written linux, windows. i using qt creator 4.0.2 (based on qt 5.7.0). i have found tutorial regarding this, found here , had issue building compilter. unfortunately while building compilter (mingw32), have run error - vtk package cannot built - , have not found solution since. for record: $ gcc --version gcc (ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005 is there other methods avaiable build cross-platform applications in linux using qt-creator? thanks in advance

javascript - In es6 I need my promise to return true or false when done -

in es6 need promise return true or false when done this attempt returns promise , need true or false return this.isuserauthenticated() .then(() => this.checkifteacherprofileexists()); the return part needs true or false. this 1 of returns looks like: isuserauthenticated = (): promise<any> => { return new promise((resolve, reject) => { this.authservice.checkifloggedin().then((isauthuser: boolean) => { resolve(true); }); }); } your return promise holding true or false . have chain .then() hold boolean. return this.isuserauthenticated() .then(() => this.checkifteacherprofileexists()) .then(v => console.log(v)); // true or false regarding comment, see @felixkling's comment - can't that, that's not how promises work.

sql - Cannot find the Nvarchar to Int conversion in my code -

i making project school have make program can create orders in. when try create orders error returned me. error converting data type nvarchar int. in advance i'm sorry if basic question easely spotted. me , project members beginning programmers cannot spot goes wrong. the code execute in vba : set rs = dbconn.execute("exec sporderplaatsen '" & me.tbtijd & "', " & me.klantnr & ", '" & me.tbophaaldatum & "', '" & me.tbafleverdatum & "', '" & me.tbophaaladres & "', " & me.tbpalletnr & ", " & me.tbaantalpallets & "") this code execute's our stored procedure. stored procedure looks this. create procedure sporderplaatsen ( @tijd time(0), @klantnr integer, @ophaaldatum date, @afleverdatum date, @palletnr integer, @aantal integer, @adres varchar(255) ) ...

Python PLY parsing : definition scope -

i'm using ply parse files containing nested blocks. typically : a { b { } c { d { } } } i using simple grammar : def p_nodes(p): ''' nodes : node nodes | node ''' # ?? def p_node(p): ''' node : identifier open_curly_brace node_çontent close_curly_brace ''' p[0] = node(p[3])#fixme? def p_node_content(p): ''' node_content : nodes | ''' if len(p) > 1: p[0] = p[1] else p[0] = none i know able access 'parent' node in parser. in other terms how can build ast can retrieve in example d child of c child of a since have visibility parent rule in parser. what should put in p_nodes , p_node valid ast can built ? thanks. we have need node class, presume like: class node: def __init__(self, children): self.children = children self....