• 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
interphx Avatar
Name:Unknown
Clan:Unknown
Member Since:Dec 2018
Last Seen:Dec 2023
Profiles:
    Following:0
    Followers:2
    Allies:0
    View Profile Badges
    • Stats
    • Kata
    • Collections
    • Kumite
    • Social
    • Discourse
    • Conversations (48)
    • Replies
    • Authored
    • Needs Resolution
    • Custom User Avatar
      • LosBlobbos
      • commented on "Evaluating prefix Polish notation" kata
      • 2 years ago

      Possible duplicate of https://www.codewars.com/kata/reverse-polish-notation-calculator/

    • Custom User Avatar
      • stellartux
      • created a suggestion for "Evaluating prefix Polish notation" kata
      • 3 years ago

      Julia translation

    • Custom User Avatar
      • trashy_incel
      • resolved a question on "Evaluating prefix Polish notation" kata
      • 3 years ago

      you are pushing strings on the stack instead of numbers ;-)

    • Custom User Avatar
      • Mislam23
      • commented on "Linked Lists - Remove Duplicates" javascript solution
      • 3 years ago

      This is helpful, will be reviewing your code!

    • Custom User Avatar
      • interphx
      • commented on "Graceful Tipping" javascript solution
      • 4 years ago

      The main idea is that the number of digits in a decimal number is roughly equal to its base 10 logarithm. For example, 10^3 = 1000 (3 + 1 digits), 10^4 = 10000 (4 + 1 digits), and so on. This allows us to approximate the range of the "elegant" value (tens, hunderds, thousands, ...).

    • Custom User Avatar
      • Quickz
      • commented on "Graceful Tipping" javascript solution
      • 4 years ago

      Hmm. Didn't think of using a logarithm. I just converted a number to a string and used it's length. Learned something new today.

    • Custom User Avatar
      • akar-0
      • resolved a question on "Evaluating prefix Polish notation" kata
      • 4 years ago

      You're right, my bad.

    • Custom User Avatar
      • Blind4Basics
      • commented on "Evaluating prefix Polish notation" kata
      • 5 years ago

      looks like you're returning a tuple at some point, tho

    • Custom User Avatar
      • akar-0
      • created a question for "Evaluating prefix Polish notation" kata
      • 5 years ago

      I get weird errors running tests, and I don't think my code is the culprit:

      Traceback (most recent call last):
        File "/runner/frameworks/python/cw-2.py", line 111, in wrapper
          func()
        File "main.py", line 16, in sample2
          test_it('+ 3 5',8)
        File "main.py", line 4, in test_it
          test.assert_approx_equals(calculate(s),n,margin=1e-6)
        File "/runner/frameworks/python/cw-2.py", line 84, in assert_approx_equals
          div = max(abs(actual), abs(expected), 1)
      TypeError: bad operand type for abs(): 'tuple'
      

      My code runs fine locally with the same expressions. Am I wrong?

    • Custom User Avatar
      • rajat004
      • created a question for "Evaluating prefix Polish notation" kata
      • 5 years ago

      Why I am getting this error
      Traceback (most recent call last):
      File "/runner/frameworks/python/cw-2.py", line 111, in wrapper
      func()
      File "main.py", line 51, in fixed_set1
      test_it('0',0)
      File "main.py", line 45, in test_it
      test.assert_approx_equals(calculate(s),n,margin=1e-6)
      File "/runner/frameworks/python/cw-2.py", line 84, in assert_approx_equals
      div = max(abs(actual), abs(expected), 1)
      TypeError: bad operand type for abs(): 'str'

      Here is my python code

      def calculate(ex):
          stack = []
      
          for i in ex[::-1].split(' '):
              if i not in '+-*/':
                  stack.append(i)
              else: 
                  a, b = stack.pop(), stack.pop()
                  stack.append(str(eval(a + i + b)))
          return stack[0]
      
    • Custom User Avatar
      • Blind4Basics
      • commented on "Evaluating prefix Polish notation" kata
      • 5 years ago

      :+1:

    • Custom User Avatar
      • docgunthrop
      • commented on "Evaluating prefix Polish notation" kata
      • 5 years ago

      I went ahead and added the following comment to the initial test setup as well: # for division, use true division, not floor division, so no room for ambiguity. :)

    • Custom User Avatar
      • Blind4Basics
      • commented on "Evaluating prefix Polish notation" kata
      • 5 years ago

      woops, I actually didn't even read that comment... x)

      Could be enough. Tho, that means the user cannot have the info before he reaches the trainer. It's a bit suboptimal, even if nothing critical, I guess.

    • Custom User Avatar
      • docgunthrop
      • commented on "Evaluating prefix Polish notation" kata
      • 5 years ago

      The initial solution setup includes the comment # should return a float. Coupled with the fact that the division operator used is / rather than //, shouldn't that suffice?

    • Custom User Avatar
      • Blind4Basics
      • commented on "Evaluating prefix Polish notation" kata
      • 5 years ago

      the description should be updated, saying expicitly that in python one should use true division, and not integer division (for now, the example of the description doesn't allow to be sure of it)

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

    Confirm

    • Cancel
    • Confirm

    Collect: undefined

    Loading collection data...