Skip to content

Commit

Permalink
update collatz sequence diagrams with title
Browse files Browse the repository at this point in the history
  • Loading branch information
dragondive committed Jul 22, 2024
1 parent bb16912 commit 63b36f8
Show file tree
Hide file tree
Showing 205 changed files with 122 additions and 1,639,265 deletions.
34 changes: 20 additions & 14 deletions src/preprocessor/collatz_sequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,34 @@ $make_direction_map()
!assert $collatz(40) == 20

!procedure $make_collatz_sequence($num)
!$counter = 0
$create_rectangle($num, $counter)
!if $num > 0
!$counter = 0
$create_rectangle($num, $counter)

!while $num != 1
!$prev = $num
!while $num != 1
!$prev = $num

!$num = $collatz($num)
!$direction = %get_variable_value($get_last_hex_digit($counter))
!$num = $collatz($num)
!$direction = %get_variable_value($get_last_hex_digit($counter))

!$counter = $counter + 1
!$counter = $counter + 1

$create_rectangle($num, $counter)
$connect_entities($prev, $num, $direction)
!endwhile
!else
!log input is $num but should be positive.
!endif

$create_rectangle($num, $counter)
$connect_entities($prev, $num, $direction)
!endwhile
!endprocedure

!$count = 1
!$count = 0
!$limit = 100
!while $count <= $limit
newpage
$make_collatz_sequence($count)
title Collatz sequence for $count
$make_collatz_sequence(%intval($count))
!$count = $count + 1
newpage
!endwhile

@enduml
@enduml
Binary file modified src/preprocessor/diagrams/collatz_sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 63b36f8

Please sign in to comment.