This is essentially a bucket sort, right? So it fails if the input doesn't fall in the range of the hash table size? Can that happen? — Jakob6 mins ago
Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a distribution sort, and is a cousin of radix sort in the most to least significant digit flavour. Bucket sort is a generalization of pigeonhole sort. Bucket sort can be implemented with comparisons and therefore can also be considered a comparison sort algorithm. The computational complexity estimates involve the number of...
@totallyhuman You answer didn't work because sets are not inherently ordered. The order you see when they output is based on a number of complex factors. I could explain if you would like.
Given the written, spelled-out representation of an integer from 1 to 10^15-1 inclusive, convert it to an actual integer in decimal.
Input Format
The input will always be a string of groups, where each group is composed only of letters and spaces(). The groups are separated by commas.
You may...
void f(char*s){char c,i=0,j=0;while(c=*(s++)){putchar(c);if(c==' ')++i;if((j<4&&i==7)||(j>=4&&i==6)){i=0;++j;putchar('\n');}}} is the code I need to save output to a char*
Can I Settle Down?
In The Settlers of Catan board game, there are five resource types: Brick, Log, Ore, Wheat, and Sheep. Building a settlement costs a Brick, a Log, a Wheat, and a Sheep. However, you can also trade in four identical resources to get a resource of a different type. For instance,...
I have an assignment in which I have to do the above with anyone language I would like. (background in java) I am trying to learn python and thought this wouldn't be too hard to implement. I just want pointers on how to structure this as I'm not sure of effective ways of coding in python. My idea...
@ASCII-only I have my program. Everything works but the newlines are supposed to be added but they are never added. Even though the code section that has the newlines being added is run.
toString[num]='\n' is not working but toString[num]=c does
in C
i want to redirect the output of a process from stdout to write to a "shared memory segment" which can be thought of as a char array or a string with a pointer
i know that there is dup2 but it takes file discriptors as argument not a pointer to an array. is there any way to redirect it to a...
Over a month ago, my chat account was suspended for various reasons, most of which being that I was not thinking things through and annoying other chat users. According to the mods, the final touch was when I posted a rickroll link.
I've thought things over for a while and I believe that I can r...
Of course, int foo[5]; is much easier than int* foo = malloc(sizeof(int)*5); (Or int* foo = (int*)malloc(sizeof(int)*5); in C++98)
But on the flipside for(char* str=foo; char c = *str; str++){} feels just a bit nicer to me than for(int i=0; i<(however you get the size of the array idk im new at c); char c = foo[i++]){}
Keep in mind I'm incredibly baised because I want to see RProgN2 hold the Quine Crown at all costs.
Anonymous
3:08 AM
@ATaco There's a considerable difference between the two. The first is statically allocated on the stack. Yes, it's possible to use an array variable as a pointer to the first element thanks to pointer decay, but arrays are not "just pointers".
Yay malbolge quine just made the quine markdown file like 10x bigger
Anonymous
A significant difference comes from the fact that array elements are guaranteed to be contiguous in memory, so pointer arithmetic within the bounds of the array is defined behavior.
a[b] is equivalent to *(a+b) thanks to pointer decay. Commutativity of addition means that *(b+a) is also equivalent. Since the syntax translation isn't strict, b[a] is also valid.
Would it be interesting to have a challenge to merge a list of (non-conflicting) objects? E.g. [{"Val":1,"demo":{"Greeting":"hello","target":"World"}},{"answer":42,"demo":{"time":"now"}}] gives {"Val":1,"answer":42,"demo":{"Greeting":"hello","target":"World","time":"now"}}
@ASCII-only Halve = cut in 2 equal sized pieces. Double = duplicate/bifurcate/palendromize. All commands could also work on codepoints for strings, but that might be a bit too situational
Increment could be useful on codepoints, but probably never halve/double