Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
using namespace std
; it forces that style on users who don't want it.std::linear_congruential_engine
here is overengineered; with this config, it generates a linear sequence with a step of 3 starting from 1 (exclusively). Every single test run would generate the sequence (4, 4+3, 4+3+3, ...) without fail. This is also not randomb
are froma
. This doesn't test how the user's solution handles values inb
that are not ina
. Also, this means thatb
preserves the order ofa
which reduces the randomness further.std::linear_congruential_engine
, the need for explicitmove
s, the magic numbers (like LN/4) and the reaally long function, I really feel like some parts can be refactored, some removed, and some restructured to make the random testing strategy more readable.never thought I would see asm here
what in the absolute code is this
Please use spoiler flag next time. Because you did integer division there. That's how Ruby's division work.
This comment is hidden because it contains spoiler information about the solution
devagya, please use spoiler flag next time.
It can be, but plenty of compilers will optimize a divide-by-two into a shift anyway. (Specifically any divide-by-power-of-two can be turned into a single shift)
Yes, bit operating is faster
This comment is hidden because it contains spoiler information about the solution
As guriyeller correctly observes, for all numbers greater than 1, multiplying will give the maximum result. So I special-cased where numbers are equal to 1, because then it's better to add them to another multiplier. For
a
andc
that can only be tob
, forb
it depends on whethera<c
or not;(a+1)c==ac+c
anda(c+1)==ac+a
. I made use of invariants throughout the various steps to arrive at a compact final expression, carefully avoiding overwriting values. All paths that add to variables make sure the correct variables are still 1 to not affect the result.i love your solution, you must be an Obfuscated C code contestant ;-)
Fixed
i was very surprised how few C solutions actually used #include <regex.h>
given that it is tagged as a regex kata.
There's compilation warnings in the test code (fixture.c).
you inspired my insanity ;)
Loading more items...