Show newer

@Absinthe

Ok i think i got it, so one word across all the products and then some new word that would produce a consistent discount of the same percentage across all products. I'll consider it when i have the mental capacity in a bit, but I think I get the idea.

@serra

@Absinthe

Would a single master word be selected as the key and then applied to all the products in the store. Or is the word unique to each item? Is the word just arbitrarily chosen?

Also is the word always exactly 10 letters long then?

@serra

@Gargron Anything I or the rest of us could do to cheer you up? Would you like a video of my friends cat talking to her I just saw, I know you like cats, might cheer you up?

@Absinthe
Ok then I'm still confused how exactly you are encoding the information into the sku
@serra

@snder

He probably isnt using a database abstraction layer. Usually if you do then you can switch to any database under the sun with little issue and more or less the same feature set.

I think pizxelfed is written in PHP which is notorious among its programmers (not saying this is the case with pizelfed) to just skip the abstraction layer all together and code raw SQL. Presuming that is the case this is usually the result, support for just one database and if any other databases are supported the feature set can often lag if it works at all.

@dansup

@snder You can do the migration issue is there is more than one way to convert some things that might exist in postgresql and some things youd have to convert by hand (like ant PL/SQL). So in practice it likely wont be trivial.

@snder convert what exactly? The database content itself or the SQL queries that create and use the data?

@Absinthe
I'm not entirely sure I understand the original problem... An item would have a name then a encoded code and the encoded code along with the name can be used to decide some pricing info. Is that it? But what if the name has fewer than 10 letters. Since there isn't a letter for every number how is that handled?
@serra

@khird

Good catch, elm isnt one of the languages i mess with so i didnt run it myself and only got a vague idea of what is going on.

@billstclair @Absinthe

@Absinthe @freemo

My Elm solution. Change the input sequence of numbers from 1 to 9, and the count plus all the possible decodings will be output instantly.

https://ellie-app.com/6Q5BTjx8CGta1

#toyprogrammingchallenge

@Absinthe
For me it was the most fun way to interpret the problem. Really enjoyed this one.

@masterofthetiger@theres.life This poll isnt even a little biased :)

Octave solution 

@khird

This is the best solution IMO for count-only (technically what the question asked).

@Absinthe

@billstclair @Absinthe Time-complexity has nothing to do with raw-speed. If you do the brute force solution and actually list all solutions with a copy approach (the absolute simplest least efficient way) then your dealing with exponential space complexity. Good luck computing large datasets on even the beefiest of machines where a linear solution would attack it with ease.

Octave solution 

@Absinthe

Linear in time and space by taking advantage of the Fibonacci numbers.

function count = interpretations(string)
ambig = string(1:end-1) == '1' | (string(1:end-1) == '2' & string(2:end) <= '6');
ambig &= string(1:end-1) ~= '0' & string(2:end) ~= '0' & [string(3:end) '1'] ~= '0';
ambig = [false ambig false];
consec = find(ambig(1:end-1) & !ambig(2:end)) - find(!ambig(1:end-1) & ambig(2:end));

fibo = zeros(max(consec), 1);
fibo(1:2) = [2 3];
for i = 3:max(consec)
fibo(i) = fibo(i - 1) + fibo(i - 2); end;
count = prod(arrayfun(@(x)fibo(x), consec)); end;

Show older
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.