As @HanonO points out, the actual code depends on which version you want to use. The code below is “Harlowe”, which is the default. Unless you deliberately chosen to use a different language, you’re using Harlowe.
In order to post twine code to this site, we must post it as Twee code. That’s the all-text equivalent of the code you produce using the Twine app (with the clickable boxes).
Twee code looks like this:
::This is a passage header
This is the body of the passage called "This is a passage header" it continues on until the next line which begins with a double colon.
This is the body of "second passage", the text that will be shown to the player and the cod to control it. All of this code is the same as you would type into the app.
So if you take the code below, and copy and paste the contents of each body into a passage with the same name, you will end up with a little working game.
The first passage (Start) is the most complicated, but really it’s only switching text to display (or not) depending on the “flags”. Flags are always “true” or “false”. They’re very quick for a computer to check, but true or false is all they can do. Again, be careful: to Twine, “true” and “True” are different things.
The very first part of it checks if the number of visits is “1”, so it displays that text. The number of visits goes up every time the player sees that passage, so afterwards it’s not true that the value of “visits” is 1 (it doesn’t care what it actually is, only that it’s not “1”.) So after that first visit, the “else” macro does the biz. Notice that you can put more than text in the hook – the stuff between the square brackets. You can put links etc in too.
(if: visits is 1)[The Great Detective looks at you.
"And so, for your final challenge, I 'ave 'idden zee three clues in different rooms! You must bring all of them to me here before I, I! Will admit you to being my assistant!
(set: $hastea to false)(set: $hasbiscuit to false)]
(if: $hasbiscuit is true)["Ah," The Great Detective says. "I see you 'ave brought to me ze clue from the Drawing Room!"]
(else:)["Alas, you have not brought to me ze clue! I suggest you search ze Drawing room!" he says impressively.]
(if: $hastea is true)["This is most encouraging!" The Great Detective says. "I 'ave the tea for my afternoon enjoyment!"]
(else:)["Mon Repos!" The Great Detective says. "Without tea, it cannot occur! I suggest you search the lodge of the Porter!"]
(if: $hastea is true and $hasbiscuit is true)["You are well on your way!" The Great Detective says. "One more clue, it eludes you! But soon the world will be set aright. I, I shall have the pleasant repos, and you shall be my assistant!"]
[[exit to the hall->hallway]]
Opening off this hallway is the [[Library->Start]] (where the Great Detective awaits), the [[Drawing Room]], the [[Porter's Lodge]] and the [[Music Room]].
(unless: $hasbiscuit is true)[ Laying on the coffee table is a biscuit. It must be a clue!
[[Take the biscuit]]
(else:)[ There's nothing else to do here except [[exit to the hall->hallway]] ]
::Take the biscuit
(set: $hasbiscuit to true)
You pick up the biscuit.
(display: "Drawing Room")
The porter's lodge is really a great, leather-bound chair by the doors.
(if: $hastea is false)[There is a cup of tea sitting on a little table beside it.
[[Pick up the tea]].]
(else:)[The little table beside it is bare.]
[[Exit to the hallway->hallway]]
::Pick up the tea
Carefully, you pick up the cup of tea.
(set: $hastea to true)
[[Return to the hall->hallway]].
I’ve left the third clue for you to implement. When you’re writing the “if” statements, be careful about the nesting. Remember in Harlowe the bit of code in parentheses () tells Twine when to display things, and the bit following, in the square brackets  tells it what it’s got to display, (or not.)
The two other rooms are implemented in slightly different ways. You can copy either one. (By the way, when I’m learning code, I try to use copy-paste as little as possible. I find I only learn stuff if I type it out one letter at a time. But, “Your Mileage May Vary”, as they say.)
You’ll need to add another flag. It can be anything you like, but must start with a dollar sign. In a proper game, you’d initialize the flags in a specially tagged passage, but I wanted to keep it simple. Notice that the other flags are initilized in the part of the start passage that only runs on the first turn. What happens if you initialize your flag somewhere else in the Start room?
Actually, you don’t need to initialize a flag if you only ever check if it’s true after you’ve used it – but until you actually use the flag it’s “uninitialised” which is neither true nor false. Personally, I always initialize my flags: it makes a nice little handy to refer to list when I’m not sure if the flag I want is $princessGrumpy or $grumpyPrincess.
The first passage doesn’t have to be called Start, but if you change it, remember to change the code in Hallway to match. Be careful when cutting and pasting passage names: Twine thinks that “bedroom” and " bedroom" (with a space at the front) are different passages. Believe me it’s much harder to spot without the quote marks!
“unless” is the mirror image of “if” if you want to say “when this situation is not true” use (unless: bla bla)
Anyway: have fun, and if you get stuck, post. We’re a friendly bunch.