12:02 AM

Monking

1:02 AM
0

I learnt a function to display the imaginary part of a complex number & that is .imag But when I was practising it, look what I found: print(5-5j.imag) #>>>0.0 print((5-5j).imag)#>>>-5.0 print(2+4j.imag) #>>>6.0 print((2+4j).imag)#>>>4.0 What's happening with the output in the 1st & 2nd case?

3 hours later…
3:39 AM
Try to think more clearly about your intended logic. You may find it helps to take a real pencil and piece of paper, and draw a flowchart. That said, questions about doing things in a shorter or "more elegant" way are generally off topic here. You may want to try codereview.stackexchange.com if the code already works correctly. — Karl Knechtel 39 secs ago

1 hour later…
4:46 AM
0

There are lots of questions in leetcode that make use of binary search or a slight variant of it. Examples include: https://leetcode.com/problems/kth-largest-element-in-an-array/ https://leetcode.com/problems/maximum-profit-in-job-scheduling (this one uses binary search to find the next eligible...

1 hour later…
6:11 AM

6:26 AM
0

I'm reading "Modern C++ Design"(A. Alexandrescu, 2002) and practicing basic TMP in chapter 3. Typelists. Since the book is quite dated, I revised example codes in C++17-esque manner. Feel free to comment anything! #include <cstddef> #include <iostream> #include <utility> #include <type_traits> /...

2 hours later…
8:30 AM
0

I use the Emgu.CV wrapper to create a grayscale image. The data of this image are to be copied into a 2D byte array. Is there a more elegant solution than mine? I'm asking here at CodeReview because my code works and the question is therefore not suitable for Stackoverflow. If you want to reprodu...

2 hours later…
10:10 AM
0

The other day, I was trying to make a minimal tree data structure for a project at work. I came up with the following code: public class Node : IEnumerable<Node> { private List<Node> _children; public string Name { get; } public Node(string name) { Name = name; ...

10:35 AM
0

Modify the calculator program from Chapter 7 to make the input stream an explicit parameter (as shown in §8.5.8), rather than simply using cin. Also give the Token_stream constructor (§7.8.2) an istream& parameter so that when we figure out how to make our own istreams (e.g., attached to files)...

@CaptainObvious This seems to be asking about interpretation of the exercise, but also has code for review. Can it be retitled and re-described to bring it on-topic? I'm not sure what close reason to use (for while it's being fixed).

11:40 AM
@TobySpeight Since the name of the book isn't included, we don't know how much of the code the OP actually wrote, maybe none?

@pacmaninbw I think the first code sample is from the book (and should probably be blockquoted) and the second sample is the OP's. BICBW...
Seems to be wanting a review of the changes made, anyway. Which is still a poor fit for CR.

But sometimes a comparative review is a real thing in the real world. Bug fixes that require a fair amount of code.

0

I want to submit some code of mine for review. Its for a class assignment that goes as follows: Test your class by starting 2 threads, both trying to add each letter of the alphabet (no order specified) as an object to the list. No duplicates are allowed. At the end of the "race", print how many...

@TobySpeight I think the reason for closure is lack of details or lack of focus and not site specific.

11:56 AM
@pacmaninbw Thanks, and for your comment on the question.

@Peilonrayz From my viewpoint good morning, is it late enough where you are to raise a pint.

Almost 1pm. But they do say it's always beer o'clock somewhere in the world!
2

@pacmaninbw I woke up around half an hour ago... So good morning to you too ;)

@Peilonrayz Time for a Bloody Mary.

@pacmaninbw Drinking on the Sabbath? Heresy!

12:02 PM
LOL!
@CaptainObvious There is no code, this is an authorship close reason.

@pacmaninbw IMO both are applicable. I've voted AoC and the close message says both :)

12:26 PM
To get help with code improvements for code that works as intended, post on CodeReview.SE. — outis 12 secs ago

1:04 PM
1

I made a CSV class which manages CSV files. Is this good?, I'm beginner btw. It's probably bad but can you give me some tips! Header file: #include <vector> #include <string> #include <fstream> #include <sstream> #include <map> #pragma once class CSVFile { public: //Debug opening mode. Prin...

1:54 PM
1

I want to implement a function (or several) that must run exactly once when the program terminates, no matter how this termination came about1. Below is my best attempt at doing this. Specifically, the code between the ####...#### dividers is the most succinct2 implementation of this functionali...

2 hours later…
3:53 PM
Monking

4:24 PM
If you want an answer to be a reference answer on StackOverflow, it needs to meet very high standards. I would suggest that you post this at codereview.stackexchange.com for review and suggestins before you post it here. — RBarryYoung 33 secs ago

4:49 PM
0

I have a following task: "Ordinary" semaphore Initialized to the number of available resources. Operations: request () - waits until the resource is released, release () - releases the resource, numberAvailable () - returns number available resources, the n which I tried to implement using Sem...

@CaptainObvious Request for rewrite.

1 hour later…
6:04 PM
0

why is my collision not working? Ball passes straight through the paddle, how do I fix this issue? Fairly new at coding and python is my first language. Any help would be appreciated. import pygame pygame.init() pygame.display.set_caption("Pong") black=(0,0,0) white = (255,255,255) purple = (1...

0

As an exercise to learn more about multi-threading and atomic operations work in C++, I decided to implement a latch class in C++11 loosely based off of std::latch class from C++20 and would like to know whether this implementation is flawed in any sort of way or form and how I could improve upon...

1 hour later…
7:18 PM
0

This question follows up on this question. After turning the while-loop into a conditional wait using std::condition_variable, I would like to know if there are still any flaws/problems with this code which implements the std::latch class from C++20 in C++11: #include <condition_variable> #include <

2 hours later…
9:23 PM
0

So in process of learning, I've started doing little programs separated into different files. This is a very simple program, took me a few minutes to do it just to have an example. the main folder contains main.py, icons folder and scripts folder with window.py and coinflipper.py. My question is...

1 hour later…
10:38 PM
0

I'm learning PowerShell for professional development, but decided to do a bit of a silly project to help learn scripting in more depth, and chose Conway's Game of Life. This is the first PowerShell script I've written besides a small toy that I wrote for an Active Directory assignment previously....

11:27 PM
0

I started to write a terminal based text RPG in python. Its mostly bug free now but I really want to know how I could improve my code and how to implement things better. I know it's a lot of code so I really want to thank you, if you're patient enough to review it. I uploaded the code to github. ...

11:52 PM
0

I have the following piece of code, and I feel like there's a way to optimise it, but for some reason I just can't think of it right now. Writing it this way feels clunky. Really appreciate any feedback/code improvements. public void updateGameState() { if (p1Count == 20) { wi...