https://www.perplexity.ai/
Try asking it:
Write the quicksort algorithm in B4X language
Try asking it:
Write the quicksort algorithm in B4X language
Perfect <--link
Last edited:
Sub Dijkstra(graph As Map, startNode As String) As Map
Dim distances As Map
distances.Initialize
For Each node In graph.Keys
distances.Put(node, 1000000) 'set initial distance to infinity'
Next
distances.Put(startNode, 0) 'set distance to start node to zero'
Dim visitedNodes As List
visitedNodes.Initialize
Dim currentNode As String = startNode
Do While currentNode <> ""
visitedNodes.Add(currentNode)
For Each neighbor In graph.Get(currentNode)
Dim tentativeDistance As Int = distances.Get(currentNode) + neighbor.Value
If tentativeDistance < distances.Get(neighbor.Key) Then
distances.Put(neighbor.Key, tentativeDistance)
End If
Next
Dim smallestDistance As Int = 1000000 'initialize smallest distance to infinity'
Dim nextNode As String = ""
For Each node In graph.Keys
If Not(visitedNodes.Contains(node)) And (distances.Get(node) < smallestDistance) Then
smallestDistance = distances.Get(node)
nextNode = node
End If
Next
currentNode = nextNode
Loop
Return distances 'return the shortest path from the start node to all other nodes'
End Sub
'Example usage:'
Sub ExampleUsage()
Dim graph As Map
graph.Initialize
graph.Put("A", CreateMap("B":2, "C":3))
graph.Put("B", CreateMap("A":2, "C":1))
graph.Put("C", CreateMap("A":3, "B":1))
Log(Dijkstra(graph, "A"))
End Sub
The greatest fun is making millionsIf you let "Perplexity" do everything, where's the fun in programming?
Also note that Perlexity takes a second or two to produce source code, I... a lot longer. It would definitely take me more than 2 seconds just to read the question!Over the past few days, the Perplexity.ai site has been changed (improved).
I didn't register and therefore couldn't save the conversation I just had with "him". I have the link to this conversation but I don't know if the conversation itself will be deleted and above all I don't know when.
I'd say it's interesting, especially for B4X beginners but not only for them (the source code can be useful even to those who don't know SQL).
My questions are in Italian but do you know how to translate them.
I wanted to see what the source code it would generate would look like. Not only; mainly I had done a similar test some time ago and the code it generated was not published in its entirety. At the time, however, I didn't know that I could continue the conversation, as is the case in ChatGPT.
I would say it was a good test and I hope you can read it, starting from this link:
https://www.perplexity.ai/search/da69eed3-c138-4974-922a-93c9bf1cb06e?s=u
Note that it sometimes answers me in Italian, other times in English; it does as he pleases