instruction stringlengths 71 95.1k |
|---|
Here's my take on the Linear Regression exercise from John Zelle's Python book.
Open a window, let the user click on as many points as they want. Upon pressing the "Done" button the regression line of those points is drawn.
from graphics import *
def dots(win):
sumx = 0
sumy = 0
sumx2 = 0
sumxy = 0
... |
I invested an hour or so to reimplement the C++ header <array>. Most stuff is in the namespace my_std, but tuple_size, etc. are not, otherwise they are useless. I aimed for C++14.
One caveat: the array<T, N>::swap member function's noexcept specification is too complicated, and I chose not to reimplement the std::is_n... |
I'm trying to implement the game Snake in Javascript and getting the computer to play it by itself, and want to check whenever the snake loops (repeats the same set of moves twice) so I can kill it.
To do this, the first thing that came to mind is saving the state the entire game at every frame (the state being the pos... |
The following is a bash script named wrapper.sh:
#!/bin/bash
data="ZAA:huhu;ZBB:blub;___uname" # actually coming from a Python script
i=1 # counter
while true ; do # loop infinitely
segment=$(echo $data | cut -d ';' -f$i)
if [ -z "$segment" ] ; then # is segment empty?
break
fi
if [[ $segment ... |
The problem is taken from one of recent SO questions:
Finding max sum of matrix elements with following constraints:
Exactly one row element has to be included in the sum
If element at (i, j) is selected, then (i + 1, j) is not.
Values in the matrix are nonnegative integers.
Below is my working (as far as I can tel... |
This filter is basically gradient detection (the variable gradImg) like an edge detection (Sobel or Prewitt filters) and also the direction of that gradient whether vertical or horizontal (dirImg).
I'm trying to optimize it to run faster and I found that this part of the code slow. Would you have any suggestions please... |
I had an idea for a __first__ special method for a class. It would be run after __new__ and before __init__ the first time a specific object is instantiated but is not then run if you instantiate the object again. For example, if you run:
class Foo:
def __first__():
print('Inside __first__')
def __init_... |
I have a project where, every time I run it, I have to:
test if some folders exist, and create them if they don't exists.
remove their content if the folders already exist.
This is the code that I developed to do this:
import os
import pathlib
def clean_Folders(directory):
folders = ['preprocessed', 'results... |
I am designing a query builder, where the user can just add conditions or groups, and each group can, in turn, have conditions in it. I came up wit the below class design. Can this design be improved?
public enum RuleType
{
Group,
Condition
}
public enum Operator
{
And,
Or
}
public enum ConditonValues
{... |
This is a simple Python script to add @unittest.skipUnless() decorators in a specified format above every function starting with test_. I want to simplify this and try and improve it. It runs extremely quickly and does the job right now, but I'm wondering if this is best practice for modifying Python files.
Do Python ... |
This is my solution to CodingBat problem p150113. My Java knowledge is from 2011 and I'd like to know if this is still the optimal way to approach such a problem. and if my code is clean and understandable.
We'll say that 2 strings "match" if they are non-empty and their first chars are the same. Loop over and then r... |
This is a Python chat room that I've been working on and it enables to you to chat to other people on the same network through Python.
Server.py:
import socket
import sys
s = socket.socket()
host = socket.gethostname()
print(" server will start on host : ", host)
port = 8080
s.bind((host,port))
name = input(str("Pleas... |
My first program using C. I would appreciate pointers on how to improve the code. I exit just before turns reach 9 and the grid is filled because it causes all sorts of bugs. The computer is random.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// Struct with all game state variables.
struct game_data {
... |
(My code is basically a rewrite of https://github.com/ababik/Remute so much of the credit goes there)
The idea is to use lambda expression to provide a general With method for immutable objects.
With With you can do:
using With;
public class Employee {
public string EmployeeFirstName { get; }
public string Employe... |
I have written a Windows Forms app that interfaces with a variety of equipment to automate the testing of some gas sensors. The program has four main objects, and sometimes these objects have to call methods or fetch properties from each other; a partial listing of the four relevant classes is below:
// GUI which crea... |
Async SelectMany takes an enumeration (length unknown) of tasks, each of which returns another enumeration (length unknown and likely different from one another), and returns results from the second dimension as soon as they are ready. I used the name FoldAsync to make it descriptive, but I'm open to suggestions.
Imagi... |
The script parses Bitcoin database (blkXXXXX.dat) files directly from raw binary to txt human readable view. And I think about how to encrease the speed of processing.
Can anyone suggest how to improve the performance? I know that the best way to encrease performance is to write this on C or C++, but what about Python?... |
I've created a code that works but takes time to run.
Is there any way of making this code work in a more efficient way?
In short terms I want to:
make a new copy of sheet 1 and 2
Select the row with the lowest value in sheet 1
Paste this row in sheet 3, and select item-number, rownumber and OP-number from this row
De... |
Here is a script that opens about 200 pictures, the first time you open the webpage, loading of the 200 pictures is fast, However if you reopen the page, it takes about 4 minutes to load the same page the second time. Please advise.
session_start();
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('... |
This is my take on an image → greyscale converter.
#greyscale.py -- Converts an image file to greyscale
from tkinter.filedialog import askopenfilename, asksaveasfilename
from graphics import *
def displayimage(imagefile):
#Open image to get width and height
image2convert = Image(Point(0, 0), imagefile)
im... |
For an assignment, I am identifying the first quarter of the 2008 recession in the United States. The Excel data I'm using can be downloaded here: gdplev.xls. How can I improve this pandas code to make it more idiomatic or optimized?
def get_recession_start():
'''Returns the year and quarter of the recession start... |
I'm working with another company in a new application for my company. My job right now is to send on demand to the other company the data that they need, ciphering some of it.
I should point out that the key is not going to be stored in any database.
Here's the code that I wrote, intended to be used in both services.
u... |
We want to create an application for the analysis of the order history at an online store. Each order is made by a customer and concerns the purchase of one or more items. Orders are stored in OR, an array of integers having 4 columns. The generic line OR[i] = [o, a, q, p] denotes the fact that in the order with code "... |
I've been implementing a MySQL client with the later purpose of automating monthly reports.
At the moment, I've got two distinct use cases: Executing a query and printing the results in files. The results are the data queried and some stats about the execution (start time, end time, duration, ...).
My problem is that I... |
I read somewhere that you should try to have as few method arguments as possible to make code easier to read, understand and use. I agree with this to a point but I'm not sure how I can make the following method easier. I think all 5 of the arguments are required.
Should I leave it as is? I think, if I was to add some... |
I have invoices, invoices_items, order, order_items. Invoices and Orders tables contain around 1 million records. Invoices_items and Orders_items tables contains more than 2 millions records. Items table contains 200,000 records. Now I want to generate a report based on my filter like customers, item categories and mor... |
I have a message coming in and I need to match it against the expected messages. The program will eventually do something as a result of receiving those messages. I am not very experienced at programming, but surely there should be a better way to declare all those messages it can be in like a separate entity and then ... |
I am traditionally a Java/Backend Developer, and have recently been spending a lot of time dealing with issues that higher tiers of support should be able to handle themselves. To assist them with this, I wrote the following script for them to extract what look like "Log Files" from Kibana, allowing them to do some Ana... |
I want to display on a view the EmployeeHistory view model sorted by elements.assignEffDateNext and I want to instantiate and populate the view model from the controller. The code analysis is saying that the IList<IDMSElementDate> EmployeePositionsOverTime should be read only. I kind of understand why.
This is what I... |
As part of an job interview process, I was tasked to write a solver for a simplified Tetris game using JavaScript. The game board size is 4x4 and there are 4 different pieces given in a .txt file. It is not allowed to rotate the pieces, so they should be placed exactly as they are specified in the file. Following norma... |
I'm creating a version of the classic sequential master file update in java. This is used when you sort two files by the same key for updating one file with the other. In this case, I'm pulling in all available note types and then comparing them against note types configured. The goal is to create two collections, the ... |
The following is my solution for an inverse mapping with bilinear interpolation on an image. The original image is img and newmatrix is the transformed image. invRot is the inverse transformation matrix.
How can I optimize the nested for loops (or remove them altogether) to give me a better time complexity for large v... |
class Link:
def __init__(self, value):
self.val = value
self.next = None
def __repr__(self):
return f"{self.val} "
def __str__(self):
return self.__repr__()
# TODO : Implement Non-recursive solutions and string representations in recursive solutions.
class LinkedList:
... |
The code below is for a coding challenge for a job. I have everything working as they requested, I've reviewed it myself and believe everything is good. I'm just looking to see if anyone see's anything that I may have done in a way that may be considered bad practice, or if there is any obvious improvements that could ... |
Purpose
This was designed to be able to seamlessly replace string SAPCustomerID and int CustomerID in parameter lists with CustomerIdentity customer without breaking existing code. This will allow the developer to choose which they can provide and gain access to the other (if needed). Parameters lists being Web API fun... |
Based on my understanding of Model View Presenter (MVP) I have it generate a diagram. Is this a correct implementation of MVP?
What deficiencies are there in my implementation?
UI
Generated diagram
The code
'LoadingModule class
'@Folder("Model")
Option Explicit
Private Type THelper
PointLoads As Long
Distri... |
This is my first Python script and I would like to hear the opinion of more experienced users, so I can do it right from the beginning instead of trying to correct my mistakes after months (years?) of coding.
#!/usr/bin/env python
import argparse
import csv
import json
import os
import sys
from pprint import pprint
_... |
Is the complexity of this code \$O(n^3)$? How can I improve the efficiency and reduce the complexity?
A = [3,2,4,2,4,2,4,5,3]
n= len(A)
def ALG2 (A,i,j): #to check whether all entries between A[i] and A[j] are the same
if i==j:
return True
for k in range (i,j-1):
if A[k] != A[k+1]:
... |
Made the game much more user-friendly than previous version - has an example grid to demonstrate input, Xs and Os are now used.
Game can now detect draw.
Changed the algorithm to detect winner, it's less buggy overall although there are still some combinations near the end of a game where it incorrectly determines a ... |
I am producing a PHP code and I want to implement it in my server to do its function. My question is, are there any vulnerabilities that I should correct?
I tried to establish the session first then I will initiate a SQL connection and I will ask the user to enter his email. Also I added the reset function of his email... |
In order to learn macros in C I decided to make a generic data structures generator for other projects that I have in C.
The main macros are the following:
CONTAINER_GENERATE(C, P, PFX, SNAME, FMOD, T) ....
CONTAINER_GENERATE_SOURCE(C, P, PFX, SNAME, FMOD, T) ....
CONTAINER_GENERATE_HEADER(C, P, PFX, SNAME, FMOD, T) .... |
I wrote a bash script for backing up my LAMP server. To be honest that's my first experience in bash so I want to ask you for help in its improvement.
#!/bin/bash
date=`(date +%Y%m%d%H%M)`
declare -A users=(
["user1"]="password1"
["user2"]="password2"
)
for user in ${!users[@]}
do
directory=$user
d... |
I made a simple async networking server and I'd like to get some input on the code, whether things can be done better and whether the code is stable (able to hold more than 1000 connections without lag) for a MMORPG game.
GameNetworkListener.cs:
using System;
using System.Net;
using System.Net.Sockets;
using System.Thr... |
This is an implementation of HttpClient Json Post by Action parameter.
Logic:
It is mainly convenient to pass the url and object (automatically converted to json by Json.Net), and can use Action as a parameter to customize function.
default timeout is 15 sec , if you want to change the time , it could change timeou... |
I want to generate all the subarrays from an array of integer as below:
func subarrays(_ arr: [Int]) -> [[Int]]{
var result = [[Int]]()
guard arr.count >= 1 else { return [arr] }
for i in 0..<arr.count {
for res in result {
var resi = res
resi.append(arr[i])
resul... |
I wrote an if statement that checks if an iteratively altered vector "crosses" the up vector (0,1,0) or the down vector (0,-1,0).
if ((lastDiff.x() > 0 && diff.x() < 0 && lastDiff.z() >= 0 && diff.z() <= 0) ||
(lastDiff.x() < 0 && diff.x() > 0 && lastDiff.z() >= 0 && diff.z() <= 0) ||
(lastDiff.x() > 0 && diff... |
I must create a program for information regarding schedules and topics of meetings at work.
The data relating to the meetings are stored in an "M" matrix with 5 columns, in which the generic row [g, m, in, fin, arg] denotes the fact that a meeting has been scheduled for day "g" of month "m", from hours "in" to "fin" ho... |
The task:
Given a word W and a string S, find all starting indices in S which
are anagrams of W.
For example, given that W is "ab", and S is "abxaba", return 0, 3, and
4.
My solution:
const anagramOccurrencesOf = (w, s) => {
const occurrencesCopy = [];
let sCopy = s.slice(0);
let inde... |
I have tested this code and it yields the expected outputs, but I want to verify if I have applied insertion sort algorithm correctly or not.
import java.util.*;
public class InsertionSort
{
static void swap(int[] arr, int i, int j)
{
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp... |
I wanted to make a very simply Battleship game in Java, any feedback is welcome.
Nevermind the getters / setters. Just assume they are there.
class Game {
Board board = new Board();
void playGame() {
Scanner scanner = new Scanner(System.in);
while (!board.allShipsSank()) {
System.... |
I wrote a class that replaces the get and set functions:
template <class T, class U = T, class V = T>
class GetSet
{
public:
template <typename = std::enable_if_t<std::is_same<U, T>::value && std::is_same<V, T>::value>>
inline GetSet() { getf = getNormal; setf = setNormal; };
inline GetSet(U (*getf)(T), T (... |
I've got the following shell script (let say get_includes.sh):
#!/usr/bin/env bash
includes=($(grep ^#include file.c | grep -o '"[^"]\+"' | tr -d '"'))
echo "0: ${includes[0]}"
echo "1: ${includes[1]}"
which aims at finding relative include files in source code file.
So for given file like this (file.c):
#include "foo... |
I just started to practice for competitive programming and just started to solve the most solved problems on SPOJ.
This is what I made for ADDREV: Adding reversed numbers in Java (https://www.spoj.com/problems/ADDREV/)
The Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancien... |
This code shows two ways to calculate size of array of any type. I would like to know, which should be preferred? Is there any advantage/disadvantage?
#include <iostream>
// First method
template<typename Arr>
std::size_t array_size_1(const Arr& arr)
{
return sizeof(arr)/sizeof(arr[0]);
}
// Second method
template<t... |
A method has been written that increments time in minutes that simulates how much time it takes to process item in a supermarket queue and if there is an empty queue, skip it and loops around to find the number of items processed in each interval (each time a minute has passed). I was wondering if there are ways to imp... |
I have written code for making a Chess Validator, which will validate the moves of a chess game.
There is a Main class which is taking the input from the user, about the move.
Problem Description
The board is maintained in the form of a 2D matrix, which contains the pieces as {color}{type}.
Eg. BH : black horse.
Pi... |
I am consistently timing out on the mentioned kata:
Task
You will be given an array of random integers and a number n. You have to extract n smallest integers out of it preserving the original order.
Examples
performant_smallest([1, 2, 3, 4, 5], 3) == [1, 2, 3]
performant_smallest([5, 4, 3, 2, 1], 3) == ... |
I have this code for predicting credit card default and it works perfectly, but I am checking here to see if anybody could make it more efficient or compact. It is pretty long though, but please bear with me.
# Import necessary libraries.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Extrac... |
I was solving this Leetcode challenge about Hamming Distance. Would love feedback on my syntax and code style. Here's the challenge description:
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given two integers x and y, calculate the Hamming distanc... |
I wrote this code to to perform the following:
I will remove the "spaces" within the url.
Return welcome message.
Redirect the user to different url.
Compute HMAC for the request.
Return and revoke the user profile picture.
Would someone please help me in checking if my code contains any security issues that I should... |
Explanation : I am adding new elements in the list until the window runs out. Head will have the earliest element and tail will have the most recent element. Once the window is over, every addition requires deletion of the very first element or least used in the list which was temporally inserted a lot earlier than oth... |
I am trying to get better at problem solving, so I am going through challenges on Project Euler.
Problem:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
My solution:
My approach to this was the following process:
Get all factors of the number
Identify p... |
My goal is to write a GUI application where a user can create a maze and select an algorithm. The passage of the algorithm from a selected start and end point should be visualized.
The following shows only the Breadth-First Search algorithm. During programming, I paid attention to the following things:
readable APIs
S... |
I'm pretty new to React and I was working on some JSON data. Now I just to understand basic concepts, so I wrote this little component, but in my eyes it's not efficient.
import React from 'react';
import {getJson} from './getJson';
import AddRow from './AddRow';
class TableComponent extends React.Component {
cons... |
First Code Review request =) I wrote this after making several projects that required a user to pick an option. I wanted to have a set way of forcing that choice in all of my projects. The module also contains a GetNumberChoice() func, but I'll save that for a separate post.
As a relatively green programmer, I'm looki... |
I've solved test task for job vacancy. Need your feedback about my solution.
Task
The image below shows the puzzle in the solved state. The puzzle consists of 10 cells. Among the cells one is empty, the rest are numbered from 1 to 9. An empty cell is used for permutations of numbers along the allowed paths shown as lin... |
I have recently created an esoteric programming language called 01 and I will be grateful for a code review and any opinions or suggestions about the future of this language.
GitHub
require 'securerandom'
require 'optparse'
COMMANDS=['>','<','+','-','.',',','[',']','0','1']
ERROR_NOT_IMPLEMENTED='Command "%s" not imp... |
I am trying to print out numbers by increasing positive and negative values around a center number, and I don't think I've found the best way. For example, say I want to find what number in a list my center value is closest to. I do that by adding one, see if it matches, then subtracting one from the original number an... |
I would like feedback on the correctness and performance of this code.
My priorities are also are readability, simplicity and self-documenting code - but I'm happy with those as they are.
I still need to do some factoring of common code between the two input lines - but I'm brushing up my C and will do that.
RA2 and R... |
I'm new to Go and wanted to implement a web server using system calls to get a better feel for how everything works.
I'm looking for feedback on idiomatic go especially error handling and using pointers.
I'm not particularly concerned about the completeness of the code. The primary goal was to learn syscalls in go.
pa... |
I have just finished my minesweeper game using tkinter and would like to know how I could improve my program.
from tkinter import *
from tkinter import messagebox
from random import randint
class setupwindow():
def __init__(window): #window is the master object of the setup window
window.root = Tk()
... |
I was wondering if there is a better way to write the following code? The code is working, I am looking for better technique to achieve the functionality, if any exists. Never mind the classes that are not shown, indentation, class names, etc. I am focused mostly on the functionality.
JsFilddle
<ul class="list-unstyled... |
The task:
Given a string of words delimited by spaces, reverse the words in
string. For example, given "hello world here", return "here world
hello"
Follow-up: given a mutable string representation, can you perform this
operation in-place?
My solution:
const reverseStr = s => s.split(' ').reverse().join(' ');
... |
I'm a self-taught programmer and I'm in the process of developing a simple 2D Isometric game.
There is next to no game content yet and I've been focusing on creating solid "foundation" first if you will, and I'm here to get some code reviews on the structure of the source code.
Is it clean
Am I using proper coding con... |
I wrote the below code which contains the following functions: establish session with the user, determine if the user is authenticated, perform ping request, search about the user from the database, reset password and import bulk product with the type text/xml.
Did I handle the functions correctly?
Is my code secure?... |
The purpose of the code is to efficiently stream JSON items from a large file.
I am wondering if this is efficient and decently idiomatic. Not sure how I could eliminate the while loop either.
module Seq =
let inline tryMove (e:IEnumerator<'T>) =
try
let moved = e.MoveNext()
if moved... |
I wrote this script to replace a VBA script for mailbox management that was in place before. Essentially, I have an Excel sheet in which the rules are defined. These have to be loaded and applied to the mails currently in the inbox. The file's structure looks like this:
criteria (required): "begins with" or "contains"
... |
I created a way to export my Google Play playlists to a text file and also a way to export all of my songs in Google Play to a text file. Now I have both the song list (in an array format) and playlist data (in object and array format) in their respective text files. Here is a simplified version of the files:
[
"so... |
I am trying to optimize matrix multiplication on a single processor by optimizing cache use. I am implemented a block multiplication and used some loop unrolling, but I'm at a loss on how to optimize further though it is clearly still not very optimal based on the benchmarks.
Matrices are in column major order.
Any sug... |
I've started learning Python yesterday with the intention of studying machine learning. Before this, my experience with programming was exclusive to my first semester where I had a C course.
I decided to work towards a final objective: have an AI learn how to win the snake game. For that goal, I had to make the actual ... |
I have an Angular component and it is just a label which renders a value and if it has an associated pipe, the output of the pipe should be rendered as value of the label. But I don't want to declare all the pipes in the component. Currently I would like to use the currency pipe and the date pipe with their parameters.... |
I have written some python code to play this scratch game.
But it is to slow to function correctly because each frame if it clicks, it takes a screenshot of almost the same thing like this
____
_ _ | ______
_|______
|
Click
Screenshot
____
_ _ | ______
__|_____
|
And ... |
Problem: Given an integer between 1 and 32767 print the individual digits with 2 spaces between them.
I am using C How To Program but this is not homework. The book has not gotten to arrays or anything more complicated than looping structures and function. I try to avoid using those structures and concepts that hav... |
My implementation of Karatsuba multiplication from Tim Roughgarden's Algorithms course. I've made a Integer class that holds an integer in string format. I've added operations to this class to add, subtract and multiply numbers. Karatsuba.cpp performs Gauss' trick (complex multiplication algorithm).
Integer.hpp
#pragma... |
new to bash , I use the following code to open the super folder with a file path.
function openUp(){
cd $(echo $1 | sed 's@\(.*\)/.*@\1@' );
open ..
}
like drag a file to terminal, then open the super folder conveniently.
openup /Users/de/Downloads/32/S01E32-array-arrayslice-collection-collections-1-master.zip
... |
38. Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n where 1 ≤ n ≤ 30, ... |
I have two methods which are GetMinimumSize() and GetMaximumSize().
They return the maximum size of the window, and they take one parameter, which is an enum either WindowSizeLimitParam::Width, or WindowSizeLimitParam::Height, because of course, we want to specify which maximum or minimum we want to get.
Here is the e... |
In a service I'm developing I'm using three cloud services (five if you count additional two streaming services I have to create that are used by those cloud services in turn) and to orchestrate bits and pieces incoming I need a cache for objects relating data from all those services. That cache has to be is safe to ac... |
I had answered this question from stackoverlow and the code below is code that I wrote to explain to the OP a possible way to achieve what I believe they were looking for.
The general idea that I got from them was that they were trying to open a file with a specified file name and if that file does exist that they in ... |
I'm working on a game project (with Unity) that shall handle user credentials and other data. The game connects send requests to a php script and this script send requests to the database. After spending some days learning about sql injections and password handling, I came up with this approach. I am obviously still ve... |
I'm trying to write a policy based auto-registering class using the Curiously Recurring Template Pattern. I decided as design choice to not using registering macro.
Factory Class
template<typename Base>
class Factory{
template<typename, typename>
friend class Registrable;
public:
static Base* create(std::stri... |
I completed this WordPress coding task as part of an interview. I'm hoping someone can review my work and comment on everything, especially my general approach to the task, and the sanitization of output. The client's previous developer had already completed this project, but was leaving the company. So the client wa... |
I made myself a simple script (Batch/JScript) that download a pic from a blog (APOD) & set it as wallpaper.
@if (@a==@b) @end /*
Set BaseUrl=https://apod.nasa.gov/apod/
set yr=%date:~8,2%
set mn=%date:~3,2%
set dy=%date:~0,2%
set dte=%yr%%mn%%dy%
set SaveDest=C:\Users\ME\Desktop\Wallpaper\%dte%.jpg
Set Url=%baseUrl%ap... |
One of the big problems I have is cleanly converting from an internal datatype to an external datatype. We can all do it the not so clean way, however I think this add too much mess.
I can use libraries that read from a filetype to a Python object, however some libraries don't allow you to convert the data from one typ... |
I've written a python program to rank the names that appear in the file(s) based on their frequency. In other words, there are multiple files and want to rank the frequency of the names that appears the most first, then the least at the end. Each name can appear only once in each file. In other words, the same name can... |
I added Rock, Paper, Scissors to one of my programs. I'm new to python and PEP 8, so I want to see how to improve my work.
def rock_paper_scissors(name):
play_rps = True
while play_rps:
rps = ["rock", 'paper', 'scissors']
player_rps = input("Rock, Paper, or Scissors: ").lower()
com_rps =... |
I'm new to python and PEP 8, so I want to see how to improve my work. This is my first big project without a guide. This is 184 lines. I think I murdered PEP 8 and need help fixing that.
import random
name = "null"
jokes_list = ["Why did the chicken cross the road? To get to the other side.", "The only time incorrectly... |
I need to deserialize an XML file, without using any sort of "reflection" (or meta-programming). Instead, I need to do it via a raw object, that knows of it's structure and can properly identify and deserialize itself.
In this case, I have an XML file that looks like the following:
<Test>
<Item>
<Group>
... |
I'm beginning to learn WPF and wanted to do a quick exercise. The code is as simple as it gets but I tried to evaluate each and every possible edge case. Any improvement is welcome, thanks.
C#:
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
namespace Calculator
{
///... |
From the HackerRank question definition:
The word google can be spelled in many different ways.
E.g. google, g00gle, g0oGle, g<>0gl3, googl3, GooGIe etc...
Because
g = G
o = O = 0 = () = [] = <>
l = L = I
e = E = 3
That's the problem here to solve.
And the match has to be only this single word, nothing more, nothing
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.