• Sign Up
    Time to claim your honor
  • Training
  • Practice
    Complete challenging Kata to earn honor and ranks. Re-train to hone technique
  • Freestyle Sparring
    Take turns remixing and refactoring others code through Kumite
  • Community
  • Leaderboards
    Achieve honor and move up the global leaderboards
  • Chat
    Join our Discord server and chat with your fellow code warriors
  • Discussions
    View our Github Discussions board to discuss general Codewars topics
  • About
  • Docs
    Learn about all of the different aspects of Codewars
  • Blog
    Read the latest news from Codewars and the community
  • Log In
  • Sign Up
mdsmithson Avatar
Name:Matthew Smithson
Clan:Unknown
Skills:rust, elixir, f#, js, sql
Member Since:Mar 2016
Last Seen:Feb 2024
Profiles:
Following:6
Followers:6
Allies:6
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations (25)
  • Replies
  • Authored
  • Needs Resolution
  • Custom User Avatar
    • Efesto
    • commented on "Pyramid Array" elixir solution
    • 5 years ago

    You could replace def pyramid(n) when n == 0, do: [] with def pyramid(0), do: []

  • Custom User Avatar
    • Haksell
    • commented on "Is n divisible by x and y?" cpp solution
    • 5 years ago

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
    • mdsmithson
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    Forked this to avoid potential redundancy of repeated tests.

    defp rand_int(), do: 2..80 |> Enum.filter(fn x -> x not in [4,7,15,25] end) |> Enum.random

    As 4,7,15,25 are already tested in the prior tests.

  • Custom User Avatar
    • docgunthrop
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    @Steffan153, whoops, you're right. PascalCase is what I meant 🙃

  • Custom User Avatar
    • user8436785
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    camel case is camelCase, that's PascalCase.

  • Custom User Avatar
    • docgunthrop
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    One other thing -- Elixir naming convention for modules is CamelCase. I forgot to change it here, but it's not a big deal as it doesn't have any effect on the kata.

  • Custom User Avatar
    • docgunthrop
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    I forked your translation here: https://www.codewars.com/kumite/5db25e422f349c0015b154ca?sel=5dc70c502c135e0016bf8b75

    Some changes and recommendations:

    • the function name should be consistent with the original kata. I changed it from start to create_spiral
    • the functions that don't need to be accessed in your solution module can be set as private functions (ie. defp instead of def)
    • don't expose spoiler code by putting it in the preloaded section; here I moved the reference solution and put it in the test module instead.
    • you can group individual fixed tests within a single describe block
    • the final test suite should include both fixed and random tests; I added the fixed tests back in there
    • avoid unnecessary repetition: instead of writing the same test block for random testing 20 times, use a "loop" instead

    One other change I made was to the random number generator; changed it from selecting from the range 0..100 to 2..80. This is because 0 and 1 are already tested in the fixed tests, so we can avoid potential redundancy there. The upper bound was decreased due to the variance in completion time; lowering it ensures that the test setup doesn't become the bottleneck.

    EDIT: for bullet point #2, I meant to say "functions that don't need to be accessed from outside the module" should be set to private.

  • Custom User Avatar
    • mdsmithson
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    Awesome, that is helpful to know. I have updated the kata details accordingly, and updated the solution to a matrix of integers.
    Thanks for that tip!

  • Custom User Avatar
    • docgunthrop
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    We could change this to be by numbers.. Its just that the output wont look like what people are expecting even though its technically accurate.

    You can override the default output format so it doesn't display as a charlist.

    x = [68,77,81,69,72]
    IO.inspect(x,charlists: :as_lists)# [68, 77, 81, 69, 72]
    IO.inspect(x)# 'DMQEH'
    
  • Custom User Avatar
    • mdsmithson
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    Pardon me, this is my first attempt at a kumite.
    I have now updated it to include truly random tests between 100.

    Also, regarding using strings instead of integers; its because lists in erlang are basically binary char lists, and certain combinations of numbers emit random strings..

    We could change this to be by numbers.. Its just that the output wont look like what people are expecting even though its technically accurate.

  • Custom User Avatar
    • docgunthrop
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    Another question -- why use strings rather than integers? The other translations use integers.

  • Custom User Avatar
    • docgunthrop
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    There don't appear to be any random tests. Are you sure you updated it?

  • Custom User Avatar
    • mdsmithson
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    Updated to include random tests.

  • Custom User Avatar
    • docgunthrop
    • commented on ""The Clockwise Spiral" Elixir Translation"
    • 6 years ago

    The full test suite should include random tests.

  • Custom User Avatar
    • mdsmithson
    • commented on "Find the stray number" kata
    • 6 years ago

    indeed, its not a kata issue.

  • Loading more items...
  • © 2025 Codewars
  • About
  • API
  • Blog
  • Privacy
  • Terms
  • Code of Conduct
  • Contact

Confirm

  • Cancel
  • Confirm

Collect: undefined

Loading collection data...