instruction stringlengths 71 95.1k |
|---|
The question can be found here https://leetcode.com/problems/letter-case-permutation
Given a string S, we can transform every letter individually to be
lowercase or uppercase to create another string. Return a list of all
possible strings we could create.
My question pertains mostly to the pattern that I am foll... |
You are given the following information, but you may prefer to do some research for yourself.
1 Jan 1900 was a Monday.
Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, twenty-nine.
A leap year occurs on a... |
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100!
def fact(n):
"""returns factorial of n."""
if n <= 1:
return 1
return n * fact(... |
I'm currently working on a unit testing course (NUnit 3.x). I've been tasked with a simple class to test all edge cases.
using System;
namespace TestNinja.Fundamentals
{
public class DemeritPointsCalculator
{
private const int SpeedLimit = 65;
private const int MaxSpeed = 300;
public i... |
Let \$d(n)\$ be defined as the sum of proper divisors of \$n\$ (numbers less than \$n\$ which divide evenly into \$n\$).
If \$d(a) = b\$ and \$d(b) = a\$, where \$a ≠ b\$, then \$a\$ and \$b\$ are an amicable pair and each of \$a\$ and \$b\$ are called amicable numbers.
For example, the proper divisors of 220 are 1, 2,... |
I wanted to detect if I have a member in a simple POD struct and after some searching and merging some methods I found on the web I've come up with this solution:
#include <iostream>
template<class...Fs>
struct funcs_t{};
template<class F0, class...Fs>
struct funcs_t<F0, Fs...>: F0, funcs_t<Fs...> {
funcs_t(F0 f0... |
Please can I have some feedback on my Python Turtle implementation of the 15 Puzzle?
I have deliberately avoided using OOP as my aim is to develop a clear and clean coding style suitable for teaching programming at school (at a level before OOP is relevant). I also tried to avoid using globals by passing arguments, but... |
Recently I got test task at the project, it is fairly simple:
const _ = require('underscore');
// Challenge:
//
// Write a function that accepts as argument a "function of one variable", and returns a new
// function. The returned function should invoke the original parameter function on every "odd"
// invocation, r... |
I have solved an assignment (Exercise 3) from the MOOC Object-Oriented programming with Java, part II, but I'm not enrolled in said course.
Assignment Summary:
Make a simple calculator. You may create a Reader class that
encapsulates the Scanner-object in order to communicate with the user.
The Scanner-object can... |
I need to read a remote file using FTP and process it and insert the processed data to a PostgreSQL database in another server.
The below code is working fine, but i want some advice to modify few things.
In this line i don't want to write the actual details, I want that to
be hidden from my script. How can i do that?... |
Double Pendulum
I made a little application that embeds a matplotlib dynamic plot into tkinter that enables control through the tkinter GUI. Code is in Github. It also uses numpy and scipy to solve the ordinary differential equations for a double pendulum.
To change the initial theta's just drag the bobs to another pos... |
I have ported Stempel stemmer in Java (Apache Lucene) to Python. I come from Java world, so I'm afraid my translation might not be "pythonic" enough.
I would like to hear your feedback on quite representative part of the code, translation of Diff class that applies stemming command (diff) to a string (dest).
@classme... |
Short problem description:
A sequence of numbers are antiarithemtic if there exists no three
numbers a_i, a_j, a_k – where a_i preceeds a_j which then again
preceeds a_k in the sequence – such that a_i - a_j = a_j - a_k.
Example: (5, 0, -1, 3, 1) is not antiarithemtic, because 5-3 =
3-1, wheras the sequence (... |
This question is to see if I can get some input on the "design pattern" I tried to implement here. I'm just learning about closure in JavaScript and I think I'm starting to get it. I'm wondering if the way I wrote this code is or is not terrible stylistically.
The code in question is attempting to answer a challenge g... |
Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand
first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for
each name, multiply this value by its alphabetical position in the list to obtain a name score.
For example,... |
I am check first time userDefaults will not save value return 0 else get value from userDefaults
I am checking if userDefaults will not save the value, and If it doesn't, return 0. If it does, then I get the value from userDefaults.
func scaleMeter() {
let numberPicker = NumberPicker(delegate: self, maxNumber: 100... |
This is the code I came up with:
void set_bit_at_pos(int* num, int pos, bool val)
{
if (val) {
int mask = 1 << pos;
*num |= mask;
}
else {
int mask = ~(1 << pos);
*num &= mask;
}
}
I'm new to bitwise operations, so this approach may not be the best. Nevertheless any sug... |
codility OddOccurrencesInArray:
A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
For example, in array A such that:
A[0] = 9 A[1... |
Link To Question
Given a string, return a version without the first and last char, so
"Hello" yields "ell". The string length will be at least 2.
without_end('Hello') → 'ell'
without_end('java') → 'av'
without_end('coding') → 'odin'
This is the code I wrote as a solution to this problem. I feel that this simple of a ... |
I have Gig and Singer Active Record models (standard--no customization just yet) with a many-to-many relationship through a generic join table which holds nothing but the respective ids of Gig and Singer. My form sends a given gig id and all the singers who will be attending, denoted with check boxes. I need to have ... |
The objective of the game is to survive as long as possible. You have a need and that is hunger. Your hunger decreases by 10 every 3 minutes and if your hunger reaches 0 you will die and the amount of time you survived will be displayed. You need to eat or drink something to increase your hunger and that cost money! yo... |
This is my first react app and it was for a job interview challenge. The app is really simple and it works, but although I don't think I'm gonna get it, could I have some feedback about what is wrong and how could I improve it?
***I already submitted this, so is not cheating, I just need to know how can I be better
Th... |
I'm building a basic data pipeline in .NET to extract data from tables in our RDBMS systems, that exports into columnar storage using Parquet. I'm using Parquet's row group to batch up the writes into manageable segments as switching from rows to columns means holding a chunk of data in memory.
Having to write each col... |
This is a simple implementation of Django's sample project "Poll" using and express.
The controller code:
export default class AuthController {
private db: AuthDb;
constructor(db: AuthDb) {
this.db = db;
}
login = async (user: User) => {
try {
userValidator(user);
... |
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of
the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call
it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:
012 021 102 120 201 210
What is ... |
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn−1 + Fn−2, where F1
= 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the first term to contain three digits.... |
I'm a beginner in Python and I made a password checker. I'm following these rules:
I have to use regex
password must be at least 8 characters
must have at least one lower case character
must have at least one upper case character
must have at least one special character
must have at least one number
I also wanted to ... |
I had the following assignment for the Python 101 course I'm taking in my university.
'''
Modify the naive implementation (see below) of a sorting algorithm so that
the list to be sorted is modified *in place*.
Here is the idea:
1. Iterate over all indices i = 0, 1, 2, ... of the input list
2. Find the index j of t... |
I'm parsing STL files to load the coordinates. My code is:
void Importer::scanFileSTL_ASCII(
QVector<QVector3D> &vertices, // Coordinates to be filled
const QUrl &url)
{
QFile file;
file.setFileName(url.toLocalFile());
if (!file.open(QIODevice::OpenModeFlag::ReadOnly | QIODevice::OpenModeFlag::Text... |
I am implementing Kalman filtering in R. Part of the problem involves generating a really huge error covariance block-diagonal matrix (dim: 18000 rows x 18000 columns = 324,000,000 entries). We denote this matrix Q. This Q matrix is multiplied by another huge rectangular matrix called the linear operator, denoted by H.... |
I've written what I think is a constant time implementation of a uniqueness check. I've seen many algorithms online, which run in linear time, but was wondering whether my conclusion that this runs in constant time was correct.
I've seen many linear versions of this algorithm, but I haven't seen any that run in O(1).
A... |
I would like to write a little pet project using Clojure to study it, something like Stack Overflow client.
Here is a my first code to get list of new questions from site. I am in the very beginning in Clojure so any help will be appreciated.
core.clj:
(ns stackify.core
(:require [clj-http.client :as client]
... |
create a function which predicts the next time a satellite image will be taken of a certain location.
When there is enough data to do so, the function should print a prediction for when the next picture will be taken.
and when there is no enough data then return error.
if prediction date is less than current date, the... |
I have the following code that I wrote in order to find the correct password by generating hashes out of all possible combinations and comparing each of them with the target. I'm trying to make GetPasswordFromHash() as efficient as possible, in regards to multi-threading, and I've decided to pick PLINQ for that.
Scrypt... |
This is an OOP version of Lastest version of my Blackjack game. Also, it now uses PostgreSQL as database.
import random
import typing as t
from enum import Enum
from functools import partial
import os
from getpass import getpass
from re import match
import bcrypt
import psycopg2
import attr
lock = partial(attr.s, aut... |
Coming from a software engineering background I don't have so much experience developing games. Below is a simple 2d tile connect game.
What would people improve about it? What are some good practices that could be applied here and what would people suggest?
Board.cs - main script that handles setting up and resetting ... |
I am writing a bootloader that needs to load a file from a FAT32 filesytem. Since I need to load both the root directory first to find the start of the file, and then the actual file, I wrote a function to load a sequence of clusters from the disk to 0x8000 in memory (since the bootloader is loaded from 0x7C00-0x7DFF a... |
My Android app must request my Cloud Functions server to create in-app products at runtime ; then, the server responds with the created one-time product. I've written the server Cloud Function that creates the product. Here is how it works (full minimal, executable code is embedded at the end of the question):
My func... |
This is my first experience of designing classes with inheritance. I would like to get feedback on the interaction between the presented classes. It is unlikely that this code will seem complicated. But if you need a description of it, please specify in the comments.
There are several classes that describe the model.
... |
I'm attempting a practice problem in Codeforces that requires you to find the number of multiples of 3 less than or equal to a given number. I have written the following code but it gives a TLE once the test case reaches the order of 108.
int x = Reader.nextInt();
int count = 0;
for(int i = 3; i<=x; i++){
if(i%3 =... |
I was coding the problem here. I think I have solved it, but I ran into time limit exceeded issues. I am new in Competitive Programming, so I was looking for a better, time efficient logic for solving the same.
Time limit: 1 secs
My time: 3.01 secs
The problem in short:
Given the numbers [1 .. N ] to be put in a bi... |
I'm in the process of independently learning Generics as a way to build on a college assignment for Binary Search Tree. I've completed this program without Generics first and now I've converted over but I wanted to get some peer review. It seems to be working well and I've run a few tests already.
Would you do anything... |
I am given 8 positive 32-bit integer numbers. The task is to write program to count all X-bits.
X-bits are groups of 9 bits (3 rows x 3 columns) forming the letter "X". task is to count all X-bits and print their count on the console. Valid X-bits consist of 3 numbers where their corresponding bit indexes are exactly {... |
I have this, I guess, new Ruby syntax in my method but Rubocop are warning me that the second last line is too long. Could you please help me to refactor this method?
def show
identification_document = IdentificationDocument.find(params[:id])
authorize identification_document
return unless identification_document... |
Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
2 ** 2 = 4, 2 ** 3 = 8, 2 ** 4 = 16, 2 ** 5 = 32
3 ** 2 = 9, 3 ** 3 = 27, 3 ** 4 = 81, 3 * 5 = 243
4 ** 2 = 16, 4 ** 3 = 64, 4 ** 4 = 256, 4 ** 5 = 1024
5 ** 2 = 25, 5 ** 3 = 125, 5 ** 4 = 625, 5 ** 5 = 3125
If they are then placed in numerical... |
Problem Statement
Emma is playing a new mobile game that starts with consecutively
numbered clouds. Some of the clouds are thunderheads and others are
cumulus. She can jump on any cumulus cloud having a number that is
equal to the number of the current cloud plus 1 or 2. She must
avoid the thunderheads. Determ... |
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
\$1634 = 1^4 + 6^4 + 3^4 + 4^4\$
\$8208 = 8^4 + 2^4 + 0^4 + 8^4\$
\$9474 = 9^4 + 4^4 + 7^4 + 4^4\$
As 1 = 1^4 is not a sum it is not included.
The sum of these numbers is \$1634 + 8208 + 9474 = 19316\$.
Find th... |
I have a Qt tree view which has a custom tree header. The tree has a so called mode, by default there are two. During each of the modes a different tree is shown. The mode switcher is presented as a context menu of the tree header.
Having a context menu on tree header isn't that hard. But in my case I need to make a tr... |
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
from time import time
def fact(n):
"""returns factorial of n."""
total = 1
for number in ... |
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
How many circular primes are there below one million?
Here's my implementation in Python 3. Awaiting f... |
I'm a C++ dev, and I've recently started working my way through Clean Code*. Whenever I encounter an example I think I could improve, I try to re-implement it in C++.
On pp. 28-29 there is an example with a message building class, which looks like this when implemented in C++ (includes and namespaces omitted):
.h
clas... |
I am very new to concurrent programming in general and want to know if my implementation is thread-safe.
I'm currently working on implementing a TCP client in golang. The service listens on a port and accepts HTTP requests. On a parallel, the service also establishes a connection to an outside TCP server to which it w... |
The decimal number, 585 = 1001001001 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include leading zeros.)
Awaiting feedback.
def is_palindrome(n):
"""return... |
It's a task from a Ruby-course, in which I'm currently enrolled:
Ruby Course - Page
Precisely it's one of the assignments for the first week.
Following idea:
Your are given a list in which finished work-tasks are logged.
[
{work: "item 1", date: "2017-04-26", time: 20},
{work: "item 2", date: "2017-04-27", time: 27... |
I need to make an unknown number of api calls, up to 5 max probably. But most samples I've seen show only a couple of async calls so are effectively hard coded to the number of calls being made.
This is what I came up with as a demonstration, it has an array with three sleep times in it to simulate an API call of varia... |
As you probably know, Python slices like arr[1:3] etc. do NOT provide a view onto list and instead creates a copy of the list, what can be not optimal performance if array is big and you make for example arr[1:] (copies all exept first)
the idea of a view to an array is like :
class ylist_view():
def __init__(sel... |
Problem Statement:
Given a 6×6 2D Array, arr:
1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
We define an hourglass in A to be a subset of values with indices
falling in this pattern in arr's graphical representation:
a b c
d
e f g
There are 16 hourglasses in arr, and an hourglass sum is t... |
I have a system that stores resources. A resource contains a string that represents a user role, for example "3".
With this user role "3", you can retrieve a list of permissions for the user role, for example ["1", "2", "3"]. This list represents actions a user can perform (1 = read, 2 = write, etc).
So given user ro... |
The problem in simple words: I have three arrays of double values (x-, y- and z-coordinates) and need to find the index of the point which has minimum distance to a reference points. I do not need the actual value of this distance. If the minimum distance is not unique, any index where its value occurs may be returned.... |
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
Find the sum of the only eleven primes that are both truncatable from l... |
This is my first Python program and all it does is print out a description of the specific "Alien Class" that the user inputs.
Looking for tips and pointers and what I can do better and what I am doing well.
# Initializing the alien army with different alien classes
alien_army = {
'rogue': {
'name': 'rogu... |
I am trying to display images from a folder in my project using the "fs" module with NodeJS. I need to read all images in a directory and run them in a loop for them to be displayed. I was able to do it but I'm not sure if this is the proper or good way to do it.
I inserted my readdir (Reading Files Asynchronously) ins... |
This is a USB related question, but the problem is not USB specific. When reading data from a USB endpoint, there are two patterns I am concerned with. Request/Response like HTTP (done over the Bulk endpoint), and Interrupt transfer where one would continuously poll the interrupt endpoint without writing data to the de... |
Take the number 192 and multiply it by each of 1, 2, and 3:
192 × 1 = 192
192 × 2 = 384
192 × 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)
The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, an... |
I'm new to MySQL database design.
My question is this database is correctly built or not.
We used the users table to login and get account type
and here the code to login
$result = mysqli_query($db->_connect()," SELECT * FROM users WHERE nam = $_n AND pas = $_p ");
if (!empty($result)) {
// check for empty resu... |
I am looking to optimize the nested for-loops shown in the code below.
I have a list, mixtures, that contains points that represent 1 Gaussian Mixture (GM) on each line. My goal is to run a function kl_divergence between all combinations of GM's (with i≠j) and store the results in an array PxP.
Note: The following mix... |
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property.
Let \$d_1\$ be the 1st digit, \$d_2\$ be the 2nd digit, and so on. In this way, we note the following:
\$d_2d_3d_4=406\$ is divi... |
I am making a small console app to get XML from an API and then save the data to a database. While this project was not created via test-driven-development, I have tried to make it such that tests can be written easily and properly. Additionally, the core portions of the application are in a separate library project, a... |
Pentagonal numbers are generated by the formula, \$P_n=\frac{n(3n−1)}{2}\$. The first ten pentagonal numbers are:
1, 5, 12, 22, 35, 51, 70, 92, 117, 145
It can be seen that \$P_4 + P_7 = 22 + 70 = 92 = P_8\$. However, their difference, \$70 − 22 = 48\$, is not pentagonal.
Find the pair of pentagonal numbers, \$P_j\$ a... |
I am currently working on building a calculator using Java and JavaFX to practice my coding skills. I wrote the following methods to evaluate a given expression.
What can I improve? Is there anything you would recommend me to change to optimize my program?
public static String evaluate(String expression) {
char[]... |
My path to learning C++ has been a rough one. Currently, I'm writing a project and my knowledge is very outdated. While I can write code that accomplishes the tasks required, I'd like to improve and learn new aspects of the language.
So, I've written a class called Sequencer. It works. It's not great. It's not terribl... |
Triangle, pentagonal, and hexagonal numbers are generated by the
following formulae:
Triangle: \$T_n=\frac{n(n+1)}{2}\$ 1, 3, 6, 10, 15, …
Pentagonal: \$P_n=\frac{n(3n−1)}{2}\$ 1, 5, 12, 22, 35, …
Hexagonal: \$H_n=n(2n−1)\$ 1, 6, 15, 28, 45, …
It can be verified that \$T_{285} = P_{165} = H_{143} = 40755\$.
Find t... |
The following Python class is what I am trying to refactor in the case where I have to add validation of the existence of an AWS cloudformation stack before creating it in the method create_cfn_stack :
import boto3
import botocore
from botocore.exceptions import ClientError
class AWSPlugin(object):
""" AWS Plugin ... |
I would like to share a matplotlib real-time monitor plot that I needed for another application. Basic trick is to reverse the time, so that t=0 is now and t=20 is twenty seconds in the past and to plot the signal from 0 at the right towards the left. The core method is update that reverses time using the deque appendl... |
I'm doing an experiment trying to freshen up my unit-testing and learn dynamic programming. Every test passes but I'm curious of the result of some of them and worried if I'm doing the testing correctly. Currently I just got the one scenario for each method, with the input of 40, the goal of this test is to test which ... |
I was looking for comments (on performance and general implementation) on the following Linked HashMap implementation in C:
typedef int (*cmp)(void *a, void *b);
typedef size_t (*hash_fn)(void *val, int bound);
typedef struct {
int index;
size_t hash;
void *key;
void *val;
struct Entry *next;
s... |
The following code evaluates probability mass function for all possible states of a model.
def PDF(size):
b = np.random.randn(size)
J = np.random.randn(size, size)
density_func = np.zeros(2**size)
states = dec2bin(size)
for i in range(2**size):
density_func[i] = np.exp((np.dot(b, states[... |
I have been implementing a library of PLC logic blocks (i.e. AND gates, OR gates,
RS flip-flops and TON, TOF and TP timers) in C++. I have decided to model all of
these logic blocks with C++ classes which implement common interface
namespace LogicBlocks
{
class LogicBlk {
public:
enum LogicType_e{
POS, // ... |
I am trying to emulate a C++ enum class in C and the code works as I expect. I used this code as indicated on
Stack Overflow.
// .................................................... JOIN
#define JOIN(id,_1) id ## _1
// .................................................... CONCAT
#define CONCAT(id,_1) JOIN(id,_1)
#ifdef... |
I've created a Node class which contains two important properties:
public Node Parent { get; private set; }
private List<Node> Children { get; set;}
As the name suggests, the Parent object holds information about the ancestor of a certain node, if the parent is the root of the tree, then the parent is set to null. An... |
I've made the following to draw a series of zooming in images of a fractal.
using Distributed, FileIO, ImageCore, Images, ImageView
@everywhere function mandel_pow(z::Complex, p::Number)
c = z
maxiter::UInt8 = 255
for n = 1:maxiter
if abs2(z) > 4
return n-1
end
z = z^p +... |
update1:
- I need to make two different api calls.
- from the result of first api call I am getting id in the variable firstAPIid,
https://reqres.in/api/users?page=2
- I need to pass this id firstAPIid to the second api call.
can you review my code.
I did multiple api calls through promise.
right way is through prom... |
I created an algotrithm that groups a sorted list of coordinates into buckets based on their proximity (30) to one another.
Steps:
Create a new key with a list value and pop the first point in the list into it
Scan the list of points for points that are close to it. Push matches to the new list and replace values wit... |
I have two dataframes (x and y) that I need to join, conditional on the timestamp in x falling within the time interval of two columns in y. I've accomplished this using data.table::foverlaps() by adapting some of the code in this stackexchange question), but in order to get it to work on my data I had to set the key ... |
I have written a file compressor in python. The program generates a file filled with sequences of the same character with a random length, and compresses that file. I would like feedback on code readability, efficiency, and any other nitpicks that you find. Any and all feedback is considered and appreciated!
compress.p... |
I recently got a prompt when looking for a job. To spare any details, the company decided not to get back to me, so because I did not get a code-review/feedback from them, I was wondering if someone would review this and tell me how i could improve it.
Here is a link to the full prompt (pretty long) with sample input ... |
The series, \$1^1 + 2^2 + 3^3 + \ldots + 10^{10} = 10405071317\$.
Find the last ten digits of the series, \$1^1 + 2^2 + 3^3 + \ldots + 1000^{1000}\$.
def self_power(n):
"""returns sum of self powers up to n."""
total = 0
for i in range(1, n + 1):
total += i ** i
return str(total)[-10:]
if __... |
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual
in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are
permutations of one another.
There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes, exhibiting this
pro... |
For this Code, I am provided a text file that contain several cities. I am suppose to identify the cities mentioned and print their state and country.
Requirements: If a mentioned city is in two or more countries, I ask the user to mention which city they are talking about. In addition if there is a slight typo, I ask ... |
I'm calculating now the total garnered hours student get in school using php.
(Same concept in getting the total work hours in employee for timesheets)
So I have an array $attendance where the student check in and out in school.
$attendance = [
"2019-07-01 08:03:00",
"2019-07-01 12:12:00",
"2019-07-01 13:03:00",
... |
I've been working on a a text based game with a very simple battling system. There are way to many questions I can ask to get reviewed about this project, but I'll take small steps at a time (this is my first post).
I'm mostly concerned about how I handle command input and the execution of said commands within the game... |
I've written a Caesar Cipher in python (a more in-depth explanation is provided in the docstring at the top of the program). At first, it was supposed to just be the cipher, but I expanded it to have the user guess the original string, given the encoded string. I would like feedback on the caesar algorithm, and any oth... |
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953.
Which prime, below ... |
Could someone share some light and check if this is okay for apache httpd security/good standards? I'm using apache httpd to call my Node.js app that is running with Express and also configuring SSL.
apache2.conf:
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRe... |
This works but it doesn't really seem ideal. Is there a better way to write this using react-router? Initialization and pagination are just React containers holding logic. DisplaySaves is a component that renders some stuff to the screen.
<div>
<BrowserRouter>
<Route path="/authorize_callback" exact component={In... |
I have a mutableListOf a sealed class.
I am trying to compare the result coming from the api with the ones saved in the db so I can update my UI base on isSaved attribute. Here is my code :
sealed class MasterList(val type: Type) {
data class FavoriteList(
val list: List<Info>
): MasterList(Type.FAVORI... |
Just starting out trying to do some python for data analysis. I am a total beginner and have figure out how to brute force somethings, but I know it is inefficient but don't know how to do it without messing up what i have.
I have multiple webpages to scrape and then store data in a data frame. The code is identical fo... |
I've written below python script just to invoke parallel threads of a command nslookup linux-host01 dns-server, i'm Just trying to flood the DNS Server dns-server with multiple number of queries in parallel way.
As an argument to this script i'm passing a hostlist file example linux-host01 , linux-host02 etc.
To achiev... |
Can anybody find anything to pick apart in this script?
# Copyright (c) 2019. Legorooj
import sys
import os
docstring = '''
add_alias [alias] [command]'''
if len(sys.argv) <= 1:
print(docstring)
else:
alias, cmd = sys.argv[1], sys.argv[2]
print('Adding alias...')
os.system(f'echo "alias {alias}={cmd}... |
I often find in codebases something on the order of if (sprockets.Count() > 0) which is easily replaced with LINQ's if (sprockets.Any()). This keeps the entirety of sprockets from having to be iterated over completely (to get the count) then comparing to zero. Further, the business logic often reads something like "if ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.