Viewing a single comment thread. View all comments

monkorn t1_j4jmu88 wrote

Don't just tell it to do it step by step, show it how to do it step by step and keep track as it goes. It will handle it then.

Prompt: I would like you to process the the following strings like this example: "1 0 1 1 0 1 0 0 0" Step 1. Start with a count of 0. Step 2: Look at the first digit in the string and remove it, it's a 1, so add that value to the count. The new count is 1. The new string is "0 1 1 0 1 0 0 0". Continue until the string is empty. Can you try on "1 0 1 1 1 0 1 0 1 0 1"?

> Start with a count of 0

> Look at the first digit in the string "1 0 1 1 1 0 1 0 1 0 1" which is 1, so add that value to the count. The new count is 1. The new string is "0 1 1 1 0 1 0 1 0 1"

> Look at the first digit in the new string, which is 0, so add that value to the count. The new count is 1. The new string is "1 1 1 0 1 0 1 0 1"

...

> Look at the first digit in the new string, which is 0, so add that value to the count. The new count is 6. The new string is "1"

> Look at the first digit in the new string, which is 1, so add that value to the count. The new count is 7. The new string is ""

> The string is now empty, the final count is 7.

7

CosmicTardigrades OP t1_j4jn6ga wrote

Thank you. I'll try.

It seems that we should teach it to build a Turing machine that solves the question instead of letting it comes out one (which is likely to be wrong) itself?

2

visarga t1_j4k5jfh wrote

Wrong tool for this kind of task, it should generate a Python function which will give you the answer when evaluated on the input. And this approach would generalize better. The Turing machine approach is useful when you're dealing with concepts that don't fit well into Python code.

2

CosmicTardigrades OP t1_j4k5ols wrote

Yeah. You‘re right. The essence is to construct a right model for “counting”

1