On a somewhat related note, I just ate a really good sandwich. Good but it made a huge mess all over me, my kitchen, and the table. It was a struggle that ultimately ended with the sandwich's defeat and subsequent consumption.
(there was no peanut butter)
Most of the people come here to talk about code golf. I come here to make smart-ass comments and talk about sandwiches.
I definitely support conversations about a good sandwich. I just had Spangles' peanut butter and jelly steakburger with bacon and jalapenos, so these things have been on my mind. (By the way, they put chunky peanut butter on it, the way God intended)
@Geobits Granted, butter and peanut butter serve two different purposes. Outside of the state of Iowa, I don't think too many people eat butter sandwiches.
Shortest Cut and Paste Sort
Given a string containing a random sequence of unique characters A to Z (all upper case, no duplicates), determine the fastest method of a "cut-and-paste" sort and output the
sort sequence to a specific format (detailed below).
Definition of Cut-And-Paste Sort, by ...
I can't find out what is wrong with my program; I need to find the 10,001th prime number. I'm relatively new to Java, so help is appreciated:
public class Problem7 {
public static void main(String args[]){
int[] Primes = new int[10001];
for(int i = 0; i < 150000; i++){
int count ...
LindenMASM
LindenMASM is an Assembly-like programming language which can be used to generate images from Lindenmayer systems. Lindenmayer systems are very interesting in the fact that they can provide a rudimentary method of generating fractals, such as a Sierpinski triangle. They are also inter...
Consider a string of length N, such as Peanut Butter with N = 13. Notice that there are N-1 pairs of neighboring characters in the string. For Peanut Butter, the first of the 12 pairs is Pe, the second is ea, the last is er.
When the pairs are mostly different characters, the string has a chunky...
+--+ +--+
| | | | +--+ +--+
| | | | | | | |
+--+ +--+ +--+ +--+
The people of ASCIIville are rebuilding their city and are sketching out new blueprints. Your job is to draw their new city based on how many buildings they want.
The input will be how many buildings there are. Each buildin...
Lossy ASCII art compression
code-challenge ascii-art printable-ascii compression overhanded
Background
This is the creepiest fractal I know (and also one of my favorites):
Using PICASCII, I've converted this picture to ASCII art and, with the correct font, this is the result:
See for you...
@Dennis Only one kind of peanut butter? That's such a foreign concept to me. Are you in the US? You're not missing anything with Jif though, it only loosely qualifies as peanut butter since it's mostly corn syrup.
@AlexA. Which is precisely why I can't eat it. I live in South America. Peanut butter isn't very popular here. Myself not included, I don't know anyone who eats it.
Even my wife, who likes to put crushed peanuts in her coffee, doesn't eat peanut butter.
It can be in any language, plus the map must be in the output only not in the source code.
This is my first question here, so please feel free to edit it. Also, there might be some rules about scoreboard which I'm not familiar how to put it here.
Cheers!
This is a challenge of practicing golf optimization in Python -- reusable tricks and shortcuts to shave off a few characters. Many will be familiar to Python golfers and use common ideas from the Python Tips. Some of these use Python-specific features that you might not know exist unless you've s...
Well on Android I wouldn't think twice about using an Asynctask for that case. I believe Future is going to be your closest comparison to that. But like I said, I'm not an expert on desktopy Java concurrency.
Thus my confusion. There are no stats comparing my user case (o anything related ot that). But Disruptor is the best thread communicator there is . Faster than Blocking Queues
The small bit I've learned about Disruptor in the last few minutes of reading tells me that it should work just fine, but is probably overkill where a simple queue would work. Unless you find that you're actually having a bottleneck on the communication.
if 4 thread enter that if condition with queue.size > some_number, they will all call an asyncTask flushQueue which flushes the queue and makes its size 0. So out of the 4, 1 will do that, flush all the data from the queue, but other 3 will uselessly flush an almost empty queue.
If you're just synchronizing on the condition, then you could use a flag instead of a bare conditional. Flag it as flush needed for one thread, and clear the flag when the queue is flushed? Not very elegant...
That way you're not synchronizing flushQueue() itself.
Let's call ABC a triangle which has every side as an integer.
Every ABC that has at least 1 median (https://en.wikipedia.org/wiki/Median_(geometry)) that is also an integer will be considered a valid triangle (they are all unique, so <6,6,5> = <5,6,6>, for example).
T(N) represents the number of...
LindenMASM
LindenMASM is an Assembly-like programming language which can be used to generate images from Lindenmayer systems. Lindenmayer systems are very interesting in the fact that they can provide a rudimentary method of generating fractals, such as a Sierpinski triangle. They are also inter...
Translate Treehugger to BrainF**k
code-challenge (?)
Overview
This problem deals with two esoteric programming languages that I will briefly describe for completeness.
Brainfuck is a language that has only 8 commands. Imagine a tape of values (generally 0-255) stretching infinitely to the rig...
I'm thinking of starting answering questions in XSLT, but I don't know what the standard method of input would be?
I'm thinking of an XML file like so:
<?xml version="1.0" encoding="ISO-8859-1"?>
<input>Put your input here</input>
And then you access the input by using the following code:
<...
> Some say the toast will end up chunky, Some say up smooth. From what I’ve tasted of peanut butter I hold with those who favor chunky. But if I had another slice, I think I know enough of taste To say that for distraction smooth Is also great And would suffice.
@randomra I will probably have 4-5 smallish snippets of code. They won't be particularly advanced. Things like adding two numbers, repeating input backwards, or simple patterns. I do intend to make full use of the binary tree, wherever it applies. I will likely use several completely unnecessary operations traversing the tree to throw more naive approaches off.
This is Weekly Challenge #2. Theme: Translation
Write a program or function that takes in source code for a program in Prelude and outputs code for an equivalent program in Befunge-93. For the program to be equivalent, it should, for any given input, produce the same output as the Prelude progra...
Print the Biggest Number
code-challenge
Challenge
Well, the challenge is what it says what it says on the tin: write a program which outputs the longest number it can.
This is not an opportunity to screw around with the rules however, and you must output the number as a number and not in alge...
Yeah, I'm trying to think of ways to make it a bit easier. It's not a full translation, since there is a known finite number of inputs on each test. My approach was to find the deepest that the program would ever go in TH, and put each possible node accessed into an array, BF style.
@randomra I think there's a clever way to do it... Alternatively, I could limit it such that it is guaranteed that only printable ASCII are given as input to the TH. Or even better, only digits 0-9.
@BrainSteel My first impression tells me it's probably doable by enumerating the cells like you would a priority queue/heap. Then going down a branch is either 2n or 2n+1, going up a branch is n/2. You'd have to keep checking a specific cell to know where to go next. My only problem though is where it's possible to translate a number n in a cell to doing > n times
Each TH cell would probably have to map to a group of at least 2 BF cells, so that you can also make the return trip back to the "pointer" cell (pointer cell probably needs to be near a few temp cells for arithmetic too)
shrugs not sure if I'm making any sense, but it seems feasible in my head (but then again everything does until the bugs come knocking)
Lossy ASCII art compression
code-challenge ascii-art printable-ascii compression overhanded
Background
This is the creepiest fractal I know (and also one of my favorites):
Using PICASCII, I've converted this picture to ASCII art and, with the correct font, this is the result:
See for you...
1300 years ago, the English theologian Bede earned the honorific by which he is now known ("The Venerable Bede") by, among other things, convincingly computing the date of Easter for a number of years. This required reconciling the old, Jewish, lunar calendar with the newer solar one, a task made...
Minimal character set
Choose a language and find a minimal set of characters that you can use to write any program in that language. Then provide either a conversion program (preferred) or a proof that any program can be converted to use that character set.
Related python question; related javs...
This program is supposed to determine how many days someone has lived. There is a test that checks some functions to see if they compute the right answer. My program gets the right answer for the first and fifth test but is just a day off for the other three. ie 59 instead of 60.
def leap_year(x...
@randomra I want to get the minimal set (so smaller character set should be better for the same language), but at the same time, I don't want unary to win automatically