instruction stringlengths 71 71.9k |
|---|
Find the largest rectangle area on a bar graph. Example: if you had a graph of 1,4,5,3,3,5 the answer would be 15 (3x5) which is formed by the rectangle that is 3 high and spans from position 2 (1 based) to 6.
Please review my answer and comment about runtime complexity, memory usage, and basically anything else you ... |
Here is my class file to compute MD5 hashes on a file. I wanted to be able to easily calculate them without having to create a lot of overhead in the code using the class.
Can anyone tell me a list of improvements to make this class acceptable?
package Md5Generator;
/**
*
* @author jacob
*/
import java.io.IOExcept... |
I have 4 panels that will contains tables for data. There will be instances where a panel will contain no data, so I have combated wasted space with the code below. I'm relatively new to both jquery and bootstrap and just wanted to ensure I was using the best practice.
$(document).ready(function() {
$('#panel1CB').... |
As an example code I've given here, I have the feeling the use of std::shared_ptr is wrong and should be replaced using a std::unique_ptr because there's no real shared ownership semantics, besides of temporary needs.
How could that code be refactored correctly, e.g. using std::unique_ptr instead?
#include <memory>
#in... |
Here is a snippet of code from a project I have been working on that can be found here. I am looking for suggestions on how I can improve my code to make it cleaner and maybe improve performance.
from PIL import Image, ImageDraw
import subprocess as sp
import numpy
from pathlib import Path
import argparse
import Avera... |
I'm flattening a JSON structure where objects have their interaction type appended at the end, for use in an HTML/PDF generated file. I have variable names for Checkboxes, Text inputs, TextCheck is a combined checkbox/input that needs to be broken apart for my logic. Lastly, I have a Radio Index and Radio Label ojbect ... |
Problem
Suppose we abstract our file system by a string in the following
manners:
The string dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext represents:
dir
subdir1
subdir2
file.ext
a directory dir contains an empty sub-directories subdir1 and a sub-directory subdir2 containing a file file.ext.
The string
... |
I'm writing a simple set/framework of extension methods for argument/parameter validation. What I'm mostly concerned about, ATM is the performance, against the simpliest boilerplate
if(obj == null)
throw new ArgumentNullException()
The framework I came up with is like that:
The Validatable class packing the base o... |
I am doing some challenges, and in one challenge given a non-empty array of int, I am to return a new array containing the elements from the original array that come after the last 4 in the original array. The original array will contain at least one 4.
E.g:
post4([2, 4, 1, 2]) → [1, 2]
post4([4, 1, 4, 2]) → [2]
p... |
I just started messing around with Java's BufferedImage. I had an idea to try to encode a message into a picture by coloring each pixel a certain color that corresponds to a certain character.
Here's the above paragraph as a picture:
It took about 18 minutes to generate. Note the black parts. Those are spaces.
And her... |
I provide a class to use but for convenience I want the class to implement some instance methods as static methods. This was fast and concise but it feels smelly, probably because I'm modifying the class after I create an instance of it. Is this ok?
const logLevel = !args['v'] || args['v'] === true ? 0 : parseInt(... |
I am building an application, and I needed an attribute similar to AuthorizeAttribute, supporting Roles but not using the MembershipProvider roles. (Basically, with the setup I have, I cannot rely on the User.IsInRole method - it's not always accurate, so I manually query the roles in my MasterDbContext instead.)
I hav... |
I wrote a calculation that finds coordinates on an edge of a square, but it came out as a really long nested tangle of conditions. After some reduction and finding common pieces I arrived at this example:
// targetX, targetY, sourceX, sourceY are provided as parameters
// and are markers for the centers of the two ... |
Here is a single-header small unit testing framework I wrote, that makes use of mostly preprocessor macros. I made it for knowing how unit testing works and, also, try to depend less of third-party libraries.
Code:
utest.hpp:
#ifndef CYNODELIC_UTEST_UTEST_HPP
#define CYNODELIC_UTEST_UTEST_HPP
/* Usage:
* 1. Initializ... |
Main ObjectPool Class: It uses atomic operations and a concurrent linked queue to achieve the best performance compared to Apache commons pool. I want to make sure there are no concurrency issues even though unit tests passed without any issue.
import java.util.LinkedList;
import java.util.List;
import java.util.concur... |
Please comment on my DFS implementation and test, I would like to get comments about algorithm correctness.
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root (selecting some arbitrary node as the root in the case of a graph) and explores as far a... |
I am new to Test Driven Development and currently practicing it with some problem statement. Following is an Assembly Line Problem statement I solved using TDD approach in java. Please provide me some guideline on improving it, also if I am doing it the correct way?
Orignal Problem Statement is : http://www.geeksforgee... |
I have written a class with a function that reads out the CSV from the webpage and creates an object with it.
The class seems too big - it seems very unoptimized, prone to mistakes and it's not very readable. How can I clean this class up so that it isn't so large and obstructive?
public class Player
{
public strin... |
This is my implementation of "merge sort" in C++. I'm still a newbie at C++ so:
Have I understood how merge sort works and implemented it in the right way?
Have I used any bad practices?
How could the code be improved upon in terms of efficiency?
Criticism is welcome and appreciated!
#include <iostream>
#include <vec... |
I have been working on Google Foobar since a few days ago. I am currently in the third level but is stuck in the second challenge of "Prepare the Bunnies' Escape."
I have checked this post but it did not fully resolve my problem in Google Foobar as it is still giving me Time limit exceeded errors.
For reference, here i... |
You can play this game as much as you want and after every game, you win/loss is recorded. Javascript has -0 and +0 so I guess that's why the counter acts weird at the beginning. Took me 4 months to do this (from never having heard of objects to this : feels good). I can't load images here at codereview so the link to ... |
Problem statement
You're researching friendships between groups \$n\$ of new college students where each student is distinctly numbered from \$1\$ to \$n\$. At the beginning of the semester, no student knew any other student; instead, they met and formed individual friendships as the semester went on. The friendships ... |
I was trying to implement method number 2, from this article.
Method 2 (Use temporary array) K largest elements from arr[0..n-1]
Store the first k elements in a temporary array temp[0..k-1].
Find the smallest element in temp[], let the smallest element be min.
For each element x in arr[k] to arr[n-1] If x is greater... |
I'm making event system for my RPG game, and I want to know what I can do better, because I think that there are a lot things that can be better. Note that this code is still not completed but it works good, so could you tell me what of bad practises can you find there?
Event:
using UnityEngine;
[System.Serializable]
... |
I am going to prepare some test data for a compression test. One of the them is the 'worst case test', which should make the compressor work worst. Use random number to generate such a file is an idea, but there still contain some kind of patterns in the data. Using 7zip to compress such a file, I get a output file ... |
question:
answer(start,length)
#start is the starting number of the matrix
#length is number of rows.
example 1:
answer(0,3)
0 1 2 /
3 4 / 5
6 / 7 8
where the answer is 2 (by using XOR (^) checksum is 0^1^2^3^4^6 == 2.)
example 2:
answer(17,4)
17 18 19 20 /
21 22 23 / 24
25 26 / 27 28
29 / 30 31 32
which produc... |
This is a continued discussion from (4 sum challenge) by return count only.
Problem
Given four lists A, B, C, D of integer values, compute how many tuples
(i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.
To make problem a bit easier, all A, B, C, D have same length of N
where \$0 \le N \le 500\$... |
Because I'm rather new to PHP and Object Oriented Programming, I'm often looking for some practice. Thus I decided to focus on making a browser-based Mafia game that should work like a Dutch variant: http://www.bendes.nl/.
Before I go any further, I would like to put a disclaimer right here. I'm new to StackExchange an... |
I am writing a python code to recursively traverse a directory containing only text files and then print the 10 digit Indian phone number and all its variants. I am very new to python and I have written the following code to print the numbers and this code is working fine. I want to know if there is any other better wa... |
I have this old graded homework, I am looking how to improve the or shorten the code, I have some lines with over 200 chars.
to_pairs(network) does the opposite.
n_friends(network, n) gets a network (the second presentation) and returns a set of names of persons that have exactly n friends.
lonely(network) returns a... |
I am building a UI which fetches a list of features based on an ID and then the user can edit the list of features and save it. The script also build the UI based on the data structure currently hard coded in.
Was hoping you guys review it and let me know how I can improve it
"use strict";
var activeFeatures = [
... |
I wrote JavaScript code for finding the first two consecutive prime numbers (that doesn't have divisors except one and itself) with a specific gap between them. It works well but take too much time to give results for large numbers.
When I tested this, it took about 48s to give the result:
gap = 8 ,start = 3,000,000 a... |
I want to find all of the whole numbers in a string that starts with { and ends with }, and uses , to separate each number.
I use sscanf to find and match each item in the string—for example:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
const char *str = "{0,1,22,333,4,55,6,77777,8... |
I am aware that there are other ways of implementing a priority queue e.g. using a sorted array/list. Would appreciate some comments on my implementation of a basic priority queue supporting three simple operations: Insert, Min, Max
public class QueueEntry<TKey, TValue> : IComparable<QueueEntry<TKey, TValue>> where TKe... |
I have some coordinates looking like
N47° 15' 36.75",E011° 20' 38.28",+001906.00
and I've created a class to parse and convert them to Double:
struct PLNWaypointCoordinate {
var latitude: Double = 0.0
var longitude: Double = 0.0
init(coordinateString: String) {
self.latitude = convertCoordinate(s... |
An array is defined to be "maxmin equal" if it contains at least two different elements and the number of times the maximum value occur is the same as the number of times the minimum value occur. So {11, 4, 9, 11, 8, 5 , 4, 10} is maxmin equal, because the max value 11 and min value 4 both appear two times in the array... |
I have a program that specifies when an alarm should be active (say, 10AM to 8PM). Part of my program then checks if the alarm is active right now. The "is it active" checker needs to deal with alarm ranges that cross the midnight boundary into tomorrow (say, 8PM to 10AM alarm).
I am currently handling this with redund... |
AES encryption in Go is already pretty simple, Gencrypt is a package that acts as a wrapper around Go's standard packages used for AES encryption to make it even more simple.
https://gitlab.com/zfeldt/gencrypt
go get gitlab.com/zfeldt/gencrypt
My questions are mostly centered around this part of the package (gencrypt.... |
I need to get the value of item inside of this string and parse it as JSON. I've got some working code but I feel like it could be optimized (a lot) and cleaned up (a lot). Any tips or pointers are appreciated. Thanks!
My current code:
let result = script.match(/item:(.*|[\s\S]*)onSelected/gm)[0];
result = result.repl... |
I'm trying to design and develop a singleton class that will handle resolution and configuration of log4j (not log4j2). The basic idea is to have a single class, reusable in any application, that handles log4j configuration and management.
I want the following features available:
Singleton, one instance, conserve mem... |
For my mathematical research, I am to deal with very large numbers and I know that the standard C types are not going to stand a chance against them due to their limited capacity, so I decided to write a super calculator in C language in hope that I won't have to resort to a super computer.
I started with an add functi... |
I'm practising with graphs, and trying to solve a problem of calculating the minimum number of flight segments, applying breadth-first search.
The code is working, but I think, that it's not clean.
Can anyone suggest how I refactor it to make it cleaner?
def distance(adj, s, t):
n = len(adj)
queue = []
vi... |
Is there any way to make this for loop more concise or efficient? I fell like there should be a way that you can cahnge the for loop so that it is about half the size that it is know. By the way, the array list defaultArabic has the values of {1,5,10,50,100,500,1000). Also, I'm not sure if you need to know this, but th... |
I'm looking for any possible improvements in terms of memory usage and speed, but really any advice is welcome.
Problem statement:
John has discovered various rocks. Each rock is composed of various
elements, and each element is represented by a lower-case Latin letter
from 'a' to 'z'. An element can be present mu... |
I have just started Haskell, and I want to check if my code is following the spirit of the language.
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
fibonacci :: [Int]
fibonacci = 1 : 1 : (next 1 1)
where
next x y = sxy : (next... |
This is the final version of my ordered-by-insertion map in C++. What do you think and how can I make it even better? I'm open to all kind of suggestions! I intend to make a similar class, this time, a ordered-by-insertion set!
#ifndef CORE_TABLE_H
#define CORE_TABLE_H
template <typename K, typename V>
class core_tabl... |
I have been implementing the OAuth 2.0 implicit flow to secure the API I use in an Angular SAP. Please, could you review my code? I am sure there is a lot of stuff to improve in it.
I have separated the API into two instances:
Authentication server which checks the user and password and issues tokens.
Resource server ... |
Problem
Find 2nd degree connections ( friends’ friends), output these 2nd
degree connections ranked by number of common friends (i.e 1st degree
connections) with you, (example: if 2nd degree connection A has 10
common friends (1st degree connections) with you but 2nd degree
connection B has 8 common friends (1... |
I have created a DatabaseConnection class as this:
class DatabaseConnection
{
public SqlConnection sqlconn { get; set; }
public DatabaseConnection(string server, string db, string user, string pass)
{
sqlconn = new SqlConnection(@"Data Source=" + server + ";Initial Catalog=" + db + ";User ID=" + use... |
I am currently implementing a Poker game, I have created all the logic for getting the rank of a hand, and I now have to determine the winner of a given hand.
Due to this being Poker, there may be multiple winners in a round. I, therefore, need to find all the keys (Player) that have the best hand (regardless of how ma... |
I attempted to recreate the Polybius square, also called the Polybius checkerboard, which was used in Ancient Greece for cryptography. Since it is an uncommon cipher, it is nowhere on Code Review.
Although the program technically works, it ended up very messy.
#include <iostream>
#include <algorithm>
#include <vector>
... |
Problem statement
Given a collection of intervals, merge all overlapping intervals.
For example:
Given \$[1,3],[2,6],[8,10],[15,18]\$,
return \$[1,6],[8,10],[15,18]\$.
My introduction of algorithm:
I worked on the algorithm several times before, and then also studied a few of "merge intervals" questions on this site,... |
For a template such as:
I'm using the following approach
Get the height of the viewport via javascript (Let's say 500px)
Deduct the header and footer height from it (Let's say header and footer are 50px each. So the end result will be 400px)
Apply the end result as height of the main content div via javascript
Use ov... |
I was doing a few basic Java recursion problems to refresh my memory with recursion (honestly never had to use it in a long, LONG, time), along with using it as a useful way to prepare for any possible interviews for entry level positions. I came upon this problem on codingbat.com:
Given a non-negative int n, compute... |
Problem statement
Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings.
Input Format
First line contains \$T\$, the number of testcases. Each testcase consists of string \$S\$ in one line.
Constraints
\$1 \leq T \leq 10\$
\$2 \leq length(S) \leq 100\$
String \$S\$ contains only the l... |
Since I sanitize all the user-provided string before upload them to the DB, I wanted to give the users the possibility to format text as it happens here on Stack Exchange or on WhatsApp:
*word* -> bold
_word_ -> italic
This class contains two functions:
upload(): is called when the user upload a text and it replaces... |
I have a data structure like this which holds start/end dates:
----|-----------|-----------
Item| start | end
----|-----------|-----------
1 |2017-05-12 | 2017-05-12
2 |2017-05-12 | 2017-05-13
3 |2017-05-13 | 2017-05-13
4 |2017-05-13 | 2017-05-14
5 |2017-05-14 | 2017-05-15
6 |2017-05-15 | 2017-05-16
7 ... |
So there's not much here to "normalize" the database (really only the OrderItems class and maybe the Table Meta class as well) but I'm relatively happy with it.
My only concern is the repeated Name property in many of the tables but since it doesn't appear in all tables, it doesn't make sense to me to put it in the met... |
How can I write this more pretty?
private void _detailSpread_OnCellFocusChange(object sender, CellFocusChangeEventArgs e)
{
if (e.SourceCol == _detailSpread.GetColNumber("article"))
UpdateDimensionData(_detailSpread.GetColID(e.SourceCol), _detailSpread.Rows[e.SourceRow]);
else if (e.SourceCol == _detail... |
In this problem, we are given a 2-dimentional grid, with each cell being walkable or holding a wall. Given an integer \$s \geq 0\$, find the shortest path from the source node to target node breaking no more than \$s\$ walls.
Grid.java
package net.coderodde.grid.router;
import java.util.Objects;
public final class Gr... |
Part 1: Beginnings of a Poker hand classifier
Part 2: Beginnings of a Poker hand classifier part 2
I'm a beginner programmer, working on learning c# and object orientation and have been working on a poker hand classifier for practice. I've expanded my class since last part and made some decisions that i would really li... |
Here's my attempt at a binary search algorithm:
int[] intArr = new int[11] { 0, 5, 13, 19, 22, 41, 55, 68, 72, 81, 98 };
int search = 55;
bool found = false;
while (!found)
{
// if array is of length 1, and number does not equal search value, break
if (intArr.Length == 1 && intArr[0] != search)
... |
I wrote a function which takes in input a list of strings that is splitted by comma. Then each generated string is trimmed.
Example:
INPUT: [[Cat, Dog, Snake]]
OUTPUT: Cat Dog Snake
In particular, I'm interested in removing parenthesis and commas.
This is the code I wrote, but I think it is awful and not so effi... |
I have the following lines to parse from a log file with 8000 lines which takes about 5 minutes to parse:
text="2017-01-12 15:16:42,404 - RestLogger[10c059f7] - INFO - rest_server::log_request:102 - REST call: <POST /multi/ HTTP/1.1> with args {} and content {u'inv_initiators': {u'path': u'/v2/types/initiators/', u'arg... |
I'm new to web development and this is my first website. I was wondering if my login and registration system is secure. I was also wondering how to handle viewing parts of a webpage when the user isn't logged in (ie. hide a section if the user isn't logged in). Sorry in advance if there's irrelevant stuff in the code.
... |
I'd like shorten my jQuery. I know this is possible using this element and child but I don't know how it works.
I have an element being shown and hidden on click, basically. They all have the same ID, just different classes.
How is it possible to achieve this?
This is what my HTML looks like:
<div id="spotparent">
<... |
I present here a piece of code taken from a book about mastering Qt5.
it's the use of unique_ptr in the way shown below which I found to be suspicious and unusual(IMO).
class AlbumDao
{
public:
AlbumDao(QSqlDatabase& database);
void init() const;
void addAlbum(Album& album) const;
void updateAlbum(co... |
My code calls 1 column of a dataframe, turns it into an array and plots it.
I want to able to do this for all the columns without having to repeat the code many times.
How can I do this?
#Code to create fake data
df = pd.DataFrame(np.random.rand(10,5), columns=list('abcde'),
index=list('nopqrstuvw'))
df.columns.n... |
Introduction
I want to check whether number is in given range.
Function takes:
long number that should be checked
2 longs threshold values
byte range mode
Range mode is represented as number of type byte that can be from 0 to 4
0 for 00 => exclusive check
3 for 11 => inclusive check
1 for 01 => maximum - inclusive, ... |
Use Case: I have a form application in which I log events to a file/database and have a need to also raise those events to the application itself (for display purposes). Think old school updating status bar with the same content that you will log to a file.
The solution I put in place is a custom log4net class (since ... |
I implemented this for the Prime Generator problem on SPOJ, but I am only getting 0.01s run-time, and would like to be able to match the run-times of the top submissions, which are all 0.00s.
What are some suggestions for optimizations that I can do to improve the efficiency of this algorithm?
Input: The input begins ... |
Linked list using smart pointers, iterative implementation. It amazes me how a std::forward_list does not allow the list to be walked until the last pointer is null.
I would appreciate if you could pay special attention to usage of shared_ptr.
#include <iostream>
#include <string>
#include <memory>
#include <cmath>
co... |
I have the following tables
productstbl
===========================================
SegmentCode CategoryId ParentId
============================================
-----------------------------------------------------
categoriestbl
==================
CategoryId name
====================
------------------------------... |
Problem:
For a given board, judge who had complete a continuously line (could
be horizontal, vertical or diagonal) of 5 pieces. Input is a 15×15
chess board, could be white (1), black (2) or empty (0). Return if
white win, if black win, if both win or if none of them win.
My specific questions are:
I enumerate... |
I would like to know how to know how can I optimize my current Post method , I initialize object where I am creating list of json items. Also how can I reduce many if and if else statments? For this post and get methods I am using swagger , is it possible to declare exceptions objects somewhere globaly? What kind of go... |
Well, I am writing a web service using PHP to return data from a DB in JSON format. I need to query 3 tables, which have a one-to-many relationship, like shown below:
Contact Group ---(has)---> Contact ---(has)---> Phone number
Here I want to get an array of each group, in each group, get an array of all contacts and ... |
I have been working on a custom Tree class that enforces certain rules upon insertion and deletion.
The implemented tree is a Red-Black-Tree but since the implementation is far too long, I will not post the complete code but only the relevant parts. I have also reduced the code and removed the Red-Black-Tree specific p... |
Context
I m studying clean code and I m actually working on the banker account Kata. Taken from Sandro Mancuo's github account, here's the job I have to do :
Deposit and Withdrawal
Transfer
Account statement (date, amount, balance)
Statement printing
And here's the Kata rules :
One level of indentation per method
Don’... |
The goal of the code below is to have an abstract base class that defines simple methods and attributes for the subclasses. This is part of an application that provides the code base for others to develop their own subclasses such that all methods and attributes are well implemented in a way for the main application to... |
This code will take the array shown and display 4 random entries in the format shown (or near enough).
Are there any parts of this that can be optimised? I'm not happy about the if statement.
<?php
function shuffle_assoc($list) {
if (!is_array($list)) return $list;
$keys = array_keys($list);
shuffle($keys);
... |
Just wondering if there's anything I can improve on, I just started with Python recently and this is one of my first programs.
# Defining Score variables
x = 0
score = x
# Question One
print("What is 1 + 1")
answer_1 = input("a)1\nb)2\nc)3\nd)4\n:")
if answer_1.lower() == "b" or answer_1.lower() == "2":
print("C... |
The idea is to obtain the keys as a list ordered by the natural ordering of the keys but first of them all the ones that have priority, stated by the method hasPriority(). The custom comparator code block feels out of place and I wonder if it is possible to improve the code:
private List<String> orderedKeys() {
ret... |
I would like someone to look at my class for reading messages from a network socket. In short, the whole app should behave like a regular ping command with some additional functionalities. The point here is that I want to separate the reading of messages, and processing (which is done each second). This object is run i... |
Is there any way I can minimise this code.The code will get the neighbours of the current node and point the arrow to the current node
private boolean isDiagonal(int x, int y, Node node) {
if (x == -1 && y == 1) {
node.arrow.setDrawable("bottom-right");
return true;
} else if (x == 1 && y == 1) ... |
An array is said to be hollow if it contains 3 or more zeros in the
middle that are preceded and followed by the same number of non-zero
elements. Write a function named isHollow that accepts an integer
array and returns 1 if it is a hollow array, otherwise it returns 0.
The function signature is int isHollow(... |
In another post I created a piece of data, which make compressor annoyed.
Create 'worst case test' data for compression test
Now I am trying to make it happy. I generate another data set, with a lot of duplicated binarys. Of couse a data set composed of only one value is the best, but that is too easy.
This time I us... |
I have recently upgraded to AngularJS 1.5 and as the title says, I want to use different templates depending on a value in the item object passed.
After some research I found multiple ways to accomplish my task and I have picked out two of the (many) ways I found. Since I'm still quite new at Angular I was curious abou... |
I am working on a pet project of mine which I've recently revived after a year long hiatus. The application is a note-taking application with client-side encryption. If you need an analogy think Evernote meets LastPass.
Before any version of the app hits the first beta testers I would like to have the encryption relate... |
I am writing some tests in selenium webdriver (on node.js). and have made a custom function to check the css value of an iFrame Element. I'm a coding beginner.
The script tests an app where the user writes the image width they want (just putting in a number) and the image in an iFrame should change width. This is trick... |
I solved the problem to print all possible subsets of an array. I just want to know a better approach or anything different I could have done.
Question: Print all possible subsets of an array.
My approach: I know that there are \$2^N\$ (no. of elements in the set) subsets and each subset can be represented with the hel... |
For my computer science class, I've implemented a Java version of a queue and would like to know if there's anything wrong with it. After my tests, it seems to work fine, but maybe somebody can point out what can be improved or if something is wrong.
public class Queue<E> implements IQueue<E> {
private E[] internalQue... |
This is my implementation of an .NET ValidationAttribute to validate a string against a JSON schema. The JSON schema file is stored within the application as an embedded resource and is referenced by passing its fully qualified name in the constructor.
A couple of things I'm not 100% about:
Returning ValidationResult ... |
I'm trying to learn some coding to broaden my scope of knowledge, and I seemed to have run into a bit of a conundrum.
I'm trying to create a program to output the number of characters, digits, punctuation, spaces, words and lines that are being read in from a file.
Here is the text file I am reading in:
See Jack run. J... |
In my web-app, it is possible to delete an Item when visiting any of 4 different pages:
the Show Item page
the Edit Item page
the List Items page
the List Items in Room page
If the visitor uses a delete button on either of the 2 List pages, they should remain on their current page when the deletion is complete. But i... |
I got an interesting interview question related to JavaScript:
In JavaScript please create a storing function called storingFn with the following characteristics:
Read Cafefully
Save immutable key-values.
The values can only be accessed by storingFn and should not be exposed in the global scope.
It can't use Browse... |
Any suggestions on how to improve this code (other than arbitrary call-stack depth)?
#include <iostream>
#include <vector>
template <typename T>
void merge(const std::vector<T>& left, const std::vector<T>& right, std::vector<T>& merged)
{
auto i = left.begin();
auto j = right.begin();
auto k = merged.begin... |
Objective
I set up my page to dynamically wrap <i> tags around a targeted keyword (string) on a title.
Background
When I worked on the static parts of the website, I could manually wrap that word. But Some parts of the page will be generated by the server, so if the word appears in the title, I need it wrapped so that ... |
This is a Date class I made for a hobby project. It does not deal with time at all; that is, the smallest unit of time it considers is one day, and no concern with time zones.
Where I do most of my coding, I'm not allowed C++11, so if there are any new languages features that would apply here, I am definitely intereste... |
This code gives me what I am looking for. But I'm just thinking how I can streamline the if statements because I would be repeating myself a couple of times, and that's not really good isn't it?
import requests
import pandas
from sqlalchemy import create_engine
import os
import numpy
from selenium import webdriver
from... |
I'm using Python 3 and have written this code to find the right triangle sides when given the perimeter:
def intRightTri(p):
l = [(a,b,c) for a in range (1, p)
for b in range (1, p)
for c in range (1, p)
if (a**2 + b**2 == c**2) and (a + b + c == p) and (a<=b) and ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.