instruction stringlengths 71 71.9k |
|---|
This is an object exposed to the view and is being used on directives within the same view. The directives need to track changes on the ctrl.filters.applied object. It's a simple part of a project at my work and I'd like to know if I'm doing it right.
Other properties and methods are just being used on the view itself.... |
I would like some advice on how I could make it less repetitive and use more functions and classes.
#include <iostream>
#include <string>
using namespace std;
class date
{
public:
date() = default;
date(istream &is) { is >> year >> month >> day; }
bool organizeInfo();
bool organize();
ostream &ou... |
A date is un-ambiguous when each number may be
decided to be day or month or year given the range
limitation of these numbers.
For example
\$14\$ cannot be a month number
\$2008\$ cannot be a day number
@param un_ambiguous_date: an un-ambiguous scrambled date,
of the format X/Y/Z where X, Y, Z correspond ... |
As part of a past assignment, I've expanded on this implementation of ls to have more options available, including non-standard ones.
It currently supports these (described on this page):
-a
-d
-h
-i
-l
-p
-Q
-R
-S
-t
-U
Other than that, it doesn't list a total field nor does it have coloring. It also doesn't have t... |
I am working on an special version of Secret Santa with internal sub-groups.
Typical Secret Santa (SS) requirements:
Cannot be assigned to themselves
Should be random
Every participant should be assigned to someone
Every participant should have someone assigned to
Special requirements; there are subgroups that should... |
For MAX value of 1000000000 (\$10^9\$), it takes about 45 seconds to reach the line where it prints "done". How can I speed this up?
Is printing to screen always going to take so much time? I know it's hardware.
On increasing the size of MAX beyond \$10^9\$ gives me an exception on the line memset(a, true, MAX);. Is th... |
UPDATE: Added concise problem summary and sample output log.
I tried coding a sample Java program to solve a problem statement:
Java Banking Demo Problem statement
Complete code for Java Banking Demo
Concise Problem summary:
Design and Implement an Engine that processes the SMS messages which
are sent from a users... |
I'm currently working with the LLVM JIT framework. There is some graph I had to implement for internal cost bench-marking. It has cyclic node dependencies, so I have to use std::weak_ptr pointers for nodes' children instead of their std::shared_ptr counterparts. When it came to implementing child iterators for the grap... |
I am new to Sails.js, Node.js, and web application development in general. My current understanding is that well-written controllers should be "skinny" meaning they should be as simple as possible, easily readable, and abstracted by using helper functions to reduce the amount of code in the controller itself.
I want my... |
This is a c++11 implementation of Huffman-encoding that I wrote as a hobby. My main goal in writing it was to get more accustomed to c++11 and STL in general, as well as stuff like bit-manipulation.
Here are the classes bifstream and bofstream (binary ifstream/ofstream). I wrote these so that I could read in/write out ... |
I recently wrote a Fibonacci program in Python, and one of the answers mentioned an Infinite Sequence. I decided to implement an infinite sequence in Java, as I am not that experienced in Python.
import java.math.BigInteger;
import java.util.LinkedList;
import java.util.List;
public class InfiniteFibonacci {
/**
... |
This is the main.c file for Khronos, a personal project of mine. This is basically where the whole program is setup, run and then quit. I'll post the short summery of what this file does from the README.md:
How Khronos Works
The process starts off by recording a .flac file with the help of
LibSndFile and PortAudio... |
I decided to write a pathfinding algorithm in order to expose myself to the world of pathfinding and for me to further understand more advanced algorithms such as A*. I chose C# due to its flexibility compared to other languages such as Java.
I will start with the basic objects and work up to the more complex ones.
vec... |
This morning I've seen this on Twitter:
http://mynewtechworld.tumblr.com/post/135545896048
I case that somebody can't see the image:
I
01101100
01101111
01110110
01100101
you.
Just for fun I wrote this binary to ascii-converter in JavaScript:
var chars = [
'I ',
0b01101100,
0b01101111,
0b01110110,... |
I was trying to achieve a simple problem :
If the user is an employee of the store, he gets a 30% discount
If the user is an affiliate of the store, he gets a 10% discount
I came up with the following :
The abstract super class :
abstract class Customer {
String cid;
String customer_name;
double fare;
Custo... |
While fiddling around, I've made a very simple and naive function to retrieve any repeated sub-string within a certain string.
function getRepetitions(str, length){
if(isNaN(length))
{
throw new TypeError('length must be a number');
}
if(length < 1 || length > 2147483647)
{
throw ne... |
Preliminaries
Given two matrices
$$
A = \begin{pmatrix}
a_{11} & a_{12} & \dots & a_{1q} \\
a_{21} & a_{22} & \dots & a_{2q} \\
\vdots & \vdots & \ddots & \vdots \\
a_{p1} & a_{p2} & \dots & a_{pq} \\
\end{pmatrix}
\text{ and }
B = \begin{pmatrix}
b_{11} & b_{12} & \dots & b_{1r} \\
b_{21} & b_{22} & \dots & b_{2r} \\
... |
I know I should use mvvm, but just starting with WPF, here is my code:
MainWindow.xaml
<Window x:Class="EasyUpdater.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008... |
Assignment: Develop a Java application that will input the number of miles driven and gallons used (both as integers) for each trip. The program should calculate and display the miles per gallon obtained for each trip and print the combined miles per gallon obtained for all trips up to this point. All averaging calcula... |
I'm not sure what the best way is when dealing with users calling start() multiple times or stop() before calling start(), I decided to silently return. I lean towards not using exceptions for these situations. Is there a good argument to be made for exceptions? Is there a different or better mechanism?
Looking for:
S... |
This is a script that must send an email at each new article published on a specific website. Any suggestions or improvements to do?
SENDER_EMAIL="sender@example.com"
TO_EMAIL="myemail@example.com"
RSS_SITE="example.com/feed.xml"
CHECK_INTERVAL=10
while [ 1 ]; do
LINK_ARTICLE=$(rsstail -i 1 -u $RSS_SITE -l -n 0 -... |
On Wikipedia, if you click the first non-italicised internal link in the main text of an article that's not within parentheses, and then repeat the process, you usually end up on the "Philosophy" article (see this Wikipedia essay).
To test this idea, I made a simple Python module that does the "clicking" programmatica... |
I have this code which generates and shows list of selectable items that user can post to controller in order to save into database.
Model looks like this:
public class DeliveryAddressSelectionModel()
{
public List<DeliveryAddress> DeliveryAddresses { get; set; }
public List<int> SelectedAddressIDs { get; set; }
}
... |
I've created a console/terminal command handling module that allows the programmer to bind functions to a command name and later execute them from std::string. What's new is that it handles most stuff automatically and allows for usage such as:
void func1_ptr(const std::string& name) {
std::cout << "Hello " << name... |
I'm trying to build a game where a client gets to play against a server in a game of Tic Tac Toe. I've built the game and followed a somehow structured design of how the game is supposed to happen, with the client and the server exchanging messages, but they seem to lose synchronisation at the beginning of the game.
T... |
I am very new to this. Hope someone could help me suggest how to improve the code.
I have two tables where I need to get the SQL data and output it into XML format. I am using LINQ method. Below how the code looks like.
#region Database XML Methods
private static void CreateDatabaseXml(string path)
{
tbchrData... |
I have created a JavaScript based game, which is based on the card game War. I think I am reusing a lot of my code, but I am not entirely sure what I can really improve. I have a lot of functions, which could probably be improved.
Please take a look and give me a review of it. I think I nailed it, but let me know what ... |
I've been given a homework assignment to make a function to check whether 2 given arrays with the same given size have exactly the same set of elements.
My function seems to be working but I feel like I don't use the principles of recursion properly in my function.
I'm not allowed to use dictionary like data structures... |
I am facing the following problem: I have a special data structure that is a dictionary whose keys are integers (dimensions). The values are also dictionaries whose keys are strings (geometric types) and whose values are numpy arrays (connectivities). Something like this:
custom = {1: {'a': np.zeros(10), 'b': np.zeros(... |
code from suggestions in comments here. I will still write it like the first time, so you do not need to read the old question.
I've created a UDF some time ago and used it pretty often till now in different ways (but mainly to compare a "history" of data like having different filters at the same time). While there is ... |
Despite the fact that this code works, I would like to know if there's any situation I did not anticipated, and/or if what I am trying to do is some what wrong.
-std=C++11 flag needed
#include <iostream>
#include <string>
#include <map>
#include <typeinfo>
#include <functional>
class object
{
public:
virtual ... |
For my CS class, we were tasked with writing a program that calculates all the possible results from rolling two n-sided dice. For example, the input of 4 would print [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8]. Or, if the input was 3, it would print [2, 3, 3, 4, 4, 4, 5, 5, 6].
I was given enough test cases ... |
I've created a UserScript for adding follow-up reminders to any post (question or answer) here on the Stack Exchange network. I did this in response to a stackoverflow meta post feature request which sparked my interest.
It adds a calendar icon into the vote cell which displays a datepicker where you can select a remin... |
This code was made to find all the perfect numbers between 1 and 1000. A perfect number, is a number where all of it's divisors add up to that number.
For example:
6 is divisible by 3,2, and 1 and3+2+1 = 6. Therefore 6 is a perfect number.
public class Perfect {
public static void main(String[] args) {
fina... |
I'm programming a basic command line calculator in java that can parse expressions and evaluate them, does not handle brackets yet.
For example an expression: \$9+9/2^2*5-1\$.
At this point I can give my program an expression that contains exponents, and It will evaluate them one by one until there are none left.
For e... |
I made this little code to see what brute forcing is like. I made this with a complete guess on how it works. This code works fine but it seems to take much much longer than it really should. I have the Scanner there so I can tell the program what password it is searching for. I have the timeMillis also just for person... |
I am just looking for code review and overall critique. I want to know what I can do better and how can I do things more efficiently in Java.
I need particular feedback on the use of my ArrayList in my colsToRows method and then how I converted it back to regular arrays in Java. What better step could I have taken ther... |
I've built a web crawler using the BeautifulSoup library that pulls stock ticker data from CSV files on Yahoo finance, and charts the data using matplotlib. I'm wondering if there are any ways to improve the code I've written, because there are some parts that I think could be a lot better.
import urllib.request
from ... |
I'm using a factory for my $http get requests.
When I pull single json objects from the $http, it works pretty quickly
I now have items coming through as an array. It is very inefficient, & slow. Images 'pop' in.
Ideally it would just load one list (of say 10 images) then know to load the next list, say after 4 swipes... |
I am programming a language interpreter in C# and have recently created a set of functions that receive either a string or a string[] and split it by a received string.
For example, with a string:
"Hey:123:hello:456"
":"
It will return this array:
{"hey","123","hello","456"}
And with a string[]:
{"a:b","c","d:e:f"}
"... |
I'm just a Clojure noob (started learning yesterday). Here is my helloworld program. It factorizes number into primes. Do you have any comments? How could I make this code cleaner and shorter? Maybe I can deduplicate some things?
(defn lazy-primes
([] (cons 2 (lazy-seq (lazy-primes 3 [ 2 ]))))
([current calculate... |
I need to develop an API. The functions of the API are requests that call the services exposed by a server.
Initially the API worked like this:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import logging
import suds
import json
import string
import socket
import signal
import traceback
from suds.client impor... |
Since reading Robert Martin's book "Clean Code" I have been inspired to revisit and refactor some of my code to break it down into succinct methods and small specialised classes.
Given the need to retrieve the NameAttribute off the Name2 property of the TestObject class below...
public class TestObject
{
... |
I have the following code to generate an URL based on alias and args provided
/**
* Get the url by alias.
*
* @param string $alias
* @param array $args
*
* @return mixed
*/
public function url($alias, array $args = [])
{
if (empty($this->map[$alias])) {
return null;
}
$segments = explode('/'... |
Follow up form Extending Sieve of Eratosthenes beyond a billion
Taking suggestions from the comments on the previous post:
Updated Code: This takes about 22 seconds for MAX as \$10^9\$ to reach "done". This is a significant improvement.
void sieve_of_eratosthenes(){
bool* a;
a = (bool*)malloc(MAX * sizeof(bool)... |
I've Implemented a Serialization Utility which Serializes/DeSerializes a class, along with writing JUnit Test Cases for the same.
Please Review the code and Suggest me how to improve it. Particularly in generics as I've not written much code with Generics in java.
SerializableEmployee.java - Class to be Serialized
pu... |
From my previous question, I got great feedback which helped improve my code which I submitted. I went back and built upon that and came back to see if my code is an improvement.
try:
from tkinter import *
except ImportError:
from Tkinter import *
import time
import random
with open("NAME_FILE.txt") as f... |
I would like to know if this fullscreen page with image and overlay is written clearly. I'm afraid that those two empty divs (topOverlay, and topImage) are not correct. Someone told me that I shouldn't use empty divs when there's another way to do it, but I couldn't find an alternative way in this case. Is there a diff... |
This project utilises the external-workbook-retrieval methods found here for the second workbook.
This is the beginning of a project. The code here covers:
Initial setup (define workbooks, unmerge any cells in data input)
Then, for the 3 worksheets across 2 workbooks: Find the table ranges (this workbook only), Create ... |
This feels wrong:
private decimal ConvertStringToDecimal(string decimalString, decimal defaultReturnValue)
{
var returnDecimal = defaultReturnValue;
try
{
returnDecimal = decimal.Parse(decimalString.Trim());
}
catch (Exception)
{
// naughty
}
return returnDecimal;
}
but I thin... |
I created a plot on which the y value is visible with the marker.
What's your opinion ?
I wonder if I could have done something simpler.
(code should run in a Jupyter notebook)
%matplotlib inline
fig = plt.figure()
axes = fig.add_axes((1,1,1,1))
X = np.array([3,3.2,3.5,3.8,3.9,5,5.5,5.8,5.9,5])
y = np.array([1,1,1... |
This generic function invokes a property of a given object by name:
Private Shared Function GetPropertyValueByName(Of TObject, TProperty)(
ByVal T As TObject,
ByVal PropertyName As String) As TProperty
Dim result = GetType(TObject).GetProperties() _
.Where(
Functio... |
I have a custom dictionary where the values are numpy arrays. I would like to have a convenience function that creates a copy of its content except that the values are changed. If no value is passed, then the default None is assigned to the keys, else a value is set. The function can also work with a callable function,... |
So I have the below (which is working correctly and all my unit tests are passing) but it's ugly and is violating SOLID, I will have to change the class every time I want to be able to map a different type (The multiple if statements).
Code
/// <summary>
/// Maps the matching properties from one type to the other by na... |
I have a 2D array class that is actually mapped to a 1D vector. For example, to obtain an element at a particular position, the code is as follows:
template <typename T>
T mat <T>::at(const size_t &row, const size_t &col) const
{
return m_values[row*ncol() + col];
}
Here's the relevant section of the class in-contex... |
I think the following is good but wondering if it can be simplified or improved.
My condition for code execution is the following:
It is a Monday
AND
It is not the Monday following the last Saturday in the month.
This is the current sql:
DECLARE @now DATETIME = DATEADD(dd,DATEDIFF(dd,'19000101',SYSDATETIME()),'19000101... |
I created a key in Windows registry to have an option on every folder which allows me to simply right click, choose the right option and have a PDF made, either from JPGS, or PNGs, or TIFs.
My registry key is as follows:
'"C:\strawberry\perl\bin\perl.exe" "C:\Users\michal\Documents\createpdf\790024.pl" "%1"'.
The cod... |
I need to redo a migration occasionally. The workflow is usually something like this:
find or ls | grep the migration using some keyword
copy the timestamp
paste the timestamp in bundle exec rake db:migrate:redo VERSION=123
As I hate repetitive work, I wrote a small bash script that allows running a migration using o... |
I haven't made a game in Excel yet, so I decided to Make Conway's Game of Life.
If you wish to play along, I've uploaded the workbook here.
Right now it's very rudimentary (No user interface, no buttons/controls, no automatic tick-increment), but I would like to, in the future, add all of the above. Perhaps even make i... |
I'm reducing a large array of objects to a simple object with 8 properties. I'm currently using Array.prototype.reduce to loop through the array of objects to create a new object. In order to assign a correct key to the value in the array I'm using a switch statement. My code currently works, but I'm looking to refine ... |
The latest new refactoring for our friend Rubberduck is Encapsulate Field:
This image, for the sake of brevity, shows the result of the refactoring and the UI together. The three properties below the field are what is inserted by it.
All together, I am pretty satisfied with the code, so I need you to inspect it and he... |
Here is the updated code. The original question can be found here.
I would love it if you posted more ways I can improve this code. I am still fairly new to Java so I am not entirely sure how to make it any better.
package hexTox;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class Main {
... |
I want to learn OOP and I am creating a little CMS for practice and to use it as a base for other projects in the future.
This is the complete code: GitHub
My major concerns are code structure, security and re-usability, but any feedback is welcome.
About code structure, I am using classes and it all works well but the... |
My team and I have a very poor understanding of best practices in relation to telnet. We have Task.Delay and Task.Wait in the code, including async voids and from what I understand those are potential areas that can cause deadlocks and other issues.
I'm trying to understand async in relation to running a telnet client.... |
I am seeking a review of a previous project I completed in my first term at university. The submission was graded 18/20 however the feedback was minimal and gave no suggestions regarding further improvements.
The specification prohibited the use of any non-primitive data types.
Concise problem specification:
Studen... |
I have a Part of Speech Tagger written in PHP that currently takes a relatively long and unpredictable time to execute - just wanted to know if any of you knew of any quick ways I can improve time efficiency in this class - not necessarily related to the algorithm itself, but even the construction of the PHP code.
<?ph... |
Lately there has been some questions regarding calculators, where the response typically has suggested simplifying the logic and using either abstract syntax tree or token lists (like I did myself in a Java calculator question).
To prove the concept, and as a training exercise for my self I implemented this calculator ... |
I have made a little shop keeper program and I would love someone to critique it and list all of the improvements I could make. This is my first time using OOP techniques so I imagine there is a lot to be improved upon.
This program allows you to purchase - and sell - up to 5 items from a shop seller and has a currenc... |
After reading this article, I've decided to take a crack at implementing a "safe_strcpy" function that would remove some of the errors that the author speaks about. Obviously, my safe_strcpy() function is inspired by his. Below, I've created a simple class that houses a std::array of one of the many different kinds of ... |
I have created canvas (800x400) - and filled it with a grid. It works but the rendering of the grid (lines) takes around 3 seconds, which seems excessively long. Am I doing something wrong?
var drawGrid = function(w, h, id) {
var canvas = document.getElementById(id);
var ctx = canvas.getContext('2d');
ctx... |
I do not have a whole lot to do over winter break, so I wrote this little script to automate a Wordpress install (currently can only install once instance) on a fresh Debian server (tested, working with Wheezy). It may be pretty sloppy because it's the first thing I've actually tried, but it's a start I guess. I was no... |
Following-up to my previous question, this class is now based on an iterator. The class, instead of forcing the programmer to use up a bunch of memory just to get each progressive number once, they can now use an iterator. The class itself is also now based on an iterator, which makes my life easier too. No more initFi... |
Following function will parse string resp, which will be like shown in following example. I will get an IP address in the form of a hexadecimal string like "C0A2AA32" and I need to convert that string and save it to a file.
Example of resp: "This is just a string with ip="2342A022" now I need to parse it"
void WritePub... |
I'm trying to practice STL so I implemented breadth first search and depth first search. I have designed the graph class so that vertices can be arbitrary hashable object.
Any feedback would be appreciated
#include <deque>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <iostream>
template... |
I have created a StopWatch class to measure the performance of any code. I use this StopWatch code in any of my multithreading projects as well.
public static class StopWatch {
public static ConcurrentHashMap<Long, Long> histogram = new ConcurrentHashMap<Long, Long>();
/**
* Creates an instance of the ti... |
I have a below code which constructs the URL given a FlowType enum.
private String getURL(FlowType type) throws Exception {
StringBuilder url = new StringBuilder();
if (TestUtils.isProduction()) {
if (type.equals(FlowType.HOLDER)) {
url.append(VISITOR);
} else {
url.appe... |
Yesterday morning I decided to stop procrastinating and start learning me some Haskell.
So far I've made this, which is a simple cli 'dice rolling' utility that can be used like:
$ ./dice 3d20
You rolled: 17
The code looks like this:
import Data.List.Split
import Data.Char
import Control.Monad
import Control.Monad.Ran... |
I need the byte representation of a given type, especially double, float, int8, etc.
typealias Byte = UInt8
enum ByteOrder {
case BigEndian
case LittleEndian
}
func pack<T>(var value: T, byteOrder: ByteOrder) -> [Byte] {
let valueByteArray = withUnsafePointer(&value) {
Array(UnsafeBufferPointer(s... |
I request a review on the way multiple producers and consumers access multiple shared queues.
What I have done here requires the threads to check for the space in queues minimum two times. Can it be made better someway?
Of course, I can create another queue where these queues will be kept in the decreasing order w.r.t ... |
The code has been test to work by the parameters listed below I just wanted to know if there were any details that I missed or blatantly overlooked.
Develop a Java application that determines whether any of several department-store customers has exceeded the credit limit on a charge account. For each customer the foll... |
Requirement
I have an entity named ImportData which can be processed once in order to extract data from a file fed to the application.
I need to make sure that, in case of concurrency, only one process is capable of processing that import data. Other processes shall not attempt to read the file and insert data into dat... |
So, I have two tables, customers and orders and I want to get all orders associated with a customer.
The tables look like this:
Customers
customer_no order_no
1027 V327
1027 V391
1028 V400
etc..
Orders
order_no article1 article2 size order_date quantity
V327 Jeans Bla... |
I'm just wondering what is the cleanest way you can write your GUI/Swing code? Right below is the code I have for my main frame. Could you guys let me know if it looks clean/understandable, and if there is any way I can improve it?
The code I have provided is the main frame of my program, which is basically a GUI progr... |
Problem statement
Create one form having registration and student login fields for course using HTML5 elements and CSS3 styling.
Expected Output
Solution
<style type="text/css">
.div{
height: 20px;
background-color: #2A646C;
width: 60%;
margin: auto;
... |
About / Background
This is indirectly a follow up from: General Game Loop 3.0, if you prefer to test against it, feel free to. That code is very outdated now though. A test suite is given at the end.
For the actual class to direct feedback against: MyText.java, a short description of it follows beneath, as well as a te... |
I wrote a program to simulate this week's 538 Riddler, reproduced below:
You’ve just finished unwrapping your holiday presents. You and your
sister got brand-new smartphones, opening them at the same moment. You
immediately both start doing important tasks on the Internet, and each
task you do takes one to five... |
I have a third-party object with asynchronous start and stop methods. Each start and stop may fail with exception. The object is not re-entrant, i.e. I can only call its start or stop method after the previous start/stop has completed.
I need to have a class that handles those transitions to the correct (=last asked) s... |
This is something I put together from a 3D Soft Renderer I previously wrote in Java. I have less experience in C++, but I thought that being able to render 3D shapes in a console simply by printing characters (Like Perspective ASCII Art) would be a fun challenge.
This was mainly for educational and learning purposes an... |
The following code finds the max depth of nested parentheses in the given string - for example, for {}{}{{}} it outputs 2. If the given string doesn't contain correct sequence of parentheses (like {{}), it outputs "NIE". User enters the length of the string and the string.
My concerns: the algorithm is somewhat slow, a... |
On my site I have a navbar component that I want to customize for each and every ng-view I end up loading. Currently I'm doing this as follows. I have a NavCtrl for the navbar itself and my ng-view directive sits outside the scope of this controller. And I use a navbar service to change/override functionality in the na... |
I am beginner in EmberJS. I have made todomvc for ember v2 for learning Ember.
My implementation works without controller. I use components instead controllers.
In the documentation I see:
Controllers are very much like components, so much so that in future versions of Ember, controllers will be replaced entirely wit... |
This is my Queue implementation in Java. Would appreciate a review of the code.
import java.util.Iterator;
public class Queue<T>implements Iterable<T> {
private Node first, last;
private int size;
@Override
public QueueIterator iterator() {
return new QueueIterator();
}
private class... |
I have 2 methods for getting data from the database (the data I get are both List of tuples with doubles and datetimes in it). I would like to know if it is possible to use one method for both queries.
How can I make this code DRY? In my opinion I'm defining 2 methods which clearly does nearly the same. How can I impro... |
I have two files, namely:
File1:
CL1 AA XX YY ZZ SS \n
CL2 3_b AA
File2:
AA string1
AA string2
3_b string3
My expected output is:
CL1 AA string1
CL1 AA string2
CL2 3_b string3
CL2 AA string1
CL2 AA string2
For this I wrote a following code:
import numpy as np
print("Reading Files...")
header = open('File1'... |
I have the following code which sets input values using jQuery/AJAX. Can the repetition of the code be shortened in anyway? It's mainly the AJAX requests I'd like shortened. It doesn't seem right to be making so many AJAX requests but despite my research I can't seem to find a way to improve things.
// set property def... |
I just some reviews on how I can make it more efficient or cleaner and what I should fix in general.
class bankAcc
{
public:
bankAcc() = default;
bankAcc(string fn, string ln) : firstName(fn), lastName(ln) {}
bool createUser(istream &is);
bool login() const;
private:
bool correctLogin(const string&,... |
I have lines_list_copy of the form:
[['a1', 'b1', 'c1', 'd1', 'e1'], ['a2', 'b2', 'c2', 'd2', 'e2'], ... ]
I needed to remove all duplicate entries where a,b,c,d are identical. So note that I don't care about what value e has. So for example, If lines_list_copy = [['a1', 'b1', 'c1', 'd1', 'e1'], ['a2', 'b2', 'c2', 'd... |
The challenge is simple:
Return the length of the longest word in the provided sentence.
The solution is just as simple:
function findLongestWord(str) {
arr = str.split(' ');
size = 0;
for (var s in arr) {
if (arr[s].length > size) {
size = arr[s].length;
}
}
return size;
}
However, I vaguely... |
I have created mini-opengl program that draw simple chess board on screen by using SFML windows model only. The program runs fine. The main purpose of this program is to keep it as simple as possible and it is not rely on any of OpenGL helper functions like glOrtho or gluOrtho2D for converting coodinates. Also, it is n... |
Here's my implementation of a Singly Linked List. Would appreciate a review.
public class SList<T> {
private Node head;
private int size;
private class Node<T>{
public Node(){
item = null;
next = null;
}
public Node(T item){
this.item = item;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.