I'm learning c++ and here I've written a little toy program that is supposed to list all the arguments passed to it through the command line.
#include <iostream>;
using namespace std;
int main (int argc, char *argv[]) {
for (int number = 1; number < argc; ++number) {
cout << argv[number] <<...
In python, If I have a function that returns an object, say someEncapsulatingClassObject.foo() returns _foo, and _foo's class has a member function bar(). Do i have to first save a reference to _foo, then apply bar to it, as in _foo.bar(), or is there some way to chain them together?
I tried someEncapsulation.foo().bar(), and that does not work unfortunately. I'm not even sure what this concept would be called
huh, and now it works, but in a different location in my code...
I have to do a function called findsaw. This function searches for the longest sequence of toggled consecutive bits in an integer and returns the index of the first bit of the sequence, the sequence must start from the least significant bit.
In the case there are multiple answers(sequences with...
Hi, welcome to Stack Overflow! This kind of question is probably better suited to this site: codereview.stackexchange.com. On codereview you are likely to find more people who can answer your question in a way that is more helpful for you in the long run. — William Patton39 secs ago
On Code Review we can help you improve your working code, however that would not be a good place to ask how to write new functionality to your code (that is explicitly off-topic as "code that is not written yet" therefore not reviewable). — Phrancisjust now
The returned class as result
public class cs_HttpFetchResults
{
public bool blResultSuccess = false;
public string srFetchBody = "";
public string srFetchingFinalURL = "";
public bool bl404 = false;
}
The HttpWebRequest version is shown below
publi...
So I originally asked this question on the main Stack Exchange site but it was recommended I post here instead.
OK, so Im working on a pretty simple Text Adventure game. Right now I have a functioning menu, and a very simple "battle mode" which will be converted into a random encounter as soon a...
Today, I tackled this coding question:
Given a singly-linked list, check whether its length is even or odd in a single pass. An Empty list has 0 nodes which makes the number of nodes in it even.
Would the time complexity of my code be O(n)? Do you guys see any improvements that can be made? Plea...
Here is my implementation of a Pascal program, which is used to print an n-order Pascal triangle.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import operator
from itertools import starmap, tee
from functools import lru_cache
def pairwise(iterable):
"""
s -> (s0,s1), (s1,s2), (s2,s3...
I have not really asked for a code review. I just said any feedback is welcome. Also, if the question is "too broad", anyone care to point me in some direction, if not answer anything exactly ? I didnt ask for code, I am just asking if artificial intelligence can be applied in the direction in which I am going with this code. Also, if you people don't help cases like this, can you point me to some site with lesser hotshots and those who really wanna help the beginners ?! That'd be great, thanks ! — TARUN SHARMA12 secs ago
I was inspired by another question to post another method of finding the two points in a plane that are closest to each other1.
This one is a line-sweep algorithm. It works roughly like this:
Sort the points based on their X coordinates.
Take two left-most points. They give us our first guess ...
I think StackOverflow is more "solving problem" site. You should check out CodeReview site, because I think you will get faster answer there — koceeng6 secs ago
ALTER PROCEDURE generate_invoices
AS
BEGIN
DECLARE @id_employee INT
DECLARE @id_client INT
DECLARE @id_service INT
DECLARE @amount INT
DECLARE @payment_way VARCHAR(20)
SET @id_employee = (SELECT TOP 1 id_employee FROM Employee ORDER BY NEWID())
SET @id_client = (SELECT TOP 1 ...
Note: This is my first question here so feel free to give me advice in the comments. I have read the How to ask a question page but I may have missed something
I have decided to create a discount Pokemon battle simulator using a module called guizero. It's basically a wrapper for tkinter that is...
Problem
A jamcoin is a string of N ≥ 2 digits with the following properties:
Every digit is either 0 or 1.
The first digit is 1 and the last digit is 1.
If you interpret the string in any base between 2 and 10, inclusive, the resulting number is not prime.
Not every string of 0s and 1s is a jam...
This is my first attempt at object oriented javascript code. Could you please review it and provide your comments, tips etc.
I have been writing Javascript codes for few years now but this is first time I am trying to write OOJscript code. I read about OOJscript, but I am not still very confiden...
Does this sound doable or am i just wasting my time ?
I mean, should i take the step and complicate things more. I do after all have a working installer. But, a self updating installer sounds better.
Main question is, For the ease of allowing modders to create and upload modifications at will, ...
I consume an API which gives me this type of JSON:
{
"data": {
"name": "Start",
"pid": "1",
"position": {
"data": {
"x": "31",
"y": "330"
},
"metadata": "empty"
}
},
"metadata": "empty"
}
I have created the classes with objects with the s...
PRIME1- Prime Generator
The code is working fine and it's generating a prime number from M to N but the only problem is I'm getting TLE when I submit my answer. How do I optimise my code to pass the time limit?
number-theory
Peter wants to generate some prime numbers for his cryptosyste...
I have implemented Iterator pattern please have a look at the code given below,
The interface Container.java,
public interface Container<T> {
Iterator<T> getIterator();
}
interface Iterator.java,
public interface Iterator<T>{
boolean hasNext();
T next();
}
class ResourceCon...
I was doing this HackerRank problem which basically boils down to counting overlapping substrings in a string. I used this solution from StackOverflow to build this program -
def overlapping_occurrences(string, sub):
count = start = 0
while True:
start = string.find(sub, start) ...
I try to improve my code so that I don't have to program a try - catch block all the time.
e.g. at the moment I have to write many codeblocks like this:
try {
$login_feld = $SeleniumObj->driver->findElement(WebDriverBy::id("login_feld"));
} catch(NoSuchElementException $exception) {
$Se...
After reading this answer to the question "High execution time to count overlapping substrings", I decided to implement the suggested KMP alogrithm. I used the pseudo-code listed on Wikipedia for the functions kmp_table and kmp_search.
However, when running it on some corner-cases, I have observ...
I wrote this tic tac toe game in react. I am learning react now. Feedback is welcome. PS. I deliberately used single file, to focus on React and not other aspects.
<!-- 3x3 Tic tac toe implementation in React JS. Giorgi Moniava. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<...
I'm learning Algorithms, Data structures and C.This is an exercise set by myself to implement a simple linked list data structure with insertion algorithm in C, to better understand the subject.
All answers are highly appreciated, here's the code.
linkedlist.h / linkedlist.c
#ifndef LINKEDLIST...
I have a JSF project. This project is composed by some Maven Modules.
I have one module that need to read and write some files on server. To do this I need to know the "real" full path of the application/server.
The way it is coded, only the View layer can access this information by this method...
google says to embed this code for my website viewers to see a specific calendar, but wix says it is not acceptable. I am a beginner working for non-profit. Please help!
Thanks
I have a program that lets the user input numbers into an array as long as they wish, stopped with a negative input.
After this info-feeding is ended, the program outputs a table like the following:
number | occurrences
How can i go about it?
package questions;
import java.util.Scanner;
pu...
I want to use cases in switch statements using a defined functions that is compiled of 7 different integers. I want to use switch statements to know if the defined function is true or false. I do not know how to create a formula that is compiled with integers. I do not want to add the integers to...
this doesn't look like an answer or a question... if you want code review for working code, there's a separate site for that. For your specific question, I think that was answered, so you can accept one of the existing answers. — eis36 secs ago
I have had a terrible time trying to understand the process of working with methods. Specifically, I have found no one who can truly explain the concept of a method "returning" something. I believe I finally got through that but my code still won't work. Here is the code from the three locations,...
I'm prepping for a coding interview, and am examining the task of correcting unbalanced parentheses. The finger tree seems to be the right data structure.
As a proof of concept I've used Data.Sequence to test my idea. If this is the right direction to go, I'll write more specialized finger tree c...
In Node-based client-side libraries you can use all the handy bells and whistles like require and import but plain browser JS doesn't have anything like that yet
Eventually I'm sure it will have that in the browser, it's just that it takes time for all browsers to adapt to new changes in JavaScript standards
Good Morning Gents,
I'm trying to practice functional programing using javascript. These pure functions just work together to find the difference between two arrays. I know that this might be an impractical example of functional programing but, could you let me know where I can improve or maybe ...
recently I wrote something in the Arnold C language, however my Media compiler keeps rejecting it. It claims things such as syntax error.
IT'S SHOWTIME
HEY CHRISTMAS TREE isLessThan10
YOU SET US UP @NO PROBLEMO
HEY CHRISTMAS TREE n
YOU SET US UP 0
STICK AROUND isLessThan10
GET TO THE CHOPPER n
...
11,520 generations per clock count / 10,016 x 6,796 box / 244,596 pop count
There you go... Was fun.
Well, the design is certainly not optimal. Neither from the bounding box standpoint (those 7-segment digits are huge), nor from the initial population count (there are some useless stuff, and so...
I've been through a lot of posts over the web(and in SO) saying that it is not possible. However, I did the following code:
var a = {
_sum: 0,
_timer: null,
_resetTimer: function() {
if (this._timer) {
window.clearTimeout(this._timer);
}
this._timer = window.setTimeout(this._en...
I have a class which will have two instances and those two instances will be accessed by two different threads. I want to have a dictionary that is accessible from both the threads(with different instances of the same class) in a reliable way.
class DemoClass()
{
priv...
It sounds like you have a lot more in your page object than you should. Remember, the page object should contain things related to the page in question. It shouldn't contain things like common methods, database connectors, and the like. Those should be in some Utils class elsewhere so it can be called when needed. You might post your code over at codereview.stackexchange.com and get some feedback there. — JeffC56 secs ago
Bayesian: "Hello, Machine Learner!"
Frequentist: "Hello, Machine Learner!"
Machine Learning: "I hear you guys are good at stuff. Here's some data."
F: "Yes, let's write down a model and then calculate the MLE."
B: "Hey, F, that's not what you told me yesterday! I had some univariate data a...
We cannot recommend a specific pattern without knowing more about your objects. You might want to ask a new question at Code Review with your real, current code that is to be improved (or redone). But your context-lacking basic question "can I chain something instead of passing it as an argument" can only be answered with "No". — Bergi26 secs ago
Given a 2D array of unsigned integers and a maximum length n, find a path in that matrix that is not longer than n and which maximizes the sum. The output should consist of both the path and the sum.
A path consists of neighbouring integers that are either all in the same row, or in the same col...
My answer is different than the others and some people may not like it. The answers people have provided you are very idealistic. Sure, you may get lucky and get hired based on your "honest" answers and self discovery that you have realized that you need to communicate more effectively and give...
#include <iostream>
#include <cstdlib>
#include <conio.h>
using namespace std;
int source,No_Of_Nodes,No_Of_Edges,visited[20],Graph[20][20],Graph1[20][20];
int main()
{
int i,j,vertex1,vertex2,cost;
cout<<"\t\t\tGraphs\n";
cout<<"Enter the no of Vertices : ";
cin>>No_Of_Nodes;
...
@JohnBollinger Interesting coding model. Does the builder then edit the code with (void) if determined ignoring the return values was a reasonable choice, ignores select diagnostics (which could be 100s to 1000s of them), blanket turns-off the warning, goes back to the writer who then edits in a (void) or what? My model is one where code that passes code review no longer generates diagnostics. If such a pedantic diagnostic was required, then many (void) would exist and the diagnostic would not keep popping up on next builds. — chux36 secs ago
Write a Java program that:
„ Reads from Mr. Nader the amount of money with him.
„ Reads from Mr. Nader many lines; each line consists of 2 values: the name of
product, and its price.
„ At the end, the program should print a message indicating if Mr. Nader has enough money or not. Only if he has e...
The example below, permits assigning an array of pointers to a class to an array of pointers to that class' base (Coercion By Member Template Pattern).
Given that D derives from B, a D object is-a B object. However, an array of D objects is-not-an array of B objects. This is prohibited in C++ b...
could you guys give me some comments on the code in those 2 apps I have done?
First of them is a simple Snake game, second is an app that helps me to keep my back straight.
Thanks!
https://github.com/RGuInquire/Snake
https://github.com/RGuInquire/WatchYourBack
I'm feeling old already... it's (almost?) two years since I did my final Bachelor project, though I actually did classes for a year or so afterwards just to round it off
Is this good code? I do believe I improved quite a lot since last year, still I would really appriciate some feedback :)
import javax.swing.JOptionPane;
import java.util.ArrayList ;
public class IfNotRepeated {
/*
* 7.12 (Duplicate Elimination) Use a one-dimensional array to solve th...
Help please implement a class classes pyramid card deck here and I realized
Create a class called PyramidBoard that contains state (variables) and behavior (methods) that are necessary to play the solitare.
Note: Implement the PyramidBoard class using design patterns.
Note: Pyramid must support t...
I wrote this demo just for practice purpose, I would like to get some helps that could further improve my code quality. Any suggestion for improvement would be appreciated.
This code is a simple demonstration of stack implementation (by using array List).
User will be asked for the option of a...
If you have working code and are just looking for ways to improve it, your question belongs on Code Review. This site is for questions related to actual problems you're facing with your code, not peer review. — Ken White44 secs ago
@DanielKamilKozar: Code review would have a serious talk to you if you moved this question. They expect working code. I don't see any in the question. — Olaf40 secs ago
http://imgur.com/a/Y3ck4
The link above shows an assignment that I have no idea where to start. I haven't done Java in years and again I have no idea what to do. Any help or an outline would be appreciated.