last day (15 days later) » 

00:51
1
Q: Dictionary Code Golf

Julian SilvestriNew to code golf and enjoying it. I have a problem that I cannot figure out and am curious if others can solve it. Start with two dictionaries, y and z: y = {'a': 1, 'c': 3, 'e': 5, 'g': 7} z = {'b': 2, 'd': 4, 'f': 6, 'h': 8} y and z both map length-1 strings to numbers, where each number is...

How strict is the input and can you add some test cases? Btw, Welcome to PPCG
I am sorry but can you dumb that down for me :( New here = noob
I mean, can we take the input in a different format than the one you provided? Also It would be great if you add some Input -> Output examples so we can test our submissions and confirm they are correct.
It would be good if you take a look at the help center specifically at the how to ask section. Also for futures challenges I recommend you to use the sandbox to get feedback before posting it into the main site.
Is this a challenge or asking for tips?
I'm a bit confused what you are actually asking.. What would the expected output be for your example input lists y and z?
00:51
Hi and welcome to PPCG! I'm sorry that you are running into some trouble. We know that we are very strict with posts, but I promise it is for a good reason. Currently there are a few things that make this challenge unclear to me: are you asking about one specific situation or are you posing a general challenge? If the former, this should be written as a tips question, if the latter we try to avoid unnecessary language restrictions. In either case, I think adding a sample x will help clear up what you mean to accomplish. Good luck!
I apologize for the poor clarity of my question. I hope my edited answer provides some clarity! Thanks all
That helps, but I'd recommend adding code that accomplishes your task (no matter how poorly golfed) so that we can help improve it. (Your edit made me believe you want a tip - if not feel free to revert my edit)
What happens when a letter greater than m occurs in the input? Or is m the last letter possible?
M is the last letter in the input. Input is strict to be kept the same as shown
@Fryamtheeggman the desired output is a single dictionary 'x' which is composed of dictionaries 'y' and 'z'. ALSO, my intention with this was to get the fewest possible characters to accomplish this as a challenge to others (but also to help me)
Sorry, but with your edit I just got more confused. You say: "Multiply each odd number by 2 and each even number by 3. Each letter in ...." but then on the desired output, all I see is dicts y and z together, no multiplications happened. Correct if I am wrong.
00:51
I have updated edits again... if still unclear I will just take down.. not sure how else to state it lol Its my fault
Rod
Rod
@JulianSilvestri what should be done on overflow -> y={'v':22}, also you state that the x dict should be ordered, but dictionaries don't preserve order
@Rod 'v' should not be present as the input should be kept the same as shown. Also yes you are right that dicts do not maintain order but you can use this. docs.python.org/3/library/….
"Multiply each odd number by 2 and each even number by 3" But you multiply 8 by 3? Am I missing something therE?
@DimChtz 8 is an even number ??
Are these values being dictionaries critically important? The values are essentially directly related to each other one-to-one by mapping the letter to a character code and subtracting an offset. You can see what I mean in this which I've been fiddling with to see if I understand what you are asking for. Is there a reason you can't use a list of just numbers?
00:51
@JulianSilvestri Sorry, my mistake. I messed odd and even meanings..
What exactly is the submission format? Should the submission be a Python snippet which operates on already-existing variables? (otherwise there may be other ways to do the work without actually creating the dict x)
About language-specific challenge: We have reasons against them. For special cases, they should be carefully sandboxed to see how the community reacts. If you want to make this a tips question (question, not challenge), you should post your own (reasonably golfed) code.
@user202729 This is not a challenge, it is a [tips] question.
@mbomb007 the tips tag was added later, and not by the OP. It wasn't entirely clear, although it looked like a tips question.
@mbomb007 It isn't really possible to give tips without a piece of code. From tag info page: "For questions asking for tips on a specific piece of code, to make it a better answer to a programming challenge that is on-topic on this site."
I removed the [tips] tag, but still voting to close as unclear.
00:51
I'm pretty sure that you can't have a dictionary in a particular order, as Rod has stated above, it's unclear what you mean. Maybe collections.OrderedDict (not represented by dict's syntactic sugar)?

last day (15 days later) »