logic

Is it possible to use an AND operator in grepl()?

喜欢而已 提交于 2019-12-01 15:07:55
问题 I want to search for anything that begins with 55 and anything that has the word Roof (case-sensitive, for those who are curious) in it. So far I have been unsuccessful, as I can only seem to use the OR operator: grepl("*^55|*Roof", dataset$longname) Ultimately, I want to achieve something like this: grepl("*^55&&*Roof", dataset$longname) or grepl("*^55&*Roof", dataset$longname) (Clearly, neither of these work - they're for illustration only.) I want my results to show anything that begins

Generating unique ids with the max length of 3 digits/letters/simbols

只谈情不闲聊 提交于 2019-12-01 14:50:59
I have a list of 75200 words. I need to give a 'unique' id to each word, and the length of each id could be 3 letters or less. I can use numbers, letters or even symbols but the max length is 3. Below is my code. import java.io.*; import java.util.*; public class HashCreator { private Map completedWordMap; private String [] simpleLetters = {"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"}; private String[] symbols = {"!","@","#","$","%","^","&","*","~","?"}; private String indexNumber; String currentlyUsingLetter, currentlyUsingSymbol;

A C program to check if the entered date is valid or not

牧云@^-^@ 提交于 2019-12-01 13:53:33
问题 I was asked to right a program which checks if the date entered by the user is legitimate or not in C. I tried writing it but I guess the logic isn't right. //Legitimate date #include <stdio.h> void main() { int d,m,y,leap; int legit = 0; printf("Enter the date\n"); scanf("%i.%i.%i",&d,&m,&y); if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0)) {leap=1;} if (m<13) { if (m == 1 || (3 || ( 5 || ( 7 || ( 8 || ( 10 || ( 12 ))))))) {if (d <=31) {legit=1;}} else if (m == 4 || ( 6 || ( 9 || ( 11 ) ) )

Implementing OR,AND using XOR

ぐ巨炮叔叔 提交于 2019-12-01 12:57:37
问题 I want to know that if I can implement or,and functions using only xor . I think It is impossible but I need to prove that. Any ideas? Thanks in advance. 回答1: You cannot implement OR or AND gate only by using XOR because it is not a universal gate. Also the XOR function can't tell the difference between '1,1' and '0,0' at it's inputs. Inverting the inputs/output in whatever combination makes a new gate with an XOR or XNOR function. Here is an argument against XOR and XNOR as universal gates.

Selecting the earliest date from a given dataset in R

℡╲_俬逩灬. 提交于 2019-12-01 12:52:41
I have a data set with many rows but I picked only a few as shown below and need to pick only the earliest SORT_DT among all with the rest all variables remaining the same. CUST_NO ID_NO SYMBOL AUTO_CREATE_DT CLASS_TYPE SORT_DT 1 107 10120 1 2014-05-12 G/L 2015-01-09 2 107 10120 1 2014-05-12 G/L 2015-11-10 3 107 10120 1 2014-05-12 G/L 2014-06-18 4 107 10120 1 2014-05-12 G/L 2014-05-12 5 107 10120 1 2014-05-12 G/L 2015-07-10 6 107 10120 1 2014-05-12 G/L 2015-10-09 7 107 10120 1 2014-05-12 G/L 2016-04-08 8 107 10120 1 2014-05-12 G/L 2016-01-08 9 107 10120 1 2014-05-12 G/L 2016-12-22 10 107 10120

I need help finding an alternative to synchronous jQuery ajax

十年热恋 提交于 2019-12-01 12:51:49
I have a very complex form which contains multiple tabs. Each tab contains a unique Plupload instance (for uploading multiple images). The form allows a user to upload a medical image 'case' where each case is made up of multiple imaging 'studies' (e.g. CT scans) and each study contains multiple images. When the user clicks the 'submit' button, I intercept the click with jQuery because I need to do the following: Check the required fields are entered [easy] Get a unique id number from my server. This id number is required by each Plupload instance to know which directory to upload to. In my

Python Logical Operation

梦想与她 提交于 2019-12-01 12:17:41
问题 I'm pretty new to python and I'm working on a web scraping project using the Scrapy library. I'm not using the built in domain restriction because I want to check if any of the links to pages outside the domain are dead. However, I still want to treat pages within the domain differently from those outside it and am trying to manually determine if a site is within the domain before parsing the response. Response URL: http://www.siteSection1.domainName.com If Statement: if 'domainName.com' and

Selecting the earliest date from a given dataset in R

孤者浪人 提交于 2019-12-01 11:57:37
问题 I have a data set with many rows but I picked only a few as shown below and need to pick only the earliest SORT_DT among all with the rest all variables remaining the same. CUST_NO ID_NO SYMBOL AUTO_CREATE_DT CLASS_TYPE SORT_DT 1 107 10120 1 2014-05-12 G/L 2015-01-09 2 107 10120 1 2014-05-12 G/L 2015-11-10 3 107 10120 1 2014-05-12 G/L 2014-06-18 4 107 10120 1 2014-05-12 G/L 2014-05-12 5 107 10120 1 2014-05-12 G/L 2015-07-10 6 107 10120 1 2014-05-12 G/L 2015-10-09 7 107 10120 1 2014-05-12 G/L

How to connect sql server through java code?

南楼画角 提交于 2019-12-01 11:46:08
I am creating application where I need to connect my services to sql server. When I run the test code after adding dependency, it runs successfully. This is the test code which runs successfully : import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.*; public class SQLConnection { public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection conn =

I need help finding an alternative to synchronous jQuery ajax

女生的网名这么多〃 提交于 2019-12-01 09:45:28
问题 I have a very complex form which contains multiple tabs. Each tab contains a unique Plupload instance (for uploading multiple images). The form allows a user to upload a medical image 'case' where each case is made up of multiple imaging 'studies' (e.g. CT scans) and each study contains multiple images. When the user clicks the 'submit' button, I intercept the click with jQuery because I need to do the following: Check the required fields are entered [easy] Get a unique id number from my