Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #532 // Make bridge map (getBridgeMap)

Lua code

1  
get("#349") -- table functions
2  
3  
function getBridgeMap(masterBridge)
4  
  local title = getSnippetTitle(masterBridge)
5  
  local _, _, masterSourceID, masterDestID = title:find("from (#%d+) to (#%d+)")
6  
  
7  
  local idmap = {}
8  
  idmap[masterSourceID] = masterDestID
9  
  
10  
  local refs = findNTTitle("Need bridge from % following master bridge "..masterBridge)
11  
  for r in all(refs) do
12  
    local title = getSnippetTitle(r)
13  
    local _, _, sourceID = title:find("^Need bridge from (#%d+)")
14  
    idmap[sourceID] = '<unbridged '..sourceID..'>'
15  
  end
16  
  
17  
  local refs = findNTTitle("A bridge from % following master bridge "..masterBridge)
18  
  for r in all(refs) do
19  
    local title = getSnippetTitle(r)
20  
    local _, _, sourceID, destID = title:find("^A bridge from (#%d+) to (#%d+)")
21  
    idmap[sourceID] = destID
22  
  end
23  
  
24  
  return idmap
25  
end

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #532
Snippet name: Make bridge map (getBridgeMap)
Eternal ID of this version: #532/1
Text MD5: 7816d61affda4c468e0cff515adfe8f3
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-15 03:47:19
Source code size: 841 bytes / 25 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 637 / 143
Referenced in: [show references]