Ad
  • Custom User Avatar

    Took me 30 mins i just did this for fun

  • Custom User Avatar
  • Custom User Avatar

    ok, well i can just be a bit lazier.
    exec(__import__("marshal").loads(__import__("codecs").decode("63000000000000000000000000000000000200000040000000730c00000065006400830101006401530029027a476f72206a757374206265206c617a69657220616e6420637265617465206d79206f776e2070726f6772616d207468617420646f65732062797465636f646528696d206c617a79294e2901da057072696e74a90072010000007201000000fa083c737472696e673eda083c6d6f64756c653e0100000073020000000c01","hex")))

    p.s. this is for logging to console

  • Custom User Avatar

    sth i made on my own (i dont think ill reveal it? if youre interested u can read up here and try to implement one yourself, or perform it by hand)

  • Custom User Avatar

    what program

  • Custom User Avatar

    Thanks, edited the description to more precisely indicate what would happen when shooting with less than 20 energy

  • Custom User Avatar
  • Custom User Avatar

    yes i used a program to convert it (i wrote the program myself tho)

    heres the original code

    import string;ceasar=lambda s,n: "".join([c for c in map(lambda c: (string.ascii_lowercase[n:] + string.ascii_lowercase[:n])[ord(c)-97] if c in (string.ascii_lowercase[n:] + string.ascii_lowercase[:n]) or c in (string.ascii_uppercase[n:] + string.ascii_uppercase[:n]) and c.islower() else (string.ascii_uppercase[n:] + string.ascii_uppercase[:n])[ord(c)-65] if c in (string.ascii_lowercase[n:] + string.ascii_lowercase[:n]) or c in (string.ascii_uppercase[n:] + string.ascii_uppercase[:n]) and c.isupper() else c, s)])
    
  • Custom User Avatar

    Althought the params would've no meaning if not used (static names copied from the original solution), it makes sense to give more emphasis on the part of the description talking about this =)
    Dunno about the spoiler mark, it's kinda of borderline ^^,

  • Custom User Avatar

    I checked your solution. Doing many floating point divisions in loop accumulates rounding error too quick. This can be easily worked around, for example, by accumulating divisor and not changing actual variable, but working with variable/divisor instead. This would be enough in this kata.

    Also, there is a math function that can be used to count digits or groups of 3 digits in the integer part of the number, which can be used instead of counting in loop (which is not necessary in this kata though).

  • Custom User Avatar

    For authoring kata, I've found that Codewars' Discord channel #kata-ideas is helpful, too. People on there can help you refine an idea or point out what's already been done.

    Yes, I definitely enjoy the logical aspect. I'm a retired teacher (of German and coding) and only do a little paid coding work and volunteer tutoring (in coding) at this point. Most of my students have been beginners, so it was usually important to help them understand the nature of the problem before diving into the coding. A few of them went on to work in the software field, which was pretty satisfying to me.

  • Custom User Avatar

    Thanks for your kind comments. I tend to break these things down into small steps and then handle those one after the other in a way that is manageable and understandable for me (and maybe the beginner students I used to teach). In many of my Codewars solutions, I could save a lot of lines of code by importing libraries to take advantage of the methods they provide, and by chaining methods to accomplish more than one thing at a time, etc. I noticed in your own solution, for example, that you used a multiple assignment from the input to get the car brand, engine type, and firing order all at once. That's one line of code that I took five lines to accomplish -- not necessarily a smart move on my part or something to emulate :-) But it makes sense to me.

    The funny thing is, I write project code somewhat differently. There I use a lot of libraries and tend to take advantage of the more advanced features of a language more than I do on Codewars. Not sure why the difference! Maybe because I wanted my inexperienced students to look at my Codewars solutions and be able to understand them more quickly.

    I hope we'll see more kata authored by you. I like the ideas you've had so far!

  • Custom User Avatar

    Thanks. I don't exactly write the shortest code :-) but I do try to organize and comment it so that I can figure it out again when I come back to it later!