## c ++ – Rock Paper Scissors Engine – Code Review Stack Exchange

View over rocks, paper, scissors. C ++ had made me think from the beginning about how I would program this simple game in C ++. The `Scissors stone paper` The class contains the essential features of printing and evaluating each round of play as well as generating randomly chosen moves. I did not encode player input because that did not seem too interesting. Instead, the sample program plays only 20 rounds against itself and outputs the result. No statistics are collected or stored.

One function that exists is that there is one `#define` to select whether to use the classic game or the improved version "Rock-Paper-Scissors-Lizard-Spock". (With a bit more work that I did not invest in, you could allow a fairly generic nature $$n$$-ary relationship as the basis of the game.) The other notable feature is that the `Operator <` is intentional `Private` because the $$<$$ The operation implemented here does not represent a partially ordered set, as this is not the case transitive. In simple terms, we would normally expect that $$(a However, this is not the case here.

I would be interested in commenting on these or other design decisions or implementation details.

``````#include
#include
#include
#include
#include

// define ENHANCED for an enhanced version with Spock, Lizard on nonzero
#ifndef IMPROVED
#define ENHANCED 0
#endif

Great RockPaper Scissors
{
Public:
RockPaper Scissors (std :: size_t num) {
if (num> = words.size ()) {
throw std :: range_error ("invalid choice");
}
Choice = num;
}
static RockPaperScissors random ();
const std :: string_view & vs (const RockPaperScissors & b) const;
friend std :: ostream & operator << (std :: ostream & out, const RockPaperScissors & rps);
Private:
bool operator == (const RockPaperScissors & b) const;
bool operator <(const RockPaperScissors & b) const;
#if IMPROVED
static constexpr std :: array Words {"rock", "paper", "scissors", "spock", "lizard",};
#otherwise
static constexpr std :: array Words {"rock", "paper", "scissors"};
#endif
static constexpr std :: array Results {"LOSE", "TIE", "WIN"};
std :: size_t choice;
};

std :: ostream & operator << (std :: ostream & out, const RockPaperScissors & rps) {
Return << rps.words[rps.choice];
}

RockPaperScissors RockPaperScissors :: random () {
static std :: random_device rd;
static std :: mt19937 gen {rd ()};
static std :: uniform_int_distribution <> dis (0, RockPaperScissors :: words.size () - 1);
std :: size_t which {static_cast(dis (gen))};
return RockPaper Scissors {which};
}

bool RockPaperScissors :: operator == (const RockPaperScissors & b) const {
Return choice == b.
}

bool RockPaperScissors :: operator <(const RockPaperScissors & b) const {
return (choice + 1)% words.size () == b.choice || (Option + 3)% words.size () == b.choice;
}

const std :: string_view & RockPaperScissors :: vs (const RockPaperScissors & b) const {
if (* this == b) {
Return results[1];
} else if (* this <b) {
Return results[0];
}
Return results[2];
}

int main ()
{
for (int Trials = 20; Trials - Trials) {
auto a = RockPaperScissors :: random ();
auto b = RockPaperScissors :: random ();
std :: cout << a << "vs." << b << ":" << a << "" << a.vs (b) << "S!  n";
}
}
``````

## How to set up code review in a naive team?

I work in a place where programming is an important part of the job, but where code review is not heard by anyone.

As something enthusiastic about programming, I've seen many questions about code reviews here and especially about stackoverflow, but I could not experience it myself in a professional context.

For a little more context, I work in epidemiology. There is a team of data managers who set up databases (`Oracle SQL`) based on raw data. Then every researcher will write code (in `R` or `SAS`) independently to query the database and perform its analysis. Code written by one researcher is not normally used by another. A study is judged by its results. As long as they are likely, small mistakes can slip through.

There is no code review, neither in the Data Manager team nor in the research team, to track errors. I think that can be very beneficial for both teams, and I want to convince the boss to think about it.

Googling "Manual Code Review Guidelines" does not provide useful insights into the setup, but only in terms of enhancements.

How is code review usually introduced in naive teams? Where can I find the resources that will teach my boss the real benefits and methodology for setting up code?

## New post or new page Permalink :? Preview = true Submit for review

Hello, I have paid top-notch technical support to move a shared hosting site to a VPS.
After 3 weeks, about 6 new installations, over 150 emails, I am still at a loss as to how this problem can be solved.
Trusted Customer Technical Support is no longer a problem as they will need to reinstall everything and cause 2 hours of downtime for my users.
We tried to enable and disable all plugins. I deactivated the plugin "classic editor" and reinstalled it. Incidentally, what gives me a completely white post screen in the disabled state.
I've created a duplicate page to test exchanging topics. You can not do it on the live site because it uses Beaver Builder, which destroys it when you swap themes.
Suggestions please, as this has become a time and money pit. I also have no way to post, I can only submit for review.
My wp_capabilities are
a: 1: {s: 13: "administrator"; s: 1: "1";}

## Review: NetworkOne.forumotion.com

NetworkOne – Tech. News. Streaming.
http://networkone.forumotion.com/

## Google Sheet – Data Review, Limitation

I supported a project on Kickstarter, and the project creator started the delivery process. However, it takes a lot of time to complete the assignments and many people are impatient and upset. And it does not help if the project creator does not provide useful information about the shipping status.

To help people, I've decided to create a spreadsheet that will capture supporters' order information and track whether their order has been shipped or not.

However, there are some people who love to troll and spam the table with useless information. It does not help that Google Sheet has no detailed permission restrictions.

I have to prevent duplicate data being entered (spam). So far, I can set the data validation using a custom formula like this:

= countif (A \$ 1: A1, A1) = 1

However, this only works if users manually enter duplicate data. When they fill cells or when they copy and paste data into multiple cells, data validation does not work.

I also need to prevent them from adding new sheets or deleting an entire sheet.

## C – Separator – Code Review Stack Exchange

Problem: An integer between 1 and 32767 prints each number with two spaces.

I use C How To Program, but these are not homework. The book did not come to arrays or anything more complicated than loops of structures and functions. I try not to use the structures and concepts not yet introduced. I get the digits to split and output. I was wondering if there is a better way to do this with the tools I have.

My code:

``````// ------------------------------------------------ -----------------------------
// Program: EX5_22.c - Separate digits
// Programmer: Joseph Cunningham
// class: CsC_20 - c
// date: 16.02.19
//
// This program prompts the user to enter a number between 1 and 32767. Then it will be displayed
// Output this number separated into their constituent numbers with two spaces
// between each digit
// ------------------------------------------------ -----------------------------

#include
#include

int getNumLength (int number);
not separated (int number, int power); // Fucntion prototype

int main (void)
{
// variable statement

int number; // Number entered by the user for digitizing
makes int; // Stream to generate the divisor

// Ask user to enter a number

printf ("Please enter a number (1-32767):");
scanf ("% d", & number);

// Get the power for the divisor

power = getNumLength (number);

// output digits

separated (number, power);

Return 0;
}

// ------------------------------------------------ -----------------------------
// function: getPower (number) - counts the number of digits in the number to
// create a force
// input: int number - the number entered by the user
// output: none
// return value - length of the Thr number
// ------------------------------------------------ -----------------------------

int getNumLength (int number)
{
int length; // the length of the number

while (number! = 0)
{
Number = number / 10;
Length ++;
}

Return length;
}

// ------------------------------------------------ -----------------------------
// Function: Separate (number) - Separates an integer between 1 and displays it
// -32767 in his digits
// input: int number - intger between 1 - 32767, int power - power for divisor
// output: digits separated by 2 spaces
// return value: none
// ------------------------------------------------ -----------------------------

not separated (int number, int power)
{
int divisor; // the divisor of the power
int i; // Loop counter

for (i = power - 1; i> = 0; i--)
{
divisor = (int) pow (10, i);
printf ("% d", number / divisor);
number = number% divisor;
}
}
``````

## Two-player authentication at Python – Code Review Stack Exchange

Any help would be great 🙂

``````print (& # 39; Please enter your username & # 39;)

if username == & # 39; user 1 & # 39 ;:

print (hello & # 39; + username + & # 39; Please enter our password & # 39;)

if username == & # 39; user1 & # 39; and password == & # 39; Abc123 & # 39 ;:
print ("Welcome")

otherwise:

print (& # 39; wrong information & # 39;)

If username == user 2 & # 39 ;:

print (& # 39; hello & # 39; + username + & # 39; Please enter our password & # 39;)

If username == & # 39; user 2 & # 39; and password == & # 39; Abc 321 & # 39 ;:
print ("Welcome")

otherwise:
print (& # 39; wrong information & # 39;)
``````

Note that this is the first time an authorization system, since I started using Python this week.

## Python: Cycles and Indexes – Code Review Stack Exchange

Write a function that receives a list of integers "L1" and returns a list "L2" of the same length as "L1" whose generic element is L2[i] is equal to the first major element of L1[i] in "L1" available. If no element is greater than L1[i], then L2[i] must be set equal to L1[i],

Example:
If L1 = [6, 1, 7, 3, 7, 8, 9, 4]Then the function returns the list L2 = [7, 6, 8, 6, 8, 9, 9, 6]Since the first element in "L1" is greater than 6 7, the first element in "L1" is greater than 1 6, the first element in "L1" greater than 7 is 8 and so on.

Once the main element is found, I do not know how to stop the cycle and restart from the next element. Any idea?

``````def list_major (L):
L2 = []
for i in range (len (L)):
for j in range (len (L)):
if L[j] > L[i] and J! = i:
L2.append (L[j])
if L[i] > L[j]:
L2.append (L[i])
Return L2

list_major ([6,1,7,3,7,8,9,4])
``````

## Python Coding with Security Depth – Code Review Stack Exchange

``````import base64
Import mime types
import os
import hashlib
import hmac
import requests

of django.core.urlresolvers import the other way around
from django.http import HttpResponse
redirect from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt

def ordenary (s):
return s.strip (). replace (& # 39; & # 39 ;, & # 39;) .lower ()

def form_of_message (request):
env = {& 39; message & # 39 ;: request.GET.get (& # 39; message & # 39 ;, & # 39; hello & # 39;)}
Answer = render (request, & # 39; forms / message_form.html & # 39 ;, env)
response.set_cookie (key = & # 39; message_rendered_at & # 39 ;, value = time.time ())

def proxy (request):
url = request.GET.get (& # 39; url & # 39;
Forwarding (URL)

def compute_hmac_signature (message, key):
Key = bytes (key, & # 39; UTF-8 & # 39;)
message = bytes (message, & # 39; UTF-8 & # 39;)

digest = hmac.new (key, message, hashlib.sha1) .hexdigest ()
Returns "sha1 = {}". format (str (digest))

def user_pic (request):
"" "A view that returns the user's avatar image." ""

Base path = os.path.join (os.path.dirname (__ file__), & # 39; ../../images/avatars & # 39;)
Filename = request.GET.get (& # 39; u)

To attempt:
data = open (os.path.join (base path, filename), & rb & # 39;). read ()
except IOError:
Return rendering (request, & # 39; templates / avatar.html & # 39;)

Return HttpResponse (data, content_type = mimetypes.guess_type (filename)[0])
``````