mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-10-31 18:37:48 +08:00 
			
		
		
		
	 f616dac7da
			
		
	
	f616dac7da
	
	
	
		
			
			* Fix is_empty() implementation in the stack and queue chapter * Update en/CONTRIBUTING.md * Remove "剩余" from the state definition of knapsack problem * Sync zh and zh-hant versions * Update the stylesheets of code tabs * Fix quick_sort.rb * Fix TS code * Update chapter_paperbook * Upload the manuscript of 0.1 section * Fix binary_tree_dfs.rb * Bug fixes * Update README * Update README * Update README * Update README.md * Update README * Sync zh and zh-hant versions * Bug fixes
		
			
				
	
	
		
			35 lines
		
	
	
		
			764 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			764 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| =begin
 | |
| File: built_in_hash.rb
 | |
| Created Time: 2024-04-13
 | |
| Author: Xuan Khoa Tu Nguyen (ngxktuzkai2000@gmail.com)
 | |
| =end
 | |
| 
 | |
| require_relative '../utils/list_node'
 | |
| 
 | |
| ### Driver Code ###
 | |
| if __FILE__ == $0
 | |
|   num = 3
 | |
|   hash_num = num.hash
 | |
|   puts "整數 #{num} 的雜湊值為 #{hash_num}"
 | |
| 
 | |
|   bol = true
 | |
|   hash_bol = bol.hash
 | |
|   puts "布林量 #{bol} 的雜湊值為 #{hash_bol}"
 | |
| 
 | |
|   dec = 3.14159
 | |
|   hash_dec = dec.hash
 | |
|   puts "小數 #{dec} 的雜湊值為 #{hash_dec}"
 | |
| 
 | |
|   str = "Hello 演算法"
 | |
|   hash_str = str.hash
 | |
|   puts "字串 #{str} 的雜湊值為 #{hash_str}"
 | |
| 
 | |
|   tup = [12836, '小哈']
 | |
|   hash_tup = tup.hash
 | |
|   puts "元組 #{tup} 的雜湊值為 #{hash_tup}"
 | |
| 
 | |
|   obj = ListNode.new(0)
 | |
|   hash_obj = obj.hash
 | |
|   puts "節點物件 #{obj} 的雜湊值為 #{hash_obj}"
 | |
| end
 |