Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
If your representation means that
a
andb
are encoded as the same thing, that means you need to change your representation!It seems that you're representing trees as nested parentheses, where something like
(()())
might represent a tree with two subtrees, each represented by()
. But that's not necessarily a good representation: don't tie yourself to the notion that the string of parentheses has to look anything like the tree it represents.I'm not sure how much I can say as a hint without giving away an answer, but maybe this might help. The four simplest strings of parens I can think of are the following:
Whatever mapping you choose, these will have to map to unique and distinct trees. Why not pick the four simplest possible trees, and see if you can spot a pattern?
I have the same problem.
With the condition that "" is a valid tree, I decide to make it a minimal tree (so that this definition would work recursively.)
This has a problem, because that means the tree
are both represented by:
If I choose "" to represent Leaf, information are lost: I can no longer tell whether a subtree is on the left or on the right if there's only one subtree.
What could be a better way to model trees?
Thank you.
Fixed
Got the same problem in Haskell with a different case.
And again: Falsifiable (after 7 tests):
(19,409,52675715324794896384) expected (36376152090211696640,1,7) but got (36376152090211697611,1,7)
clearly the result cannot be even and mine is correct: https://www.wolframalpha.com/input?i=19*409%5E7
In initial haskel code skeleton the exported function is named incorrectly:
module Kata (arrowArea) where -- this should be 'module Kata (x) where'
x :: Int -> String
x = undefined
Ok. There are 20 users that solved the kata in Haskell.
I've seen another issue that akar-O raised for the Haskell version. Let me check if we can solve it.
This comment is hidden because it contains spoiler information about the solution
Hi @casual dingbat. Which language?
Tests are inaccurate:
Falsifiable (after 30 tests):
(23,241,14932274143297536) expected (9983789202489408,10,1) but got (9983789202489409,10,1)
you are multiplying two odd primes to some powers and getting even number.
yeah i didn't understand what bang meant
There's no reason that
"()"
has to represent aLeaf
. You can decide on your own mapping when answering the question, as long as it forms a bijection any mapping is valid. I think most representations would have""
represent aLeaf
, and"()"
might represent something likeLeaf :*: Leaf
.I am wondering what "" represents as I am assuming that () is a Leaf.
That is probably the worst described Kata I have done.
Mind sharing which tool did you use for that? Since writing FSM is pretty easy however manual conversion doesn't sound appealing.
Loading more items...