Skip to main content
5 votes
Accepted

Tower of Hanoi in Racket

Regarding Style It would probably be more idiomatic to use a named let form in place of the internal define form for ...
ad absurdum's user avatar
4 votes
Accepted

Is this OR procedure correct?

or-l Is a Poor Name The OP procedure or-l is correct in that it yields correct results for its inputs. This ...
ad absurdum's user avatar
3 votes

Tower of Hanoi in Racket

The code looks fine, though I'd suggest to follow the usual Lisp style and not having dangling parentheses around: ...
ferada's user avatar
  • 11.4k
3 votes
Accepted

Brute-force algorithm to solve allocation/assignment in Racket

Here's my re-implementation of the Python code: ...
Shawn's user avatar
  • 431
3 votes

Implementations of unzip in Racket

The apply+foldl approach in WorBlux's answer can be simplified by using the split-at-right ...
Shawn's user avatar
  • 431
3 votes
Accepted

Implementations of unzip in Racket

Doing it with folds pretty much begs you to create a custom accumulator and recursive function or fold within a fold like that. A couple notes. I don't think foldr...
WorBlux's user avatar
  • 521
3 votes
Accepted

Binary search tree insertion in Racket

As you suspected, you don't need append for this problem. The trick is to notice that if, for example, your goal is to create the list ...
assefamaru's user avatar
2 votes

Permutation-stream based n-queens solution

Variable Names There is little reason not to give the variables clear meaningful names. Using abbreviations leads to using bd in ...
ben rudgers's user avatar
  • 2,713
2 votes
Accepted

Recamán's Sequence in Racket

This code is not exactly linear as member is a o(n) time function and grown in proportion to curr-seq, making the whole ...
WorBlux's user avatar
  • 521
2 votes

Wide-stripes function in Racket

To answer that first, you don't need anything complicated, just observe that the pattern is binary, on and off, and compare that with how odd and even numbers are following the same pattern, then ...
ferada's user avatar
  • 11.4k
1 vote

Why is this racket n queens code so inefficient?

Probably not. C++ is known for its raw performance. It can work with data that is close to the machine's underlying representation, and easily compiles down fairly directly to machine code. Not ...
JDługosz's user avatar
  • 11.7k
1 vote
Accepted

Racket code to find missing ranges

Your solution seems to me quite complex, with iterations, recursions, and the use of match. Here is an alternative version with a simple linear recursion, where the ...
Renzo's user avatar
  • 2,095
1 vote
Accepted

Stack calculator in Racket

Bug The - and / operators interpret their operands backwards from the typical RPN order. That is, I expect ...
200_success's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible