instruction
stringlengths
71
71.9k
The challenge: Suppose you are inhabitant of a planet where 1, 7, and 9 are lucky digits. A lucky number for you is a number that contains only your lucky digits in it. For ex: 1, 79, 911, 9917 etc., are lucky, where as 5, 172, 93, 170 are not. Given a integer N, count the number of lucky numbers in the range 1 to N. ...
I am building a JS router and would like to have some help doing it. It will work like so: A list of routes is given with a URL pattern attached in each one. [ { url : "/home"}, { url : "/user/:id"} ] I want a function that will find the appropriate pattern when we pass it a route URL and will return the object ...
This is an update for this post. I fixed all style-issues from the comments, but still have a few questions left: Someone commented that my last post contained too many functions, which could be easily implemented by the user of the library himself. Is this a basic enough set of functions? Is anything missing? (I hid ...
I have been playing around with OpenGL and created a fairly basic 2D animation was just hoping someone could take a look and give me some pointers. Main.cpp: #include "glut.h" #include <math.h> #include <stdio.h> int bc = 0.4; //building color int frame=0; class points{ public: float x, y; }; points startLine[2...
I'm replicating a scenario on a sample set for better understanding. Database Table: Products Report required from that table, the query is working fine, and I'm able to get the required result. But, I believe it can be optimized. So, looking for help to improve it. Any help in simplifying this one would be great! N...
Allow me to provide some context. I have a UITableViewCell that contains an EditText and a Button. This cell is then inserted into the self.tableView.tableHeaderView property of the table to achieve the following result: Below is my implementation for the view controller: class ViewController: UITableViewController { ...
This is the code I am using for a distributed system. The code will be used to allow the server to send parts of a (really big) document which will be processed by the connected clients. Please tell me what things would make it more efficient and if there are any security issues that I can correct without addition of a...
I am currently studying c programming, but I'm at a very basic level. So for practice I made a program that reads a string and inverts it. I want to know if the code is readable and how I can improve it. /* * Goal: Given a string, invert it, then print the result. * Author: Lúcio Cardoso */ #include <stdio.h> #includ...
I'm a C++ programmer and thought I'd revisit the roots, so I scribbled something really quickly. I would appreciate input on how my C code is looking! slist.h #ifndef SLIST_H #define SLIST_H #include <stddef.h> #include <stdbool.h> struct slist_s { int key; struct slist_s* next; }; typedef struct slist_s sl...
Here is command line for playing two videos side by side in sync in FFmpeg (ffplay). It can be useful for comaring videos, for example. ffplay -v warning -f rawvideo -s 800x400 -i /dev/zero -vf 'movie=video1.mkv,scale=400x400 [mv2] ; movie=video2.mkv,scale=400x400 [mv1]; [in][mv1] overlay=0:0 [tmp]; [tmp][mv2] overlay=...
This code reads text from the web using a WebDriver element and writes data to a JSON file. I had to use if-else (to write only the last line to the JSON file) just because of the asynchronous behaviour of NodeJs, otherwise I was trying to add fs.appendFile(filepath,"}") in the end to close the JSON file. I just want y...
I have the following two methods that write to file various data line by line. Both methods differ from each other only by few lines what would be the best way to refactor them that when in future I want to add another method (for example, CreateXYZLegacyInFile) it would be least time consuming. public string CreateCVT...
I have two functions right now: TUNNEL_COMMAND = "ssh -L 27017:localhost:27017 username@ip -f -N" def kill_tunnel(): p = subprocess.Popen(["ps", "aux"], stdout=subprocess.PIPE) out, err = p.communicate() for line in out.splitlines(): if TUNNEL_COMMAND in line: pid = int(line.split()[1])...
I am having problems with my code because I am using a system called styleci. Can you please check it? How can I make it better and more secure? <?php /* * Tecflare Corporation * Copyright Tecflare Corporation * Provided by the Tecflare Corporation System * * Code has been scanned by styleci.io */ $host = $_POST['...
I have a device I connect to on TCP socket. I send it a message with what I want and it sends back all sorts of useful information: Header: +---------------+----------+----------+ | MagicWord | 2 bytes | 0xCAFE | | Version | 1 byte | 0x02 | | Type | 1 byte | Variable | | UTC offset | 1...
This was a learning experience. I have looked around and found some better ways to write some things but wanted a second opinion to look at what I've written and kind of analyze it as well. I just finished my first "Text based game" sort of deal. I believe that it's poorly written and is pretty long for the short amoun...
I've been working on numerals conversion lately. Now the JavaScript course I'm following asked me to do something similar for Roman numerals. To keep things fresh and given the amount of test-cases provided I decided to write this one Test-Driven Development style. That is, for as much as I understand it. First I check...
I have a function here and wondered how well this can be refactored. I currently have this: status=`git status 2>&1 | tee` dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"` untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"` ahead=`echo -n "${s...
I am looking to build a list of words (three letters or more) that make up a large list of six-letter words. I was wondering if there was a cleaner or more efficient way to loop through the characters to build these subsets. The top of this program (not posted) takes two .txt files - one containing the list of 6-letter...
I have a Multivalued map (javax.ws.rs.core.MultivaluedMap<String, String>) which I want to convert to regular HashMap so I got below code: private Map<String, String> convertMultiToRegularMap(MultivaluedMap<String, String> m) { Map<String, String> map = new HashMap<String, String>(); if (m == null) { re...
In Python 3.4, a Counter object called cnt like this: Counter({'0200': 3, '3000': 2, '3011': 2, '0210': 1, '4000': 1}) is to be written to a comma-separated file. I first tried with CSV and DictWriter that I had not used before, but I kept getting misty errors and was pressed for time, so I decided to make this ...
I wrote an abstract Configuration class, then an ConnectionConfiguration class and then an DatabaseConnection class. ConnectionConfiguration extends Configuration DatabaseConnection extends ConnectionConfiguration My reason for doing this was to learn more about object-oriented design and better PHP programming the r...
I've started building extension methods for my EF classes like below because it makes building queries so easy, and the intellisense provided helps keep people from writing a new Where() clause in code every time they do to do something. Example Extensions to an EF User Class public static class UserIQX { public ...
I'm writing code to create a list of new areas for patches of conserved land within a watershed based on the current size distribution of conserved land patches that are in the watershed now. I'm generating a new random area based on a normal probability density function fitted to the log-transformed distribution of t...
Within our application I need to work a lot with simple IDs (just integers). They are used to make queries against a database. For performance reasons I don't want to materialize them to Entities before the query. Example: // not really *that* static typed public void DoQuery(int userId, int groupId) { } Because I wa...
I have a table that look like this ID NIP SHIFT DATE 289305 01000267 M 2015-12-01 00:00:00.000 289306 01000267 P 2015-12-01 00:00:00.000 289307 01000267 S 2015-12-01 00:00:00.000 289127 01020358 M 2015-12-01 00:00:00.000 289128 01020358 P 2015-12-01 00:00:00.000 289129 01020358...
I'm trying to learn linked lists so I can answer interview questions. Even though I've seen plenty of tutorials to understand how they supposedly work, I don't know if I am doing a good job because I have no one to get feedback from. class Node(object): def __init__(self, data, next_node = None): self.data...
Here's a program I made for estimating a double integral over a general region. It's pretty accurate, but it's VERY, VERY slow. (Getting an accurate enough result takes about 30 seconds) Here's the code; the lines are indented just for readability. ClrHome Input "Surface: ",Str0 Str0→Y₈ Input "y-Bound 1: ",Str0 Str0→Y₉...
I'm working on a programming challenge and the question is as follows: Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display). Max starts to type all the values from a to b...
I receive a string with a lot of characters that I don't need and I am trying to remove them and replace them with characters that I am able to work with. My current structure has me redefining the var multiple times which I feel is not efficient and can probably be done better. Please let me know of a more effective w...
Can you review the code? #include <stdio.h> #include <pthread.h> #include <windows.h> #include "bin/include/pthread.h" #include "bin/include/sched.h" #include "bin/include/semaphore.h" #define TCOUNT 10 #define WATCH_COUNT 12 int count = 0; pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cou...
The code converts hexadecimal into octal. The function is working, but it takes more than a second to process the input. How can I optimize this? import java.util.Scanner; public class BasicTranformSixteenToEight { public static void toBinaryTransform(int n, char[][] arry, String[] arryBinaryStr) { ...
I would like to refactor this code printing odd and even numbers with two threads considering agile practice: public class EvenOddNumberPrinter {     private static class NumberPrinter {         // To check if even number is printed or not.         private boolean isEvenPrinted = true;         public void printOdd(i...
Consider the following function: def test_func(all_copies, checker): bad_copies = set(c[0] for c in itertools.permutations(all_copies, 2) if not checker(*c)) all_copies = [c for c in all_copies if c not in bad_copies] return all_copies This function returns a list of elements that are not overshadowed by a...
I'm working on several projects involving Telegram bots and I've decided to make a library that meets my needs. Basically, there is already a Python library for Telegram bots (import telegram in my code), but I wanted to wrap it to make it even more convenient to me. In terms of functionality it works fine. But I'm a s...
I recently made a post on Code Review entitled Writing lists to .csv file. I found the feedback extremely helpful, and wished to provide a continuation of that particular topic; of working with Python and .csv files. I therefore set the somewhat more complex challenge of creating and populating a table within a .csv fi...
I am making a permutation generator in c. Any ideas how I can make it faster? #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]){ char s[] = "abcdefghijklmnopqrstuvwxyz"; int n = 8, c[n], i, l = strlen(s); char w[n]; for(i = 0; i < n; i++){ c[i] = 0; w[i] = '\0'; ...
I have a service which takes a lot of key value parameters in a URL. Only a few are mandatory and others are optional. It's up to the customer whether they want to set those optional parameters or not. The mandatory parameters are userid or flowid. They can be set together or independent of each other so below are the ...
This question is connected to the previous one: Request handler based solely on reflections I have edited the code, taking tim's answer in regard, editing the Kernel class cohesion. <?php namespace Qobox; class Kernel { private $request; private $module; /** * Kernel constructor. */ public ...
I've written a simple interpreter with ANTLR for evaluating Roman numerals. Here's the contents of the grammar file (Roman.g4): grammar Roman; root : (oneThousand)* hundreds? tens? units?; // --- I, II, III, IV, IX or V VI, VII, VIII units : one ((one)* | five | ten) | five (one)*; // --- X, XX, XXX, XL, XC or L,...
I recently found an interesting series that describes the specifics of how interpreters and compilers work, explaining each step (with code) and encouraging the reader to do exercises. My code is mostly based on the boilerplate provided in the first tutorial. The description didn't really seem clear enough to me, so I ...
The task is pretty simple: implement a timer that executes tasks when the next event takes place. I created a task scheduler based on a priority queue. A new thread is created for TaskTimerRunnable and sleeps during run() until the next task. When a new task is added, it checks if the time for the new task is sooner t...
This code add functionality to a GUI designed using PyQt. It cannot run alone, but I can provide the code. I am not asking for someone to provide criticism for every single function written here, but one or two tips would make me a happy camper. I would like to know if there is something I am making more complicated th...
I have Tornado chat with export to Redis. Other scripts will export messages from Redis to MongoDB in the time. It works, but how is it written? def tornadoredis_client(): client = tornadoredis.Client(*configuration.REDIS_CONFIG) client.connect() return client class PlansqTornadoChat(SockJSConnection): ...
What I'm wanting to do is create a String readFile(Path filePath, Charset encoding) method, that returns the entire contents of a given file. I'm wanting the equivalent of Guava's Files.toString(file, encoding), but without calling the Path.getFile() method (as this method only works with the default filesystem provide...
Now I am pretty crappy at software architecture. I think I was able to make this relatively concise. Please, any input is helpful! var cheerio = require("cheerio"), request = require("request"), sqlite3 = require("sqlite3").verbose(), colors = require("colors"), fs = req...
In an effort to make my code more testable, I'm trying to make use of constructors and prototypes. Here is a working Google Apps Script (GAS) for creating a new submenu under the Addon main menu in a Google Spreadsheet. If a user clicks the 'Show' menu item, a sidebar will appear. var UI = function (menuName, menuFunct...
I started writing Rust by doing a simple program that will print all prime numbers until it reaches the upper bound that is provided through standard input. Here is my code use std::io; fn main() { println!("Enter a number: "); let mut limit = String::new(); io::stdin().read_line(&mut limit).expect("failed...
I'm looking for a better way to make a background operation with abort/cancel support. Right now I use this approach: Task.Factory.StartNew(() => { var cts = new System.Threading.CancellationTokenSource(); var ct = cts.Token; try { var t = System.Threading.Thread.CurrentThread; usin...
Handy wrapper for aggregates to use with emplace*() container's member functions: #include <type_traits> #include <utility> template< typename type > struct aggregate_wrapper : type { aggregate_wrapper() = default; template< typename ...arguments, bool is_noexcept = noexcept(::new (std::dec...
I have the following C code that finds numbers between 1 and 10000 whose sum of digits are prime and save then to a file. #include<stdio.h> #include<conio.h> int sum_of_digits(int); int check_prime(int); void save_to_file(int); int main() { int i, num, isPrime; for(i=2; i<=10000; i++) { num = sum_o...
I am currently in the process of learning C++ from C++ Primer. I have found the exercises in this book to be somewhat dull in that they only test syntax and not reasoning. As such, I have recently written a somewhat advanced C++ calculator. It is advanced in that it can interpret more complex ideas than a simple operat...
I have implemented a class which implements a list of my custom DateObj. I have sorted the list in a peculiar manner based on the current month. I achieved my desired results, but I'm required to call Collections.sort() four times to achieve it. I feel this could be improved. Any thoughts? //Custom Date Object public c...
I created a simple minesweeper game as I am trying to get my hands dirty in JavaScript. I have tried to use the oops while doing this. I am posting 3 files: index.html minesweeper.js minesweeper.css Also: It does not have 2 major features - timer and flagging. You may find the UI not-so-pleasing. I have hosted the ...
A Sudoku puzzle is a 9 × 9 grid with some numbers between 1 and 9 in it, that has to be filled in so that every row, every column, and each of the nine 3 × 3 blocks contain all the numbers from 1 to 9. For example the following matrix is not a valid solution of a Sudoku puzzle: the fourth column contains two 7'...
Have you ever being implementing Option<T> functional type? It is discussed here. Basically, it is about using IEnumerable<T> with no or only one element instead of potentially nullable object reference in C#. We can empower LINQ functionality to streamline processing reducing cyclomatic complexity because of no if(nul...
Based on the previous question, I have implemented all suggestions with slight modifications. The game seems fine, are there any further improvements needed in this game? #include <iostream> #include <cassert> #include <random> #include <algorithm> #include <array> #include <map> #include <numeric> #include <conio.h> ...
I have the following code for the BST for the inorder, postorder, preorder, breadth first and depth first traversals. Can you review and let me know the optimisation points and issues, if any? import java.util.ArrayDeque; import java.util.Queue; import java.util.Scanner; import java.util.Stack; public class BST { ...
Building on top of the classes in this question of mine, I've made this class to support the moving of the entities for my given assignment: Welcome to the Bridge Crossing Problem. Person Pn can cross the bridge in n minutes. Only one or two persons can cross at a time because it is dark, and the flashlight must b...
Given the following working code: def get(self, key, default=None, type=None): """Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function ...
I am trying to write a parser from JSON data which I get from Google requesting coordinates of a city, which will create my specified object structure. For parsing, I've written a custom TypeAdapter. It is my first time working with Gson, so probably my parsing method can be improved. Any suggestions? JSON I receive: ...
I am doing some math - combining, reusing, extending different analyses methods over the same original data set. It would be reasonable to use C# extension methods in my case instead of defining everything in one class. The same time there are too much stuff to be constantly recalculated in this extension methods - I d...
The app is a todo list with a three-day calendar. Users can add and remove lists and it's all stored in local storage. My aim was to use vanilla JS but I did use jQuery for the date picker. I'm just looking for some feedback on my code. This is my first app I have coded and I'm looking for some constructive criticism o...
I wrote a simple quadratic function solver with unit tests. Can anyone check if this is okay? Quadratic function class public class QuadraticFunction { private Integer a,b,c; public QuadraticFunction(Integer a, Integer b, Integer c) { this.a = a; this.b = b; this.c = c; } publi...
This is how I achieved it: <script type="text/javascript"> // Get this monday var dif, d = new Date(); dif = (d.getDay() + 6) % 7; d = new Date(d.getTime() - dif * 24*60*60*1000); d.setHours(0,0,0); var thisMondayUnixtimestamp = Math.round((d.getTime() / 1000)); console.log('thisMondayUnixtimestamp', thisMondayUnixti...
This is my attempted solution to Question 1.3 from "Cracking the Code Interview", 6th ed. Question: Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the true length of the string. #incl...
I've been working on a regex-based UK postcode validation and format correction tool - with the aim of creating a list of postcodes that can be readily geocoded. The variety of postcode formats is explained here. I have based my regex on a discussion here. My correction tool is designed to cope with a number of commonl...
The code works well and does what I intend for it to do. In essence, it opens a file referenced as 'resource'. This is a .csv file. I then searches for the keys in the dictionary and for each key that it encounters, it replaces it with the value - the dictionary being 'rep'. It then exports this to a new .csv file. The...
I'm developing a WordPress plugin using the singleton pattern with the following requirements: There should ever exist one instance of the plugin Another instance of the object should never be instantiated, created, cloned, copied etc in any way. The singular plugin object and its public methods and vars should be eas...
I have some XML that I am parsing in Python and I need to insert the data on the database. This is current implementation of my code that is working. Actual XML: <JobTechData xmlns="http://tempuri.org/JobTechData.xsd"> <TechDataParams> <ProcessType>IONMILL1</ProcessType> <RunNumber>125229</RunNumber> <R...
I am trying to learn to code using Dependency Injection and Inversion of Control in Go. Please consider the following code. I am basically creating an interface ListingManager and then an implementation of it. I am using the New() function as a means to initialise the implementation. While not show, I would probably ad...
This program creates an integer array with a random size of 5-50 elements (inclusive). It then fills the array with random numbers between 0 - 100 (inclusive). The interesting part comes when I then have to print the array as a table limited at 5 columns wide. Also, the array must be centered on an output screen 80 cha...
Here is my code. I simulated a stack rather than used some regular recursive algorithm because I needed to keep track of two variables: the path to the biggest file and its size. Besides I wrote a few tests. My solution on Github. DirectoryIterator.java import java.io.File; import java.util.ArrayDeque; import java.util...
What do you think about the following approach to CRUD? Here is the reading+pagination example. DTO types have Dto* prefix, EF Entity Types have E* prefix. DAL example: class UserQuery : PagingQuery { public int CompanyId { get; set; } } interface IUserReader { IPage<DtoUser> Read(UserQuery query); } class User...
For the first time ever I decided to write a bash script. It works fine, but I'm feeling that I didn't write the most efficient code in order for future extension of the script. I also don't really get a good feeling on the look of the code. Any suggestions on how to improve the script? Purpose of the script: To pull a...
I would like to create a collection of binaries with n set bits and total length should be between n and 31; also those set bits should be randomly positioned. For example if n = 3, then [1;0;1;0;1], [1;0;0;1;1;] and [1;1;1;0;0] should all be possible with equal chance. Below is my implementation and any feedback is we...
What is so bad about [Flags] enum? It does not support IEnumerable<T> anyhow, so to get one we need to use syntax like (see): new HashSet<WhatToInclude>(new []{ WhatToInclude.Cleaners, WhatToInclude.Managers} Here is the helper class Flag<T> to discuss. We can use it this way: class Color : Flag<Color> { ...
I forked this StackExchange Data Explorer (SEDE) query from another one, and made it a bit more complex. I'm looking for feedback on my style, as well as answers to other questions (see below). -- top users: NYC -- forked from Avinash Raj's query for Chennai select row_number() over(order by u.Reputation desc) as [...
This approach was born out of wanting to pass a logical expression (E.G. ">=10000") as a parameter to a function. So, I built an Enum and a function to use it to evaluate logical expressions. Is this a good, maintainable, scalable approach? Public Enum comparisonOperator '/ Used [[ ]] because the outer set escape t...
Basing my work on a JavaScript progress bar created by another person, I added an animated percentage count. This solution is really ugly but it works. I don't know how to avoid having to declare the percentage value twice in the HTML. I would also like to unify the parts of the code responsible for the progress bar ...
I programmed a web adaption of the game Simon for to improving my JavaScript skills. A live version of the results are here. I got two more ideas which I like to incorporate. Moreover, I'd like to improve the look. But before I go on I would like to make some improvements. I guess there are a few necessary. function ...
I use the code (provided below) to check for certain criteria in a row. In this case, if cell F in worksheet "Swivel" contains "After Dispute For SBU" then that row needs to be highlighted in yellow and the text changed to red, then the row needs to be copied to another sheet named "Disputed" that is within the same wo...
This is my first game made using Pygame of about 550 lines of code. Advice and suggestions are more than welcome. ## Game music Attribution ##Frozen Jam by tgfcoder <https://twitter.com/tgfcoder> licensed under CC-BY-3 <http://creativecommons.org/licenses/by/3.0/> from __future__ import division import pygame import r...
I'm trying to learn more algorithmic techniques and I came across an interesting application of recursive backtracking: solving a Sudoku puzzle. I'm looking for a review concerning code style, quality, algorithmic correctness, and maybe tips on how to extend the algorithm/program. #include <array> #include <stdexcept> ...
I am learning Python, and would like to learn how to make this code simpler and easier to read. Things I am hoping to learn: What variables might be appropriate? How can I make it simpler? Is there any way to make it more efficient? What can be put into functions without sacrificing readability? import random yn = ra...
A recent comment to an answer of mine here on Code Review brought up an interesting point. The comment was that one should use std::vector<char> over std::vector<bool> in most cases because the standard requires std::vector<bool> to actually pack bits. I replied that for small vector sizes, the speed wouldn't matter ...
All I am trying to achieve is better use of built-in ES functions. var arr = [0, 1, 2, 3, -1, -2, -3]; function countPositiv(p, c, i, a) { if(c > 0){ return p+1; } else { return p; } } var positiv = arr.reduce(countPositiv, 0); console.log(positiv);
I have two classes responsible for attributes validation: class NameValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) message = options.fetch(:message, I18n.t('errors.attributes.name.invalid')) record.errors[attribute] << message unless NameValidator.valid_name?(value) end ...
Long story short: I wanted some of the time-saving functionality of jQuery without the bulk of the entire library. So, I wrote a lightweight shorthand library inspired by jQuery I'm calling Mozart JS, and I'd like to see how I can further enhance it without major impact on load times. Thoughts? Full library on GitHub. ...
The problem is (source)... By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? This is my second attempt at the problem, and gets the correct answer in about a second. I wasn't too unhappy with that until I noticed a C# solution in the...
The soundex algorithm maps several spellings of a name to a 4 character term. (hopefully mapping all different transcriptions to the same term) The steps as described in Introduction to information retrieval are: Keep first Letter for the rest: Change any of 'A', 'E', 'I', 'O', 'U', 'H', 'W', 'Y' to zero Change all ...
I need to call different functions depending on which enum value is used as parameter. it's working as it should do, but I wanted to ask if there's a proper way to do this without lacking a good performance? public enum Comparator { Greater=1,Equal=0,Lower=-1 } public enum ComparableValues { R,G,B,Yellow,Violett...
This is a simple implementation of text prediction using a list of keywords and UITextChecker. This is working correctly, but I think I could have implemented better. My goal is to use a protocol oriented approach. protocol KeywordSuggester { func suggestion(word: String) -> String? func loadKeywords() -> Set...
What do you think about this approach to validate and analyze URLs? There are Url and Url<TResource> model types to represent generic and specific site URL respectively. Specific site URLs can be validated against specific schema and provide custom data extraction API. Let's imagine the following DTO and EF Entity Typ...
I have written Python code that generates a plot. In the code below, when I set maxtime = 0.1, the program takes ~50s and when I set maxtime = 1, it takes ~420s. I need to run it for maxtime = 1000. I am familiar with Python syntax and writing "Matlabic" code, but am lost in writing natively "Pythonic" code. As a resul...
I have an array for an English sentence (enSentence) and for a German sentence (deSentence). Each value represents one word. I want to print every possible phrase pair (enPhrase and dePhrase), where no phrase contains more than maxhPhraseLength words. A phrase can consist of a single word, all words of the sentence, an...
I have this small piece of code written in a class. I am looking for a nicer way to write this, preferably avoiding nested if statements like what I currently have: @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { TheatreListDataWrapper[] selectedOperations = getSelectedDatas(); boolean ...
Just started learning Java Strings. Tried to implement the Soundex algorithm. Package to hold the String related functions package com.java.strings; public class StringFunctions { /** * Removes all the spaces in a given String. * E.g: : "A B CDD" becomes "ABCDD" */ public static String ...
You have one form and you can register a user. It can be god or mortal, but it also requires all the information to let you save the user or the change. When you have all the registers that you want you can edit one or delete it. I'm new using Angular and I want tips to use it better. I also want to see other ways to d...
Using OCR, my program reads the current selection for each of these categories: format, invert color? and storage. The OCR result will always have inconsistent error here and there, which is why I need a Regex match and return the correct wording for each selection: //format private Regex bmp8 = new Regex(".bmp...