This represents a dealer (server) for Texan Hole'em.
This is not a full hold'em game but it is working code for what it does. It shuffles, deals the hole cards, board, and collect blinds. It does not yet support real betting nor award the pot. It just fakes a pot. Real betting gets complex. It...
I am trying to create a function prime-factors that returns the prime factors of a number. To do so, I created is-prime function, and prime-factors-helper that will do a recursive check of the prime factors.
(defun is-prime (n &optional (d (- n 1)))
(if (/= n 1) (or (= d 1)
(and (/=...
It's that time of the year again!... Elections! Wait, what? It's not a regular thing around here? Maybe it should be!
With Mat and 200_success stepping down, elections should be coming soon (in 3-6 weeks?). It seems the perfect time(*) to offer my diamond up for grabs now, to give you, dear comm...
Hi SueSiv, welcome to StackOverflow! I think the first part of your question ("could someone check through my code and tell me if my design for a digital watch looks ok structurally") would do better on the code review stack exchange. — Erty Seidohl39 secs ago
To an extent, yes. In this particular case, no.
I don't see a problem with allowing questions that have Stack Overflow Exceptions, provided the code works acceptably on a smaller input set. If we were to eliminate questions with SOE, then by all rights we should eliminate time-limit-exceeded que...
@Teja this section is meant to unbug an issue from your program, to request another strategies perhaps codereview is your destination. (just iterating what I'm been told) — Abra00117 secs ago
I am pretty new to python as a front end dev and i loved it! So i started to build a tool fetching facebook places api and there is api rate limit 200 requests/per hour and even i set long delays, i get an error of "(#613) Calls to this api have exceeded the rate limit." I dont know where to optimize it but i need you to take a look at my code as a better pythonist …
I am a newbie, so, nice to meet you! I am in a Java 1 course in college and we have this invoice application. I have written the code, and I can get it to do everything EXCEPT give me the the average invoice amount, and the average discount amount. This is supposed to show if the user enters "n"....
How to make the program generate 5 non-repeating random words from the array (without using array list)? Thank you!
`public static void main(String[] args)
{
String[] solo = {"mom", "hello", "dad", "hope", "love"};
Random rand = new Random();
String word;
for (int i = 0; i < 5; ...
Here is the problem I am working on -
There is N x N field on which missiles are being bombarded. Initially,
all the cells in this field have 0 value. There will be M missiles
bombarded on this field. ith missile will have power Pi and it will
affect all the cells in region with (Ai,Bi...
I'm wrote a method that tries to send message on emails, but i have some concerns about HTMLBody. Please make a review about this method.
CODE:
public class Ticket
{
private readonly string _currentProject;
private readonly DateTime _creationDate;
private readonly string _userName;
...
I have a Node.js app / Web API that runs on an Azure app service with a single CPU.
One of the functions needs to run for a long time, perhaps tens of seconds, while the server should continue to process other requests, i.e. the function should not be blocking.
My idea is to use await new Promi...
When you have achieved a somewhat satisfactory state with your program, feel free to head over to Code Review and post the code there with an explanation of what it does. It seems you are using outdated resources to learn Perl, and there is a lot you could improve. We'll give you valuable input over there. — simbabque14 secs ago
So I have an input form, and when you press enter I want it to call a function. I was wondering what "the right" way of doing this is.
Right now I have an input looking like this:
<input
type="text"
placeholder="Enter key words"
value={this.state.value}
onChange={this.handleC...
The following code is JUST THE BEGINNING OF a problem I am trying to solve. I cannot pass the rspec tests because it is returning my answer as an array, not a string. Here is my code:
class Book
def title
@title
end
def title=(title)
@title = title.split(" ")
...
I am looking for suggestions on how to make this cleaner. I have written a method inside this method called doSave() which calls a service to save a line item of a PO as they type. The performance of this is not very good and I find it dirty. How can I make this better/cleaner?
async saveField(f...
I have a index.php file with
<!--Bootstrap scripts-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.1/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twi...
I'm currently working on a simple command line application in Haskell and I have three functions that are quite repetitive.
The three functions:
getAllFilmsByDirector :: [Film] -> String -> String
getAllFilmsByDirector filmsDb directorName = unlines [name ++ ", " ++ director ++ ", " ++ show ye...
@200_success, @janos, @MathieuGuindon I didn't thought that going skiing over the weekend will result in 3 mods to step down. If I knew this I wouldn't have gone. Sad, really sad. Well I wish you all the best and hope you will still be arround here. You all did a great job ! @janos I hope you will run again. @MathieuGuindon its nice to see your real self instead of a mug ;-)
Any pointers on the level of security this hashing function perform at?
I have never had to really write my own modules for security before.
public static class Hashing
{
public static int SaltSize = 32;
public static string HashPassword(string passwordToHash, byte[] salt, int numberOf...
It is for a stationery store inventory program using C++.
The program is to read a text file and store the data from the text file into an array of structures. The problem comes in when my string variable has spaces . How do I use the >> operator in reading each line in my text file and for it to...
@200_success What feels sad is that, for most of us who joined just a bit before or after the graduation, the mod team was like a model figure. And we’re not used to it changing.
This is a great candidate for Code Review (note that their question format is slightly different, so be sure to read their Tour and How to Ask pages). — msanford50 secs ago
@200_success From my perspective site activity is low as of late. Compare last quarter stats with the same from two years ago... Seems like everyone's busy of late
@Zeta Fair point. If it's just for 10K's I don't think that many would use it from a small pool anyway.
@Zeta Not just that, the rep went from 10k to 2k for the highest. All I mean is I think there's a problem. I don't know what it is, or how to 'fix' it however... :(
I have a portion of a script here, and the whole script works just fine.
However, I feel like it's inefficient and may work better in a class/function format. This is a script scheduled to run every night and go between databases to select records, compare them, pull data based on comparisons an...
FWIW "challenges" started out as weekend-challenge, with the idea being you have the weekend to build a quick solution for a small problem, e.g. tic-tac-toe, or rock-paper-scissors, or evaluating a poker hand, whatever.
@MathieuGuindon Those short challenges are already handled by sites like Codewars, Codingame or others. It would be great if their users would know about CR.
Then again, given the usual quality of the solutions I'm not sure about that…
Well, I'm going to finish my checkers website and set my game controller up as a KOTH for PPCG (I need the rep for bounties--they have some awesome stuff over there).
Then I'll see about hosting some sort of a challenge over here.
Remember, on CR, it's not so much winning that counts, it's the participation.
I was wondering whether it is a good aproach to have Identity 2.0 UserManager next to UnitOfWork pattern? I am using UserManager only in login and register as it gives freedom of not taking care of password hashing (also provides options to email user etc.) and user-to-role management. Although f...
I wrote the following code. A user in STACKOVERFLOW website recommended me to write my code here in order to be reviewed for optimization.
How could I optimize it?
Could I have this code in a pro and better form and performance?
import numpy as np
import emcee
import matplotlib.pyplot as plt
fro...
Hey! Welcome to Meta.CR! The "intrusion" is more than welcome IMO - back in the pre-graduation days of CR we even ran "contests" on meta to boost meta activity and community building: the winning ad would get to be posted on other sites' community-ads post, like you just did. — Mathieu Guindon ♦2 mins ago
I may or may not run, depending on how active I am until the election.
@Malachi That's actually why 200 is leaving. He doesn't want to be with us forever. He says we need to learn to get along without him (not a direct quote).
Given an array of integers, sort the array into a wave like array and return it,
In other words, arrange the elements into a sequence such that a1 >= a2 <= a3 >= a4 <= a5.....
Example
Given [1, 2, 3, 4]
One possible answer : [2, 1, 4, 3]
Another possible answer : [4, 1, 3, 2]
NOTE : If there ...
@MathieuGuindon I guess this was the problem... I wasn't that active in Meta when they came about. I guess a 2-3 hour challenges in a month would be good fun. Even more so if we extended the time for entries to 'win'
it was really more of a coordinated "let's all solve the same problem in whatever language we feel comfortable with (or not), and put them all up for review over the weekend"
That makes sense, I guess we could make a little meta to find out what we actually want them to be. I liked them, I just don't have the time to enter some times.
OK, weekend challenge.... we all solve the Rock Paper Scissors Lizzard Spock problem with our 'favourite' language, and we all have to post a question here with our solution to be reviewed.
Welcome to StackOverflow :-) While StackOverflow is for questions about specific programming problems/algorithms and how to solve them, the CodeReview community is for running code and how to make it shorter/better. Please consider to ask your question there :-) — Philipp Maurer49 secs ago
I wrote the following code. A user in STACKOVERFLOW website recommended me to write my code here in order to be reviewed for optimization.
How could I optimize it?
Could I have this code in a pro and better form and performance?
EXPLANATION: This code calculate multiplication of three matrix in ...
so as I said in title, I'm an aspiring coder, and I have questions as to how to start a project for an RPG. first of all, what coding language would be best. and once you answer that, how do I add graphics, and how do I add save data.do you have any suggestions for me?
I have an array of non-Equatable objects. I want to remove all the duplicates from the array.
class SomeObject { // non-equatable
var index: Int!
init(_ index: Int) { self.index = index }
}
var data: [SomeObject] = [SomeObject(0), SomeObject(1), SomeObject(1), SomeObject(2), SomeObject(...
From the outset, let me state that I'm working with some older technology. I'd rather use Entity Framework, but I have to use what the client is using if I want to get paid.
I am converting some old VB6/VBA code to C#. The VB code relies on RecordSet, which allow you to browse results of a query...
Welcome to CR! Pick a language - any language - and learn enough of it to implement something that works. Once you have that, this community will help you learn the quirks of whatever language you picked, and help you pick up and master programming concepts like abstraction, encapsulation, and everything you need to write clean, maintainable, flexible, professional code. — Mathieu Guindon ♦19 secs ago
It's that time of the year again!... Elections! Wait, what? It's not a regular thing around here? Maybe it should be!
With Mat and 200_success stepping down, elections should be coming soon (in 6-8 weeks?). It seems the perfect time(*) to offer my diamond up for grabs now, to give you, dear comm...
An implementation of huffman encoding / decoding as a learning excercise. Since I'm still new to Rust, so any tips about making things more natural for the language are appreciated.
mod huff {
use std::boxed::Box;
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::...
I pulled a prank on my girlfriend. I said "I resigned". We're buying a house, just got the financing approved. Her face went white. Then I said "as a moderator on Code Review". She hit me. I guess I earned it. but yeah, ..I need to slow down SE activity and focus on my dayjob and my family.
maybe I (seriously) run this time around....let me think on that one for a day or two
I was given a problem where a Java program crashes 50 % of the time. It included this part
for (Object o : l) {
for (Object o2 : l) {
if (!o.equals(o2) && distance(o, o2) <= 1) {
l.remove(o);
}
}
And the exception was a ConcurrentModificationException. So I ...
I am new to python so tips to any part of the code are welcome.
My main problem is how to "overload" the function properly. Is this how supposed to be done with parameters that gets passed exculsivly?
It is intended that only Bytes, Words or a DWord will get passed in the corresponding parameter...
Program to compare if files within two directories are having same content
I followed the approach of getting the list of files under two directories recursively and store it in different list with it is canonical path.
Then using two loops, compared the each file line by line. Below is my code...
Since we've not had any fun in a little while, I thought maybe it'd be a good idea to 'bring back' the fun. In the past this has been in the form of Winterbash, community challenges, best of Code Reviews, and a couple other things.
I'm unsure what we as a community want to do, and so I think it'...
Since we've not had any fun in a little while, I thought maybe it'd be a good idea to 'bring back' the fun. In the past this has been in the form of Winterbash, community challenges, best of Code Reviews, and a couple other things.
I'm unsure what we as a community want to do, and so I think it'...
Zombie Hunting Season
The old memes pretty much all happened during the Great Revival, during which we equated unanswered questions with zombies, and votes/answers with ammunition.
The site currently has ~10% unanswered questions, which means a population of ~5K zombies; how about reopening zom...
I strongly doubt that Loki would name something after Thor. Unless it was to ingratiate himself for some nefarious scheme. — Konrad RudolphApr 24 '12 at 12:41
@Hosch250 Browser extension, similar to "uBlock Origin" and NoScript. Blocks external resources by default and XHR requests. Can be set-up per site, domain and so on.
Try them out yourself and if they don't work, post a new question detailing what's wrong. We usually don't have the context to run it for you nor have the capacity to do so. There is the Code Review site to ask for reviews. — akarnokd26 secs ago
The Zombies are on their way to eat our statistics. Fortunately, we have a way to get rid of them: our votes. However, we need to find them first. The /unanswered section is too large and contains many strong enemies were we have to write a review first. But the StackExchange Data Explorer can sn...
@Zeta I think that's really worthy of a meta question. I'd like to say yeah. Something like a splitter is defiantly an algorithm IMO, and they can be improved. But I don't think every blueprint can and will be on-topic
@SimonForsberg That's what I'm wondering too. There are games like TIS-100, Shenzen I/O, MRHD or Human Resource Machine, which essentially ask you to write code in a assembly-lite language. Those questions are on-topic on Arqade, of course, but that doesn't necessarily make them off-topic for CR, does it?
@Hosch250 I wanted to know how to make a 1 -> 7:3:4 splitter a little while ago. IMO the pipes I wrote defiantly count as an algorithm. as IIRC I used two RNG cyclers.
Write a program that prompts the user to enter a number between 1 and 5 and prints the number in words. For instance, if 1 is the input, the output should be One. If the user enters a different number than 1 to 5 the program should display the message: Entry is out of range. Provide the code that...
@skiwi To be honest, I didn't give it too much thought. I'm not sure whether you can store conditions in a blueprint in Factorio, but let's say your blueprint is a station that automatically unloads a completely unsorted train and sorts it manually (no robots).
I don't know if someone said it, but even if I'm sad for mods leaving, I must say I enjoyed quite a lot the title you've come up with! It's in the spirit of Code Review and having good titles :)
@skiwi Depends on your definition of code I guess... You could class as subset of Conway's game of life as 'code', since you can program a computer in it... But you wouldn't class a single dot in it as 'code'.
I'm voting to close this question as off-topic because questions seeking critique of working should be asked on our sister site Code Review. — Miles Budnek36 secs ago
Caveat: if you don't know whether the code works as intended, it's not ready for Code Review. Test it, make the necessary changes, then put it up for review. — Mathieu Guindon17 secs ago
I'm trying to make a function that returns the Item at the Kth to last element of an unsorted singly linked list using recursion. I'm wondering if there is any way to break this recursion when I find the answer.
public static object ReturnKthToLastElementRecursive(int k, Node currentNode)
{
...