Categories
Mastering Development

Cannibals and missionaries problem python -artificial intelligence algorithm

I’m trying to solve the cannibals and missionaries problem in python (with some additional criteria, but the main idea is the classic one). So, in the class Graph, I initialize the state (number of cannibals, number of missionaries, available seats in the boat, units of food (missionaries can feed cannibals if there are more cannibals […]

Categories
Mastering Development

Why is it printing None?

I know this is a simple question, but I would like to know why it is printing None. It just prints None when coding it directly from my terminal. If I write the same code in a file or in a online Python compiler and then run it, I don’t get the same output. Coding […]

Categories
Mastering Development

How to find matches faster with SpaCy Matcher?

I’m trying to use the SpaCy Matcher package to detect matches whenever there is a passive voice in the sentences. I’ve written the pattern below and it finds the passive verbs and sentences correctly. Though my problem right now is with speed. I have around 1 million records and each record has around 10 sentences. […]

Categories
Mastering Development

I installed python 3.9.1 but can not open jupyter notebook or jupyterlab

I just install and even reinstalled but when I try to open jupuyterlab or p notebook it gives following error File "c:\users\v\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\v\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\v\AppData\Local\Programs\Python\Python39\Scripts\jupyter-notebook.EXE\__main__.py", line 4, in <module> File "c:\users\v\appdata\local\programs\python\python39\lib\site-packages\notebook\notebookapp.py", line 49, in <module> from zmq.eventloop import ioloop File […]

Categories
Mastering Development

Closure compilation error “cannot be stored outside of its closure” on environment variable

I’m getting on with Rust, and there’s this error that took me hours but still I can’t understand it. I’ve gone through the book multiple times and I don’t see this code violate the rule stated in the error msg. fn main() { println!("Hello, world!"); Solution::add_two_numbers( Some(Box::new(ListNode::new(0))), Some(Box::new(ListNode::new(0))), ); } struct Solution {} // Definition […]

Categories
Arduino Ask Engineering

Problem in interfacing esp8266 with Arduino ide for simple blink program

Arduino: 1.8.13 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Serial, None, Only Sketch, 115200" In file included from c:\programdata\matlab\supportpackages\r2018b\3p.instrset\arduinoide.instrset\idepkgs\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\algorithm:60:0, from C:\ProgramData\MATLAB\SupportPackages\R2018b\3P.instrset\arduinoide.instrset\idepkgs\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Arduino.h:238, from sketch\Blink.ino.cpp:1: c:\programdata\matlab\supportpackages\r2018b\3p.instrset\arduinoide.instrset\idepkgs\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\utility:68:28: fatal error: bits/c++config.h: No such file or directory #include <bits/c++config.h> ^ […]

Categories
Arduino Ask Engineering

How do you concatinate an interger with a string in server.send data?

I have a class I am trying to add its global counting variable value to int switch0; class void webpage() { server.send( 200, "text/html", "<html> \ <body> \ <p>Plant 0 has been fed "+switch0+" times<p> \ <form name=’frm0′ method=’post’> \ <input type=’text’ name=’sw0′ value=8000> \ <input type=’submit’ value=’Submit’> \ </form> \n\ <form name=’frm1′ method=’post’> \ […]

Categories
Mastering Development

spaCy Pattern Matching – OR statements

is there a way to use or apply "OR" logic to pattern matcher? Something like can be done with regex? I don’t want to have to create individual parsers for each occurrence, if possible (car, boat, bus, for example). I am also thinking that if I can do that, I can use a script to […]

Categories
Mastering Development

how to store form cleaned_data in a Django session

I am developing an ads web site using Django 3.0 and Python 3.8. I want to build multi step form wizard using django session. I have tried previously formtools.wizard but it failed to satisfy all of my requirements. Thus, I decided to write my own code to do that using session to pass form inputs […]

Categories
Mastering Development

Subtract the value in a field in one row from all other rows of the same field in pandas dataframe

I have a dataframe as shown below: data = {‘sid’:[1,1,1,2,2,2], ‘field1’:[‘start’, None, None, ‘start’, None, None], ‘field2’:[‘a’, ‘b’, ‘z’, ‘d’, ‘z’,’s’], ‘val’:[20, 22, 23, 40, 45, 47]} df = pd.DataFrame(data) print(df) sid field1 val 0 1 start 20 1 1 None 22 2 1 None 23 3 2 start 40 4 2 None 45 5 […]