instruction stringlengths 71 71.9k |
|---|
The code generates all combinations of filename with underscore _:
def filename_generator(name, path=''):
names = []
for i in range(len(name)):
p = '_'.join([x for x in name[i:]]) + path
names.append(name[:i] + p)
names += filename_generator(name[:i], p)
return sorted(list(set(nam... |
Here is what appears to be a fairly easy problem:
Write a program that prompts the user to enter several integers in any
combination of octal, decimal, or hexadecimal, using the 0 and
0x base prefixes; interprets the numbers correctly; and converts
them to decimal form. Then your program should output the values... |
I am learning dynamic programming and I have written down some code for longest increasing subsequence. I would like to know if there is any case or any area of improvement in the terms of optimization/programming style.
/**
* LIS = Longest increasing subsequence.
* Input = [10, 22, 9, 33, 21, 50, 41, 60, 80]
* Outp... |
I am using Imaplib to fetch data from Gmail and get the number of emails each day. I am going to login using Imaplib twice for fetching emails for the inbox well as for the outbox (sent mail). Is it possible that I have to login only once and get result as I need?
The code works fine and I am asking for review that how... |
I have developed a class that utilises the session_set_saver_handler function so I can store sessions within my DB. The class works just as I would like.
However, my only concern is the way I have approached the session timeout.
Current the _read() function code looks like:
/**
* Read session function
* @ac... |
In response to a feature-request on meta, I spent a few hours today creating the feature in php.
This application adds a review shield to your GitHub repository (or wherever else you want it).
It looks like the following:
To use it, use standard image/link markdown, like this:
[ and today I made this solution to Project Euler #2. The problem is to sum the even Fibonacci numbers. My program uses the matrix representation of the linear relation between consecutive Fibonacci numbers to calculate the coefficients for an equation. This equation will generate... |
Below is my jQuery scriptfile, all the functionality works (except for the click events on IE). I bring this before you guys to ensure I am effectively separating concerns and writing efficient scripts.
( function( $ ) {
$( document ).ready(function() {
setTimeout(textFill, 50);
fitheadliner();
showExcer... |
I'm currently working on an Android app and I need to translate keys of type String to Integers which are determined at compile time of R.raw.
Right now I have found two ways of creating such a Map that holds all (needed) values of R.raw:
private static final Map<String, Integer> map = ImmutableMap.<String, Integer>b... |
I've been writing a somewhat complicated service that involves a lot of API function calls in Angular. After a somewhat tortured first attempt I have tried to take more of an MVC approach rewritten the Angular in the following ways.
All data, once it's retrieved from the API, is stored in a Service with a setter or ge... |
This is a registration and login program I made in Python that runs through the terminal. I am new to programming so I didn't have any actual use for this, I simply made it for practice. Please give me tips on minimizing code and making things shorter, point out any bad programming practices I used here and how I can c... |
I wrote a script that tests monophyly by computing Bayes Factor on a sample of trees from Bayesian MCMC analysis from MrBayes and BEAST posterior tree sample files. This is the natural way I write code and am looking for improvement. I am trying to read some theoretical articles and other code, but that doesn't bring r... |
This is the Text Justification challenge at LeetCode:
Given an array of words and a length \$L\$, format the text such that each
line has exactly \$L\$ characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many
words as you can in each line. Pad extra... |
I have a CSV with 5+ million rows and I want to filter it:
with open("test1.csv") as csv_file:
writer =csv.writer(outputfile, delimiter=',')
for row in csv.reader(csv_file, delimiter=','):
row = [int(x) for x in row]
for i in range (1,11):
if add_i (row) == True:
bre... |
I wrote this program which reverses the words in a given string. Please review and give your inputs.
private static void reverseWords(String value) {
// reverse the whole string
value = reverseInOofN2Time(value);
// now split (on space) the string into an string array
String[] strArr = value.split(" ")... |
Below is the problem taken from here.
Question 10: GCD*
The greatest common divisor of two positive integers a and b is the largest integer which evenly divides both numbers (with no remainder). Euclid, a Greek mathematician in 300 B.C., realized that the greatest common divisor of a and b is one of the following:
the... |
I am very new to Laravel. I am building a website where multiple users can have one or more roles. I have a users table and a user_roles table. Each user_roles column has a user_id and an enum field where they can be a "referee", "coach", or "player". Whenever I want to check if the User is a certain member of a role I... |
Please review my code:
public class Anagram {
public static void main(String args[]) {
String[] arr = { "abc", "cbc", "bcc", "dog", "god", "mary", "army",
"rty" };
HashMap<Integer, List<String>> mapList = new HashMap<Integer, List<String>>();
for (int i = 0; i < arr.length;... |
I have millions of files in a folder. File types will be with the name PES_timestamp and DOM_timestamp. I have to aggregate all PES and DOM filenames into one file which has the same filename.
The Aggregator program picks up only matching PES and DOM file pairs based on the timestamp of the file name from the incoming ... |
The following method reads specially formatted text (TOML) from a file and parses the input using a parser to get a few properties, which are then used to create an object.
The profiler tells me that this method is the bottleneck in my program. While parsing ~5000 files, this method eats up over 95% of the total runnin... |
Print the following pattern, when you invoke inverse_cascade(1234)
1
12
123
1234
123
12
1
Solution:
def inverse_cascade(n):
def grow(n):
if n < 10:
print(n)
else:
grow(n // 10)
print(n)
def shrink(n):
if n < 10:
print(n)
else:
... |
I have made an implementation of Sieve of Eratosthenes algorithm in Java, and am not certain that it is as efficient as possible.
I have looked at other peoples implementations on Google, and on this site, which raised concerns for me, as no one has taken a similar approach to me.
public class sieveOfEratosthenes {
... |
I am interested in octants in plane geometry, which basically involves dividing a plane into 8 equal parts according to a certain point.
Octants are particularly useful while implementing the Bresenham's algorithm.
Problem
Given two points A = (x1, y1) and B = (x2, y2), how to determine in which octant belongs B acco... |
Problem:
Using the recursion approach, find a Fibonacci sum without repetition of computation.
def sum_fibonacci(n):
"""Compute the nth Fibonacci number.
>>> sum_fibonacci(35)
9227465
>>> sum_fibonacci(10)
55
>>> sum_fibonacci(0)
0
>>> sum_fibonacci(1)
1
>>> sum_fibonacci(5)
... |
This code prints numbers in a triangled way, such as:
1
12
123
12
1
This is the code:
def triangled(num):
num = str(num)
pieces = [num[:i] for i in range(len(num))]
return pieces + [num] + pieces[::-1]
def triangled_print(num):
for i in triangled(num):
print(i)
triangled_print(123456789)
|
After reading this question I wanted to write a short example of how a list or sequence could be shuffled in .net. The result turned out to not be very short:
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
class Program
{
private static void Main()... |
I made a 16 character code generator. It works like a charm now, but I was wondering if there's any way to do it more efficiently.
public partial class MainWindow : Window
{
//Globals
string[] Letters = new string[27] { "A", "B", "C", "D", "E", "F", "G", "H", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "... |
I need to run fork workers every 5 seconds. Is there a way to do it more ideomatic? I'm embarrassed about $running variable.
use 5.010;
use strict;
use warnings;
use AnyEvent;
use AnyEvent::Util;
my $running;
sub work1 {
say "work1";
sleep 1;
}
sub work2 {
say "work2";
sleep 1;
}
sub do_work {
... |
As I'm reading the Java code of some other people, I found him using an approach of assigning a format string to a variable and using the variable for String.format in the code:
private final static String URI_SUFFIX_FORMAT = "view/%s";
@Inject
private UriBuilder uriBuilder;
public void buildUriForMusic(String dir)
{... |
I need to get every UTC day stamp in yyyy-MM-dd format (e.g. "2015-07-02") between any two arbitrary Date fields.
My first attempt is this:
public static Set<String> getUTCDayStringsBetween(Date startDt, Date endDt) {
if (!startDt.before(endDt)) {
throw new IllegalArgumentException("Start date (" + startDt ... |
Basic Info: This question is my second attempt at this question. It is based on a question similar to this Codility question. The input (an int array), the outpout (an integer) and the method signature (public int solution(int[] A)) are given.
Situation:
A critter starts at (0, 0) on a Cartesian graph. We have a non-e... |
Could you please review my spinlock implementation?
class spinlock {
private:
static const std::thread::id lock_is_free;
std::atomic<std::thread::id> lock_owner;
int lock_count;
public:
spinlock() : lock_owner(lock_is_free), lock_count(0) {
}
void lock() {
static thread_local std::thre... |
The data are organised as long format data. 4 individuals are observed during 4 or 5 days (BCSID is the name of the unique key). Basically, the data describe activities performed during these 4-5 days. START describe the start time of activities and MAINACT the activities.
The data:
data = structure(list(BCSID = c("B10... |
I have a list of tuples or a NumPy array (it can be either of them as the variable comes as a list and will end up being a NumPy array) and I want to order them in a specific way (that I am not able to phrase it).
Let's make an example:
boundary=[(1, 2), (1, 3), (3, 4), (2, 4)];
Desired output:
[(1, 2), (2, 4), (4,... |
This is real JavaScript/Lodash code used in a project I'm currently working on, but actually this particular question bothers me quite often regardless of the language. Say, I need to generate some data relying on some filtered out piece of other date.
Here are three approaches:
// filtering out, then just map
var acti... |
I recently implemented a dynamic voting protocol for a replicated filesystem. I would really appreciate it if you can review the design and some choices made with regards to sharing of Locks & shared objects.
The code is quite big hence I'm not going to post it all here. It was for a school project (already graded).
I... |
For the first time ever, I'm integrating an MVC website to an ASP.NET Web API 2 web service (both of which are coded by myself).
I'd appreciate it if you can just look this over for me and let me know if I'm on the right track here as far as the integration goes.
I'm working based on this tutorial but I had a little tr... |
I'm at a loss as to how I could optimize this bit of code. I realize I could place these objects into some sort of array, but I'm not sure how to go about this.
$(document).ready(function () {
var $stripe01 = $('.stripe-01');
var $stripe02 = $('.stripe-02');
var $stripe03 = $('.stripe-03');
var $stripe0... |
I wanted to be able to tokenize a few different containers so I created a generic way to do it. I originally wrote this in Visual Studio 2012, but I had to modify it to get it to compile on Ideone.
Here is a brief description of my tokenizer functions:
Tokenize (): Tokenizes a container based on a single delimiter.
Tok... |
I was asked before an interview to create a console application that will work out the score of a word for the board game scrabble. It worked fine but the feedback I received said:
"there were no comments at all, some strange logic and uses exceptions to handle bad input.
In summary the Developers reviewing this felt t... |
I want to understand Haskell better by trying to stretch possibilities of Functor, Applicative, and Monad as much as possible and study how they behave. So in Learn You a Haskell there's an exercise to generate all possible moves for a knight from a given position on chessboard:
moveKnight :: KnightPos -> [KnightPos] ... |
I'm writing a PCL that uses an HttpClient to go visit a few sites and extract data from them. My initial code looked like this:
public static class Download
{
public async static Task<byte[]> FromYouTubeAsync(string videoUri)
{
using (var client = new HttpClient())
{
string source = ... |
I am able to send requests to the web service using javax.xml.soap.*. I would like to convert the code to use webServiceTemplate.
I am struggling with creating request and result objects. (sample I've found is related to xml not SOAP)
I am also wondering whether there are advantages to using
webServiceTemplate over... |
After studying and considering the reviews for this code, I began working on the code, and came up with this. It has much better error and disconnect detection, and it also resolves addresses:
#include <arpa/inet.h>
#include <error.h>
#include <fcntl.h>
#include <netdb.h>
#include <signal.h>
#include <stdlib.h>
#includ... |
Audiobooks make my life easier when I have idle ears and a mind free to wander, but something better for my eyes to do.
This program is one of my more recent efforts to allow most of the stories written on popular websites to be transformed into a more accessible audio format so that they can be enjoyed without having ... |
I have a jQuery code that helps me to scroll to specific sections on mouse scroll. To handle mouse scroll events I am using the jQuery mousewheel plugin.
function goTo(location) {
$('html,body').animate({
scrollTop: $(location).offset().top
}, 'slow');
};
//Mous... |
I am new to repository pattern. If I want to join two tables, where should I implement the logic? I have implemented it as shown below. Is there any better way to achieve the same?
This is my UserRepository class:
public class UserRepository : Repository<UserMaster>, IUserRepository
{
public UserRepository(DbContex... |
I have a FIFO queue of packets, which maintains:
Push index
Pop index
Count
I would like to assert my dequeuing algorithm:
if (push_index >= (count-i))
pop_index = push_index-(count-i);
else
pop_index = MAX_NUM_OF_PACKETS+push_index-(count-i);
Here is the code that I have used in order to test it:
#include <... |
The javascript method Math.random() returns a (pseudo-)random float between 0 (inclusive) and 1 (exclusive).
In some use cases, I need both limits to be excluded, a random float between 0 (exclusive) and 1 (exclusive).
This is what I currently use to generate said random float:
do {
var random = Math.random();
} wh... |
Have I over-ridden GetHashCode properly in the below code?
public class ODPair
{
#region Constructors and Destructors
public ODPair(string origin, string destination)
{
if (string.IsNullOrEmpty(origin))
{
throw new ArgumentNullException(origin, "Origin of an ODPair should be non... |
I've created a program where the user is, at first, presented with a window with a yellow circle (random size, random coordinates) and a Start button. Once the user presses Start, the circle, when hovered over, will turn red in color and when it is clicked, another circle (random size, random coordinates) will be gener... |
I have implemented the gossip algorithm in distributed systems for review.
Gossip class
import random
import socket
from threading import Thread
import time
class GossipNode:
# hold infected nodes
infected_nodes = []
# initialization method.
# pass the port of the node and the ports of the nodes conn... |
I'm currently learning Clojure to try to get a good understanding of functionnal programming, so I wrote this brainfuck interpreter that takes a filename on the command line. I tried to make it as correct as I could, but I'm sure there are many things that would make more sense that I didn't think about, or bugs (altho... |
I've been recently working on a custom rational number implementation. Due to not very interesting reasons, using this implementation is not an option.
I'd appreciate comments of anyone who has the time to review the code. The posted code is free to use, so you can make good use of it should you want/need to.
The imple... |
It first creates a server and waits to connect. Once the client connects to the server he gets the line. If he puts the correct code he gets output -> good job. If not -> the software disconnects.
My question is whether there is some sort of security hole in the software that allows you to know (as a client) the passwo... |
I have created a php contact form and have tried to make it relatively secure. I've added a honeypot field that should be left blank, code to ensure all required fields are filled out and code to prevent email injection. I realise there are endless ways to tighten up on security but I am trying to keep this script ligh... |
I'm planning on taking on this community challenge. However, before my tics get tactical, I'd appreciate some feedback on the simpler implementation.
Screenshots:
Factoring in all the logic/edge conditionals was unexpectedly challenging and leaves me wondering if:
This is done efficiently? Get the feeling that some... |
I have been working for about a week on a calculator in Tkinter, and the result is a very ugly, but functional calculator. Is it possible to clean up the code, and make it more readable?
from Tkinter import *
import tkMessageBox
import sys
import os
import math
main = Tk()
string = []
x = 'add'
def exit():
sys.... |
I recently wrote a chat bot for a chat room here at Code Review. The chatroom is meant to be a place where people can come and pimp a post.
That chat bot is meant to handle a list of subscribed people and a list of pimped IDs.
People on the subscribed list can pimp posts and will get notified when someone else pimps ... |
I have just finished up making an object Depth Management system that I will be using for drawing and explicitly drawing. Because we all know that the order in which things are drawn heavily effects the way the game will look.
My system has a very simple and easy to follow code, and the only problems I have found are t... |
I have a very simple view that handles touch events and draws accordingly. It's nothing significant, but it does use a bit more CPU than I would like (35%). Again, it is the bare minimum (<90 lines), but I can't really think of a simpler way to draw using user input. What would you change?
import UIKit
class DrawView:... |
I have an array with the following structure
Array
(
[0] => Array
(
[area] => Area ABC
[activity] => Array
(
[0] => Activity 1
[1] => Activity 2
)
)
)
I'm trying to render this array in the fol... |
I've been working on this for the last few days. Any improvement ideas? (Notes are very simple, making this for school and notes have to be for complete novices to Python).
import random # Allows the computer to generate random numbers, vital for the program to function correctly.
import sys # Al... |
In preparation for the end of Code Review's 2015 election, I've built a simple bot to get the election votes, run OpenSTV on them, and post the result to a chatroom. I'm using this Python implementation of STV and ManishEarth's ChatExchange.
import getpass
import logging
import os
import time
import urllib
import sys
f... |
I am currently working on an implementation of SoundCloud for a 3rd party iOS app, and as there is no SDK anymore I am doing all my calls via Alamofire.
This is what SC expects you to send in your body params:
{ "playlist":
{"tracks":[
{"id":"__"},
{"id":"__"},
{"id":"__"}]
}
}
I han... |
I know this type of question has been asked before. However, my reason for asking it is gaining insight into what is expected in a 45 min interview when asked to implement graph algorithms. I have never had to give an interview, but have been asked in several interviews, questions pertaining to graphs. Specifically adj... |
This code works as intended, however, I am sure that there is a way to condense the xmldataLoad method. If someone could maybe explain a better approach than what I have done with the method, I would be extremely grateful.
Essentially, what I am saying is I am rather new to using LINQ and don't fully understand the var... |
Mac doesn't have the Unix clock_gettime so I am trying to create something that's really portable and only dependent on C.
So far I've come across this function:
static void current_utc_time(struct timespec *ts) {
#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
clock_serv_t cclock;
mach_... |
I've implement a custom dropdown, that help to find users from data. Each item have a userpic, first name and last name. And my task is create a dropdown with settings like use picture or not. I coded it in create function, in a loop with if-statement: if (is_use_picture) { /* ... */ }. It would be great if I could get... |
This is the HackerRank problem Algorithmic Crush:
You are given a list of size N, initialized with zeroes. You have to perform M operations on the list and output the maximum of final values of all the N elements in the list. For every operation, you are given three integers a, b and k. The value k needs to be added t... |
I wrote a little function that monitors some directories. If a file gets created, it will check in the extension list for a match. Can you please tell me if I could make my function better in any way?
private void sysWatcher_Created(object sender, FileSystemEventArgs e) {
try {
if (File.Exists(e.FullPath)... |
I am new to PHP and was just wondering if there is a better way to write the following OR if it would make any difference to use elseif here instead of multiple if statements - especially if the options in questions might be more than in the example here (the current code is working).
Note: I cannot use switch here si... |
I'm completely new to Groovy, but have many years of Java experience, and recently I have started working on a Grails application, currently it contains the following:
User and Person domain classes
UserService service class
UserController controller class to offer a REST API
This application is written using Groovy ... |
I have the following code blocks that generate apparently random numbers by using thread timing variations.
I am looking for a general code review, and a specific focus on whether the results are "true random numbers".
For computers with more than two CPUs
#include<chrono>
#include<iostream>
#include<thread>
using name... |
I wanted to create a simple and easy to use permissions system. The ones I've found on the Internet would need to attach every permission to a route manually (e.g. Entrust).
My idea is to build a permission name out of the current action, so for example method 'store' in 'TestController' becomes 'test.store' permission... |
I need to concatenate 3 input fields into a string which is formatted as a date dd-mm-yyyy, using type="date" or new Date() will not work in my scenario because Firebase doesn't allow it for some reason. I came up with a rather ugly solution, but I'm not quite sure how to improve it. delete is bad for performance, but ... |
I've made the following python script to to append the contents of the latest Stackage nightly build to the global cabal config file (instead of going to the site, copying the page and appending it manually...). I would appreciate your feedback:
"""
Appends the latest stackage nightly sources from Stackage(http://www.s... |
I have built an RC car and attached a Raspberry Pi to it - in order to control it, I wrote some Java code to listen to commands over the network and make the car move accordingly.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class... |
Instructions:
Write a Java program the displays the State bird and flower. You should use your IDE for this exercise. The program should prompt the user to enter a state and print both the state bird and flower. The user should be able to enter a State without worrying about case. (e.g. Users could enter Maryland, mar... |
I've been inspired by @SirPython's SirAlfred JavaScript chat bot, so I went and made my own. This one is slightly different though, in the fact that it can accept input in a more lenient way. For example, here's a "conversation" with the bot:
sudo make me a sandwich bot
BOT: It will be done master.
sudo make me a sand... |
In JavaScript, I wrote a class that can be optionally instantiated with the new keyword, but can also be called statically as well. What is the best way to demonstrate this behavior in comment syntax? I was thinking something like this:
// localize constant
var PI = Math.PI;
/**
* Complex constructor
* optionally in... |
Most of what I'm writing is pretty quick and dirty as I'm crashing through a lot of stuff to learn. My variable/function/class names are most likely not efficient and I still need to get a lot of the PEP8 formatting down.
That said, I put a quick Tic Tac Toe game together in Python. I'm going to add some decision logic... |
The following C++ code is a lightweight implementation of in-close algorithm. Full details of the project can be found here.
I was trying to translate the C++ code to C# but it's very difficult to manage. That new version simply doesn't work due to pointer implementation. In fact, I need to keep using pointers because ... |
I'd like to have some feedback on this sieve of erasthotones that I've wrote. It outputs all prime numbers up to n correctly (I've tested with the first 10k prime numbers).
Is this well written? Does it look good for python programmers?
I've made the math up to the sqrt of n + 1, which improved the performance a lot.
i... |
I am preparing for interviews, and have implemented a solution to this problem from Geeks for Geeks:
Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given sum.
I don't fully have my head wrapped around the dynamic programming approach. If I pro... |
I have been through a few SQLite tutorials and wrote this code on my own to reinforce the principles. The tutorials I went through varied widely in a few areas so this is what I came up with as a combination of everything.
Other than the two classes I have listed below, all I have is one activity that adds, remove, in... |
I'm pretty new to C# and was just wondering if there is a better way I can write this calculator that I made:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AnthonyCalculator
{
... |
This is a simple example of script to run the test write/read performance of third party software of the drive in Windows environment.
Please let me know if you find any place can be better improved, thanks.
#! /usr/bin/env python
import sys, os
import PCMark
import PCMTest
from decimal import Decimal
import re
impor... |
After the advise from this code review I have come up with the following changes. I'll go in the same order as my previous post. This post is mainly for an updated version so that others can see the previous posts suggestions. If I have made any mistakes please let me know.
ObjectPoolManager.cs:
public class ObjectPool... |
I implemented a Sudoku validation program.
Can this be optimized even further in terms of performance?
public class ValidSudoku {
public boolean verifySudoku(int arr[][], int num, int i, int j, int row, int col) {
return (verifyRow(arr, num, i, j, col)
&& verifyCol(arr, num, i, j, row)
... |
Whenever using ArrayList, the method containsAll(collection) runs in time \$\mathcal{O}(mn)\$, where \$n\$ is the size of ArrayList and \$m\$ is the length of collection. However, it relies only on equals(Object)-method.
I have this subclass of ArrayList that does the same in time \$\mathcal{O}(n)\$, but relies on hash... |
I am making a small 2D game with the use of Allegro 5 library. I am making use of inheritance e.g. sprite class as the base class and player class as the child class, but I want to know if it's a good idea to approach it in this way and other ways that are better to do this, if there are any.
Main.cpp
#include "Allegro... |
The following script draws 6 numbers at random.
I input another 6 numbers and compare with random numbers generated, if they're the same, you win.
<html>
<body>
<form align="center" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
Numele jucatorului <input type="text" name="nume" min=... |
I've recently coded an event manager with performance as the main factor. I'd like to know what you think of it and what could be made better.
public class EventManager {
public static EventManager mouseRightClick = new EventManager(EventType.mouseRightClick), mouseLeftClick = new EventManager(EventType.mouseLeftC... |
I have a written some code which helps me to get OAuth Access Code from Reddit. Reddit uses standard OAuth2, so like any other OAuther server, here's are the steps to perform:
The client/app sends app key, app secret and redirect URL to browser.
User authorizes it and gives permission.
Reddit sends request back, with ... |
For a puzzle I had to brute force a password. I've never used goroutines before, and I don't have much experience in concurrency.
This is the cksum function, which takes an array of the ASCII code for each letter in a string (a is 97, b is 98...etc):
func cksum(bytes []int) int{
a := 0
b := 0
for i := 0; i ... |
The program sorts the array from lowest to highest and outputs the index of the searched value:
public static void main(String[] args) {
Integer[] random = {6, -4, 12, 0, -10};
List<Integer> list = new ArrayList<Integer>(Arrays.asList(random));
Collections.sort(list);
Integer[] array = list.toArray(new... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.